mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
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:
parent
d05491c8ab
commit
396490cc77
3 changed files with 13 additions and 19 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue