Add independent alignment for custom roles #217
Merged
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.
Adds support for a third alignment option
'independent'alongside'good'and'evil', enabling custom roles with unique win conditions (e.g., Tanner who wins if eliminated during day phase).Changes
Constants & Validation
INDEPENDENT: 'independent'toALIGNMENTobject in both client and server globalsGameCreationRequest.deckIsValid()to accept independent as valid team valueRole Sorting
UI & Display
InProgress.jsto render three team containers (good, evil, independent)player-list-moderator-team-independentcontainer toMODERATOR_GAME_VIEWHTML templateStyling
#d4a027).independent,.independent-players,.game-role-independentclassesTests
Original prompt
Add "Independent" Alignment for Custom Roles
Overview
Add support for a third alignment option called "independent" in addition to the existing "good" and "evil" alignments. This will allow users to create custom roles with their own win conditions (like the Tanner, who wins if eliminated during the day).
This feature should ONLY be available for custom roles - do not create any default independent roles.
Required Changes
1. Update Constants (Both Client and Server)
Client:
client/src/config/globals.jsINDEPENDENT: 'independent'to theALIGNMENTobject (currently lines 22-25)Server:
server/config/globals.jsINDEPENDENT: 'independent'to theALIGNMENTobject (currently line 25-27)2. Update Validation Logic
Server:
server/model/GameCreationRequest.jsdeckIsValidmethod (around line 42) to accept 'independent' as a valid team value(entry.team === ALIGNMENT.GOOD || entry.team === ALIGNMENT.EVIL)to also includeALIGNMENT.INDEPENDENT3. Update UI Components
Client:
client/src/view_templates/CreateTemplate.js<option value="independent">independent</option>Client: Update role display logic in multiple files:
Files that need updates for displaying independent roles with proper styling:
client/src/modules/game_creation/RoleBox.js(around lines 28-33, 204-208)client/src/modules/game_creation/DeckStateManager.js(around lines 143-151, 182-195)client/src/modules/game_state/states/InProgress.js(around lines 284-302, 458-467)client/src/modules/game_state/states/Ended.js(around lines 62-75)client/src/modules/game_state/states/shared/SharedStateUtil.js(around lines 149-175)client/src/modules/game_creation/GameCreationStepManager.js(around lines 456-477)For each file, ensure:
roleElement.classList.add(alignment)where alignment can be 'good', 'evil', or 'independent'4. Add CSS Styling
Client: Create styling for independent alignment
Add CSS rules for the
.independentclass to distinguish independent roles visually. This should be added to the relevant stylesheets (likelyclient/src/styles/create.cssand other game-state related CSS files).Suggested styling:
.independentclass for role elements, role names, role cards, etc.Example CSS to add:
5. Update Role Sorting Logic
Anywhere roles are sorted by team/alignment, update to handle three alignments:
Apply this pattern to all role sorting instances found in the codebase.
6. Update Player Grouping in InProgress View
Client:
client/src/modules/game_state/states/InProgress.jsUpdate the
renderPlayersWithRoleInformationmethod (around lines 284-302) to:Testing Considerations
After implementation, verify:
Files to Modify
Must modify:
client/src/config/globals.jsserver/config/globals.jsserver/model/GameCreationRequest.jsclient/src/view_templates/CreateTemplate.jsclient/src/modules/game_creation/RoleBox.jsclient/src/modules/game_creation/DeckStateManager.jsclient/src/modules/game_state/states/InProgress.jsclient/src/modules/game_state/states/Ended.jsclient/src/modules/game_state/states/shared/SharedStateUtil.jsclient/src/modules/game_creation/GameCreationStepManager.jsCSS ...
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.