WebGL: show alliance request+duration icon, show ally and team mate targets too, some optimization#3971
Conversation
…eren't calculated yet). Show Nuke icons (fix: was incorrectly skipped for local player). Show ally and team mates' targets too (weren't calculated yet). Remove unnecessary allocations. Nukes loop had two new sets, transitive targets was a new set and now uses predicate, localPlayer.allies and localPlayer.embargoes were both put in new set instead of using .includes directly)
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughPlayerView adds transitive-target detection; ComputePlayerStatusOptions splits numeric ChangesTransitive Target Support and Player Status Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 2
🤖 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/render/frame/derive/PlayerStatus.ts`:
- Line 98: The code currently sets target = opts.isTransitiveTarget ?
opts.isTransitiveTarget(sid) : false which forces target to false when
isTransitiveTarget is omitted; change this to use the local-player direct-target
check as the default: set target = opts.isTransitiveTarget ?
opts.isTransitiveTarget(sid) : localPlayer.targets.includes(sid) so PlayerStatus
(and the variable target) preserves direct-target behavior when
opts.isTransitiveTarget is not provided.
- Around line 95-125: The nuke scanning loop should run regardless of the
local-player guard so replay mode and self-checks can set
nukeActive/nukeTargetsMe; move the units iteration that sets nukeActive and
nukeTargetsMe (the loop over units that checks u.ownerID === sid, u.isActive,
NUKE_ACTIVE_TYPES.has(u.unitType) and inspects tileState[u.targetTile] against
localPlayerSmallID) out of the "if (localPlayer !== undefined && sid !==
localPlayerSmallID)" block (or duplicate the nuke detection logic before that
guard) while keeping alliance/allianceReq/embargo/target logic inside the guard;
ensure you still respect tileState and localPlayerSmallID checks when computing
nukeTargetsMe.
🪄 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: 45748b66-14df-4053-893f-63ed4c56b08c
📒 Files selected for processing (4)
src/client/render/frame/derive/PlayerStatus.tssrc/client/view/GameView.tssrc/client/view/PlayerView.tstests/client/render/frame/derive/player-status.test.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/client/render/frame/derive/player-status.test.ts (1)
86-336: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy liftUse
setup()helper for this test suite.These tests still build state by hand and call
computePlayerStatusdirectly. Please migrate this suite tosetup()and exercise core simulation as required by the test conventions.As per coding guidelines
tests/**/*.test.ts: Use thesetup()helper fromtests/util/Setup.tsto create test game instances and exercise core simulation directly.🤖 Prompt for 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. In `@tests/client/render/frame/derive/player-status.test.ts` around lines 86 - 336, The test suite currently constructs state manually and calls computePlayerStatus directly; migrate it to use the tests/util/Setup.ts setup() helper so tests drive the core simulation instead. Replace direct playersMap/ps/unitsMap/unit construction with setup() to create a Game instance, add players/units via the setup APIs, advance the simulation as needed, then read computed player status via the same public path that computePlayerStatus uses in production; keep assertions the same but reference the game-derived status instead of the direct computePlayerStatus call. Ensure cases that need tileState or localPlayerSmallID set those via the setup API or simulation helpers (e.g., placing tiles, setting local player) and still test flags like crown, traitor, disconnected, nukeActive, nukeTargetsMe, alliance/target/embargo accordingly.
🤖 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.
Outside diff comments:
In `@tests/client/render/frame/derive/player-status.test.ts`:
- Around line 86-336: The test suite currently constructs state manually and
calls computePlayerStatus directly; migrate it to use the tests/util/Setup.ts
setup() helper so tests drive the core simulation instead. Replace direct
playersMap/ps/unitsMap/unit construction with setup() to create a Game instance,
add players/units via the setup APIs, advance the simulation as needed, then
read computed player status via the same public path that computePlayerStatus
uses in production; keep assertions the same but reference the game-derived
status instead of the direct computePlayerStatus call. Ensure cases that need
tileState or localPlayerSmallID set those via the setup API or simulation
helpers (e.g., placing tiles, setting local player) and still test flags like
crown, traitor, disconnected, nukeActive, nukeTargetsMe, alliance/target/embargo
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 24797d10-1987-4be1-82d7-f4a683a67a28
📒 Files selected for processing (2)
src/client/render/frame/derive/PlayerStatus.tstests/client/render/frame/derive/player-status.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/client/render/frame/derive/PlayerStatus.ts
Description:
Show nuke icons during replay too (when there's no localPlayer).
Show alliance request envelope icon, and duration in alliance icon (weren't calculated yet).
Show ally and team mates' targets too (weren't calculated yet).
Remove unnecessary allocations. Nukes loop allocated two new sets, transitive targets was a new set and now uses predicate with fallback to localPlayer.targets, localPlayer.allies and localPlayer.embargoes were both put in new set instead of using .includes directly.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
tryout33