PDS warning before continuing with combat/landing#4579
PDS warning before continuing with combat/landing#4579
Conversation
|
Don't push this unless you test it out with a few players/PDS fireres |
|
Also does this handle if the player declined to fire PDS? I don't think I saw it decrease the counter for that situation. In general I think this may be the wrong fix for the issue |
This is the decline button handler. And, if you have a different solution you want to go with, all good. This was generated by Copilot and I just cleaned it up a bit. |
There was a problem hiding this comment.
Pull request overview
Adds a “pending PDS decisions” guardrail so players are warned before proceeding to landing/combat while Space Cannon Offense decisions are still outstanding during a tactical action.
Changes:
- Track the number of pending PDS decision-makers when finishing movement into an activated system.
- Warn (and require a second press) when attempting to start combat rounds/AFB rolls or land units while PDS decisions are pending.
- Decrement the pending counter when a PDS player fires Space Cannon Offense or declines.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/ti4/service/tactical/TacticalActionService.java | Initializes pending PDS decision tracking when PDS2 coverage exists after movement. |
| src/main/java/ti4/helpers/ButtonHelper.java | Adds warning + pending-counter bookkeeping; hooks warning/decrement into combat roll resolution. |
| src/main/java/ti4/buttons/handlers/unitPickers/TacticalActionButtonHandlers.java | Blocks landing on first click when PDS decisions are pending (warns instead). |
| src/main/java/ti4/buttons/handlers/combat/CombatButtonHandler.java | Decrements pending counter on “Decline PDS”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| && warnIfPendingPdsDecisions(player, game, event)) { | ||
| return; | ||
| } | ||
| if (rollType == CombatRollType.SpaceCannonOffence) { |
There was a problem hiding this comment.
decrementPendingPdsDecisions(game) is triggered for any SpaceCannonOffence roll, which can happen outside this “pending PDS decisions” window (e.g. EBS / other effects) and can also be invoked multiple times per player via repeated button presses or internal recursion. That can prematurely drive the counter to 0 and suppress the intended warning even though some PDS players never decided. Consider tying the pending state to the specific tactical-action/system (e.g. include active system + eligible factions) and making decrement idempotent per faction/decision rather than a raw global counter.
| if (rollType == CombatRollType.SpaceCannonOffence) { | |
| if (first && rollType == CombatRollType.SpaceCannonOffence) { |
| MessageHelper.sendMessageToChannel( | ||
| game.isFowMode() ? player.getCorrectChannel() : event.getMessageChannel(), msg); | ||
| ButtonHelper.decrementPendingPdsDecisions(game); |
There was a problem hiding this comment.
declinePDS now decrements the global pending-PDS counter, but this handler doesn’t prevent (a) non-eligible players from clicking Decline in the shared combat thread, or (b) the same player clicking Decline multiple times. Either case can incorrectly reduce the counter to 0 and remove the warning while other PDS-capable players still haven’t responded. Consider validating the clicker is in the eligible PDS-cover list for the relevant system and recording per-faction “responded” state so the decrement is only applied once per eligible player.
| if (!game.isL1Hero() && !ctx.playersWithPds2.isEmpty()) { | ||
| ButtonHelper.setPendingPdsDecisions(game, ctx.playersWithPds2.size()); | ||
| ButtonHelperTacticalAction.tacticalActionSpaceCannonOffenceStep( | ||
| game, player, ctx.playersWithPds2, ctx.tile); |
There was a problem hiding this comment.
setPendingPdsDecisions is only called when playersWithPds2 is non-empty, so the stored pending-PDS state can leak from a previous activation/tactical action (e.g., next activation has no PDS coverage, or the tactical action ends without any PDS player clicking fire/decline) and incorrectly warn/block later land/combat rolls. Consider always clearing/resetting this state (set to 0) when there are no PDS players, and also clearing it as part of tactical-action cleanup (e.g., resetStoredValuesForTacticalAction / end-of-tactical-action).
| if (!game.isL1Hero() && !ctx.playersWithPds2.isEmpty()) { | |
| ButtonHelper.setPendingPdsDecisions(game, ctx.playersWithPds2.size()); | |
| ButtonHelperTacticalAction.tacticalActionSpaceCannonOffenceStep( | |
| game, player, ctx.playersWithPds2, ctx.tile); | |
| if (!game.isL1Hero()) { | |
| int pendingPdsCount = ctx.playersWithPds2.size(); | |
| ButtonHelper.setPendingPdsDecisions(game, pendingPdsCount); | |
| if (pendingPdsCount > 0) { | |
| ButtonHelperTacticalAction.tacticalActionSpaceCannonOffenceStep( | |
| game, player, ctx.playersWithPds2, ctx.tile); | |
| } |
Codex generated this pull request, but encountered an unexpected error after generation. This is a placeholder PR message.
Codex Task