bugfix, CostPartMana tried to take color of X into account

This commit is contained in:
Maxmtg
2013-04-03 18:54:11 +00:00
parent a787b9a075
commit e7365a8068
3 changed files with 10 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ package forge.card.cost;
import forge.Card;
import forge.FThreads;
import forge.card.MagicColor;
import forge.card.ability.AbilityUtils;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostBeingPaid;
@@ -117,13 +118,13 @@ public class CostPartMana extends CostPart {
final Card source = ability.getSourceCard();
ManaCostBeingPaid toPay = new ManaCostBeingPaid(getManaToPay());
if (this.getAmountOfX() > 0) {
if (this.getAmountOfX() > 0 && !ability.getSVar("X").equals("Count$xPaid")) {
// if X cost is a defined value, other than xPaid
if (!ability.getSVar("X").equals("Count$xPaid")) {
// this currently only works for things about Targeted object
int xCost = AbilityUtils.calculateAmount(source, "X", ability) * this.getAmountOfX();
toPay.increaseColorlessMana(xCost);
}
byte xColor = MagicColor.fromName(ability.hasParam("XColor") ? ability.getParam("XColor") : "1");
toPay.increaseShard(ManaCostShard.valueOf(xColor), xCost);
}

View File

@@ -79,9 +79,6 @@ public final class ManaCost implements Comparable<ManaCost> {
* the parser
*/
public ManaCost(final IParserManaCost parser) {
if (!parser.hasNext()) {
throw new RuntimeException("Empty manacost passed to parser (this should have been handled before)");
}
final List<ManaCostShard> shardsTemp = new ArrayList<ManaCostShard>();
this.hasNoCost = false;
while (parser.hasNext()) {
@@ -90,8 +87,7 @@ public final class ManaCost implements Comparable<ManaCost> {
shardsTemp.add(shard);
} // null is OK - that was generic mana
}
this.genericCost = parser.getTotalColorlessCost(); // collect generic
// mana
this.genericCost = parser.getTotalColorlessCost(); // collect generic mana
// here
sealClass(shardsTemp);
}

View File

@@ -85,7 +85,8 @@ public class ManaCostBeingPaid {
@Override
public int getTotalColorlessCost() {
return unpaidShards.get(ManaCostShard.COLORLESS);
Integer c = unpaidShards.get(ManaCostShard.COLORLESS);
return c == null ? 0 : c.intValue();
}
}