mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
updated counter adding text to handle articles correctly
This commit is contained in:
parent
f9dfb56d4e
commit
f76107702f
6 changed files with 49 additions and 35 deletions
|
|
@ -1,20 +1,21 @@
|
|||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import java.util.Locale;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class AddCountersAllEffect extends OneShotEffect {
|
||||
|
|
@ -60,7 +61,7 @@ public class AddCountersAllEffect extends OneShotEffect {
|
|||
if (counter.getCount() > 1) {
|
||||
sb.append(CardUtil.numberToText(counter.getCount(), "a")).append(' ').append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counters on each ");
|
||||
} else {
|
||||
sb.append("a ").append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on each ");
|
||||
sb.append(CounterType.findArticle(counter.getName())).append(' ').append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on each ");
|
||||
}
|
||||
sb.append(filter.getMessage());
|
||||
staticText = sb.toString();
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import java.util.Locale;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AddCountersAttachedEffect extends OneShotEffect {
|
||||
|
|
@ -26,9 +27,8 @@ public class AddCountersAttachedEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param textEnchanted text used for the enchanted permanent in rule text
|
||||
*/
|
||||
public AddCountersAttachedEffect(Counter counter, DynamicValue amount, String textEnchanted) {
|
||||
|
|
@ -77,7 +77,7 @@ public class AddCountersAttachedEffect extends OneShotEffect {
|
|||
if (counter.getCount() > 1) {
|
||||
sb.append(CardUtil.numberToText(counter.getCount())).append(' ');
|
||||
} else {
|
||||
sb.append("a ");
|
||||
sb.append(CounterType.findArticle(counter.getName())).append(' ');
|
||||
}
|
||||
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter on ");
|
||||
sb.append(textEnchanted);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
|
@ -19,11 +21,10 @@ public class AddCountersControllerEffect extends OneShotEffect {
|
|||
private final boolean enchantedEquipped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter Counter to add. Includes type and amount.
|
||||
* @param counter Counter to add. Includes type and amount.
|
||||
* @param enchantedEquipped If true, not source controller will get the
|
||||
* counter, but the permanent's controller that the source permanent
|
||||
* enchants or equippes.
|
||||
* counter, but the permanent's controller that the source permanent
|
||||
* enchants or equippes.
|
||||
*/
|
||||
public AddCountersControllerEffect(Counter counter, boolean enchantedEquipped) {
|
||||
super(Outcome.Benefit);
|
||||
|
|
@ -71,7 +72,7 @@ public class AddCountersControllerEffect extends OneShotEffect {
|
|||
sb.append("its controller gets ").append(Integer.toString(counter.getCount())).append(' ').append(counter.getName()).append(" counters");
|
||||
staticText = sb.toString();
|
||||
} else {
|
||||
staticText = "its controller gets a " + counter.getName() + " counter";
|
||||
staticText = "its controller gets " + CounterType.findArticle(counter.getName()) + " " + counter.getName() + " counter";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
|
|
@ -12,11 +8,17 @@ import mage.cards.Card;
|
|||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -40,12 +42,11 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param informPlayers
|
||||
* @param putOnCard - counters have to be put on a card instead of a
|
||||
* permanent
|
||||
* @param putOnCard - counters have to be put on a card instead of a
|
||||
* permanent
|
||||
*/
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard) {
|
||||
super(Outcome.Benefit);
|
||||
|
|
@ -135,12 +136,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
} else if (amount.toString().equals("X") && amount.getMessage().isEmpty()) {
|
||||
sb.append("X ");
|
||||
} else {
|
||||
//if counter name starts with a vowel use 'an' instead of 'a'
|
||||
if ("aeiou".indexOf(counter.getName().toLowerCase(Locale.ENGLISH).charAt(0)) >= 0 ){
|
||||
sb.append("an ");
|
||||
} else {
|
||||
sb.append("a ");
|
||||
}
|
||||
sb.append(CounterType.findArticle(counter.getName())).append(' ');
|
||||
plural = false;
|
||||
}
|
||||
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter");
|
||||
|
|
|
|||
|
|
@ -79,12 +79,12 @@ public class AddCountersTargetEffect extends OneShotEffect {
|
|||
permanent.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + permanent.getLogName());
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + permanent.getLogName());
|
||||
} else if (player != null) {
|
||||
player.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + player.getLogName());
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + player.getLogName());
|
||||
} else if (card != null) {
|
||||
card.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
|
|
@ -104,12 +104,13 @@ public class AddCountersTargetEffect extends OneShotEffect {
|
|||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("put ");
|
||||
String counterName = counter.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (counter.getCount() > 1) {
|
||||
sb.append(CardUtil.numberToText(counter.getCount())).append(' ');
|
||||
} else {
|
||||
sb.append("a ");
|
||||
sb.append(CounterType.findArticle(counterName)).append(' ');
|
||||
}
|
||||
sb.append(counter.getName().toLowerCase(Locale.ENGLISH)).append(" counter");
|
||||
sb.append(counterName).append(" counter");
|
||||
if (counter.getCount() > 1) {
|
||||
sb.append('s');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public enum CounterType {
|
|||
HEXPROOF("hexproof"),
|
||||
HIT("hit"),
|
||||
HOOFPRINT("hoofprint"),
|
||||
HOUR("hour"),
|
||||
HOURGLASS("hourglass"),
|
||||
HOUR("hour", "an"),
|
||||
HOURGLASS("hourglass", "an"),
|
||||
HUNGER("hunger"),
|
||||
ICE("ice"),
|
||||
INCARNATION("incarnation"),
|
||||
|
|
@ -158,7 +158,7 @@ public enum CounterType {
|
|||
TRAMPLE("trample"),
|
||||
TRAP("trap"),
|
||||
TREASURE("treasure"),
|
||||
UNITY("unity"),
|
||||
UNITY("unity", "a"),
|
||||
VELOCITY("velocity"),
|
||||
VERSE("verse"),
|
||||
VIGILANCE("vigilance"),
|
||||
|
|
@ -171,10 +171,16 @@ public enum CounterType {
|
|||
WISH("wish");
|
||||
|
||||
private final String name;
|
||||
private final String article;
|
||||
private final CounterPredicate predicate;
|
||||
|
||||
CounterType(String name) {
|
||||
this(name, "aeiou".contains("" + name.charAt(0)) ? "an" : "a");
|
||||
}
|
||||
|
||||
CounterType(String name, String article) {
|
||||
this.name = name;
|
||||
this.article = article;
|
||||
this.predicate = new CounterPredicate(this);
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +193,10 @@ public enum CounterType {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
public String getArticle() {
|
||||
return article;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create instance of counter type with amount equal to 1.
|
||||
*
|
||||
|
|
@ -268,6 +278,11 @@ public enum CounterType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static String findArticle(String name) {
|
||||
CounterType counterType = findByName(name);
|
||||
return counterType == null ? "a" : counterType.article;
|
||||
}
|
||||
|
||||
public CounterPredicate getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue