Improved and fixed cards texts:

* fixed wrong texts for draw card abilities;
 * added multi-effects text generation instead copy-paste (concatBy).
This commit is contained in:
Oleg Agafonov 2019-01-04 23:51:42 +04:00
parent 83cf370cc6
commit f6585ef734
23 changed files with 144 additions and 140 deletions

View file

@ -1,9 +1,7 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.MultikickerCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
@ -18,20 +16,32 @@ import mage.util.CardUtil;
public class DrawCardSourceControllerEffect extends OneShotEffect {
protected DynamicValue amount;
protected String whoDrawCard = "";
public DrawCardSourceControllerEffect(int amount) {
this(new StaticValue(amount));
this(amount, "");
}
public DrawCardSourceControllerEffect(int amount, String whoDrawCard) {
this(new StaticValue(amount), whoDrawCard);
}
public DrawCardSourceControllerEffect(DynamicValue amount) {
this(amount, "");
}
public DrawCardSourceControllerEffect(DynamicValue amount, String whoDrawCard) {
super(Outcome.DrawCard);
this.amount = amount.copy();
this.whoDrawCard = whoDrawCard;
setText();
}
public DrawCardSourceControllerEffect(final DrawCardSourceControllerEffect effect) {
super(effect);
this.amount = effect.amount.copy();
this.whoDrawCard = effect.whoDrawCard;
setText();
}
@Override
@ -53,7 +63,7 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder();
boolean oneCard = (amount instanceof StaticValue && amount.calculate(null, null, this) == 1)
|| amount instanceof PermanentsOnBattlefieldCount || amount.toString().equals("1") || amount.toString().equals("a");
sb.append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card");
sb.append(whoDrawCard.isEmpty() ? "" : whoDrawCard + " ").append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card");
if (!oneCard) {
sb.append('s');
}