mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user