Repository navigation
Fow test copy 2 - #2415
Fow test copy 2#2415VariableVince wants to merge 1 commit into
Conversation
|
|
WalkthroughAdds Fog of War game mode to the game with comprehensive support across eight languages, UI selection components, a new FogOfWarLayer rendering system with chunk-based dirty rendering and vision updates, fog-aware input handling with touch support, and FFAR-based player spawning logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Game as Game Tick
participant FOW as FogOfWarLayer
participant Units as Player Units
participant Territory as Territory
participant Render as Render Context
Game->>FOW: tick()
FOW->>Units: Query unit positions & vision ranges
Units-->>FOW: Return vision data per unit type
FOW->>Territory: Query allied borders (20-tile radius)
Territory-->>FOW: Return border tiles
FOW->>FOW: Update fog map with vision coverage
FOW->>FOW: Apply fade toward 0.8 for memory
FOW->>FOW: Mark dirty chunks
FOW->>FOW: renderFog() - only dirty chunks
FOW->>FOW: Apply territory tint (green overlay)
FOW->>FOW: Composite fog with per-pixel alpha
FOW->>Render: Draw fog canvas
Render->>Render: Display to screen
sequenceDiagram
participant Player as Player Click
participant Input as InputHandler
participant FOW as FogOfWarLayer
participant Menu as BuildMenu
Player->>Input: onPointerUp(event)
Input->>Input: Check if modifier key + FogOfWar mode
alt Fog of War Mode
Input->>Input: Convert screen to world coords
Input->>FOW: getFogValueAt(tile index)
FOW-->>Input: Return fog value
Input->>Input: Check if fog >= 0.8 (fully fogged)
alt Fully Fogged
Input->>Input: Suppress menu display
else Not Fogged
Input->>Menu: Show build menu
end
else Other Mode
Input->>Menu: Show build menu normally
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks❌ Failed checks (2 inconclusive)
✅ Passed checks (1 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: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/client/graphics/GameRenderer.ts (1)
235-312: Wire the fog layer onto the renderer instanceWe instantiate
fogOfWarLayerbut never assign it toGameRenderer.fogOfWarLayer. Because of that, anything callingrenderer.fogOfWarLayer(e.g.InputHandler.setFogOfWarLayer,playerInfo.setFogOfWarLayer) still receivesnull, so the fog-aware gating added in this PR never runs. Please store the reference on the renderer before returning it.- return new GameRenderer( - game, - eventBus, - canvas, - transformHandler, - uiState, - layers, - fpsDisplay, - ); + const renderer = new GameRenderer( + game, + eventBus, + canvas, + transformHandler, + uiState, + layers, + fpsDisplay, + ); + renderer.fogOfWarLayer = fogOfWarLayer; + return renderer;Also applies to: 333-334
🧹 Nitpick comments (1)
src/client/graphics/layers/BuildMenu.ts (1)
133-170: Give the fog layer a concrete type
fogOfWarLayeris typed asany, so the compiler cannot protect us from wiring mistakes in the new fog-dependent logic. Please import the actual layer class (or an interface) and declare this field as that concrete type (optionally| null). That keeps the code idiomatic and prevents silent regressions if the fog layer API changes.-import { translateText } from "../../../client/Utils"; +import { translateText } from "../../../client/Utils"; +import { FogOfWarLayer } from "./FogOfWarLayer"; ... - public fogOfWarLayer: any = null; + public fogOfWarLayer: FogOfWarLayer | null = null;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
resources/lang/de.json(1 hunks)resources/lang/en.json(1 hunks)resources/lang/es.json(1 hunks)resources/lang/fr.json(1 hunks)resources/lang/ja.json(1 hunks)resources/lang/pt-BR.json(1 hunks)resources/lang/ru.json(1 hunks)resources/lang/zh-CN.json(1 hunks)src/client/ClientGameRunner.ts(8 hunks)src/client/HostLobbyModal.ts(2 hunks)src/client/InputHandler.ts(8 hunks)src/client/SinglePlayerModal.ts(1 hunks)src/client/graphics/GameRenderer.ts(6 hunks)src/client/graphics/TransformHandler.ts(2 hunks)src/client/graphics/layers/BuildMenu.ts(3 hunks)src/client/graphics/layers/FogOfWarLayer.ts(1 hunks)src/client/graphics/layers/GameLeftSidebar.ts(4 hunks)src/client/graphics/layers/GameRightSidebar.ts(4 hunks)src/client/graphics/layers/Leaderboard.ts(15 hunks)src/client/graphics/layers/MainRadialMenu.ts(8 hunks)src/client/graphics/layers/NameLayer.ts(4 hunks)src/client/graphics/layers/PlayerInfoOverlay.ts(10 hunks)src/client/graphics/layers/RadialMenuElements.ts(6 hunks)src/core/GameRunner.ts(4 hunks)src/core/Util.ts(0 hunks)src/core/execution/ExecutionManager.ts(4 hunks)src/core/execution/FFARSpawner.ts(1 hunks)src/core/game/Game.ts(1 hunks)
💤 Files with no reviewable changes (1)
- src/core/Util.ts
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1655
File: resources/maps/giantworldmap/manifest.json:165-174
Timestamp: 2025-07-31T12:03:08.052Z
Learning: In OpenFrontIO draft PRs, flag names in map manifest files may be placeholders that will be updated to match the actual SVG flag file names when the assets are received. The final naming depends on the actual flag SVG files provided, not code naming conventions.
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
Applied to files:
src/client/graphics/layers/GameLeftSidebar.tssrc/client/SinglePlayerModal.tssrc/client/graphics/layers/NameLayer.tssrc/client/graphics/GameRenderer.tssrc/client/graphics/layers/RadialMenuElements.tssrc/client/graphics/layers/Leaderboard.tssrc/client/graphics/layers/PlayerInfoOverlay.tssrc/client/InputHandler.tssrc/client/graphics/layers/MainRadialMenu.tssrc/client/graphics/layers/GameRightSidebar.tssrc/client/HostLobbyModal.tssrc/client/ClientGameRunner.ts
📚 Learning: 2025-10-21T20:06:04.823Z
Learnt from: Saphereye
Repo: openfrontio/OpenFrontIO PR: 2233
File: src/client/HostLobbyModal.ts:891-891
Timestamp: 2025-10-21T20:06:04.823Z
Learning: For the HumansVsNations game mode in `src/client/HostLobbyModal.ts` and related files, the implementation strategy is to generate all nations and adjust their strength for balancing, rather than limiting lobby size based on the number of available nations on the map.
Applied to files:
src/client/SinglePlayerModal.tssrc/core/execution/FFARSpawner.tssrc/core/execution/ExecutionManager.tssrc/client/HostLobbyModal.tssrc/core/GameRunner.ts
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/SinglePlayerModal.tssrc/core/execution/ExecutionManager.tssrc/client/graphics/layers/PlayerInfoOverlay.tssrc/client/InputHandler.tssrc/client/HostLobbyModal.tssrc/client/ClientGameRunner.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: For the window close confirmation feature in `ClientGameRunner.ts`, the troop count requirement (>10,000 troops) from issue #2137 was intentionally removed because it was arbitrary and troop count can be reported as low despite having significant land. The confirmation now triggers for any alive player regardless of troop count.
Applied to files:
src/client/SinglePlayerModal.tssrc/client/graphics/layers/Leaderboard.tssrc/client/ClientGameRunner.ts
📚 Learning: 2025-10-18T11:00:57.142Z
Learnt from: NewYearNewPhil
Repo: openfrontio/OpenFrontIO PR: 2230
File: src/client/graphics/GameRenderer.ts:269-277
Timestamp: 2025-10-18T11:00:57.142Z
Learning: In src/client/graphics/GameRenderer.ts, the GameRecapCapture implementation does not use setCaptureRenderEnabled on layers. Instead, it uses RecapCaptureSurface.capture() to render capture layers (TerrainLayer, TerritoryLayer, RailroadLayer, StructureIconsLayer, UnitLayer) directly to an off-screen canvas without requiring layer-level capture mode methods.
Applied to files:
src/client/graphics/layers/NameLayer.tssrc/client/graphics/GameRenderer.tssrc/client/graphics/layers/FogOfWarLayer.tssrc/client/graphics/layers/Leaderboard.tssrc/client/graphics/layers/PlayerInfoOverlay.tssrc/client/graphics/layers/GameRightSidebar.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: In `ClientGameRunner.ts`, the `myPlayer` field is always set when `shouldPreventWindowClose()` is called, so the null check in that method is sufficient without needing to fetch it again from `gameView.playerByClientID()`.
Applied to files:
src/client/graphics/layers/NameLayer.tssrc/client/graphics/layers/Leaderboard.tssrc/client/ClientGameRunner.ts
📚 Learning: 2025-06-22T21:51:14.990Z
Learnt from: devalnor
Repo: openfrontio/OpenFrontIO PR: 1248
File: src/client/graphics/layers/TerritoryInfoLayer.ts:20-20
Timestamp: 2025-06-22T21:51:14.990Z
Learning: In TerritoryInfoLayer.ts, the highlightedTerritory field uses both null and undefined intentionally: undefined represents initial state or inactive layer (Ctrl released), while null represents active layer with no territory being highlighted at cursor position. This distinction is important for proper state change detection.
Applied to files:
src/client/graphics/TransformHandler.tssrc/client/graphics/layers/FogOfWarLayer.tssrc/client/graphics/layers/PlayerInfoOverlay.ts
📚 Learning: 2025-08-23T08:03:44.914Z
Learnt from: ElMelchizedek
Repo: openfrontio/OpenFrontIO PR: 1876
File: src/core/execution/FakeHumanExecution.ts:547-592
Timestamp: 2025-08-23T08:03:44.914Z
Learning: In OpenFrontIO, FakeHumanExecution is used for AI-controlled nations that simulate human behavior, which is distinct from PlayerType.Bot. FakeHumanExecution players are not PlayerType.Bot - they represent more sophisticated AI that mimics human nation behavior, while PlayerType.Bot represents basic AI players.
Applied to files:
src/core/execution/FFARSpawner.tssrc/core/execution/ExecutionManager.tssrc/client/graphics/layers/PlayerInfoOverlay.tssrc/core/GameRunner.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.
Applied to files:
src/core/execution/FFARSpawner.tssrc/core/execution/ExecutionManager.tssrc/core/GameRunner.ts
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenuElements.tssrc/client/graphics/layers/MainRadialMenu.ts
📚 Learning: 2025-06-02T14:27:37.609Z
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
Applied to files:
resources/lang/pt-BR.jsonresources/lang/fr.json
📚 Learning: 2025-10-20T11:02:16.969Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:57-57
Timestamp: 2025-10-20T11:02:16.969Z
Learning: In src/core/execution/FakeHumanExecution.ts, the correct MIRV victory denial thresholds are VICTORY_DENIAL_TEAM_THRESHOLD = 0.8 (80% for team games) and VICTORY_DENIAL_INDIVIDUAL_THRESHOLD = 0.65 (65% for individual players), not 0.85 and 0.7 as might be mentioned in some documentation.
Applied to files:
src/core/execution/ExecutionManager.ts
📚 Learning: 2025-08-28T22:47:31.406Z
Learnt from: BrewedCoffee
Repo: openfrontio/OpenFrontIO PR: 1957
File: tests/core/executions/PlayerExecution.test.ts:16-39
Timestamp: 2025-08-28T22:47:31.406Z
Learning: In test files, PlayerExecution instances must be manually registered with game.addExecution() because the setup utility doesn't automatically register SpawnExecution, which would normally handle this during the spawn phase in a real game.
Applied to files:
src/core/execution/ExecutionManager.ts
📚 Learning: 2025-10-18T17:54:01.311Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:172-173
Timestamp: 2025-10-18T17:54:01.311Z
Learning: In src/core/execution/FakeHumanExecution.ts, MIRVs and ground attacks should not be mutually exclusive. The considerMIRV() method should not short-circuit maybeAttack() - both actions can occur in the same tick.
Applied to files:
src/core/execution/ExecutionManager.ts
📚 Learning: 2025-05-31T18:15:03.445Z
Learnt from: 1brucben
Repo: openfrontio/OpenFrontIO PR: 977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
Applied to files:
src/client/graphics/layers/Leaderboard.ts
📚 Learning: 2025-06-20T20:11:00.965Z
Learnt from: devalnor
Repo: openfrontio/OpenFrontIO PR: 1195
File: src/client/graphics/layers/AlertFrame.ts:18-18
Timestamp: 2025-06-20T20:11:00.965Z
Learning: In the OpenFrontIO codebase, UserSettings instances are created directly with `new UserSettings()` in each component that needs them. This pattern is used consistently across at least 12+ files including OptionsMenu, EventsDisplay, DarkModeButton, Main, UserSettingModal, UsernameInput, NameLayer, AlertFrame, UILayer, InputHandler, ClientGameRunner, and GameView. This is the established architectural pattern and should be followed for consistency.
Applied to files:
src/client/InputHandler.ts
📚 Learning: 2025-08-28T15:14:40.664Z
Learnt from: mokizzz
Repo: openfrontio/OpenFrontIO PR: 1956
File: src/client/InputHandler.ts:430-449
Timestamp: 2025-08-28T15:14:40.664Z
Learning: On trackpads and touchscreens, users don't expect purely vertical two-finger swipes to trigger zoom. Pan detection using deltaX !== 0 is appropriate since any horizontal movement indicates pan intent, and zoom should be handled via pinch gestures instead.
Applied to files:
src/client/InputHandler.ts
📚 Learning: 2025-11-07T00:23:48.555Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 2408
File: src/client/InputHandler.ts:485-485
Timestamp: 2025-11-07T00:23:48.555Z
Learning: In JavaScript/TypeScript PointerEvent and MouseEvent, the properties event.x and event.y are aliases for event.clientX and event.clientY. They represent the same viewport-relative coordinates and can be used interchangeably.
Applied to files:
src/client/InputHandler.ts
📚 Learning: 2025-08-16T10:52:08.292Z
Learnt from: TheGiraffe3
Repo: openfrontio/OpenFrontIO PR: 884
File: resources/lang/en.json:456-461
Timestamp: 2025-08-16T10:52:08.292Z
Learning: In OpenFrontIO, translation files in resources/lang/*.json (except en.json) should not be updated in regular PRs. Only dedicated translation PRs titled "mls" and made by Aotumori should update non-English locale files. Regular PRs should only update en.json when adding or modifying translation keys.
Applied to files:
resources/lang/ja.jsonresources/lang/fr.json
📚 Learning: 2025-05-19T06:00:38.007Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.
Applied to files:
src/client/ClientGameRunner.ts
🧬 Code graph analysis (18)
src/client/graphics/layers/GameLeftSidebar.ts (2)
src/core/EventBus.ts (1)
EventBus(7-44)src/core/game/GameView.ts (1)
myPlayer(579-581)
src/client/SinglePlayerModal.ts (2)
src/client/Utils.ts (1)
translateText(92-147)src/client/LangSelector.ts (1)
translateText(254-274)
src/client/graphics/layers/NameLayer.ts (2)
src/core/game/GameView.ts (2)
GameView(434-765)nameLocation(308-310)src/client/graphics/TransformHandler.ts (1)
TransformHandler(16-300)
src/client/graphics/TransformHandler.ts (1)
src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)
src/core/execution/FFARSpawner.ts (6)
src/core/PseudoRandom.ts (1)
PseudoRandom(3-76)src/core/execution/SpawnExecution.ts (1)
SpawnExecution(7-61)src/core/game/Game.ts (2)
Game(654-738)PlayerInfo(396-416)src/core/Schemas.ts (1)
GameID(24-24)src/core/Util.ts (1)
simpleHash(64-72)src/core/game/GameMap.ts (1)
TileRef(3-3)
src/client/graphics/GameRenderer.ts (2)
src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)src/client/graphics/layers/NameLayer.ts (1)
NameLayer(38-696)
src/client/graphics/layers/BuildMenu.ts (3)
src/core/game/GameView.ts (2)
x(658-660)y(661-663)src/core/game/GameImpl.ts (2)
x(780-782)y(783-785)src/core/game/GameMap.ts (2)
x(122-124)y(126-128)
src/client/graphics/layers/RadialMenuElements.ts (1)
src/client/graphics/layers/NameLayer.ts (2)
NameLayer(38-696)isPlayerNameVisible(658-695)
src/core/execution/ExecutionManager.ts (5)
src/core/execution/NoOpExecution.ts (1)
NoOpExecution(3-12)src/core/game/Game.ts (1)
PlayerInfo(396-416)src/core/execution/SpawnExecution.ts (1)
SpawnExecution(7-61)src/core/game/GameImpl.ts (1)
nations(226-228)src/core/execution/FFARSpawner.ts (1)
FFARSpawner(8-148)
src/client/graphics/layers/FogOfWarLayer.ts (3)
src/client/graphics/layers/Layer.ts (1)
Layer(1-7)src/core/game/GameView.ts (3)
GameView(434-765)myPlayer(579-581)unit(645-647)src/client/graphics/TransformHandler.ts (1)
TransformHandler(16-300)
src/client/graphics/layers/Leaderboard.ts (3)
src/core/game/GameView.ts (6)
player(583-589)PlayerView(177-432)x(658-660)y(661-663)myPlayer(579-581)nameLocation(308-310)src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)src/client/Utils.ts (1)
translateText(92-147)
src/client/graphics/layers/PlayerInfoOverlay.ts (3)
src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)src/client/graphics/layers/NameLayer.ts (1)
NameLayer(38-696)src/core/game/GameView.ts (4)
x(658-660)y(661-663)player(583-589)PlayerView(177-432)
src/client/InputHandler.ts (3)
src/client/graphics/UIState.ts (1)
UIState(3-6)src/core/EventBus.ts (1)
EventBus(7-44)src/core/game/GameView.ts (2)
x(658-660)y(661-663)
src/client/graphics/layers/MainRadialMenu.ts (3)
src/client/graphics/layers/RadialMenuElements.ts (1)
MenuElementParams(34-47)src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)src/client/graphics/layers/NameLayer.ts (1)
NameLayer(38-696)
src/client/graphics/layers/GameRightSidebar.ts (2)
src/core/game/GameView.ts (10)
GameView(434-765)myPlayer(579-581)playerViews(619-621)player(583-589)x(658-660)y(661-663)units(302-306)units(637-644)unit(645-647)tile(102-104)src/client/graphics/layers/FogOfWarLayer.ts (1)
FogOfWarLayer(6-505)
src/client/HostLobbyModal.ts (1)
src/client/Utils.ts (1)
translateText(92-147)
src/client/ClientGameRunner.ts (3)
src/core/game/GameView.ts (2)
tile(102-104)actions(275-281)src/core/game/Game.ts (1)
PlayerActions(740-745)src/core/game/GameMap.ts (1)
TileRef(3-3)
src/core/GameRunner.ts (1)
src/core/game/Game.ts (1)
PlayerInfo(396-416)
🔇 Additional comments (10)
resources/lang/zh-CN.json (1)
260-262: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "战争迷雾" is appropriate for Simplified Chinese.resources/lang/fr.json (1)
263-265: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "Brouillard de guerre" is appropriate for French.Note: While non-English locale files are typically updated only in dedicated translation PRs, this feature addition requires coordinated localization updates across all supported languages.
Based on learnings
resources/lang/es.json (1)
205-207: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "Niebla de guerra" is appropriate for Spanish.resources/lang/ja.json (1)
263-265: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "戦争の霧" is appropriate for Japanese.resources/lang/ru.json (1)
263-265: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "Туман войны" is appropriate for Russian.resources/lang/de.json (1)
235-237: LGTM - Fog of War translation addedThe new
fog_of_wartranslation key has been added correctly with proper JSON syntax. The translation "Kriegsnebel" is appropriate for German.src/client/SinglePlayerModal.ts (2)
184-193: LGTM - Fog of War game mode card added correctlyThe new Fog of War option card follows the existing pattern for FFA and Teams cards. The translation key
game_mode.fog_of_warcorrectly references the new localization entries added across all language files.
197-197: LGTM - Team count conditional updated appropriatelyThe conditional now hides the Team Count section for both FFA and Fog of War modes, which makes sense since Fog of War appears to be a free-for-all variant without team assignments.
src/client/graphics/TransformHandler.ts (1)
10-10: LGTM - FogOfWarLayer reference addedThe addition of a public nullable
fogOfWarLayerfield allows other components to inject and access the Fog of War layer through the shared TransformHandler reference. The nullable type is appropriate since Fog of War may not always be active.Also applies to: 27-28
src/client/InputHandler.ts (1)
483-514: Confirm the object passed intosetGameexposesrenderer.transformHandlerInside
onPointerUpwe guard fog access withif (this.game.renderer && this.game.renderer.transformHandler), butsetGamecurrently receives aGameView(norendererproperty) in the existing client setup. That means this branch never runs and the build menu still pops up on fully fogged tiles. Please either pass in the renderer (or the transform handler) explicitly, or refactor this code to use data that is always present onGameView. Could you double-check the wiring and adjust accordingly?
| if (this.eventBus) { | ||
| this.eventBus.emit({ type: "leaderboardToggled", show: this.isLeaderboardShow }); | ||
| } | ||
| } | ||
|
|
||
| private toggleTeamLeaderboard(): void { | ||
| this.isTeamLeaderboardShow = !this.isTeamLeaderboardShow; | ||
| // Emitting event when the team leaderboard is toggled | ||
| if (this.eventBus) { | ||
| this.eventBus.emit({ type: "teamLeaderboardToggled", show: this.isTeamLeaderboardShow }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Emit real EventBus events
EventBus.emit routes listeners by the event class. Emitting a bare object ({ type: "...", show: ... }) means every listener sees the constructor Object, so nobody subscribed with eventBus.on(SomeEvent, …) will be notified. Please introduce proper GameEvent classes (or reuse existing ones) and emit instances instead of plain objects.
🤖 Prompt for AI Agents
In src/client/graphics/layers/GameLeftSidebar.ts around lines 88 to 99 the code
emits plain objects ({ type: "...", show: ... }) which route listeners by Object
constructor and will not match eventBus.on(SomeEvent, ...). Replace those
plain-object emits with real GameEvent instances: either reuse existing event
classes (e.g., LeaderboardToggledEvent / TeamLeaderboardToggledEvent) or create
them if missing, construct new instances with the show flag, and call
this.eventBus.emit(new LeaderboardToggledEvent(this.isLeaderboardShow)) and
this.eventBus.emit(new TeamLeaderboardToggledEvent(this.isTeamLeaderboardShow))
so listeners subscribed by event class receive the events.
| function isPlayerNameVisible(params: ExtendedMenuElementParams): boolean { | ||
| // If we're not in Fog of War mode, the name is always visible | ||
| if (params.game.config().gameConfig().gameMode !== GameMode.FogOfWar) { | ||
| // In FFA and Team modes, check if the selected player exists and is alive | ||
| return params.selected !== null && params.selected.isAlive(); | ||
| } | ||
|
|
||
| // If we don't have access to the selected player, assume it's not visible | ||
| if (!params.selected) { | ||
| return false; | ||
| } | ||
|
|
||
| // If we don't have access to nameLayer, assume it's not visible | ||
| if (!params.nameLayer) { | ||
| return false; | ||
| } | ||
|
|
||
| // Check if the player's name is visible through NameLayer | ||
| return params.nameLayer.isPlayerNameVisible(params.selected); | ||
| } |
There was a problem hiding this comment.
Don’t gate the info menu by the player name anchor fog
isPlayerNameVisible calls nameLayer.isPlayerNameVisible, which checks the fog value at the player’s nameLocation. During Fog of War it’s common to scout a frontline tile (fog < 0.8 at the clicked tile) while the player label deep in their territory is still masked (fog ≥ 0.8). In that case this helper returns false, so the info menu stays disabled even though the user can see and interact with the tile. That blocks alliance, chat, donation, and other diplomacy actions right when players need them most. Please base the visibility check on the tile we opened the menu on (or reuse the fog value you already compute for the root menu) instead of the label location.
- if (!params.nameLayer) {
- return false;
- }
-
- return params.nameLayer.isPlayerNameVisible(params.selected);
+ const fogLayer = (params as any).fogOfWarLayer;
+ if (!fogLayer) {
+ return params.selected.isAlive();
+ }
+
+ const tileX = params.game.x(params.tile);
+ const tileY = params.game.y(params.tile);
+ const idx = tileY * params.game.width() + tileX;
+ return fogLayer.getFogValueAt(idx) < 0.8;🤖 Prompt for AI Agents
In src/client/graphics/layers/RadialMenuElements.ts around lines 324 to 343, the
current isPlayerNameVisible uses nameLayer.isPlayerNameVisible (which checks fog
at the label location) causing the info menu to be disabled when the clicked
tile is visible but the name anchor is fogged; change the logic so that during
FogOfWar you determine visibility from the menu root tile's fog value (or reuse
the already-computed fog value for the root menu) instead of calling
nameLayer.isPlayerNameVisible; keep the existing non-FogOfWar check and null
checks for params.selected, but when FogOfWar use the tile/fog check (or a
passed-in rootFog boolean) to decide visibility so the info menu enables when
the clicked tile is visible even if the name label is masked.
| if (this.mg.config().gameConfig().gameMode === GameMode.FogOfWar && this.mg.inSpawnPhase()) { | ||
| // Convert all intents to NoOpExecution during spawn phase in FOW mode | ||
| return new NoOpExecution(); | ||
| } |
There was a problem hiding this comment.
Keep spawn fallback alive in Fog of War
Right now every Fog of War intent during the spawn phase becomes a NoOp. When FFARSpawner.spawnHuman gives up after 10 000 tries, that human stays unspawned and, with this guard, cannot send a manual spawn intent to recover. Please keep the old fallback by letting spawn intents through until the player has actually spawned.
- if (this.mg.config().gameConfig().gameMode === GameMode.FogOfWar && this.mg.inSpawnPhase()) {
- // Convert all intents to NoOpExecution during spawn phase in FOW mode
- return new NoOpExecution();
- }
+ if (this.mg.config().gameConfig().gameMode === GameMode.FogOfWar && this.mg.inSpawnPhase()) {
+ if (intent.type !== "spawn" || player.hasSpawned()) {
+ return new NoOpExecution();
+ }
+ }Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/core/execution/ExecutionManager.ts around lines 55–58, the current guard
converts every Fog of War intent to NoOp during the spawn phase which blocks
manual spawn retries; change it so spawn intents are exempted until the player
has actually spawned. Concretely: when in FogOfWar spawn phase, only convert
non-spawn intents to NoOp (or convert intents to NoOp only for players that are
already spawned), and allow IntentType.Spawn (or the code path that triggers
FFARSpawner.spawnHuman) to pass through; use the existing player-spawned check
on the player ID or call the manager method that reports whether the
player/entity is spawned to decide when to stop exempting spawn intents.
| private randTile(): TileRef { | ||
| const x = this.random.nextInt(0, this.gs.width() - 1); | ||
| const y = this.random.nextInt(0, this.gs.height() - 1); | ||
| return this.gs.ref(x, y); | ||
| } |
There was a problem hiding this comment.
Fix randTile bounds
PseudoRandom.nextInt treats the upper bound as exclusive. Passing width() - 1 / height() - 1 therefore prevents the last column and last row from ever being picked, so some land tiles will never be considered for spawns. Please feed the raw width/height into the call so every tile is reachable.
- const x = this.random.nextInt(0, this.gs.width() - 1);
- const y = this.random.nextInt(0, this.gs.height() - 1);
+ const x = this.random.nextInt(0, this.gs.width());
+ const y = this.random.nextInt(0, this.gs.height());🤖 Prompt for AI Agents
In src/core/execution/FFARSpawner.ts around lines 102 to 106, randTile currently
calls this.random.nextInt(0, this.gs.width() - 1) and nextInt(0,
this.gs.height() - 1) which treats the upper bound as exclusive and therefore
never selects the last column/row; change the calls to this.random.nextInt(0,
this.gs.width()) and this.random.nextInt(0, this.gs.height()) so the full range
[0, width-1] and [0, height-1] can be returned, leaving the rest of the method
unchanged.
| const prefix = prefixes[this.random.nextInt(0, prefixes.length - 1)]; | ||
| const suffix = suffixes[this.random.nextInt(0, suffixes.length - 1)]; | ||
| return `${prefix}_${suffix}`; |
There was a problem hiding this comment.
Use full prefix/suffix ranges
The same exclusive-upper-bound behavior means the last prefix and suffix entries are never used. Bumping the bounds to the raw array lengths restores the full variety without changing randomness elsewhere.
- const prefix = prefixes[this.random.nextInt(0, prefixes.length - 1)];
- const suffix = suffixes[this.random.nextInt(0, suffixes.length - 1)];
+ const prefix = prefixes[this.random.nextInt(0, prefixes.length)];
+ const suffix = suffixes[this.random.nextInt(0, suffixes.length)];📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const prefix = prefixes[this.random.nextInt(0, prefixes.length - 1)]; | |
| const suffix = suffixes[this.random.nextInt(0, suffixes.length - 1)]; | |
| return `${prefix}_${suffix}`; | |
| const prefix = prefixes[this.random.nextInt(0, prefixes.length)]; | |
| const suffix = suffixes[this.random.nextInt(0, suffixes.length)]; | |
| return `${prefix}_${suffix}`; |
🤖 Prompt for AI Agents
In src/core/execution/FFARSpawner.ts around lines 144 to 146, the random index
bounds use lengths minus one so the final prefix/suffix entries are never
selected; update the calls to this.random.nextInt to use the raw array lengths
(e.g., nextInt(0, prefixes.length) and nextInt(0, suffixes.length)) so the upper
bound is exclusive but covers the full array range.
Description:
Describe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME