From ccc935a025147f8a3513573c8b272cf7f451d4bd Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Tue, 21 May 2019 01:16:16 +0000 Subject: [PATCH] Fix the express mana payment sometimes presenting the player with choices which are not legal. --- .../main/java/forge/match/input/InputPayMana.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/forge-gui/src/main/java/forge/match/input/InputPayMana.java b/forge-gui/src/main/java/forge/match/input/InputPayMana.java index 809bf29ce0a..516fa477976 100644 --- a/forge-gui/src/main/java/forge/match/input/InputPayMana.java +++ b/forge-gui/src/main/java/forge/match/input/InputPayMana.java @@ -316,8 +316,20 @@ public abstract class InputPayMana extends InputSyncronizedBase { } else { chosen = chosenAbility; } + ColorSet colors = ColorSet.fromMask(0 == colorNeeded ? colorCanUse : colorNeeded); - chosen.getManaPartRecursive().setExpressChoice(colors); + + // Filter the colors for the express choice so that only actually producible colors can be chosen + int producedColorMask = 0; + for (final byte color : ManaAtom.MANATYPES) { + if (chosen.getManaPartRecursive().getOrigProduced().contains(MagicColor.toShortString(color)) + && colors.hasAnyColor(color)) { + producedColorMask |= color; + } + } + ColorSet producedAndNeededColors = ColorSet.fromMask(producedColorMask); + + chosen.getManaPartRecursive().setExpressChoice(producedAndNeededColors); // System.out.println("Chosen sa=" + chosen + " of " + chosen.getHostCard() + " to pay mana");