Skip to content

feat(alliances): custom alliance duration lobby control#4522

Merged
evanpelle merged 3 commits into
openfrontio:mainfrom
Zixer1:feat/custom-alliances
Jul 8, 2026
Merged

feat(alliances): custom alliance duration lobby control#4522
evanpelle merged 3 commits into
openfrontio:mainfrom
Zixer1:feat/custom-alliances

Conversation

@Zixer1

@Zixer1 Zixer1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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).

  • 0 minutes disables alliances, same behavior as the old toggle.
  • 1 to 15 sets the alliance duration in minutes.

How it works:

  • Adds one game-config field, customAllianceDuration (minutes).
  • Config.allianceDuration() uses it when set (and falls back to the existing 5 minute default), and Config.disableAlliances() returns true when it is 0.
  • The legacy disableAlliances boolean is still read, so older/archived configs keep working.
  • Validation reuses the existing parseBoundedIntegerFromInput and toggle-input-card helpers, so it behaves like the other numeric lobby options (spawn immunity, max timer).
  • The join-lobby screen shows "Alliances: {x}m", or "Alliances: Disabled" at 0.
image image image

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

Please put your Discord username so you can be contacted if a bug or regression is found:

zixer._

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.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26838176-8b79-4eef-8a32-f2f0dad2a836

📥 Commits

Reviewing files that changed from the base of the PR and between 3be026a and c6d04dc.

📒 Files selected for processing (3)
  • src/client/HostLobbyModal.ts
  • src/client/SinglePlayerModal.ts
  • src/client/components/ToggleInputCard.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/client/components/ToggleInputCard.ts
  • src/client/HostLobbyModal.ts
  • src/client/SinglePlayerModal.ts

Walkthrough

This 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.

Changes

Custom Alliance Duration

Layer / File(s) Summary
Schema, config, and server sync
src/core/Schemas.ts, src/core/configuration/Config.ts, src/server/GameServer.ts
GameConfigSchema accepts customAllianceDuration; Config reads it for alliance disable and duration logic; GameServer.updateGameConfig stores it from incoming config payloads.
Toggle input zero hint
src/client/components/ToggleInputCard.ts
ToggleInputCard adds an optional zeroLabel hint and renders it when the enabled input value is numeric zero.
Host lobby custom alliances UI
src/client/HostLobbyModal.ts
HostLobbyModal replaces the old alliances toggle with custom alliances state, a minutes input card, updated toggle handling, reset behavior, and a customAllianceDuration payload.
Single player custom alliances UI
src/client/SinglePlayerModal.ts
SinglePlayerModal updates defaults, state, rendering, change tracking, reset logic, handlers, and game start payloads to use customAlliances, customAllianceMinutes, and customAllianceDuration.
Join lobby alliance display
src/client/JoinLobbyModal.ts
JoinLobbyModal shows alliances as disabled when customAllianceDuration is zero and formats positive values in minutes.
Translations and config tests
resources/lang/en.json, tests/CustomAllianceDuration.test.ts
en.json replaces the alliances labels with custom alliances copy and adds the minutes placeholder; the new test file covers zero, max, unset, and legacy boolean behavior.

Achievement Eligibility Caching

Layer / File(s) Summary
Eligibility loading and medal counting
src/client/SinglePlayerModal.ts
SinglePlayerModal adds module-level cached eligibility loading, clears failed in-flight state for retries, and guards medal counts until eligibility manifests finish loading.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • openfrontio/OpenFrontIO#4487: Both PRs change src/client/SinglePlayerModal.ts to load and use achievement-eligible maps for the medals UI.

Suggested labels: UI/UX

Suggested reviewers: evanpelle

Poem

A timer blooms where toggles slept,
With minute winds and labels kept.
Zero means off, fifteen still sings,
And medals wait for cached brave things.
⏱️🎮

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing the alliances lobby control with a custom duration flow.
Description check ✅ Passed The description matches the changeset and explains the new custom alliances control, config field, validation, and UI behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Zixer1 Zixer1 added this to the Backlog milestone Jul 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1db65a1 and 4498598.

📒 Files selected for processing (8)
  • resources/lang/en.json
  • src/client/HostLobbyModal.ts
  • src/client/JoinLobbyModal.ts
  • src/client/SinglePlayerModal.ts
  • src/core/Schemas.ts
  • src/core/configuration/Config.ts
  • src/server/GameServer.ts
  • tests/CustomAllianceDuration.test.ts

Comment thread src/client/HostLobbyModal.ts
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Jul 7, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 7, 2026
Comment thread resources/lang/en.json Outdated
Comment thread src/core/Schemas.ts
@JB940

JB940 commented Jul 8, 2026

Copy link
Copy Markdown

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.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 8, 2026
…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'.
@Zixer1

Zixer1 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author
image edited a little the ui per feedback

@github-project-automation github-project-automation Bot moved this from Development to Final Review in OpenFront Release Management Jul 8, 2026
@evanpelle evanpelle merged commit 050c760 into openfrontio:main Jul 8, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Final Review to Complete in OpenFront Release Management Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants