Skip to content

PDS warning before continuing with combat/landing#4579

Closed
wholton wants to merge 1 commit intomasterfrom
codex/add-pds-warning-and-count-handling
Closed

PDS warning before continuing with combat/landing#4579
wholton wants to merge 1 commit intomasterfrom
codex/add-pds-warning-and-count-handling

Conversation

@wholton
Copy link
Copy Markdown
Collaborator

@wholton wholton commented Mar 18, 2026

Codex generated this pull request, but encountered an unexpected error after generation. This is a placeholder PR message.


Codex Task

@wholton wholton changed the title Codex-generated pull request PDS warning before continuing with combat/landing Mar 18, 2026
@Fingon00
Copy link
Copy Markdown
Contributor

Don't push this unless you test it out with a few players/PDS fireres

@Fingon00
Copy link
Copy Markdown
Contributor

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

@wholton
Copy link
Copy Markdown
Collaborator Author

wholton commented Mar 23, 2026

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

https://github.com/AsyncTI4/TI4_map_generator_bot/pull/4579/changes#diff-58958273fad53407f6f4221e81d9346c8612c014e97f4816da906c2b66716aa2R71

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (rollType == CombatRollType.SpaceCannonOffence) {
if (first && rollType == CombatRollType.SpaceCannonOffence) {

Copilot uses AI. Check for mistakes.
Comment on lines 69 to +71
MessageHelper.sendMessageToChannel(
game.isFowMode() ? player.getCorrectChannel() : event.getMessageChannel(), msg);
ButtonHelper.decrementPendingPdsDecisions(game);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 175 to 178
if (!game.isL1Hero() && !ctx.playersWithPds2.isEmpty()) {
ButtonHelper.setPendingPdsDecisions(game, ctx.playersWithPds2.size());
ButtonHelperTacticalAction.tacticalActionSpaceCannonOffenceStep(
game, player, ctx.playersWithPds2, ctx.tile);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
@wholton wholton closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants