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.

This commit is contained in:
LevelX2 2012-10-01 00:58:22 +02:00
parent d05491c8ab
commit 396490cc77
3 changed files with 13 additions and 19 deletions

View file

@ -72,13 +72,21 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
List<String> rules = new ArrayList<String>();
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<T extends Ability> extends ArrayList<T> implements Ab
}
rules.add(sbRule.toString());
}
rules.add(ability.getRule());
}
}

View file

@ -231,8 +231,9 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> 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<T extends AbilityImpl<T>> 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();

View file

@ -156,9 +156,6 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
public List<String> getRules() {
try {
List<String> 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);