Fix: Ship stat display#3931
Conversation
WalkthroughReactivates and exports a UnitType→boat-key mapping, adds ChangesShip Statistics Type Tracking
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 (1)
src/core/game/Stats.ts (1)
37-80: ⚡ Quick winTighten boat method parameter types by method intent.
These signatures still allow the wrong ship type at compile time (trade methods can take transport type, and vice versa). That can silently reintroduce swapped stats. Use specific literal types per method.
Proposed type-tightening diff
-import { Player, TerraNullius } from "./Game"; +import { Player, TerraNullius, UnitType } from "./Game"; @@ - boatSendTrade(player: Player, target: Player, type: BoatUnitType): void; + boatSendTrade( + player: Player, + target: Player, + type: UnitType.TradeShip, + ): void; @@ - type: BoatUnitType, + type: UnitType.TradeShip, @@ - type: BoatUnitType, + type: UnitType.TradeShip, @@ - boatDestroyTrade(player: Player, target: Player, type: BoatUnitType): void; + boatDestroyTrade( + player: Player, + target: Player, + type: UnitType.TradeShip, + ): void; @@ - type: BoatUnitType, + type: UnitType.TransportShip, @@ - type: BoatUnitType, + type: UnitType.TransportShip, @@ - type: BoatUnitType, + type: UnitType.TransportShip,🤖 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 `@src/core/game/Stats.ts` around lines 37 - 80, The boat-related method signatures (boatSendTrade, boatArriveTrade, boatCapturedTrade, boatDestroyTrade, boatSendTroops, boatArriveTroops, boatDestroyTroops) currently accept a generic BoatUnitType which allows passing the wrong ship kind; change each method's "type" parameter to the precise literal/enum value that matches the method intent (e.g., use the trade-specific literal/enum member for all *Trade methods and the transport/ troop-specific literal/enum member for all *Troops methods), and then update any implementations/call sites to use those narrowed types so the compiler enforces correct ship-kind usage rather than allowing swapping trade vs transport types.
🤖 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.
Nitpick comments:
In `@src/core/game/Stats.ts`:
- Around line 37-80: The boat-related method signatures (boatSendTrade,
boatArriveTrade, boatCapturedTrade, boatDestroyTrade, boatSendTroops,
boatArriveTroops, boatDestroyTroops) currently accept a generic BoatUnitType
which allows passing the wrong ship kind; change each method's "type" parameter
to the precise literal/enum value that matches the method intent (e.g., use the
trade-specific literal/enum member for all *Trade methods and the transport/
troop-specific literal/enum member for all *Troops methods), and then update any
implementations/call sites to use those narrowed types so the compiler enforces
correct ship-kind usage rather than allowing swapping trade vs transport types.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f55f6756-07a7-4790-8b5f-a0580273f512
📒 Files selected for processing (7)
src/core/StatsSchemas.tssrc/core/execution/TradeShipExecution.tssrc/core/execution/TransportShipExecution.tssrc/core/game/Stats.tssrc/core/game/StatsImpl.tssrc/core/game/UnitImpl.tstests/Stats.test.ts
0085934 to
69100fe
Compare
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #3441
Description:
This change enables the unitTypeToBoatUnit Record type in StatsSchemas.ts for use in recording boat-usage stats, along with updating method/function signatures to accept the appropriate BoatUnit type. This includes updating test code wherever necessary in order to satisfy updated signatures.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME: TheStoneyLonesome