Skip to content

Meta: Feature/alliance cutoff#3884

Open
Zixer1 wants to merge 4 commits intoopenfrontio:mainfrom
Zixer1:feature/alliance-cutoff
Open

Meta: Feature/alliance cutoff#3884
Zixer1 wants to merge 4 commits intoopenfrontio:mainfrom
Zixer1:feature/alliance-cutoff

Conversation

@Zixer1
Copy link
Copy Markdown
Contributor

@Zixer1 Zixer1 commented May 7, 2026

Description:

Some games can sometimes last for hours in a stalemate. I was thinking a simple fix could be that at a certain point, like 45min, all alliances are auto disabled. It wont explode the map into chaos since players will still want to play smart and not mindlessly attack, but it will enable piracy and pettier border conflicts, which can evolve into a full push, speeding up the end game stalemates which sometimes are way too excessive.

All the UI additions:

589117387-ba2dc68c-0a78-4b38-bdac-22d2bf49e859.mov
Screen.Recording.2026-05-07.at.3.17.52.PM.mov
Screen.Recording.2026-05-07.at.3.16.37.PM.mov

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
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

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

zixer._

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

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: fe2513a8-7926-41af-b1af-653716029434

📥 Commits

Reviewing files that changed from the base of the PR and between 6826233 and af02913.

📒 Files selected for processing (2)
  • src/client/graphics/PlayerIcons.ts
  • src/client/graphics/layers/EventsDisplay.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/client/graphics/PlayerIcons.ts
  • src/client/graphics/layers/EventsDisplay.ts

Walkthrough

This PR implements a configurable alliance cutoff tick: warns players at -5 and -1 minutes, shows a client countdown and center overlay, blocks new alliance actions at the cutoff, expires existing alliances at the cutoff, and adds tests and config hooks.

Changes

Alliance Cutoff Tick

Layer / File(s) Summary
Configuration Contract
src/core/configuration/Config.ts, src/core/configuration/DefaultConfig.ts
Config adds alliancesCutoffTick(): Tick | null. DefaultConfig returns 0 when alliances are disabled; otherwise numSpawnPhaseTurns() + 45 * 60 * 10.
Message System
src/core/game/Game.ts, resources/lang/en.json, src/client/Utils.ts
Adds MessageType.ALLIANCES_DISABLED with ALLIANCE category mapping; maps it to warning severity. Adds four translation keys: alliances_disabled_warning_5min, alliances_disabled_warning, alliances_disabled, alliances_ending_countdown.
Core Cutoff Enforcement
src/core/game/GameImpl.ts
executeNextTick() calls checkAlliancesCutoff() which emits -5min and -1min warnings, expires alliances and rejects pending requests at cutoff, and broadcasts messages to alive players.
Alliance Operation Guards
src/core/execution/nation/NationAllianceBehavior.ts, src/core/execution/TribeExecution.ts, src/core/execution/alliance/AllianceExtensionExecution.ts, src/core/game/PlayerImpl.ts
Introduces isAlliancesBlocked() and adds early-return guards so alliance handlers, tribe acceptance, extension init, and canSendAllianceRequest() are blocked at/after the cutoff tick.
Client-Side UI & State
src/client/graphics/PlayerIcons.ts, src/client/graphics/layers/NameLayer.ts, src/client/graphics/layers/EventsDisplay.ts
Client reads cutoff tick to update alliance icon visibility and alliancesDisabled. NameLayer sets alliancesDisabled when cutoff reached. EventsDisplay adds reactive countdown, one-shot centered warning during final minute, in-panel countdown banner, and CSS animation.
Tests & Infrastructure
tests/util/TestConfig.ts, tests/AlliancesCutoff.test.ts, tests/NationAllianceBehavior.test.ts
TestConfig adds _alliancesCutoffTick override with setter/getter. New AlliancesCutoff test suite verifies blocking at cutoff, alliance expiry at cutoff, and null-cutoff behavior. NationAllianceBehavior mock updated to include alliancesCutoffTick().

Sequence Diagram(s)

