From 396490cc77a26012c62548c5ac274cd3f1f3f324 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 1 Oct 2012 00:58:22 +0200 Subject: [PATCH] Reworked text generation a bit. Now the text for alternate costs are build correct. But maybe it's better to redesign AlternateCostImpl a bit so that the value of GetName() and GetText() is for all AlternateCost classes handled in the same way. --- Mage/src/mage/abilities/AbilitiesImpl.java | 13 +++++++++++-- Mage/src/mage/abilities/AbilityImpl.java | 16 ++-------------- Mage/src/mage/cards/CardImpl.java | 3 --- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Mage/src/mage/abilities/AbilitiesImpl.java b/Mage/src/mage/abilities/AbilitiesImpl.java index 6096b12b52..8293c7285a 100644 --- a/Mage/src/mage/abilities/AbilitiesImpl.java +++ b/Mage/src/mage/abilities/AbilitiesImpl.java @@ -72,13 +72,21 @@ public class AbilitiesImpl extends ArrayList implements Ab List rules = new ArrayList(); for (T ability:this) { - if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) + if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) { rules.add(ability.getRule()); + } if (ability instanceof SpellAbility) { if (ability.getAlternativeCosts().size() > 0) { StringBuilder sbRule = new StringBuilder(); for (AlternativeCost cost: ability.getAlternativeCosts()) { - sbRule.append(cost.getName()).append(".\n"); + if (cost.getClass().getName().equals("mage.abilities.costs.AlternativeCostImpl")) + { // if the template class is used, the rule is in the getName() instead in the getText() + sbRule.append(cost.getName()).append(".\n"); + } + else + { + sbRule.append(cost.getText()).append(".\n"); + } } rules.add(sbRule.toString()); } @@ -94,6 +102,7 @@ public class AbilitiesImpl extends ArrayList implements Ab } rules.add(sbRule.toString()); } + rules.add(ability.getRule()); } } diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 7b78b87223..340f78d403 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -231,8 +231,9 @@ public abstract class AbilityImpl> implements Ability { protected boolean useAlternativeCost(Game game) { for (AlternativeCost cost: alternativeCosts) { if (cost.isAvailable(game, this)) { - if (game.getPlayer(this.controllerId).chooseUse(Outcome.Neutral, "Use alternative cost " + cost.getName(), game)) + if (game.getPlayer(this.controllerId).chooseUse(Outcome.Neutral, "Use alternative cost " + cost.getName(), game)) { return cost.pay(this, game, sourceId, controllerId, false); + } } } return false; @@ -349,19 +350,6 @@ public abstract class AbilityImpl> implements Ability { sbRule.append(": "); } } - else if (this.alternativeCosts.size() > 0) { - for (AlternativeCost cost: alternativeCosts) { - sbRule.append(cost.getText()).append("\n"); - } - } - else { - for (Cost cost: this.costs) { - if (!(cost instanceof ManaCost)) { - sbRule.append("As an additional cost to cast {this}, ").append(cost.getText()).append("\n"); - } - } - } - sbRule.append(modes.getText()); return sbRule.toString(); diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index 1c855ca3ac..0ec48ae482 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -156,9 +156,6 @@ public abstract class CardImpl> extends MageObjectImpl public List getRules() { try { List rules = abilities.getRules(this.name); - if (cardType.contains(CardType.INSTANT) || cardType.contains(CardType.SORCERY)) { - rules.add(0, getSpellAbility().getRule(this.name)); - } if (info != null) { for (String data : info.values()) { rules.add(data);