update text generation for tokens with abilities to account for new and old phrasing

This commit is contained in:
xenohedron 2024-06-04 00:55:24 -04:00
parent c558f46968
commit fd8cb28fc2
37 changed files with 82 additions and 81 deletions

View file

@ -29,6 +29,7 @@ public class CreateTokenEffect extends OneShotEffect {
private final boolean tapped;
private final boolean attacking;
private String additionalRules;
private boolean oldPhrasing = false; // true for "token. It has " instead of "token with "
private List<UUID> lastAddedTokenIds = new ArrayList<>();
private CounterType counterType;
private DynamicValue numberOfCounters;
@ -72,6 +73,7 @@ public class CreateTokenEffect extends OneShotEffect {
this.counterType = effect.counterType;
this.numberOfCounters = effect.numberOfCounters;
this.additionalRules = effect.additionalRules;
this.oldPhrasing = effect.oldPhrasing;
}
public CreateTokenEffect entersWithCounters(CounterType counterType, DynamicValue numberOfCounters) {
@ -129,33 +131,50 @@ public class CreateTokenEffect extends OneShotEffect {
}
}
/**
* For adding reminder text to the effect
*/
public CreateTokenEffect withAdditionalRules(String additionalRules) {
this.additionalRules = additionalRules;
setText();
return this;
}
/**
* For older cards that use the phrasing "token. It has " rather than "token with ".
*/
public CreateTokenEffect withTextOptions(boolean oldPhrasing) {
this.oldPhrasing = oldPhrasing;
setText();
return this;
}
private void setText() {
if (token.getDescription().contains(", a legendary")) {
staticText = "create " + token.getDescription();
String tokenDescription = token.getDescription();
boolean singular = amount.toString().equals("1");
if (tokenDescription.contains(", a legendary")) {
staticText = "create " + tokenDescription;
return;
}
if (oldPhrasing) {
tokenDescription = tokenDescription.replace("token with \"",
singular ? "token. It has \"" : "tokens. They have \"");
}
StringBuilder sb = new StringBuilder("create ");
if (amount.toString().equals("1")) {
if (singular) {
if (tapped && !attacking) {
sb.append("a tapped ");
sb.append(token.getDescription());
sb.append(tokenDescription);
} else {
sb.append(CardUtil.addArticle(token.getDescription()));
sb.append(CardUtil.addArticle(tokenDescription));
}
} else {
sb.append(CardUtil.numberToText(amount.toString())).append(' ');
if (tapped && !attacking) {
sb.append("tapped ");
}
sb.append(token.getDescription().replace("token. It has", "tokens. They have"));
if (token.getDescription().endsWith("token")) {
sb.append(tokenDescription);
if (tokenDescription.endsWith("token")) {
sb.append("s");
}
int tokenLocation = sb.indexOf("token ");
@ -165,7 +184,7 @@ public class CreateTokenEffect extends OneShotEffect {
}
if (attacking) {
if (amount.toString().equals("1")) {
if (singular) {
sb.append(" that's");
} else {
sb.append(" that are");

View file

@ -14,7 +14,7 @@ import mage.constants.Zone;
public final class EldraziSpawnToken extends TokenImpl {
public EldraziSpawnToken() {
super("Eldrazi Spawn Token", "0/1 colorless Eldrazi Spawn creature token. It has \"Sacrifice this creature: Add {C}.\"");
super("Eldrazi Spawn Token", "0/1 colorless Eldrazi Spawn creature token with \"Sacrifice this creature: Add {C}.\"");
cardType.add(CardType.CREATURE);
subtype.add(SubType.ELDRAZI);
subtype.add(SubType.SPAWN);

View file

@ -9,10 +9,10 @@ import mage.constants.SubType;
/**
* @author spjspj
*/
public final class Ooze2Token extends TokenImpl {
public final class MitoticSlimeOozeToken extends TokenImpl {
public Ooze2Token() {
super("Ooze Token", "2/2 green Ooze creature token. It has \"When this creature dies, create two 1/1 green Ooze creature tokens.\"");
public MitoticSlimeOozeToken() {
super("Ooze Token", "2/2 green Ooze creature tokens. They have \"When this creature dies, create two 1/1 green Ooze creature tokens.\"");
cardType.add(CardType.CREATURE);
subtype.add(SubType.OOZE);
color.setGreen(true);
@ -21,11 +21,11 @@ public final class Ooze2Token extends TokenImpl {
this.addAbility(new DiesSourceTriggeredAbility(new CreateTokenEffect(new OozeToken(1, 1), 2), false));
}
private Ooze2Token(final Ooze2Token token) {
private MitoticSlimeOozeToken(final MitoticSlimeOozeToken token) {
super(token);
}
public Ooze2Token copy() {
return new Ooze2Token(this);
public MitoticSlimeOozeToken copy() {
return new MitoticSlimeOozeToken(this);
}
}