sequenceDiagram
  participant Config
  participant GameImpl
  participant AllianceSubsystem
  participant ClientEvents
  Config->>GameImpl: alliancesCutoffTick()
  GameImpl->>GameImpl: checkAlliancesCutoff() each tick
  GameImpl->>AllianceSubsystem: expire alliances & reject pending (at cutoff)
  GameImpl->>ClientEvents: broadcast warnings & final message
  ClientEvents->>ClientEvents: EventsDisplay updates countdown/overlay
Loading

🎯 3 (Moderate) | ⏱️ ~25 minutes

🕐 Ticks march on, the deadline near,
Five and one—alerts appear,
Bonds unwind when the bell is rung,
Countdown blinks, the last minutes sung,
Config sets the hour, the game moves clear.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Meta: Feature/alliance cutoff' is a generic prefix-based label rather than a specific description of the main change; it lacks detail about what the feature accomplishes. Consider renaming to something more descriptive like 'Add alliance cutoff timer to reduce endgame stalemates' to clearly convey the feature's purpose.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the alliance cutoff feature, its motivation (reducing stalemates), the UI additions, and confirms translations and tests were added.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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/graphics/layers/EventsDisplay.ts`:
- Around line 834-851: Run Prettier on the file to fix formatting issues causing
CI failure; specifically reformat the CSS `@keyframes` block (named fadeInOut)
shown in the diff and the other similar blocks in the same file (the sections
around the ranges noted: 871-888 and 960-972), then add and commit the formatted
file so CI can pass. Ensure you use the project's configured Prettier settings
(e.g., npm/yarn prettier or editor integration) and do not alter the animation
semantics—only update whitespace/formatting.
- Around line 284-286: The early return when cutoff is reached skips cleanup of
stale renewal prompts; before returning from the block that computes cutoff (the
lines using cutoff, this.game.config().alliancesCutoffTick() and
this.game.ticks()), call this.removeAllianceRenewalEvents() and also prune/clear
the alliancesCheckedAt tracking (either by calling the existing pruning helper
or resetting the alliancesCheckedAt map/object) so “renew alliance” prompts are
removed when alliances are disabled.

In `@src/client/graphics/layers/NameLayer.ts`:
- Around line 174-177: The newly added multiline if in NameLayer (the block
using cutoff = this.config.alliancesCutoffTick() and the conditional checking
cutoff !== null && !this.alliancesDisabled && this.game.ticks() >= cutoff) is
not formatted to project Prettier rules; run the project's Prettier formatter
(or npm script) on src/client/graphics/layers/NameLayer.ts and commit the
resulting changes so the if-statement and surrounding lines match the
repository's formatting style, then ensure the file passes CI.

In `@src/client/graphics/PlayerIcons.ts`:
- Around line 108-112: The boolean merge for alliance cutoff is wrong: replace
the nullish coalescing used to compute alliancesOff with a logical OR so false
values are respected; specifically, change the expression that sets alliancesOff
(currently using alliancesDisabled ?? (game.config().disableAlliances() ||
pastCutoff)) to use alliancesDisabled || game.config().disableAlliances() ||
pastCutoff so that a false alliancesDisabled doesn’t short-circuit the
config/cutoff checks.
🪄 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: aff6b6f7-7673-429e-98ab-23455699a8a7

📥 Commits

Reviewing files that changed from the base of the PR and between 4889cb8 and 79f7923.

📒 Files selected for processing (16)
  • resources/lang/en.json
  • src/client/Utils.ts
  • src/client/graphics/PlayerIcons.ts
  • src/client/graphics/layers/EventsDisplay.ts
  • src/client/graphics/layers/NameLayer.ts
  • src/core/configuration/Config.ts
  • src/core/configuration/DefaultConfig.ts
  • src/core/execution/TribeExecution.ts
  • src/core/execution/alliance/AllianceExtensionExecution.ts
  • src/core/execution/nation/NationAllianceBehavior.ts
  • src/core/game/Game.ts
  • src/core/game/GameImpl.ts
  • src/core/game/PlayerImpl.ts
  • tests/AlliancesCutoff.test.ts
  • tests/NationAllianceBehavior.test.ts
  • tests/util/TestConfig.ts

Comment thread src/client/graphics/layers/EventsDisplay.ts Outdated
Comment thread src/client/graphics/layers/EventsDisplay.ts
Comment thread src/client/graphics/layers/NameLayer.ts
Comment thread src/client/graphics/PlayerIcons.ts
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

1 participant