refactor: split ServerMultiplayerRoomMixin into three focused mixins#551
Open
xpoes123 wants to merge 1 commit into
Open
refactor: split ServerMultiplayerRoomMixin into three focused mixins#551xpoes123 wants to merge 1 commit into
xpoes123 wants to merge 1 commit into
Conversation
…xins Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ~477-line
ServerMultiplayerRoomMixininserver/multiplayer/ServerMultiplayerRoomMixin.jscombined message routing, connection handling, room settings, ban/kick management, and votekick logic in a single class body, making each concern harder to locate and reason about. This is a behavior-preserving structural refactor that splits those concerns into three focused mixins without changing any method body.Problem
ServerMultiplayerRoomMixinhad grown to the point where unrelated concerns — ban timers, votekick thresholds, and a dozentoggle*/set*settings guards — were interleaved with connection and game-flow logic. There were no clear boundaries and no way to read or test one concern in isolation.Changes
server/multiplayer/BanKickMixin.js— new file; containsbanandcleanupExpiredBansAndKicks.BAN_DURATIONconstant moves here.server/multiplayer/VotekickMixin.js— new file; containsvotekickInitandvotekickVote.server/multiplayer/RoomSettingsMixin.js— new file; containsallowed, allset*methods, and alltoggle*methods.server/multiplayer/ServerMultiplayerRoomMixin.js— the three new mixins are composed viaBanKickMixin(RoomSettingsMixin(VotekickMixin(RoomClass)))at the class definition. The moved methods andBAN_DURATIONare removed. The constructor, connection handling, and game-flow logic are unchanged.MODE_ENUMimport is removed (now only used insideRoomSettingsMixin);isAppropriateStringis likewise moved toRoomSettingsMixin.All method bodies were moved verbatim. Consumer files (
ServerTossupRoom,ServerTossupBonusRoom) are untouched — the export name and(RoomClass) => ...call signature are identical.Risk & testing
This is behavior-preserving by construction: all mixins extend the same prototype chain of the same instance, so
this, instance state, cross-method calls, and everysuper.call resolve identically to before. The single constructor remains inServerMultiplayerRoomMixinso initialization runs once in the same order. Every method from the original class is present exactly once across the four files.Verified by inspection and static member-presence check. The repository has no multiplayer integration tests, so a live smoke-test is recommended before merging: join a room, buzz, answer, advance to the next question, and exercise ban, kick, and votekick against a second connected client.