GUI, game: improved priority pass on non-empty mana pool (no more confirm dialogs on active "don't lose unspent mana" and other effects, close #11717)

This commit is contained in:
Oleg Agafonov 2025-01-06 03:33:06 +04:00
parent fbd5cca14a
commit 75d241d541
2 changed files with 32 additions and 9 deletions

View file

@ -2928,7 +2928,7 @@ public class HumanPlayer extends PlayerImpl {
protected boolean passWithManaPoolCheck(Game game) { protected boolean passWithManaPoolCheck(Game game) {
if (userData.confirmEmptyManaPool() if (userData.confirmEmptyManaPool()
&& game.getStack().isEmpty() && getManaPool().count() > 0) { && game.getStack().isEmpty() && getManaPool().count() > 0 && getManaPool().canLostManaOnEmpty()) {
String activePlayerText; String activePlayerText;
if (game.isActivePlayer(playerId)) { if (game.isActivePlayer(playerId)) {
activePlayerText = "Your turn"; activePlayerText = "Your turn";
@ -2940,7 +2940,7 @@ public class HumanPlayer extends PlayerImpl {
priorityPlayerText = " / priority " + game.getPlayer(game.getPriorityPlayerId()).getName(); priorityPlayerText = " / priority " + game.getPlayer(game.getPriorityPlayerId()).getName();
} }
// TODO: chooseUse and other dialogs must be under controlling player // TODO: chooseUse and other dialogs must be under controlling player
if (!chooseUse(Outcome.Detriment, GameLog.getPlayerConfirmColoredText("You still have mana in your mana pool. Pass regardless?") if (!chooseUse(Outcome.Detriment, GameLog.getPlayerConfirmColoredText("You still have mana in your mana pool and it will be lose. Pass anyway?")
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getTurnStepType().toString() + priorityPlayerText), null, game)) { + GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getTurnStepType().toString() + priorityPlayerText), null, game)) {
sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, game, null); sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, game, null);
return false; return false;

View file

@ -38,9 +38,10 @@ public class ManaPool implements Serializable {
private boolean forcedToPay; // for Word of Command private boolean forcedToPay; // for Word of Command
private final List<ManaPoolItem> poolBookmark = new ArrayList<>(); // mana pool bookmark for rollback purposes private final List<ManaPoolItem> poolBookmark = new ArrayList<>(); // mana pool bookmark for rollback purposes
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>(); // empty mana pool effects
private boolean manaBecomesBlack = false; private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>(); // keep some colors
private boolean manaBecomesColorless = false; private boolean manaBecomesBlack = false; // replace all pool by black
private boolean manaBecomesColorless = false; // replace all pool by colorless
private static final class ConditionalManaInfo { private static final class ConditionalManaInfo {
private final ManaType manaType; private final ManaType manaType;
@ -253,6 +254,28 @@ public class ManaPool implements Serializable {
manaItems.clear(); manaItems.clear();
} }
public boolean canLostManaOnEmpty() {
for (ManaPoolItem item : manaItems) {
for (ManaType manaType : ManaType.values()) {
if (item.get(manaType) == 0) {
continue;
}
if (doNotEmptyManaTypes.contains(manaType)) {
continue;
}
if (manaBecomesBlack) {
continue;
}
if (manaBecomesColorless) {
continue;
}
// found real mana to empty
return true;
}
}
return false;
}
public int emptyPool(Game game) { public int emptyPool(Game game) {
int total = 0; int total = 0;
Iterator<ManaPoolItem> it = manaItems.iterator(); Iterator<ManaPoolItem> it = manaItems.iterator();