text fixes

This commit is contained in:
Evan Kranzler 2021-04-22 08:41:54 -04:00
parent d37b760167
commit f7340a946e
10 changed files with 42 additions and 64 deletions

View file

@ -47,7 +47,7 @@ class EnduringIdealEffect extends OneShotEffect {
public EnduringIdealEffect() { public EnduringIdealEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "Search your library for an enchantment card and put it onto the battlefield. Then shuffle"; staticText = "Search your library for an enchantment card, put it onto the battlefield, then shuffle";
} }
public EnduringIdealEffect(final EnduringIdealEffect effect) { public EnduringIdealEffect(final EnduringIdealEffect effect) {

View file

@ -72,7 +72,7 @@ class LinSivviDefiantHeroEffect extends OneShotEffect {
public LinSivviDefiantHeroEffect() { public LinSivviDefiantHeroEffect() {
super(Outcome.DrawCard); super(Outcome.DrawCard);
this.staticText = "Search your library for a Rebel permanent card with mana value X or less and put it onto the battlefield. Then shuffle"; this.staticText = "Search your library for a Rebel permanent card with mana value X or less, put it onto the battlefield, then shuffle";
} }
public LinSivviDefiantHeroEffect(final LinSivviDefiantHeroEffect effect) { public LinSivviDefiantHeroEffect(final LinSivviDefiantHeroEffect effect) {

View file

@ -8,6 +8,7 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/** /**
* @author noxx * @author noxx
@ -75,17 +76,6 @@ public class AttacksCreatureYouControlTriggeredAbility extends TriggeredAbilityI
@Override @Override
public String getRule() { public String getRule() {
String an; return "When" + (once ? "" : "ever") + " " + CardUtil.addArticle(filter.getMessage()) + " attacks, " + super.getRule();
String who = filter.getMessage();
if (who.startsWith("another") || who.startsWith("a ")) {
an = "";
} else if (who.length() > 0 && "aeiou".contains(who.charAt(0) + "")) {
an = "an ";
} else {
an = "a ";
}
return "When" + (once ? "" : "ever")
+ " " + an + who + " attacks, " + super.getRule();
} }
} }

View file

@ -27,15 +27,7 @@ public class SacrificeTargetCost extends CostImpl {
this.addTarget(target); this.addTarget(target);
target.setNotTarget(true); // sacrifice is never targeted target.setNotTarget(true); // sacrifice is never targeted
target.setRequired(false); // can be canceled target.setRequired(false); // can be canceled
this.text = "sacrifice " this.text = "sacrifice " + makeText(target);
+ ((target.getNumberOfTargets() != 1
|| (target.getTargetName().startsWith("an")
|| target.getTargetName().startsWith("a ")))
? (target.getMinNumberOfTargets() == target.getMaxNumberOfTargets()
&& target.getMinNumberOfTargets() > 1
? CardUtil.numberToText(target.getNumberOfTargets()) + " " : "")
: (target.getTargetName().startsWith("artifact") ? "an " : "a "))
+ target.getTargetName();
target.setTargetName(target.getTargetName() + " (to sacrifice)"); target.setTargetName(target.getTargetName() + " (to sacrifice)");
} }
@ -106,4 +98,14 @@ public class SacrificeTargetCost extends CostImpl {
public List<Permanent> getPermanents() { public List<Permanent> getPermanents() {
return permanents; return permanents;
} }
private static final String makeText(TargetControlledPermanent target) {
if (target.getMinNumberOfTargets() != target.getMaxNumberOfTargets()) {
return target.getTargetName();
}
if (target.getNumberOfTargets() == 1) {
return CardUtil.addArticle(target.getTargetName());
}
return CardUtil.numberToText(target.getNumberOfTargets()) + ' ' + target.getTargetName();
}
} }

View file

@ -24,11 +24,9 @@ public class TapTargetCost extends CostImpl {
this.target = target; this.target = target;
this.target.setNotTarget(true); // costs are never targeted this.target.setNotTarget(true); // costs are never targeted
this.target.setRequired(false); // can be cancel by user this.target.setRequired(false); // can be cancel by user
this.text this.text = "tap " + (target.getNumberOfTargets() > 1
= new StringBuilder("tap ") ? CardUtil.numberToText(target.getMaxNumberOfTargets()) + ' ' + target.getTargetName()
.append((target.getTargetName().startsWith("a ") || target.getTargetName().startsWith("an ") || target.getTargetName().startsWith("another")) : CardUtil.addArticle(target.getTargetName()));
? "" : CardUtil.numberToText(target.getMaxNumberOfTargets()) + ' ')
.append(target.getTargetName()).toString();
} }
public TapTargetCost(final TapTargetCost cost) { public TapTargetCost(final TapTargetCost cost) {

View file

@ -82,19 +82,16 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
private void setText() { private void setText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("each opponent sacrifices "); sb.append("each opponent sacrifices ");
if (amount.toString().equals("X")) { switch (amount.toString()) {
sb.append(amount.toString()).append(' '); case "X":
} else { sb.append(amount.toString()).append(' ');
if (amount.toString().equals("1")) { break;
if (!filter.getMessage().startsWith("a ") && !filter.getMessage().startsWith("an ")) { case "1":
sb.append("a "); sb.append(CardUtil.addArticle(filter.getMessage()));
} break;
} else { default:
sb.append(CardUtil.numberToText(amount.toString())).append(' '); sb.append(CardUtil.numberToText(amount.toString())).append(' ').append(filter.getMessage());
}
} }
sb.append(filter.getMessage());
staticText = sb.toString(); staticText = sb.toString();
} }
} }

View file

@ -16,6 +16,7 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -72,8 +73,8 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
this(StaticValue.get(1), filter, targetController); this(StaticValue.get(1), filter, targetController);
} }
public DiscardCardYouChooseTargetEffect(DynamicValue numberCardsToDiscard, public DiscardCardYouChooseTargetEffect(DynamicValue numberCardsToDiscard,
FilterCard filter, TargetController targetController) { FilterCard filter, TargetController targetController) {
super(Outcome.Discard); super(Outcome.Discard);
this.targetController = targetController; this.targetController = targetController;
this.filter = filter; this.filter = filter;
@ -111,7 +112,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
Cards revealedCards = new CardsImpl(); Cards revealedCards = new CardsImpl();
numberToReveal = Math.min(player.getHand().size(), numberToReveal); numberToReveal = Math.min(player.getHand().size(), numberToReveal);
if (player.getHand().size() > numberToReveal) { if (player.getHand().size() > numberToReveal) {
TargetCard chosenCards = new TargetCard(numberToReveal, numberToReveal, TargetCard chosenCards = new TargetCard(numberToReveal, numberToReveal,
Zone.HAND, new FilterCard("card in " + player.getName() + "'s hand")); Zone.HAND, new FilterCard("card in " + player.getName() + "'s hand"));
chosenCards.setNotTarget(true); chosenCards.setNotTarget(true);
if (chosenCards.canChoose(source.getSourceId(), player.getId(), game) if (chosenCards.canChoose(source.getSourceId(), player.getId(), game)
@ -131,7 +132,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
} }
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
player.revealCards(sourceCard != null ? sourceCard.getIdName() + " (" player.revealCards(sourceCard != null ? sourceCard.getIdName() + " ("
+ sourceCard.getZoneChangeCounter(game) + ')' : "Discard", revealedCards, game); + sourceCard.getZoneChangeCounter(game) + ')' : "Discard", revealedCards, game);
boolean result = true; boolean result = true;
@ -144,7 +145,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
if (!controller.choose(Outcome.Benefit, revealedCards, target, game)) { if (!controller.choose(Outcome.Benefit, revealedCards, target, game)) {
return result; return result;
} }
result=!player.discard(new CardsImpl(target.getTargets()),false, source,game).isEmpty(); result = !player.discard(new CardsImpl(target.getTargets()), false, source, game).isEmpty();
return result; return result;
} }
@ -180,13 +181,10 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
sb.append(". You choose "); sb.append(". You choose ");
boolean discardMultipleCards = !numberCardsToDiscard.toString().equals("1"); boolean discardMultipleCards = !numberCardsToDiscard.toString().equals("1");
if (discardMultipleCards) { if (discardMultipleCards) {
sb.append(numberCardsToDiscard).append(' '); sb.append(numberCardsToDiscard).append(' ').append(filter.getMessage());
} else { } else {
if (!filter.getMessage().startsWith("a ") && !filter.getMessage().startsWith("an ")) { sb.append(CardUtil.addArticle(filter.getMessage()));
sb.append("a ");
}
} }
sb.append(filter.getMessage());
if (revealAllCards) { if (revealAllCards) {
sb.append(" from it."); sb.append(" from it.");
} else { } else {

View file

@ -88,8 +88,7 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
sb.append(forceShuffle ? ", " : " and "); sb.append(forceShuffle ? ", " : " and ");
sb.append("put them onto the battlefield"); sb.append("put them onto the battlefield");
} else { } else {
sb.append(target.getTargetName().startsWith("a ") || target.getTargetName().startsWith("an ") ? "" : "a ") sb.append(CardUtil.addArticle(target.getTargetName()));
.append(target.getTargetName());
sb.append(forceShuffle ? ", " : " and "); sb.append(forceShuffle ? ", " : " and ");
sb.append("put it onto the battlefield"); sb.append("put it onto the battlefield");
} }

View file

@ -8,9 +8,9 @@ import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.TargetEvent; import mage.game.events.TargetEvent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import mage.util.RandomUtil; import mage.util.RandomUtil;
import java.util.*; import java.util.*;
@ -113,19 +113,10 @@ public abstract class TargetImpl implements Target {
sb.append(suffix); sb.append(suffix);
return sb.toString(); return sb.toString();
} }
if (targetName.startsWith("another")
|| targetName.startsWith("a ")
|| targetName.startsWith("an ")
|| targetName.startsWith("any ")) {
return "Select " + targetName + suffix;
}
if (getMinNumberOfTargets() == 0 && getMaxNumberOfTargets() == 1) { if (getMinNumberOfTargets() == 0 && getMaxNumberOfTargets() == 1) {
return "Select up to one " + targetName + suffix; return "Select up to one " + targetName + suffix;
} }
if (targetName.startsWith("a") || targetName.startsWith("e") || targetName.startsWith("i") || targetName.startsWith("o") || targetName.startsWith("u")) { return "Select " + CardUtil.addArticle(targetName) + suffix;
return "Select an " + targetName + suffix;
}
return "Select a " + targetName + suffix;
} }
@Override @Override

View file

@ -912,7 +912,10 @@ public final class CardUtil {
} }
public static String addArticle(String text) { public static String addArticle(String text) {
if (text.startsWith("a ") || text.startsWith("an ")) { if (text.startsWith("a ")
|| text.startsWith("an ")
|| text.startsWith("another ")
|| text.startsWith("any ")) {
return text; return text;
} }
return "aeiou".contains("" + text.charAt(0)) ? "an " + text : "a " + text; return "aeiou".contains("" + text.charAt(0)) ? "an " + text : "a " + text;