Fixed wrong ability texts with duplicated card name (see #4335)

This commit is contained in:
Oleg Agafonov 2018-01-04 20:48:41 +04:00
parent 3d53d28f5e
commit 56949414d1
5 changed files with 95 additions and 6 deletions

View file

@ -45,11 +45,17 @@ import mage.players.Player;
public class DamageAttachedEffect extends OneShotEffect {
protected DynamicValue amount;
private String sourceName = "{source}";
public DamageAttachedEffect(int amount) {
super(Outcome.Damage);
this.amount = new StaticValue(amount);
}
public DamageAttachedEffect(int amount, String whoDealDamageName) {
this(amount);
this.sourceName = whoDealDamageName;
}
public DamageAttachedEffect(DynamicValue amount) {
super(Outcome.Damage);
@ -59,6 +65,7 @@ public class DamageAttachedEffect extends OneShotEffect {
public DamageAttachedEffect(final DamageAttachedEffect effect) {
super(effect);
this.amount = effect.amount;
this.sourceName = effect.sourceName;
}
@Override
@ -86,8 +93,16 @@ public class DamageAttachedEffect extends OneShotEffect {
return staticText;
}
if ("equal to".equals(amount.toString())) {
return "{this} deals damage " + amount + " that creatures toughness to that creature";
return this.sourceName + " deals damage " + amount + " that creatures toughness to that creature";
}
return "{this} deals " + amount + " damage to that creature";
return this.sourceName + " deals " + amount + " damage to that creature";
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
}