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

@@ -59,7 +59,7 @@ public class AbilityManaPart implements java.io.Serializable {
private final String addsCounters; private final String addsCounters;
private final boolean persistentMana; private final boolean persistentMana;
private String manaReplaceType; private String manaReplaceType;
private transient ArrayList<Mana> lastManaProduced = new ArrayList<Mana>(); private transient ArrayList<Mana> lastManaProduced = new ArrayList<Mana>();
private final transient Card sourceCard; private final transient Card sourceCard;
@@ -174,7 +174,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* cannotCounterPaidWith. * cannotCounterPaidWith.
* </p> * </p>
* @param saBeingPaid * @param saBeingPaid
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@@ -191,7 +191,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* addKeywords. * addKeywords.
* </p> * </p>
* @param saBeingPaid * @param saBeingPaid
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@@ -203,7 +203,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* getKeywords. * getKeywords.
* </p> * </p>
* @param saBeingPaid * @param saBeingPaid
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@@ -215,7 +215,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p> * <p>
* addsCounters. * addsCounters.
* </p> * </p>
* @param saBeingPaid * @param saBeingPaid
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@@ -348,8 +348,8 @@ public class AbilityManaPart implements java.io.Serializable {
if(cs.hasRed()) sb.append("R "); if(cs.hasRed()) sb.append("R ");
if(cs.hasGreen()) sb.append("G "); if(cs.hasGreen()) sb.append("G ");
this.lastExpressChoice = sb.toString().trim(); this.lastExpressChoice = sb.toString().trim();
} }
/** /**
* <p> * <p>
* Getter for the field <code>lastAnyChoice</code>. * Getter for the field <code>lastAnyChoice</code>.
@@ -437,7 +437,7 @@ public class AbilityManaPart implements java.io.Serializable {
public final boolean canProduce(final String s) { public final boolean canProduce(final String s) {
return canProduce(s, null); return canProduce(s, null);
} }
/** /**
* <p> * <p>
* canProduce. * canProduce.
@@ -452,7 +452,7 @@ public class AbilityManaPart implements java.io.Serializable {
return true; return true;
} }
if (this.getOrigProduced().contains("Chosen") && sourceCard != null ) { if (this.getOrigProduced().contains("Chosen") && sourceCard != null ) {
List<String> chosenCol = this.getSourceCard().getChosenColor(); List<String> chosenCol = this.getSourceCard().getChosenColor();
if ( !chosenCol.isEmpty() && MagicColor.toShortString(chosenCol.get(0)).contains(s)) { if ( !chosenCol.isEmpty() && MagicColor.toShortString(chosenCol.get(0)).contains(s)) {
return true; return true;
@@ -610,7 +610,7 @@ public class AbilityManaPart implements java.io.Serializable {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
while(m.find()) { while(m.find()) {
if (m.group().matches("[0-9][0-9]?")) { if (m.group().matches("[0-9][0-9]?")) {
final String rep = StringUtils.repeat(repMap.get("[0-9][0-9]?") + " ", final String rep = StringUtils.repeat(repMap.get("[0-9][0-9]?") + " ",
Integer.parseInt(m.group())).trim(); Integer.parseInt(m.group())).trim();
m.appendReplacement(sb, rep); m.appendReplacement(sb, rep);
} else { } else {

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;
}
} }
} }