Avoid prompting for color when using "Add one mana of any color" effect to pay for a colorless cost

This commit is contained in:
drdev
2013-12-12 12:43:50 +00:00
parent 849655cb2f
commit bdfd2e9adf
2 changed files with 31 additions and 23 deletions

View File

@@ -164,21 +164,29 @@ public abstract class InputPayMana extends InputSyncronizedBase {
boolean choice = true; boolean choice = true;
if (guessAbilityWithRequiredColors) { if (guessAbilityWithRequiredColors) {
// express Mana Choice // express Mana Choice
final ArrayList<SpellAbility> colorMatches = new ArrayList<SpellAbility>(); if (colorNeeded == 0) {
for (SpellAbility sa : abilities) {
if (colorNeeded != 0 && abilityProducesManaColor(sa, sa.getManaPartRecursive(), colorNeeded)) {
colorMatches.add(sa);
}
}
if (colorMatches.isEmpty()) {
// can only match colorless just grab the first and move on.
// This is wrong. Sometimes all abilities aren't created equal
choice = false; choice = false;
//avoid unnecessary prompt by pretending we need White
//for the sake of "Add one mana of any color" effects
colorNeeded = MagicColor.WHITE;
} }
else if (colorMatches.size() < abilities.size()) { else {
// leave behind only color matches final ArrayList<SpellAbility> colorMatches = new ArrayList<SpellAbility>();
abilities = colorMatches; for (SpellAbility sa : abilities) {
if (abilityProducesManaColor(sa, sa.getManaPartRecursive(), colorNeeded)) {
colorMatches.add(sa);
}
}
if (colorMatches.isEmpty()) {
// can only match colorless just grab the first and move on.
// This is wrong. Sometimes all abilities aren't created equal
choice = false;
}
else if (colorMatches.size() < abilities.size()) {
// leave behind only color matches
abilities = colorMatches;
}
} }
} }