Fix places that assumed old format of ManaCost.toString() to either call new getCostString() function or assume {G} formatting

This fixes bugs with Rout ("may cast as instance if you pay 2 more" cards)
This also fixes bugs with Rune Snag ("unless player pays X" cards)
This commit is contained in:
drdev
2013-12-02 08:52:30 +00:00
parent fe04d56568
commit 1cf9a005d9
12 changed files with 60 additions and 39 deletions

View File

@@ -226,6 +226,13 @@ public final class ManaCost implements Comparable<ManaCost> {
return this.stringValue;
}
/**
* @return unformatted cost string
*/
public String getCostString() {
return ManaCostParser.stripFormatting(this.toString());
}
/**
* TODO: Write javadoc for this method.
* @return

View File

@@ -10,7 +10,7 @@ public class ManaCostParser implements IParserManaCost {
private final String[] cost;
private int nextToken;
private int colorlessCost;
/**
* Parse the given cost and output formatted cost string
*
@@ -22,6 +22,15 @@ public class ManaCostParser implements IParserManaCost {
return manaCost.toString();
}
/**
* Strip formatting from the given formatted cost string
*
* @param formattedCost
*/
public static String stripFormatting(final String formattedCost) {
return formattedCost.replaceAll("\\{([A-Z0-9/]+)\\}", "$1 ").trim();
}
/**
* Instantiates a new parser cardname txt mana cost.
*