Skip to content

Commit c7a90ca

Browse files
fix: respect mana-loss prompt during phase skip and auto-pass
Auto-passing (yield) and phase-skip both returned null from chooseSpellAbilityToPlay before reaching passPriority(), silently discarding floating mana without showing the UI_MANA_LOST_PROMPT dialog. Both paths now check willManaBeLostAtEndOfPhase() and fall through to InputPassPriority when mana would be lost. Also removes duplicate AfkTimeout import in InputPassPriority. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8c6738f commit c7a90ca

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

forge-gui/src/main/java/forge/player/PlayerControllerHuman.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,16 +1520,36 @@ public List<SpellAbility> chooseSpellAbilityToPlay() {
15201520
e.printStackTrace();
15211521
}
15221522
}
1523-
netLog.trace("Returning null (mayAutoPass) for player {}", player.getName());
1524-
return null;
1523+
// Don't auto-pass over floating mana that would be lost — fall through
1524+
// to InputPassPriority so the mana-loss dialog can fire.
1525+
if (FModel.getPreferences().getPrefBoolean(FPref.UI_MANA_LOST_PROMPT) && stack.isEmpty()) {
1526+
Player priority = getGame().getPhaseHandler().getPriorityPlayer();
1527+
if (priority != null && priority.getManaPool().willManaBeLostAtEndOfPhase()
1528+
&& priority.getLobbyPlayer() == GamePlayerUtil.getGuiPlayer()) {
1529+
// fall through to show InputPassPriority
1530+
} else {
1531+
netLog.trace("Returning null (mayAutoPass) for player {}", player.getName());
1532+
return null;
1533+
}
1534+
} else {
1535+
netLog.trace("Returning null (mayAutoPass) for player {}", player.getName());
1536+
return null;
1537+
}
15251538
}
15261539

15271540
if (stack.isEmpty()) {
15281541
if (getGui().isUiSetToSkipPhase(getGame().getPhaseHandler().getPlayerTurn().getView(),
15291542
getGame().getPhaseHandler().getPhase())) {
1530-
netLog.trace("Returning null (skipPhase) for player {}", player.getName());
1531-
return null; // avoid prompt for input if stack is empty and
1532-
// player is set to skip the current phase
1543+
// Don't skip over a phase where floating mana would be lost.
1544+
boolean wouldLoseMana = FModel.getPreferences().getPrefBoolean(FPref.UI_MANA_LOST_PROMPT)
1545+
&& getGame().getPhaseHandler().getPriorityPlayer() != null
1546+
&& getGame().getPhaseHandler().getPriorityPlayer().getManaPool().willManaBeLostAtEndOfPhase()
1547+
&& getGame().getPhaseHandler().getPriorityPlayer().getLobbyPlayer() == GamePlayerUtil.getGuiPlayer();
1548+
if (!wouldLoseMana) {
1549+
netLog.trace("Returning null (skipPhase) for player {}", player.getName());
1550+
return null; // avoid prompt for input if stack is empty and
1551+
// player is set to skip the current phase
1552+
}
15331553
}
15341554
} else {
15351555
final SpellAbility ability = stack.peekAbility();

0 commit comments

Comments
 (0)