Fix the express mana payment sometimes presenting the player with choices which are not legal.

This commit is contained in:
Michael Kamensky
2019-05-21 01:16:16 +00:00
committed by swordshine
parent f2f2ef09e2
commit ccc935a025

View File

@@ -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");