mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Improve text generation for some common draw, discard and mill effects
This commit is contained in:
parent
15fe971a36
commit
fd281ca483
8 changed files with 37 additions and 59 deletions
|
@ -82,7 +82,7 @@ class TappedCreaturesControlledByTargetCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "a";
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.u;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.IntPlusDynamicValue;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
|
@ -40,11 +40,7 @@ public final class UrborgLhurgoyf extends CardImpl {
|
|||
this.addAbility(kickerAbility);
|
||||
|
||||
// As Urborg Lhurgoyf enters the battlefield, mill three cards for each time it was kicked.
|
||||
this.addAbility(new EntersBattlefieldAbility(
|
||||
new MillCardsControllerEffect(millValue), null,
|
||||
"As {this} enters the battlefield, " +
|
||||
"mill three cards for each time it was kicked.", ""
|
||||
));
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new MillCardsControllerEffect(millValue)));
|
||||
|
||||
// Urborg Lhurgoyf's power is equal to the number of creature cards in your graveyard and its toughness is equal to that number plus 1.
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
|
|
|
@ -26,7 +26,7 @@ public enum MultikickerCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "a";
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ import mage.util.CardUtil;
|
|||
public class DrawCardSourceControllerEffect extends OneShotEffect {
|
||||
|
||||
protected DynamicValue amount;
|
||||
protected String whoDrawCard = "";
|
||||
|
||||
public DrawCardSourceControllerEffect(int amount) {
|
||||
this(amount, "");
|
||||
|
@ -34,13 +33,12 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
|
|||
public DrawCardSourceControllerEffect(DynamicValue amount, String whoDrawCard) {
|
||||
super(Outcome.DrawCard);
|
||||
this.amount = amount.copy();
|
||||
this.whoDrawCard = whoDrawCard;
|
||||
createStaticText(whoDrawCard);
|
||||
}
|
||||
|
||||
public DrawCardSourceControllerEffect(final DrawCardSourceControllerEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount.copy();
|
||||
this.whoDrawCard = effect.whoDrawCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,28 +57,17 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
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(whoDrawCard.isEmpty() ? "" : whoDrawCard
|
||||
+ " ").append("draw ").append(oneCard ? "a"
|
||||
: CardUtil.numberToText(amount.toString())).append(" card");
|
||||
if (!oneCard) {
|
||||
sb.append('s');
|
||||
}
|
||||
private void createStaticText(String whoDrawCard) {
|
||||
StringBuilder sb = new StringBuilder(whoDrawCard);
|
||||
sb.append(whoDrawCard.isEmpty() ? "draw " : " draw ");
|
||||
String value = amount.toString();
|
||||
sb.append(CardUtil.numberToText(value, "a"));
|
||||
sb.append(value.equals("1") ? " card" : " cards");
|
||||
String message = amount.getMessage();
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(" for each ");
|
||||
sb.append(value.equals("X") ? ", where X is " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
sb.append(message);
|
||||
return sb.toString();
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class MillCardsControllerEffect extends OneShotEffect {
|
|||
public MillCardsControllerEffect(DynamicValue numberCards) {
|
||||
super(Outcome.Discard);
|
||||
this.numberCards = numberCards;
|
||||
setText();
|
||||
}
|
||||
|
||||
public MillCardsControllerEffect(final MillCardsControllerEffect effect) {
|
||||
|
@ -45,12 +46,16 @@ public class MillCardsControllerEffect extends OneShotEffect {
|
|||
).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (numberCards instanceof StaticValue) {
|
||||
return "mill " + (((StaticValue) numberCards).getValue() > 1 ?
|
||||
CardUtil.numberToText(numberCards.toString()) + " cards" : "a card");
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("mill ");
|
||||
String value = numberCards.toString();
|
||||
sb.append(CardUtil.numberToText(value, "a"));
|
||||
sb.append(value.equals("1") ? " card" : " cards");
|
||||
String message = numberCards.getMessage();
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(value.equals("X") ? ", where X is " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
return "mill X cards, where X is " + numberCards.getMessage();
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,19 +55,17 @@ public class DiscardControllerEffect extends OneShotEffect {
|
|||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("discard ");
|
||||
if (amount.toString().equals("1") || amount.toString().equals("a")) {
|
||||
sb.append("a card");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(amount.toString())).append(" cards");
|
||||
}
|
||||
String value = amount.toString();
|
||||
sb.append(CardUtil.numberToText(value, "a"));
|
||||
sb.append(value.equals("1") ? " card" : " cards");
|
||||
if (randomDiscard) {
|
||||
sb.append(" at random");
|
||||
}
|
||||
String message = amount.getMessage();
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(" for each ");
|
||||
sb.append(value.equals("X") ? ", where X is " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
sb.append(message);
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,26 +74,19 @@ public class DiscardTargetEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
sb.append("that player");
|
||||
} else {
|
||||
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(getTargetPointer().describeTargets(mode.getTargets(), "that player"));
|
||||
sb.append(" discards ");
|
||||
if (amount.toString().equals("1") || amount.toString().equals("a")) {
|
||||
sb.append("a card");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(amount.toString())).append(" cards");
|
||||
}
|
||||
String value = amount.toString();
|
||||
sb.append(CardUtil.numberToText(value, "a"));
|
||||
sb.append(value.equals("1") ? " card" : " cards");
|
||||
if (randomDiscard) {
|
||||
sb.append(" at random");
|
||||
}
|
||||
String message = amount.getMessage();
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(" for each ");
|
||||
sb.append(value.equals("X") ? ", where X is " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
sb.append(message);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -546,8 +546,7 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static boolean checkNumeric(String s) {
|
||||
return s.chars().allMatch(Character::isDigit);
|
||||
|
||||
return !s.isEmpty() && s.chars().allMatch(Character::isDigit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue