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 @@ public class DamageAllEffect extends OneShotEffect {
private FilterPermanent filter;
private DynamicValue amount;
private String sourceName = "{source}";
public DamageAllEffect(int amount, FilterPermanent filter) {
this(new StaticValue(amount), filter);
}
public DamageAllEffect(int amount, String whoDealDamageName, FilterPermanent filter) {
this(new StaticValue(amount), filter);
this.sourceName = whoDealDamageName;
}
public DamageAllEffect(DynamicValue amount, FilterPermanent filter) {
super(Outcome.Damage);
this.amount = amount;
@ -61,6 +67,7 @@ public class DamageAllEffect extends OneShotEffect {
super(effect);
this.amount = effect.amount;
this.filter = effect.filter.copy();
this.sourceName = effect.sourceName;
}
@Override
@ -79,7 +86,7 @@ public class DamageAllEffect extends OneShotEffect {
private void setText() {
StringBuilder sb = new StringBuilder();
sb.append("{source} deals ").append(amount.toString()).append(" damage to each ").append(filter.getMessage());
sb.append(this.sourceName).append(" deals ").append(amount.toString()).append(" damage to each ").append(filter.getMessage());
String message = amount.getMessage();
if (!message.isEmpty()) {
if (amount.toString().equals("X")) {
@ -92,4 +99,11 @@ public class DamageAllEffect extends OneShotEffect {
staticText = sb.toString();
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
}

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;
}
}

View file

@ -45,11 +45,23 @@ public class DamageControllerEffect extends OneShotEffect {
protected DynamicValue amount;
protected boolean preventable;
private String sourceName = "{source}";
public DamageControllerEffect(int amount, String whoDealDamageName) {
this(amount, true, whoDealDamageName);
}
public DamageControllerEffect(int amount) {
this(amount, true);
}
public DamageControllerEffect(int amount, boolean preventable, String whoDealDamageName) {
super(Outcome.Damage);
this.amount = new StaticValue(amount);
this.preventable = preventable;
this.sourceName = whoDealDamageName;
}
public DamageControllerEffect(int amount, boolean preventable) {
super(Outcome.Damage);
this.amount = new StaticValue(amount);
@ -74,6 +86,7 @@ public class DamageControllerEffect extends OneShotEffect {
super(effect);
this.amount = effect.amount;
this.preventable = effect.preventable;
this.sourceName = effect.sourceName;
}
@Override
@ -98,7 +111,7 @@ public class DamageControllerEffect extends OneShotEffect {
}
StringBuilder sb = new StringBuilder();
String message = amount.getMessage();
sb.append("{source} deals ");
sb.append(this.sourceName).append(" deals ");
if (message.isEmpty() || !message.equals("1")) {
sb.append(amount);
}
@ -121,4 +134,11 @@ public class DamageControllerEffect extends OneShotEffect {
return sb.toString();
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
}

View file

@ -46,11 +46,17 @@ import mage.target.Target;
public class DamageMultiEffect extends OneShotEffect {
protected DynamicValue amount;
private String sourceName = "{source}";
public DamageMultiEffect(int amount) {
this(new StaticValue(amount));
}
public DamageMultiEffect(int amount, String whoDealDamageName) {
this(new StaticValue(amount));
this.sourceName = whoDealDamageName;
}
public DamageMultiEffect(DynamicValue amount) {
super(Outcome.Damage);
this.amount = amount;
@ -59,6 +65,7 @@ public class DamageMultiEffect extends OneShotEffect {
public DamageMultiEffect(final DamageMultiEffect effect) {
super(effect);
this.amount = effect.amount;
this.sourceName = effect.sourceName;
}
@Override
@ -90,6 +97,14 @@ public class DamageMultiEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "{source} deals " + amount.toString() + " damage divided as you choose among any number of target " + mode.getTargets().get(0).getTargetName();
return this.sourceName + " deals " + amount.toString() + " damage divided as you choose among any number of target " + mode.getTargets().get(0).getTargetName();
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
}

View file

@ -51,11 +51,17 @@ public class DamageTargetEffect extends OneShotEffect {
protected boolean preventable;
protected String targetDescription;
protected boolean useOnlyTargetPointer;
protected String sourceName = "{source}";
public DamageTargetEffect(int amount) {
this(new StaticValue(amount), true);
}
public DamageTargetEffect(int amount, String whoDealDamageName) {
this(new StaticValue(amount), true);
this.sourceName = whoDealDamageName;
}
public DamageTargetEffect(int amount, boolean preventable) {
this(new StaticValue(amount), preventable);
}
@ -64,10 +70,20 @@ public class DamageTargetEffect extends OneShotEffect {
this(new StaticValue(amount), preventable, targetDescription);
}
public DamageTargetEffect(int amount, boolean preventable, String targetDescription, String whoDealDamageName) {
this(new StaticValue(amount), preventable, targetDescription);
this.sourceName = whoDealDamageName;
}
public DamageTargetEffect(DynamicValue amount) {
this(amount, true);
}
public DamageTargetEffect(DynamicValue amount, String whoDealDamageName) {
this(amount, true);
this.sourceName = whoDealDamageName;
}
public DamageTargetEffect(DynamicValue amount, boolean preventable) {
this(amount, preventable, "");
}
@ -102,6 +118,15 @@ public class DamageTargetEffect extends OneShotEffect {
this.preventable = effect.preventable;
this.targetDescription = effect.targetDescription;
this.useOnlyTargetPointer = effect.useOnlyTargetPointer;
this.sourceName = effect.sourceName;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
@Override
@ -149,7 +174,7 @@ public class DamageTargetEffect extends OneShotEffect {
}
StringBuilder sb = new StringBuilder();
String message = amount.getMessage();
sb.append("{source} deals ");
sb.append(this.sourceName).append(" deals ");
if (message.isEmpty() || !message.equals("1")) {
sb.append(amount);
}