Add setting for automatically setting "Stop Trading with all setting" for team games#3315
Add setting for automatically setting "Stop Trading with all setting" for team games#3315DeLoWaN wants to merge 3 commits intoopenfrontio:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds a user setting, UI toggle, localization entries, and client-side game logic that schedules and emits a "Stop Trading with All" embargo automatically at team game start when enabled. Changes
Sequence DiagramsequenceDiagram
participant User
participant Modal as UserSettingModal
participant Settings as UserSettings
participant GameRunner as ClientGameRunner
participant Game as Game Engine
User->>Modal: Toggle "Stop Trading with All (Team Games Only)"
Modal->>Settings: setStopTradingAllAtStartForTeamGames(enabled)
Settings->>Settings: Write to localStorage
Settings->>Modal: Emit change notification
Modal->>Modal: requestUpdate()
rect rgba(100, 150, 200, 0.5)
Note over User,Game: Later: Team Game Starts
Game->>GameRunner: game.start()
GameRunner->>Settings: stopTradingAllAtStartForTeamGames()
Settings-->>GameRunner: enabled boolean
alt Setting enabled AND Team mode
GameRunner->>GameRunner: Calculate embargo tick (current tick + cooldown)
GameRunner->>GameRunner: Mark initialized
end
end
rect rgba(100, 150, 200, 0.5)
Note over GameRunner,Game: During Game Loop
GameRunner->>GameRunner: Check if current tick reached embargo tick
alt Tick reached
GameRunner->>Game: Emit SendEmbargoAllIntentEvent("start")
GameRunner->>GameRunner: Mark applied & clear tick
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
🧹 Nitpick comments (2)
docs/plans/2026-02-14-starting-trade-mode-design.md (1)
31-31: Remove absolute paths from documentation.The file contains machine-specific paths like
/Users/damien/git_perso/OpenFrontIO/.... Use relative paths from the repository root (e.g.,src/client/UserSettingModal.ts) for portability.This applies to lines 31, 53, 75, and 140-143.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/plans/2026-02-14-starting-trade-mode-design.md` at line 31, Remove machine-specific absolute paths in the document and replace them with repository-relative paths; for each occurrence of "/Users/damien/git_perso/OpenFrontIO/src/client/UserSettingModal.ts" (notably the occurrences reported at lines 31, 53, 75, and 140-143) change them to the relative path "src/client/UserSettingModal.ts" (or a path relative to the repo root used elsewhere), and ensure any other absolute paths in this document follow the same replacement so the doc contains no user-specific file system references.docs/plans/2026-02-14-starting-trade-mode-implementation.md (1)
98-158: Test files mentioned do not exist in this PR.The plan references several test files:
tests/core/game/UserSettings.startingTradeMode.test.tstests/client/UserSettingModal.startingTradeMode.test.tstests/client/utilities/StartingTradeModeController.test.tsThe PR description notes that tests have not been added yet. Consider adding tests or creating issues to track this work.
Do you want me to help draft test cases for the implemented behavior?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/plans/2026-02-14-starting-trade-mode-implementation.md` around lines 98 - 158, The PR references test files that are not present; add the missing tests or track them as issues so CI and reviewers know expected coverage. Create the three tests mentioned (tests/core/game/UserSettings.startingTradeMode.test.ts, tests/client/UserSettingModal.startingTradeMode.test.ts, tests/client/utilities/StartingTradeModeController.test.ts) that assert the new starting trade mode behavior (unit tests for UserSettings API, integration for UserSettingModal UI and controller utilities), or alternatively open issue(s) linking the new feature to the absent tests; ensure tests exercise the UserSettingModal.renderBasicSettings addition, the setStartingTradeMode method on UserSettingModal, and the persistence key settings.startingTradeMode, and include the four i18n keys added to resources/lang/en.json so localization is validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/plans/2026-02-14-starting-trade-mode-design.md`:
- Line 31: Remove machine-specific absolute paths in the document and replace
them with repository-relative paths; for each occurrence of
"/Users/damien/git_perso/OpenFrontIO/src/client/UserSettingModal.ts" (notably
the occurrences reported at lines 31, 53, 75, and 140-143) change them to the
relative path "src/client/UserSettingModal.ts" (or a path relative to the repo
root used elsewhere), and ensure any other absolute paths in this document
follow the same replacement so the doc contains no user-specific file system
references.
In `@docs/plans/2026-02-14-starting-trade-mode-implementation.md`:
- Around line 98-158: The PR references test files that are not present; add the
missing tests or track them as issues so CI and reviewers know expected
coverage. Create the three tests mentioned
(tests/core/game/UserSettings.startingTradeMode.test.ts,
tests/client/UserSettingModal.startingTradeMode.test.ts,
tests/client/utilities/StartingTradeModeController.test.ts) that assert the new
starting trade mode behavior (unit tests for UserSettings API, integration for
UserSettingModal UI and controller utilities), or alternatively open issue(s)
linking the new feature to the absent tests; ensure tests exercise the
UserSettingModal.renderBasicSettings addition, the setStartingTradeMode method
on UserSettingModal, and the persistence key settings.startingTradeMode, and
include the four i18n keys added to resources/lang/en.json so localization is
validated.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/plans/2026-02-14-starting-trade-mode-design.mddocs/plans/2026-02-14-starting-trade-mode-implementation.mdresources/lang/en.jsonsrc/client/ClientGameRunner.tssrc/client/UserSettingModal.tssrc/core/game/UserSettings.ts
75faaa9 to
cfd55e4
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/client/ClientGameRunner.ts`:
- Around line 411-423: The current block that sets startTradeModeInitialized and
schedules startTradeEmbargoAtTick uses
userSettings.stopTradingAllAtStartForTeamGames() without checking replay mode,
so viewers of replays may incorrectly schedule an embargo; update the logic in
ClientGameRunner (the block using startTradeModeInitialized,
startTradeEmbargoAtTick, gameView, and
userSettings.stopTradingAllAtStartForTeamGames()) to early-return or skip
scheduling when the view is a replay (e.g., check gameView.isReplay() or
equivalent) so embargo intents are only set during live games, not while
watching replays.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
resources/lang/en.jsonsrc/client/ClientGameRunner.tssrc/client/UserSettingModal.tssrc/core/game/UserSettings.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/client/UserSettingModal.ts
- resources/lang/en.json
Description:
In most team games (at least in clans), we disable the trade with all right from the start. This PR introduces a setting that automatically disables trade with all at the beginning of the game for team games only.
The default is unchanged (so trade with all is enabled).
I was also considering setting “stop trade with all” as the default option. If it was up to me I would make stop trading with all the default and I would only manually activate it in specific situations, such as when playing a game with random spawns.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found: