fixed Ward ability text (fixes #7715)

This commit is contained in:
Evan Kranzler 2021-04-17 18:36:11 -04:00
parent 326c17fe4d
commit b5e3ad2814

View file

@ -2,24 +2,30 @@ package mage.abilities.keyword;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.common.CounterUnlessPaysEffect; import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
public class WardAbility extends TriggeredAbilityImpl { public class WardAbility extends TriggeredAbilityImpl {
private final Cost cost;
public WardAbility(Cost cost) { public WardAbility(Cost cost) {
super(Zone.BATTLEFIELD, new CounterUnlessPaysEffect(cost), false); super(Zone.BATTLEFIELD, new CounterUnlessPaysEffect(cost), false);
this.cost = cost;
} }
private WardAbility(final WardAbility ability) { private WardAbility(final WardAbility ability) {
super(ability); super(ability);
this.cost = ability.cost.copy();
} }
@Override @Override
@ -47,8 +53,20 @@ public class WardAbility extends TriggeredAbilityImpl {
@Override @Override
public String getRule() { public String getRule() {
return "Ward " + this.getCosts().getText() StringBuilder sb = new StringBuilder("Ward");
+ " <i>(Whenever {this} becomes the target of a spell or ability an opponent controls, " + if (cost instanceof ManaCost) {
"counter that spell or ability unless its controller pays " + this.getCosts().getText() + ")</i>"; sb.append(' ').append(cost.getText());
} else {
sb.append("&mdash;").append(CardUtil.getTextWithFirstCharUpperCase(cost.getText())).append('.');
}
sb.append(" <i>(Whenever {this} becomes the target of a spell or ability an opponent controls, " +
"counter that spell or ability unless that player ");
if (cost instanceof ManaCost) {
sb.append("pays ").append(cost.getText());
} else {
sb.append(cost.getText().replace("pay ", "pays "));
}
sb.append(".)</i>");
return sb.toString();
} }
} }