feat(alliances): custom alliance duration lobby control#4522
Conversation
Replaces the disable-alliances toggle with a custom-alliances control (a toggle + minutes input, 0-15, step 1, mirroring the spawn-immunity card). 0 minutes disables alliances (the old behavior); 1-15 sets the alliance duration. Backed by customAllianceDuration (minutes) in the game config, with Config.disableAlliances() and allianceDuration() derived from it; the legacy disableAlliances boolean is still honored. Applied in the host and single-player lobbies, whitelisted for live lobby updates, shown in the join-lobby config, with basic bounds validation reusing parseBoundedIntegerFromInput.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughThis PR changes lobby alliance settings from a boolean to a minute-based custom duration across client, server, schema, and localization, and adds cached achievement-eligibility loading in the single-player modal. ChangesCustom Alliance Duration
Achievement Eligibility Caching
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/client/HostLobbyModal.ts`:
- Around line 356-370: The custom alliances toggle is initializing with a zero
value, so enabling it immediately disables the feature when `putGameConfig()`
runs. Update the default/initial input value in `HostLobbyModal`’s
`toggle-input-card` usage to a positive duration, and apply the same fix in
`SinglePlayerModal` so the toggle turns on with a valid non-zero duration. Keep
the change aligned with the existing `handleCustomAlliancesToggle` and
`handleCustomAllianceMinutesInput` flow so the enabled state never serializes as
zero.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8e730bf9-e7bd-46c1-bda0-175c3ce6ecc7
📒 Files selected for processing (8)
resources/lang/en.jsonsrc/client/HostLobbyModal.tssrc/client/JoinLobbyModal.tssrc/client/SinglePlayerModal.tssrc/core/Schemas.tssrc/core/configuration/Config.tssrc/server/GameServer.tstests/CustomAllianceDuration.test.ts
|
Would it also be possible to textually replace 0 by disabled? or add (disabled) behind it, whatever works. Feels a tad more finished and I don't think everyone might understand 0 means off |
Addresses PR openfrontio#4522 review: - Rename the lobby label to 'Alliance Duration' (evan). - Add an opt-in zeroLabel to toggle-input-card; the host/single-player card shows 'Disabled' under the input when the value is 0, so 0-means-off isn't cryptic (JB940). Kept customAllianceDuration nullable (see reply): it mirrors maxTimerValue and the null is the host's explicit clear signal on toggle-off, since the config merge ignores undefined.
…isabled)' Absolutely position the zero-hint so it no longer shifts the number off-center vs other cards, and reuse the 'Alliances Disabled' string (parenthesized) instead of a bare 'Disabled'.

Description:
Replaces the "Disable alliances" toggle in the host and single-player lobbies with a "Custom alliances" control: a toggle plus a minutes input (0 to 15, step 1).
How it works:
customAllianceDuration(minutes).Config.allianceDuration()uses it when set (and falls back to the existing 5 minute default), andConfig.disableAlliances()returns true when it is 0.disableAlliancesboolean is still read, so older/archived configs keep working.parseBoundedIntegerFromInputandtoggle-input-cardhelpers, so it behaves like the other numeric lobby options (spawn immunity, max timer).Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
zixer._