Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side changes for Xmas event #130

Merged
merged 18 commits into from
Dec 19, 2023
Merged

Conversation

cspotcode
Copy link
Member

@LazyDuchess @NotNite

These are the server-side code changes for the upcoming Xmas event.

Highlights

Adds SlopCrew.Server.XmasEvent.Common assembly which is shared with our Xmas plugin code. It contains the shared packet structures and serialization/deserialization logic.

Adds XmasClient: each NetworkClient also gets an XmasClient which handles all Xmas-specific custom packets from that player.

Added XmasService to update event state, broadcast it to players, and read/write it to disk.

State writes to xmas-event-state.json. I wasn't sure if logic was necessary to generate an absolute path, but I didn't see that for the database path. Should I also add explicit config to the docker-compose.yml config to put it in ./docker/slop/?

Due to time pressure, the XmasServerEventStatePacket serves double-duty. It is also used to store event state and is serialized/deserialized to a .json file on disk. So every time gifts are collected, we mutate the packet and re-send it to all clients.

xmasClient.IsSlopBrew checks an include-list of SlopBrew people. These people have "admin" power for the Xmas event, but not to the SlopCrew server. They can only rewrite Xmas event state w/XmasClientModifyEventStatePacket and can ignore the gift cooldown when testing.

Packets have a Describe method used for debug logging in our plugin, not used server-side.

Event State

Event state is a list of "phases." When players collect gifts, this increments the gift total for the active phase(s). Technically we could have multiple active phases, gifts would count towards all of them, this was a half-baked idea that I thought might be useful. Now I'm not sure.

When a phase reaches its gift target, it can auto-activates the next phase automatically. This is configurable in case we decide last-minute to trigger phases manually. If we disable auto-activate, the same phase will continue to accumulate gifts above and beyond it's goal.

The server-side is hardcoded to 7 phases though we will only use 4 or 5. I wanted wiggle-room for last-minute plugin changes without a SlopCrew change.

There's a cooldown on collecting gifts. Accept and Reject response packets tell the client if it's hitting the cooldown.

@NotNite NotNite self-requested a review December 19, 2023 03:18
Copy link
Member

@NotNite NotNite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint is probably failing but I don't particularly care because I'm gonna revert all these commits after anyways.

@@ -1,16 +1,21 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlopCrew.Plugin", "SlopCrew.Plugin\SlopCrew.Plugin.csproj", "{C33DD7D1-D576-42DC-849A-A67937645689}"
# Visual Studio Version 17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the project GUIDs seem to have been reset in the solution - unsure what could have caused this but I don't think it'll impact anything.

@NotNite
Copy link
Member

NotNite commented Dec 19, 2023

please don't bring down prod 🙏

@NotNite NotNite merged commit f356897 into SlopCrew:main Dec 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants