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 boolean persistentMana;
private String manaReplaceType;
private transient ArrayList<Mana> lastManaProduced = new ArrayList<Mana>();
private final transient Card sourceCard;
@@ -174,7 +174,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* cannotCounterPaidWith.
* </p>
* @param saBeingPaid
* @param saBeingPaid
*
* @return a {@link java.lang.String} object.
*/
@@ -191,7 +191,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* addKeywords.
* </p>
* @param saBeingPaid
* @param saBeingPaid
*
* @return a {@link java.lang.String} object.
*/
@@ -203,7 +203,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* getKeywords.
* </p>
* @param saBeingPaid
* @param saBeingPaid
*
* @return a {@link java.lang.String} object.
*/
@@ -215,7 +215,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* addsCounters.
* </p>
* @param saBeingPaid
* @param saBeingPaid
*
* @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.hasGreen()) sb.append("G ");
this.lastExpressChoice = sb.toString().trim();
}
}
/**
* <p>
* 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) {
return canProduce(s, null);
}
/**
* <p>
* canProduce.
@@ -452,7 +452,7 @@ public class AbilityManaPart implements java.io.Serializable {
return true;
}
if (this.getOrigProduced().contains("Chosen") && sourceCard != null ) {
if (this.getOrigProduced().contains("Chosen") && sourceCard != null ) {
List<String> chosenCol = this.getSourceCard().getChosenColor();
if ( !chosenCol.isEmpty() && MagicColor.toShortString(chosenCol.get(0)).contains(s)) {
return true;
@@ -610,7 +610,7 @@ public class AbilityManaPart implements java.io.Serializable {
StringBuffer sb = new StringBuffer();
while(m.find()) {
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();
m.appendReplacement(sb, rep);
} else {

View File

@@ -164,21 +164,29 @@ public abstract class InputPayMana extends InputSyncronizedBase {
boolean choice = true;
if (guessAbilityWithRequiredColors) {
// express Mana Choice
final ArrayList<SpellAbility> colorMatches = new ArrayList<SpellAbility>();
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
if (colorNeeded == 0) {
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()) {
// leave behind only color matches
abilities = colorMatches;
else {
final ArrayList<SpellAbility> colorMatches = new ArrayList<SpellAbility>();
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;
}
}
}