Counter class renamed to CounterType

This commit is contained in:
Maxmtg
2012-11-23 20:03:37 +00:00
parent 009d16a1c1
commit df47bab393
40 changed files with 225 additions and 230 deletions

2
.gitattributes vendored
View File

@@ -12535,7 +12535,7 @@ src/main/java/forge/ColorChanger.java -text
src/main/java/forge/Command.java svneol=native#text/plain src/main/java/forge/Command.java svneol=native#text/plain
src/main/java/forge/CommandList.java svneol=native#text/plain src/main/java/forge/CommandList.java svneol=native#text/plain
src/main/java/forge/Constant.java svneol=native#text/plain src/main/java/forge/Constant.java svneol=native#text/plain
src/main/java/forge/Counters.java svneol=native#text/plain src/main/java/forge/CounterType.java svneol=native#text/plain
src/main/java/forge/GameAction.java svneol=native#text/plain src/main/java/forge/GameAction.java svneol=native#text/plain
src/main/java/forge/GameActionUtil.java svneol=native#text/plain src/main/java/forge/GameActionUtil.java svneol=native#text/plain
src/main/java/forge/GameEntity.java -text src/main/java/forge/GameEntity.java -text

View File

@@ -95,7 +95,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private ZoneType castFrom = null; private ZoneType castFrom = null;
private final CardDamageHistory damageHistory = new CardDamageHistory(); private final CardDamageHistory damageHistory = new CardDamageHistory();
private Map<Counters, Integer> counters = new TreeMap<Counters, Integer>(); private Map<CounterType, Integer> counters = new TreeMap<CounterType, Integer>();
private final Map<String, Object> triggeringObjects = new TreeMap<String, Object>(); private final Map<String, Object> triggeringObjects = new TreeMap<String, Object>();
private ArrayList<String> extrinsicKeyword = new ArrayList<String>(); private ArrayList<String> extrinsicKeyword = new ArrayList<String>();
// Hidden keywords won't be displayed on the card // Hidden keywords won't be displayed on the card
@@ -1211,11 +1211,11 @@ public class Card extends GameEntity implements Comparable<Card> {
* the counter name * the counter name
* @return true, if successful * @return true, if successful
*/ */
public final boolean canHaveCountersPlacedOnIt(final Counters counterName) { public final boolean canHaveCountersPlacedOnIt(final CounterType counterName) {
if (this.hasKeyword("CARDNAME can't have counters placed on it.")) { if (this.hasKeyword("CARDNAME can't have counters placed on it.")) {
return false; return false;
} }
if (this.isCreature() && counterName.equals(Counters.M1M1)) { if (this.isCreature() && counterName.equals(CounterType.M1M1)) {
for (final Card c : this.getController().getCreaturesInPlay()) { // look for (final Card c : this.getController().getCreaturesInPlay()) { // look
// for // for
// Melira, // Melira,
@@ -1237,11 +1237,11 @@ public class Card extends GameEntity implements Comparable<Card> {
* </p> * </p>
* *
* @param counterName * @param counterName
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @param n * @param n
* a int. * a int.
*/ */
public final void addCounterFromNonEffect(final Counters counterName, final int n) { public final void addCounterFromNonEffect(final CounterType counterName, final int n) {
if (!this.canHaveCountersPlacedOnIt(counterName)) { if (!this.canHaveCountersPlacedOnIt(counterName)) {
return; return;
} }
@@ -1272,33 +1272,32 @@ public class Card extends GameEntity implements Comparable<Card> {
* addCounter. * addCounter.
* </p> * </p>
* *
* @param counterName * @param counterType
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @param n * @param n
* a int. * a int.
*/ */
public final void addCounter(final Counters counterName, final int n) { public final void addCounter(final CounterType counterType, final int n) {
if (!this.canHaveCountersPlacedOnIt(counterName)) { if (!this.canHaveCountersPlacedOnIt(counterType)) {
return; return;
} }
final int multiplier = this.getController().getCounterDoublersMagnitude(counterName); final int multiplier = this.getController().getCounterDoublersMagnitude(counterType);
if (this.counters.containsKey(counterName)) { final int addAmount = (multiplier * n);
final Integer aux = this.counters.get(counterName) + (multiplier * n);
this.counters.put(counterName, aux); Integer oldValue = this.counters.get(counterType);
} else { int newValue = addAmount + (oldValue == null ? 0 : oldValue.intValue());
this.counters.put(counterName, Integer.valueOf(multiplier * n)); this.counters.put(counterType, Integer.valueOf(newValue));
}
// Run triggers // Run triggers
final Map<String, Object> runParams = new TreeMap<String, Object>(); final Map<String, Object> runParams = new TreeMap<String, Object>();
runParams.put("Card", this); runParams.put("Card", this);
runParams.put("CounterType", counterName); runParams.put("CounterType", counterType);
for (int i = 0; i < (multiplier * n); i++) { for (int i = 0; i < addAmount; i++) {
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterAdded, runParams); Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterAdded, runParams);
} }
// play the Add Counter sound // play the Add Counter sound
Singletons.getModel().getGame().getEvents().post(new AddCounterEvent(n)); Singletons.getModel().getGame().getEvents().post(new AddCounterEvent(addAmount));
this.updateObservers(); this.updateObservers();
} }
@@ -1309,11 +1308,11 @@ public class Card extends GameEntity implements Comparable<Card> {
* </p> * </p>
* *
* @param counterName * @param counterName
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @param n * @param n
* a int. * a int.
*/ */
public final void subtractCounter(final Counters counterName, final int n) { public final void subtractCounter(final CounterType counterName, final int n) {
if (this.counters.containsKey(counterName)) { if (this.counters.containsKey(counterName)) {
Integer aux = this.counters.get(counterName) - n; Integer aux = this.counters.get(counterName) - n;
if (aux < 0) { if (aux < 0) {
@@ -1329,7 +1328,7 @@ public class Card extends GameEntity implements Comparable<Card> {
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams); Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams);
} }
if (counterName.equals(Counters.TIME) && (aux == 0)) { if (counterName.equals(CounterType.TIME) && (aux == 0)) {
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1; final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
if (hasVanish && this.isInPlay()) { if (hasVanish && this.isInPlay()) {
@@ -1386,10 +1385,10 @@ public class Card extends GameEntity implements Comparable<Card> {
* </p> * </p>
* *
* @param counterName * @param counterName
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @return a int. * @return a int.
*/ */
public final int getCounters(final Counters counterName) { public final int getCounters(final CounterType counterName) {
if (this.counters.containsKey(counterName)) { if (this.counters.containsKey(counterName)) {
return this.counters.get(counterName); return this.counters.get(counterName);
} }
@@ -1405,7 +1404,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* @return a Map object. * @return a Map object.
* @since 1.0.15 * @since 1.0.15
*/ */
public final Map<Counters, Integer> getCounters() { public final Map<CounterType, Integer> getCounters() {
return this.counters; return this.counters;
} }
@@ -1440,13 +1439,13 @@ public class Card extends GameEntity implements Comparable<Card> {
* </p> * </p>
* *
* @param counterName * @param counterName
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @param n * @param n
* a int. * a int.
* @param bSetValue * @param bSetValue
* a boolean. * a boolean.
*/ */
public final void setCounter(final Counters counterName, final int n, final boolean bSetValue) { public final void setCounter(final CounterType counterName, final int n, final boolean bSetValue) {
if (!this.canHaveCountersPlacedOnIt(counterName)) { if (!this.canHaveCountersPlacedOnIt(counterName)) {
return; return;
} }
@@ -1476,7 +1475,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* a Map object. * a Map object.
* @since 1.0.15 * @since 1.0.15
*/ */
public final void setCounters(final Map<Counters, Integer> allCounters) { public final void setCounters(final Map<CounterType, Integer> allCounters) {
this.counters = allCounters; this.counters = allCounters;
} }
@@ -1489,7 +1488,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* @since 1.0.15 * @since 1.0.15
*/ */
public final void clearCounters() { public final void clearCounters() {
this.counters = new TreeMap<Counters, Integer>(); this.counters.clear();
} }
/** /**
@@ -1589,7 +1588,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* @return a int. * @return a int.
*/ */
public final int getNetPTCounters() { public final int getNetPTCounters() {
return this.getCounters(Counters.P1P1) - this.getCounters(Counters.M1M1); return this.getCounters(CounterType.P1P1) - this.getCounters(CounterType.M1M1);
} }
/** /**
@@ -2226,7 +2225,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (p.length > 4) { if (p.length > 4) {
s.append(p[4]); s.append(p[4]);
} else { } else {
final Counters counter = Counters.valueOf(p[1]); final CounterType counter = CounterType.valueOf(p[1]);
final String numCounters = p[2]; final String numCounters = p[2];
s.append(this.getName()); s.append(this.getName());
s.append(" enters the battlefield with "); s.append(" enters the battlefield with ");
@@ -4527,10 +4526,10 @@ public class Card extends GameEntity implements Comparable<Card> {
public final int getUnswitchedAttack() { public final int getUnswitchedAttack() {
int total = this.getCurrentPower(); int total = this.getCurrentPower();
total += ((this.getTempAttackBoost() + this.getSemiPermanentAttackBoost() + this.getCounters(Counters.P1P1) total += ((this.getTempAttackBoost() + this.getSemiPermanentAttackBoost() + this.getCounters(CounterType.P1P1)
+ this.getCounters(Counters.P1P2) + this.getCounters(Counters.P1P0)) - this.getCounters(Counters.M1M1)) + this.getCounters(CounterType.P1P2) + this.getCounters(CounterType.P1P0)) - this.getCounters(CounterType.M1M1))
+ ((2 * this.getCounters(Counters.P2P2)) - (2 * this.getCounters(Counters.M2M1)) + ((2 * this.getCounters(CounterType.P2P2)) - (2 * this.getCounters(CounterType.M2M1))
- (2 * this.getCounters(Counters.M2M2)) - this.getCounters(Counters.M1M0)); - (2 * this.getCounters(CounterType.M2M2)) - this.getCounters(CounterType.M1M0));
return total; return total;
} }
@@ -4576,12 +4575,12 @@ public class Card extends GameEntity implements Comparable<Card> {
int total = this.getCurrentToughness(); int total = this.getCurrentToughness();
total += (((((this.getTempDefenseBoost() + this.getSemiPermanentDefenseBoost() total += (((((this.getTempDefenseBoost() + this.getSemiPermanentDefenseBoost()
+ this.getCounters(Counters.P1P1) + (2 * this.getCounters(Counters.P1P2))) - this + this.getCounters(CounterType.P1P1) + (2 * this.getCounters(CounterType.P1P2))) - this
.getCounters(Counters.M1M1)) + this.getCounters(Counters.P0P1)) - (2 * this.getCounters(Counters.M0M2))) + (2 * this .getCounters(CounterType.M1M1)) + this.getCounters(CounterType.P0P1)) - (2 * this.getCounters(CounterType.M0M2))) + (2 * this
.getCounters(Counters.P2P2))) .getCounters(CounterType.P2P2)))
- this.getCounters(Counters.M0M1) - this.getCounters(CounterType.M0M1)
- this.getCounters(Counters.M2M1) - this.getCounters(CounterType.M2M1)
- (2 * this.getCounters(Counters.M2M2)); - (2 * this.getCounters(CounterType.M2M2));
return total; return total;
} }
@@ -6961,7 +6960,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} else if (property.startsWith("suspended")) { } else if (property.startsWith("suspended")) {
if (!this.hasSuspend() || !Singletons.getModel().getGame().isCardExiled(this) if (!this.hasSuspend() || !Singletons.getModel().getGame().isCardExiled(this)
|| !(this.getCounters(Counters.getType("TIME")) >= 1)) { || !(this.getCounters(CounterType.getType("TIME")) >= 1)) {
return false; return false;
} }
@@ -7026,7 +7025,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
counterType = splitProperty[2]; counterType = splitProperty[2];
final int actualnumber = this.getCounters(Counters.getType(counterType)); final int actualnumber = this.getCounters(CounterType.getType(counterType));
if (!Expressions.compare(actualnumber, comparator, number)) { if (!Expressions.compare(actualnumber, comparator, number)) {
return false; return false;
@@ -8132,7 +8131,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (this.hasKeyword("If damage would be dealt to CARDNAME, " if (this.hasKeyword("If damage would be dealt to CARDNAME, "
+ "prevent that damage. Remove a +1/+1 counter from CARDNAME.")) { + "prevent that damage. Remove a +1/+1 counter from CARDNAME.")) {
restDamage = 0; restDamage = 0;
this.subtractCounter(Counters.P1P1, 1); this.subtractCounter(CounterType.P1P1, 1);
} }
if (restDamage >= this.getPreventNextDamage()) { if (restDamage >= this.getPreventNextDamage()) {
@@ -8314,7 +8313,7 @@ public class Card extends GameEntity implements Comparable<Card> {
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams); Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams);
if (this.isPlaneswalker()) { if (this.isPlaneswalker()) {
this.subtractCounter(Counters.LOYALTY, damageToAdd); this.subtractCounter(CounterType.LOYALTY, damageToAdd);
return true; return true;
} }
@@ -8326,7 +8325,7 @@ public class Card extends GameEntity implements Comparable<Card> {
GameActionUtil.executeDamageToCreatureEffects(source, this, damageToAdd); GameActionUtil.executeDamageToCreatureEffects(source, this, damageToAdd);
if (this.isInPlay() && wither) { if (this.isInPlay() && wither) {
this.addCounter(Counters.M1M1, damageToAdd); this.addCounter(CounterType.M1M1, damageToAdd);
} }
if (source.hasKeyword("Deathtouch") && this.isCreature()) { if (source.hasKeyword("Deathtouch") && this.isCreature()) {
Singletons.getModel().getGame().getAction().destroy(this); Singletons.getModel().getGame().getAction().destroy(this);

View File

@@ -24,7 +24,7 @@ package forge;
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 17.02.2010 * @version V0.0 17.02.2010
*/ */
public enum Counters { public enum CounterType {
/** The AGE. */ /** The AGE. */
AGE(), AGE(),
@@ -348,7 +348,7 @@ public enum Counters {
* Constructor for Counters. * Constructor for Counters.
* </p> * </p>
*/ */
private Counters() { private CounterType() {
this.name = this.name().substring(0, 1).toUpperCase() + this.name().substring(1).toLowerCase(); this.name = this.name().substring(0, 1).toUpperCase() + this.name().substring(1).toLowerCase();
} }
@@ -360,7 +360,7 @@ public enum Counters {
* @param name * @param name
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
private Counters(final String nameIn) { private CounterType(final String nameIn) {
this.name = nameIn; this.name = nameIn;
} }
@@ -382,10 +382,10 @@ public enum Counters {
* *
* @param name * @param name
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @return a {@link forge.Counters} object. * @return a {@link forge.CounterType} object.
*/ */
public static Counters getType(final String name) { public static CounterType getType(final String name) {
final String replacedName = name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase(); final String replacedName = name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase();
return Enum.valueOf(Counters.class, replacedName); return Enum.valueOf(CounterType.class, replacedName);
} }
} }

View File

@@ -848,7 +848,7 @@ public class GameAction {
this.moveToPlay(c); this.moveToPlay(c);
if (c.getName().equals("Dodecapod")) { if (c.getName().equals("Dodecapod")) {
c.setCounter(Counters.P1P1, 2, false); c.setCounter(CounterType.P1P1, 2, false);
} }
} }
@@ -1169,12 +1169,12 @@ public class GameAction {
} }
// +1/+1 counters should erase -1/-1 counters // +1/+1 counters should erase -1/-1 counters
if (c.getCounters(Counters.P1P1) > 0 && c.getCounters(Counters.M1M1) > 0) { if (c.getCounters(CounterType.P1P1) > 0 && c.getCounters(CounterType.M1M1) > 0) {
final Counters p1Counter = Counters.P1P1; final CounterType p1Counter = CounterType.P1P1;
final Counters m1Counter = Counters.M1M1; final CounterType m1Counter = CounterType.M1M1;
int plusOneCounters = c.getCounters(Counters.P1P1); int plusOneCounters = c.getCounters(CounterType.P1P1);
int minusOneCounters = c.getCounters(Counters.M1M1); int minusOneCounters = c.getCounters(CounterType.M1M1);
if (plusOneCounters == minusOneCounters) { if (plusOneCounters == minusOneCounters) {
c.getCounters().remove(m1Counter); c.getCounters().remove(m1Counter);
@@ -1253,7 +1253,7 @@ public class GameAction {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
c = list.get(i); c = list.get(i);
if (c.getCounters(Counters.LOYALTY) <= 0) { if (c.getCounters(CounterType.LOYALTY) <= 0) {
Singletons.getModel().getGame().getAction().moveToGraveyard(c); Singletons.getModel().getGame().getAction().moveToGraveyard(c);
} }
@@ -1467,9 +1467,9 @@ public class GameAction {
throw new RuntimeException("GameAction : destroy() invalid card.getOwner() - " + c + " " + owner); throw new RuntimeException("GameAction : destroy() invalid card.getOwner() - " + c + " " + owner);
} }
final boolean persist = (c.hasKeyword("Persist") && (c.getCounters(Counters.M1M1) == 0)) && !c.isToken(); final boolean persist = (c.hasKeyword("Persist") && (c.getCounters(CounterType.M1M1) == 0)) && !c.isToken();
final boolean undying = (c.hasKeyword("Undying") && (c.getCounters(Counters.P1P1) == 0)) && !c.isToken(); final boolean undying = (c.hasKeyword("Undying") && (c.getCounters(CounterType.P1P1) == 0)) && !c.isToken();
final Card newCard = this.moveToGraveyard(c); final Card newCard = this.moveToGraveyard(c);
@@ -1494,7 +1494,7 @@ public class GameAction {
if (game.getZoneOf(persistCard).is(ZoneType.Graveyard)) { if (game.getZoneOf(persistCard).is(ZoneType.Graveyard)) {
final PlayerZone ownerPlay = persistCard.getOwner().getZone(ZoneType.Battlefield); final PlayerZone ownerPlay = persistCard.getOwner().getZone(ZoneType.Battlefield);
final Card card = GameAction.this.moveTo(ownerPlay, persistCard); final Card card = GameAction.this.moveTo(ownerPlay, persistCard);
card.addCounter(Counters.M1M1, 1); card.addCounter(CounterType.M1M1, 1);
} }
} }
}; };
@@ -1514,7 +1514,7 @@ public class GameAction {
if (game.getZoneOf(undyingCard).is(ZoneType.Graveyard)) { if (game.getZoneOf(undyingCard).is(ZoneType.Graveyard)) {
final PlayerZone ownerPlay = undyingCard.getOwner().getZone(ZoneType.Battlefield); final PlayerZone ownerPlay = undyingCard.getOwner().getZone(ZoneType.Battlefield);
final Card card = GameAction.this.moveTo(ownerPlay, undyingCard); final Card card = GameAction.this.moveTo(ownerPlay, undyingCard);
card.addCounter(Counters.P1P1, 1); card.addCounter(CounterType.P1P1, 1);
} }
} }
}; };

View File

@@ -427,7 +427,7 @@ public final class GameActionUtil {
else if (part instanceof CostPutCounter) { else if (part instanceof CostPutCounter) {
String amountString = part.getAmount(); String amountString = part.getAmount();
Counters counterType = ((CostPutCounter) part).getCounter(); CounterType counterType = ((CostPutCounter) part).getCounter();
int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString) int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString)
: CardFactoryUtil.xCount(source, source.getSVar(amountString)); : CardFactoryUtil.xCount(source, source.getSVar(amountString));
String plural = amount > 1 ? "s" : ""; String plural = amount > 1 ? "s" : "";
@@ -724,9 +724,9 @@ public final class GameActionUtil {
final Ability ability2 = new Ability(c, "0") { final Ability ability2 = new Ability(c, "0") {
@Override @Override
public void resolve() { public void resolve() {
Counters counter = Counters.P1P1; CounterType counter = CounterType.P1P1;
if (kw.contains("+2/+2")) { if (kw.contains("+2/+2")) {
counter = Counters.P2P2; counter = CounterType.P2P2;
} }
if (thisCard.isInPlay()) { if (thisCard.isInPlay()) {
thisCard.addCounter(counter, 1); thisCard.addCounter(counter, 1);

View File

@@ -24,7 +24,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -93,7 +93,7 @@ public abstract class CountersAi {
final List<Card> boon = CardLists.filter(list, new Predicate<Card>() { final List<Card> boon = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return c.getCounters(Counters.DIVINITY) == 0; return c.getCounters(CounterType.DIVINITY) == 0;
} }
}); });
choice = CardFactoryUtil.getMostExpensivePermanentAI(boon, null, false); choice = CardFactoryUtil.getMostExpensivePermanentAI(boon, null, false);

View File

@@ -6,7 +6,7 @@ import java.util.Random;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -53,12 +53,12 @@ public class CountersMoveAi extends SpellAiLogic {
boolean chance = false; boolean chance = false;
boolean preferred = true; boolean preferred = true;
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final ArrayList<Card> srcCards = AbilityFactory.getDefinedCards(host, sa.getParam("Source"), sa); final ArrayList<Card> srcCards = AbilityFactory.getDefinedCards(host, sa.getParam("Source"), sa);
final ArrayList<Card> destCards = AbilityFactory.getDefinedCards(host, sa.getParam("Defined"), sa); final ArrayList<Card> destCards = AbilityFactory.getDefinedCards(host, sa.getParam("Defined"), sa);
if (abTgt == null) { if (abTgt == null) {
if ((srcCards.size() > 0) if ((srcCards.size() > 0)
&& cType.equals(Counters.P1P1) // move +1/+1 counters away && cType.equals(CounterType.P1P1) // move +1/+1 counters away
// from // from
// permanents that cannot use // permanents that cannot use
// them // them

View File

@@ -6,7 +6,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -22,7 +22,7 @@ public class CountersProliferateAi extends SpellAiLogic {
List<Card> cperms = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() { List<Card> cperms = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
@Override @Override
public boolean apply(final Card crd) { public boolean apply(final Card crd) {
for (final Counters c1 : Counters.values()) { for (final CounterType c1 : CounterType.values()) {
if (crd.getCounters(c1) != 0 && !CardFactoryUtil.isNegativeCounter(c1)) { if (crd.getCounters(c1) != 0 && !CardFactoryUtil.isNegativeCounter(c1)) {
return true; return true;
} }
@@ -34,7 +34,7 @@ public class CountersProliferateAi extends SpellAiLogic {
List<Card> hperms = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), new Predicate<Card>() { List<Card> hperms = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
@Override @Override
public boolean apply(final Card crd) { public boolean apply(final Card crd) {
for (final Counters c1 : Counters.values()) { for (final CounterType c1 : CounterType.values()) {
if (crd.getCounters(c1) != 0 && CardFactoryUtil.isNegativeCounter(c1)) { if (crd.getCounters(c1) != 0 && CardFactoryUtil.isNegativeCounter(c1)) {
return true; return true;
} }

View File

@@ -8,7 +8,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
@@ -141,7 +141,7 @@ public class CountersPutAi extends SpellAiLogic {
return false; return false;
} }
final int currCounters = cards.get(0).getCounters(Counters.valueOf(type)); final int currCounters = cards.get(0).getCounters(CounterType.valueOf(type));
// each non +1/+1 counter on the card is a 10% chance of not // each non +1/+1 counter on the card is a 10% chance of not
// activating this ability. // activating this ability.

View File

@@ -3,7 +3,7 @@ package forge.card.abilityfactory.ai;
import java.util.Random; import java.util.Random;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
import forge.card.cost.Cost; import forge.card.cost.Cost;
@@ -73,7 +73,7 @@ public class CountersRemoveAi extends SpellAiLogic {
} }
if (!type.matches("Any")) { if (!type.matches("Any")) {
final int currCounters = sa.getSourceCard().getCounters(Counters.valueOf(type)); final int currCounters = sa.getSourceCard().getCounters(CounterType.valueOf(type));
if (currCounters < 1) { if (currCounters < 1) {
return false; return false;
} }

View File

@@ -8,7 +8,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
@@ -75,7 +75,7 @@ public class DestroyAi extends SpellAiLogic {
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return (!c.hasKeyword("Undying") || c.getCounters(Counters.P1P1) > 0); return (!c.hasKeyword("Undying") || c.getCounters(CounterType.P1P1) > 0);
} }
}); });
} }

View File

@@ -3,7 +3,7 @@ package forge.card.abilityfactory.ai;
import java.util.Random; import java.util.Random;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic; import forge.card.abilityfactory.SpellAiLogic;
@@ -121,7 +121,7 @@ public class LifeSetAi extends SpellAiLogic {
} }
if (source.getName().equals("Eternity Vessel") if (source.getName().equals("Eternity Vessel")
&& (opponent.isCardInPlay("Vampire Hexmage") || (source.getCounters(Counters.CHARGE) == 0))) { && (opponent.isCardInPlay("Vampire Hexmage") || (source.getCounters(CounterType.CHARGE) == 0))) {
return false; return false;
} }

View File

@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -30,7 +30,7 @@ public class CountersMoveEffect extends SpellEffect {
} }
final List<Card> tgtCards = getTargetCards(sa); final List<Card> tgtCards = getTargetCards(sa);
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa); final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
sb.append("Move ").append(amount).append(" ").append(cType.getName()).append(" counter"); sb.append("Move ").append(amount).append(" ").append(cType.getName()).append(" counter");
@@ -48,7 +48,7 @@ public class CountersMoveEffect extends SpellEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card host = sa.getSourceCard(); final Card host = sa.getSourceCard();
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa); final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
Card source = null; Card source = null;
@@ -74,7 +74,7 @@ public class CountersMoveEffect extends SpellEffect {
if (source.getCounters(cType) >= amount) { if (source.getCounters(cType) >= amount) {
if (!dest.hasKeyword("CARDNAME can't have counters placed on it.") if (!dest.hasKeyword("CARDNAME can't have counters placed on it.")
&& !(dest.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && cType && !(dest.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && cType
.equals(Counters.M1M1))) { .equals(CounterType.M1M1))) {
dest.addCounter(cType, amount); dest.addCounter(cType, amount);
source.subtractCounter(cType, amount); source.subtractCounter(cType, amount);
} }

View File

@@ -9,7 +9,7 @@ import com.google.common.collect.Lists;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -71,14 +71,14 @@ public class CountersProliferateEffect extends SpellEffect {
} }
unchosen.remove(card); unchosen.remove(card);
final ArrayList<String> choices = new ArrayList<String>(); final ArrayList<String> choices = new ArrayList<String>();
for (final Counters c1 : Counters.values()) { for (final CounterType c1 : CounterType.values()) {
if (card.getCounters(c1) != 0) { if (card.getCounters(c1) != 0) {
choices.add(c1.getName()); choices.add(c1.getName());
} }
} }
if (choices.size() > 0) { if (choices.size() > 0) {
card.addCounter( card.addCounter(
Counters.getType((choices.size() == 1 ? choices.get(0) : GuiChoose.one( CounterType.getType((choices.size() == 1 ? choices.get(0) : GuiChoose.one(
"Select counter type", choices).toString())), 1); "Select counter type", choices).toString())), 1);
} }
} }
@@ -104,7 +104,7 @@ public class CountersProliferateEffect extends SpellEffect {
final Predicate<Card> predProliferate = new Predicate<Card>() { final Predicate<Card> predProliferate = new Predicate<Card>() {
@Override @Override
public boolean apply(Card crd) { public boolean apply(Card crd) {
for (final Entry<Counters, Integer> c1 : crd.getCounters().entrySet()) { for (final Entry<CounterType, Integer> c1 : crd.getCounters().entrySet()) {
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(crd.getController())) { if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(crd.getController())) {
return true; return true;
} }
@@ -150,7 +150,7 @@ public class CountersProliferateEffect extends SpellEffect {
// add a counter of one counter type, if it would benefit the // add a counter of one counter type, if it would benefit the
// computer // computer
for (final Card c : cardsToProliferate) { for (final Card c : cardsToProliferate) {
for (final Entry<Counters, Integer> c1 : c.getCounters().entrySet()) { for (final Entry<CounterType, Integer> c1 : c.getCounters().entrySet()) {
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(c.getController())) if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(c.getController()))
{ {
c.addCounter(c1.getKey(), 1); c.addCounter(c1.getKey(), 1);

View File

@@ -4,7 +4,7 @@ import java.util.List;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
@@ -19,7 +19,7 @@ public class CountersPutAllEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa); final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield"; final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
@@ -55,10 +55,10 @@ public class CountersPutAllEffect extends SpellEffect {
for (final Card tgtCard : cards) { for (final Card tgtCard : cards) {
if (Singletons.getModel().getGame().getZoneOf(tgtCard).is(ZoneType.Battlefield)) { if (Singletons.getModel().getGame().getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
tgtCard.addCounter(Counters.valueOf(type), counterAmount); tgtCard.addCounter(CounterType.valueOf(type), counterAmount);
} else { } else {
// adding counters to something like re-suspend cards // adding counters to something like re-suspend cards
tgtCard.addCounterFromNonEffect(Counters.valueOf(type), counterAmount); tgtCard.addCounterFromNonEffect(CounterType.valueOf(type), counterAmount);
} }
} }
} }

View File

@@ -5,7 +5,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
@@ -22,7 +22,7 @@ public class CountersPutEffect extends SpellEffect {
final Card card = sa.getSourceCard(); final Card card = sa.getSourceCard();
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(card, sa.getParam("CounterNum"), sa); final int amount = AbilityFactory.calculateAmount(card, sa.getParam("CounterNum"), sa);
sb.append("Put "); sb.append("Put ");
if (sa.hasParam("UpTo")) { if (sa.hasParam("UpTo")) {
@@ -86,16 +86,16 @@ public class CountersPutEffect extends SpellEffect {
for (final Card tgtCard : tgtCards) { for (final Card tgtCard : tgtCards) {
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) { if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
if (max != -1) { if (max != -1) {
counterAmount = max - tgtCard.getCounters(Counters.valueOf(type)); counterAmount = max - tgtCard.getCounters(CounterType.valueOf(type));
} }
final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard); final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard);
if (zone == null) { if (zone == null) {
// Do nothing, token disappeared // Do nothing, token disappeared
} else if (zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) { } else if (zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
tgtCard.addCounter(Counters.valueOf(type), counterAmount); tgtCard.addCounter(CounterType.valueOf(type), counterAmount);
} else { } else {
// adding counters to something like re-suspend cards // adding counters to something like re-suspend cards
tgtCard.addCounterFromNonEffect(Counters.valueOf(type), counterAmount); tgtCard.addCounterFromNonEffect(CounterType.valueOf(type), counterAmount);
} }
} }
} }

View File

@@ -4,7 +4,7 @@ import java.util.List;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
@@ -18,7 +18,7 @@ public class CountersRemoveAllEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final Counters cType = Counters.valueOf(sa.getParam("CounterType")); final CounterType cType = CounterType.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa); final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield"; final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
String amountString = Integer.toString(amount); String amountString = Integer.toString(amount);
@@ -59,10 +59,10 @@ public class CountersRemoveAllEffect extends SpellEffect {
for (final Card tgtCard : cards) { for (final Card tgtCard : cards) {
if (sa.hasParam("AllCounters")) { if (sa.hasParam("AllCounters")) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type)); counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
} }
tgtCard.subtractCounter(Counters.valueOf(type), counterAmount); tgtCard.subtractCounter(CounterType.valueOf(type), counterAmount);
} }
} }
} }

View File

@@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
@@ -37,7 +37,7 @@ public class CountersRemoveEffect extends SpellEffect {
} }
} }
else { else {
sb.append(amount).append(" ").append(Counters.valueOf(counterName).getName()).append(" counter"); sb.append(amount).append(" ").append(CounterType.valueOf(counterName).getName()).append(" counter");
} }
if (amount != 1) { if (amount != 1) {
sb.append("s"); sb.append("s");
@@ -73,18 +73,18 @@ public class CountersRemoveEffect extends SpellEffect {
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) { if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard); final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard);
if (sa.getParam("CounterNum").equals("All")) { if (sa.getParam("CounterNum").equals("All")) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type)); counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
} }
if (type.matches("Any")) { if (type.matches("Any")) {
while (counterAmount > 0 && tgtCard.getNumberOfCounters() > 0) { while (counterAmount > 0 && tgtCard.getNumberOfCounters() > 0) {
final Map<Counters, Integer> tgtCounters = tgtCard.getCounters(); final Map<CounterType, Integer> tgtCounters = tgtCard.getCounters();
Counters chosenType = null; CounterType chosenType = null;
int chosenAmount; int chosenAmount;
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final ArrayList<Counters> typeChoices = new ArrayList<Counters>(); final ArrayList<CounterType> typeChoices = new ArrayList<CounterType>();
// get types of counters // get types of counters
for (Counters key : tgtCounters.keySet()) { for (CounterType key : tgtCounters.keySet()) {
if (tgtCounters.get(key) > 0) { if (tgtCounters.get(key) > 0) {
typeChoices.add(key); typeChoices.add(key);
} }
@@ -116,7 +116,7 @@ public class CountersRemoveEffect extends SpellEffect {
// find first nonzero counter on target // find first nonzero counter on target
for (Object key : tgtCounters.keySet()) { for (Object key : tgtCounters.keySet()) {
if (tgtCounters.get(key) > 0) { if (tgtCounters.get(key) > 0) {
chosenType = (Counters) key; chosenType = (CounterType) key;
break; break;
} }
} }
@@ -147,13 +147,13 @@ public class CountersRemoveEffect extends SpellEffect {
counterAmount = Integer.parseInt(o); counterAmount = Integer.parseInt(o);
} }
} }
tgtCard.subtractCounter(Counters.valueOf(type), counterAmount); tgtCard.subtractCounter(CounterType.valueOf(type), counterAmount);
if (rememberRemoved) { if (rememberRemoved) {
if (counterAmount > tgtCard.getCounters(Counters.valueOf(type))) { if (counterAmount > tgtCard.getCounters(CounterType.valueOf(type))) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type)); counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
} }
for (int i = 0; i < counterAmount; i++) { for (int i = 0; i < counterAmount; i++) {
card.addRemembered(Counters.valueOf(type)); card.addRemembered(CounterType.valueOf(type));
} }
} }
} }

View File

@@ -6,7 +6,7 @@ import com.google.common.collect.Iterables;
import forge.Card; import forge.Card;
import forge.CardPredicates; import forge.CardPredicates;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect; import forge.card.abilityfactory.SpellEffect;
@@ -191,7 +191,7 @@ public class ManaEffect extends SpellEffect {
final String deplete = sa.getParam("Deplete"); final String deplete = sa.getParam("Deplete");
if (deplete != null) { if (deplete != null) {
final int num = card.getCounters(Counters.getType(deplete)); final int num = card.getCounters(CounterType.getType(deplete));
if (num == 0) { if (num == 0) {
sa.setUndoable(false); sa.setUndoable(false);
Singletons.getModel().getGame().getAction().sacrifice(card, null); Singletons.getModel().getGame().getAction().sacrifice(card, null);

View File

@@ -8,7 +8,7 @@ import javax.swing.JOptionPane;
import forge.Card; import forge.Card;
import forge.Command; import forge.Command;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
@@ -309,7 +309,7 @@ class CardFactoryArtifacts {
@Override @Override
public void execute() { public void execute() {
card.addCounter(Counters.CHARGE, card.getMultiKickerMagnitude()); card.addCounter(CounterType.CHARGE, card.getMultiKickerMagnitude());
card.setMultiKickerMagnitude(0); card.setMultiKickerMagnitude(0);
} }
}; };

View File

@@ -38,7 +38,7 @@ import forge.CardPredicates.Presets;
import forge.CardUtil; import forge.CardUtil;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.cost.Cost; import forge.card.cost.Cost;
@@ -92,7 +92,7 @@ public class CardFactoryCreatures {
return; return;
} else if (c.isInPlay() && c.canBeTargetedBy(this)) { } else if (c.isInPlay() && c.canBeTargetedBy(this)) {
// zerker clean up: // zerker clean up:
for (final Counters c1 : Counters.values()) { for (final CounterType c1 : CounterType.values()) {
if (c.getCounters(c1) > 0) { if (c.getCounters(c1) > 0) {
c.addCounter(c1, c.getCounters(c1)); c.addCounter(c1, c.getCounters(c1));
} }
@@ -151,7 +151,7 @@ public class CardFactoryCreatures {
if (artifacts.size() != 0) { if (artifacts.size() != 0) {
final Card c = GuiChoose.one("Select an artifact put a phylactery counter on", artifacts); final Card c = GuiChoose.one("Select an artifact put a phylactery counter on", artifacts);
if (c != null) { if (c != null) {
c.addCounter(Counters.PHYLACTERY, 1); c.addCounter(CounterType.PHYLACTERY, 1);
} }
} }
@@ -171,7 +171,7 @@ public class CardFactoryCreatures {
chosen = artifacts.get(0); chosen = artifacts.get(0);
} }
if (chosen != null) { if (chosen != null) {
chosen.addCounter(Counters.PHYLACTERY, 1); chosen.addCounter(CounterType.PHYLACTERY, 1);
} }
} // else } // else
} // execute() } // execute()
@@ -506,7 +506,7 @@ public class CardFactoryCreatures {
if (xCounters >= 5) { if (xCounters >= 5) {
xCounters = 2 * xCounters; xCounters = 2 * xCounters;
} }
c.addCounter(Counters.P1P1, xCounters); c.addCounter(CounterType.P1P1, xCounters);
} }
}; };
spell.setIsXCost(true); spell.setIsXCost(true);
@@ -520,7 +520,7 @@ public class CardFactoryCreatures {
final SpellAbility ability = new Ability(card, "0") { final SpellAbility ability = new Ability(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
card.addCounter(Counters.P1P1, this.countKithkin()); card.addCounter(CounterType.P1P1, this.countKithkin());
// System.out.println("all counters: " // System.out.println("all counters: "
// +card.sumAllCounters()); // +card.sumAllCounters());
} // resolve() } // resolve()
@@ -590,7 +590,7 @@ public class CardFactoryCreatures {
final AbilityStatic ability = new AbilityStatic(card, "0") { final AbilityStatic ability = new AbilityStatic(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
card.addCounter(Counters.P1P1, card.getMultiKickerMagnitude()); card.addCounter(CounterType.P1P1, card.getMultiKickerMagnitude());
card.setMultiKickerMagnitude(0); card.setMultiKickerMagnitude(0);
} }
}; };
@@ -642,7 +642,7 @@ public class CardFactoryCreatures {
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card crd) { public boolean apply(final Card crd) {
return crd.getCounters(Counters.ICE) >= 3; return crd.getCounters(CounterType.ICE) >= 3;
} }
}); });
@@ -656,7 +656,7 @@ public class CardFactoryCreatures {
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card crd) { public boolean apply(final Card crd) {
return crd.isPlaneswalker() && (crd.getCounters(Counters.LOYALTY) >= 5); return crd.isPlaneswalker() && (crd.getCounters(CounterType.LOYALTY) >= 5);
} }
}); });
@@ -671,7 +671,7 @@ public class CardFactoryCreatures {
@Override @Override
public void resolve() { public void resolve() {
final Card c = this.getTargetCard(); final Card c = this.getTargetCard();
for (final Counters counter : Counters.values()) { for (final CounterType counter : CounterType.values()) {
if (c.getCounters(counter) > 0) { if (c.getCounters(counter) > 0) {
c.setCounter(counter, 0, false); c.setCounter(counter, 0, false);
} }
@@ -1166,13 +1166,13 @@ public class CardFactoryCreatures {
@Override @Override
public void resolve() { public void resolve() {
card.addCounter(Counters.LEVEL, 1); card.addCounter(CounterType.LEVEL, 1);
} }
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
// Todo: Improve Level up code // Todo: Improve Level up code
return card.getCounters(Counters.LEVEL) < maxLevel; return card.getCounters(CounterType.LEVEL) < maxLevel;
} }
@Override @Override

View File

@@ -28,7 +28,7 @@ import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Command; import forge.Command;
import forge.Counters; import forge.CounterType;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Singletons; import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
@@ -178,7 +178,7 @@ class CardFactoryLands {
this.inPlay.clear(); this.inPlay.clear();
this.inPlay.addAll(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)); this.inPlay.addAll(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield));
for (final Card targ : CardLists.filter(this.inPlay, targets)) { for (final Card targ : CardLists.filter(this.inPlay, targets)) {
targ.addCounter(Counters.P1P1, 1); targ.addCounter(CounterType.P1P1, 1);
} }
} }
} }

View File

@@ -19,7 +19,7 @@ package forge.card.cardfactory;
import forge.Card; import forge.Card;
import forge.Command; import forge.Command;
import forge.Counters; import forge.CounterType;
import forge.card.replacement.ReplacementHandler; import forge.card.replacement.ReplacementHandler;
/** /**
@@ -44,7 +44,7 @@ public class CardFactoryPlaneswalkers {
public static void buildCard(final Card card) { public static void buildCard(final Card card) {
// All Planeswalkers set their loyality in the beginning // All Planeswalkers set their loyality in the beginning
if (card.getBaseLoyalty() > 0) { if (card.getBaseLoyalty() > 0) {
Command cmd = CardFactoryUtil.entersBattleFieldWithCounters(card, Counters.LOYALTY, card.getBaseLoyalty()); Command cmd = CardFactoryUtil.entersBattleFieldWithCounters(card, CounterType.LOYALTY, card.getBaseLoyalty());
card.addComesIntoPlayCommand(cmd); card.addComesIntoPlayCommand(cmd);
} }

View File

@@ -42,7 +42,7 @@ import forge.CardPredicates.Presets;
import forge.CardUtil; import forge.CardUtil;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.CounterType;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
import forge.card.CardCharacteristics; import forge.card.CardCharacteristics;
@@ -1124,7 +1124,7 @@ public class CardFactoryUtil {
final Card c = Singletons.getModel().getGame().getAction().exile(sourceCard); final Card c = Singletons.getModel().getGame().getAction().exile(sourceCard);
int counters = AbilityFactory.calculateAmount(c, timeCounters, this); int counters = AbilityFactory.calculateAmount(c, timeCounters, this);
c.addCounter(Counters.TIME, counters); c.addCounter(CounterType.TIME, counters);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(this.getActivatingPlayer()).append(" has suspended "); sb.append(this.getActivatingPlayer()).append(" has suspended ");
@@ -1154,12 +1154,12 @@ public class CardFactoryUtil {
* @param c * @param c
* a {@link forge.Card} object. * a {@link forge.Card} object.
* @param type * @param type
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @param n * @param n
* a int. * a int.
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
public static Command entersBattleFieldWithCounters(final Card c, final Counters type, final int n) { public static Command entersBattleFieldWithCounters(final Card c, final CounterType type, final int n) {
final Command addCounters = new Command() { final Command addCounters = new Command() {
private static final long serialVersionUID = 4825430555490333062L; private static final long serialVersionUID = 4825430555490333062L;
@@ -1183,7 +1183,7 @@ public class CardFactoryUtil {
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
public static Command fading(final Card sourceCard, final int power) { public static Command fading(final Card sourceCard, final int power) {
return entersBattleFieldWithCounters(sourceCard, Counters.FADE, power); return entersBattleFieldWithCounters(sourceCard, CounterType.FADE, power);
} // fading } // fading
/** /**
@@ -1198,7 +1198,7 @@ public class CardFactoryUtil {
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
public static Command vanishing(final Card sourceCard, final int power) { public static Command vanishing(final Card sourceCard, final int power) {
return entersBattleFieldWithCounters(sourceCard, Counters.TIME, power); return entersBattleFieldWithCounters(sourceCard, CounterType.TIME, power);
} // vanishing } // vanishing
// List<Card> choices are the only cards the user can successful select // List<Card> choices are the only cards the user can successful select
@@ -1342,7 +1342,7 @@ public class CardFactoryUtil {
&& card.canBeTargetedBy(ability)) { && card.canBeTargetedBy(ability)) {
ability.setTargetCard(card2); ability.setTargetCard(card2);
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Put ").append(card.getCounters(Counters.P1P1)); sb.append("Put ").append(card.getCounters(CounterType.P1P1));
sb.append(" +1/+1 counter/s from ").append(card); sb.append(" +1/+1 counter/s from ").append(card);
sb.append(" on ").append(card2); sb.append(" on ").append(card2);
ability.setStackDescription(sb.toString()); ability.setStackDescription(sb.toString());
@@ -2425,12 +2425,12 @@ public class CardFactoryUtil {
} }
// Count$CardCounters.<counterType> // Count$CardCounters.<counterType>
if (sq[0].contains("CardCounters")) { if (sq[0].contains("CardCounters")) {
return CardFactoryUtil.doXMath(c.getCounters(Counters.getType(sq[1])), m, c); return CardFactoryUtil.doXMath(c.getCounters(CounterType.getType(sq[1])), m, c);
} }
// Count$TotalCounters.<counterType>_<valid> // Count$TotalCounters.<counterType>_<valid>
if (sq[0].contains("TotalCounters")) { if (sq[0].contains("TotalCounters")) {
final String[] restrictions = l[0].split("_"); final String[] restrictions = l[0].split("_");
final Counters cType = Counters.getType(restrictions[1]); final CounterType cType = CounterType.getType(restrictions[1]);
final String[] validFilter = restrictions[2].split(","); final String[] validFilter = restrictions[2].split(",");
List<Card> validCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield); List<Card> validCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
validCards = CardLists.getValidCards(validCards, validFilter, cardController, c); validCards = CardLists.getValidCards(validCards, validFilter, cardController, c);
@@ -2445,7 +2445,7 @@ public class CardFactoryUtil {
return CardFactoryUtil.doXMath(c.getMultiKickerMagnitude(), m, c); return CardFactoryUtil.doXMath(c.getMultiKickerMagnitude(), m, c);
} }
if (sq[0].contains("NumCounters")) { if (sq[0].contains("NumCounters")) {
final int num = c.getCounters(Counters.getType(sq[1])); final int num = c.getCounters(CounterType.getType(sq[1]));
return CardFactoryUtil.doXMath(num, m, c); return CardFactoryUtil.doXMath(num, m, c);
} }
@@ -3442,13 +3442,13 @@ public class CardFactoryUtil {
* </p> * </p>
* *
* @param c * @param c
* a {@link forge.Counters} object. * a {@link forge.CounterType} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean isNegativeCounter(final Counters c) { public static boolean isNegativeCounter(final CounterType c) {
return (c == Counters.AGE) || (c == Counters.BLAZE) || (c == Counters.BRIBERY) || (c == Counters.DOOM) return (c == CounterType.AGE) || (c == CounterType.BLAZE) || (c == CounterType.BRIBERY) || (c == CounterType.DOOM)
|| (c == Counters.ICE) || (c == Counters.M1M1) || (c == Counters.M0M2) || (c == Counters.M0M1) || (c == CounterType.ICE) || (c == CounterType.M1M1) || (c == CounterType.M0M2) || (c == CounterType.M0M1)
|| (c == Counters.TIME); || (c == CounterType.TIME);
} }
/** /**
@@ -4254,7 +4254,7 @@ public class CardFactoryUtil {
String[] splitkw = parse.split(":"); String[] splitkw = parse.split(":");
String desc = "CARDNAME enters the battlefield with " + splitkw[2] + " " String desc = "CARDNAME enters the battlefield with " + splitkw[2] + " "
+ Counters.valueOf(splitkw[1]).getName() + " counters on it."; + CounterType.valueOf(splitkw[1]).getName() + " counters on it.";
String extraparams = ""; String extraparams = "";
String amount = splitkw[2]; String amount = splitkw[2];
if (splitkw.length > 3) { if (splitkw.length > 3) {
@@ -4446,9 +4446,9 @@ public class CardFactoryUtil {
@Override @Override
public void execute() { public void execute() {
if (card.isCreature()) { if (card.isCreature()) {
card.addCounter(Counters.P1P1, card.getSunburstValue()); card.addCounter(CounterType.P1P1, card.getSunburstValue());
} else { } else {
card.addCounter(Counters.CHARGE, card.getSunburstValue()); card.addCounter(CounterType.CHARGE, card.getSunburstValue());
} }
} }
@@ -4594,7 +4594,7 @@ public class CardFactoryUtil {
: Integer.parseInt(magnitude); : Integer.parseInt(magnitude);
final int totalCounters = numCreatures[0] * multiplier; final int totalCounters = numCreatures[0] * multiplier;
card.addCounter(Counters.P1P1, totalCounters); card.addCounter(CounterType.P1P1, totalCounters);
} }
}; };
@@ -4617,7 +4617,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
final Card card2 = this.getTargetCard(); final Card card2 = this.getTargetCard();
card2.addCounter(Counters.P1P1, this.getSourceCard().getCounters(Counters.P1P1)); card2.addCounter(CounterType.P1P1, this.getSourceCard().getCounters(CounterType.P1P1));
} // resolve() } // resolve()
}; };
@@ -4639,7 +4639,7 @@ public class CardFactoryUtil {
ability.setTargetCard(CardFactoryUtil.getBestCreatureAI(choices)); ability.setTargetCard(CardFactoryUtil.getBestCreatureAI(choices));
if (ability.getTargetCard() != null) { if (ability.getTargetCard() != null) {
ability.setStackDescription("Put " + card.getCounters(Counters.P1P1) ability.setStackDescription("Put " + card.getCounters(CounterType.P1P1)
+ " +1/+1 counter/s from " + card + " on " + ability.getTargetCard()); + " +1/+1 counter/s from " + card + " on " + ability.getTargetCard());
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability); Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);

View File

@@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.CardManaCost; import forge.card.CardManaCost;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
@@ -216,7 +216,7 @@ public class Cost {
final String description = splitStr.length > 3 ? splitStr[3] : null; final String description = splitStr.length > 3 ? splitStr[3] : null;
final ZoneType zone = splitStr.length > 4 ? ZoneType.smartValueOf(splitStr[4]) : ZoneType.Battlefield; final ZoneType zone = splitStr.length > 4 ? ZoneType.smartValueOf(splitStr[4]) : ZoneType.Battlefield;
this.costParts.add(new CostRemoveCounter(splitStr[0], Counters.valueOf(splitStr[1]), type, description, zone)); this.costParts.add(new CostRemoveCounter(splitStr[0], CounterType.valueOf(splitStr[1]), type, description, zone));
} }
while (parse.contains(Cost.ADD_STR)) { while (parse.contains(Cost.ADD_STR)) {
@@ -227,7 +227,7 @@ public class Cost {
final String type = splitStr.length > 2 ? splitStr[2] : "CARDNAME"; final String type = splitStr.length > 2 ? splitStr[2] : "CARDNAME";
final String description = splitStr.length > 3 ? splitStr[3] : null; final String description = splitStr.length > 3 ? splitStr[3] : null;
this.costParts.add(new CostPutCounter(splitStr[0], Counters.valueOf(splitStr[1]), type, description)); this.costParts.add(new CostPutCounter(splitStr[0], CounterType.valueOf(splitStr[1]), type, description));
} }
// While no card has "PayLife<2> PayLife<3> there might be a card that // While no card has "PayLife<2> PayLife<3> there might be a card that

View File

@@ -22,7 +22,7 @@ import java.util.List;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -38,7 +38,7 @@ import forge.view.ButtonUtil;
*/ */
public class CostPutCounter extends CostPartWithList { public class CostPutCounter extends CostPartWithList {
// Put Counter doesn't really have a "Valid" portion of the cost // Put Counter doesn't really have a "Valid" portion of the cost
private final Counters counter; private final CounterType counter;
private int lastPaidAmount = 0; private int lastPaidAmount = 0;
/** /**
@@ -46,7 +46,7 @@ public class CostPutCounter extends CostPartWithList {
* *
* @return the counter * @return the counter
*/ */
public final Counters getCounter() { public final CounterType getCounter() {
return this.counter; return this.counter;
} }
@@ -72,7 +72,7 @@ public class CostPutCounter extends CostPartWithList {
* @param description * @param description
* the description * the description
*/ */
public CostPutCounter(final String amount, final Counters cntr, final String type, final String description) { public CostPutCounter(final String amount, final CounterType cntr, final String type, final String description) {
this.setReusable(true); this.setReusable(true);
this.setAmount(amount); this.setAmount(amount);
this.counter = cntr; this.counter = cntr;
@@ -133,7 +133,7 @@ public class CostPutCounter extends CostPartWithList {
return false; return false;
} }
if (source.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") if (source.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.")
&& this.counter.equals(Counters.M1M1)) { && this.counter.equals(CounterType.M1M1)) {
return false; return false;
} }
} else { } else {

View File

@@ -23,7 +23,7 @@ import java.util.List;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -45,7 +45,7 @@ public class CostRemoveCounter extends CostPartWithList {
// Counter is tough), // Counter is tough),
// Quillspike, Rift Elemental, Sage of Fables, Spike Rogue // Quillspike, Rift Elemental, Sage of Fables, Spike Rogue
private final Counters counter; private final CounterType counter;
private int lastPaidAmount = 0; private int lastPaidAmount = 0;
private ZoneType zone; private ZoneType zone;
@@ -54,7 +54,7 @@ public class CostRemoveCounter extends CostPartWithList {
* *
* @return the counter * @return the counter
*/ */
public final Counters getCounter() { public final CounterType getCounter() {
return this.counter; return this.counter;
} }
@@ -95,7 +95,7 @@ public class CostRemoveCounter extends CostPartWithList {
* the description * the description
* @param zone the zone. * @param zone the zone.
*/ */
public CostRemoveCounter(final String amount, final Counters counter, final String type, final String description, ZoneType zone) { public CostRemoveCounter(final String amount, final CounterType counter, final String type, final String description, ZoneType zone) {
super(amount, type, description); super(amount, type, description);
this.setReusable(true); this.setReusable(true);
@@ -157,7 +157,7 @@ public class CostRemoveCounter extends CostPartWithList {
*/ */
@Override @Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
final Counters cntrs = this.getCounter(); final CounterType cntrs = this.getCounter();
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.getThis()) { if (this.getThis()) {

View File

@@ -23,7 +23,7 @@ import java.util.Random;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -248,7 +248,7 @@ public class CostUtil {
// A card has a 25% chance per counter to be able to pass // A card has a 25% chance per counter to be able to pass
// through here // through here
// 4+ counters will always pass. 0 counters will never // 4+ counters will always pass. 0 counters will never
final Counters type = remCounter.getCounter(); final CounterType type = remCounter.getCounter();
final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent; final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent;
final int currentNum = source.getCounters(type); final int currentNum = source.getCounters(type);
if (!part.getThis()) { if (!part.getThis()) {
@@ -287,9 +287,9 @@ public class CostUtil {
for (final CostPart part : cost.getCostParts()) { for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostPutCounter) { if (part instanceof CostPutCounter) {
final CostPutCounter addCounter = (CostPutCounter) part; final CostPutCounter addCounter = (CostPutCounter) part;
final Counters type = addCounter.getCounter(); final CounterType type = addCounter.getCounter();
if (type.equals(Counters.M1M1)) { if (type.equals(CounterType.M1M1)) {
return false; return false;
} }
} }

View File

@@ -18,7 +18,7 @@
package forge.card.trigger; package forge.card.trigger;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
/** /**
@@ -51,7 +51,7 @@ public class TriggerCounterAdded extends Trigger {
@Override @Override
public final boolean performTest(final java.util.Map<String, Object> runParams2) { public final boolean performTest(final java.util.Map<String, Object> runParams2) {
final Card addedTo = (Card) runParams2.get("Card"); final Card addedTo = (Card) runParams2.get("Card");
final Counters addedType = (Counters) runParams2.get("CounterType"); final CounterType addedType = (CounterType) runParams2.get("CounterType");
if (this.getMapParams().containsKey("ValidCard")) { if (this.getMapParams().containsKey("ValidCard")) {
if (!addedTo.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), if (!addedTo.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(),

View File

@@ -18,7 +18,7 @@
package forge.card.trigger; package forge.card.trigger;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
/** /**
@@ -51,7 +51,7 @@ public class TriggerCounterRemoved extends Trigger {
@Override @Override
public final boolean performTest(final java.util.Map<String, Object> runParams2) { public final boolean performTest(final java.util.Map<String, Object> runParams2) {
final Card addedTo = (Card) runParams2.get("Card"); final Card addedTo = (Card) runParams2.get("Card");
final Counters addedType = (Counters) runParams2.get("CounterType"); final CounterType addedType = (CounterType) runParams2.get("CounterType");
if (this.getMapParams().containsKey("ValidCard")) { if (this.getMapParams().containsKey("ValidCard")) {
if (!addedTo.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), if (!addedTo.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(),

View File

@@ -35,7 +35,7 @@ import forge.CardLists;
import forge.CardPredicates; import forge.CardPredicates;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.CounterType;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
@@ -2247,10 +2247,10 @@ public class CombatUtil {
if (((attacker.hasKeyword("Indestructible") || (ComputerUtil.canRegenerate(attacker) && !withoutAbilities)) && !(defender if (((attacker.hasKeyword("Indestructible") || (ComputerUtil.canRegenerate(attacker) && !withoutAbilities)) && !(defender
.hasKeyword("Wither") || defender.hasKeyword("Infect"))) .hasKeyword("Wither") || defender.hasKeyword("Infect")))
|| (attacker.hasKeyword("Persist") && !attacker.canHaveCountersPlacedOnIt(Counters.M1M1) && (attacker || (attacker.hasKeyword("Persist") && !attacker.canHaveCountersPlacedOnIt(CounterType.M1M1) && (attacker
.getCounters(Counters.M1M1) == 0)) .getCounters(CounterType.M1M1) == 0))
|| (attacker.hasKeyword("Undying") && !attacker.canHaveCountersPlacedOnIt(Counters.P1P1) && (attacker || (attacker.hasKeyword("Undying") && !attacker.canHaveCountersPlacedOnIt(CounterType.P1P1) && (attacker
.getCounters(Counters.P1P1) == 0))) { .getCounters(CounterType.P1P1) == 0))) {
return false; return false;
} }
if (checkDestroyAttackerTrigger(attacker, defender) && !attacker.hasKeyword("Indestructible")) { if (checkDestroyAttackerTrigger(attacker, defender) && !attacker.hasKeyword("Indestructible")) {
@@ -2394,10 +2394,10 @@ public class CombatUtil {
if (((defender.hasKeyword("Indestructible") || (ComputerUtil.canRegenerate(defender) && !withoutAbilities)) && !(attacker if (((defender.hasKeyword("Indestructible") || (ComputerUtil.canRegenerate(defender) && !withoutAbilities)) && !(attacker
.hasKeyword("Wither") || attacker.hasKeyword("Infect"))) .hasKeyword("Wither") || attacker.hasKeyword("Infect")))
|| (defender.hasKeyword("Persist") && !defender.canHaveCountersPlacedOnIt(Counters.M1M1) && (defender || (defender.hasKeyword("Persist") && !defender.canHaveCountersPlacedOnIt(CounterType.M1M1) && (defender
.getCounters(Counters.M1M1) == 0)) .getCounters(CounterType.M1M1) == 0))
|| (defender.hasKeyword("Undying") && !defender.canHaveCountersPlacedOnIt(Counters.P1P1) && (defender || (defender.hasKeyword("Undying") && !defender.canHaveCountersPlacedOnIt(CounterType.P1P1) && (defender
.getCounters(Counters.P1P1) == 0))) { .getCounters(CounterType.P1P1) == 0))) {
return false; return false;
} }

View File

@@ -25,7 +25,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -217,7 +217,7 @@ public class EndOfTurn extends Phase {
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return c.getName().equals("Lighthouse Chronologist") && (c.getCounters(Counters.LEVEL) >= 7); return c.getName().equals("Lighthouse Chronologist") && (c.getCounters(CounterType.LEVEL) >= 7);
} }
}); });

View File

@@ -26,7 +26,7 @@ import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.CardPredicates.Presets; import forge.CardPredicates.Presets;
import forge.Counters; import forge.CounterType;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
@@ -176,9 +176,9 @@ public class Untap extends Phase {
} }
} }
} }
} else if ((c.getCounters(Counters.WIND) > 0) && Singletons.getModel().getGame().isCardInPlay("Freyalise's Winds")) { } else if ((c.getCounters(CounterType.WIND) > 0) && Singletons.getModel().getGame().isCardInPlay("Freyalise's Winds")) {
// remove a WIND counter instead of untapping // remove a WIND counter instead of untapping
c.subtractCounter(Counters.WIND, 1); c.subtractCounter(CounterType.WIND, 1);
} else { } else {
c.untap(); c.untap();
} }

View File

@@ -31,7 +31,7 @@ import forge.CardLists;
import forge.CardPredicates; import forge.CardPredicates;
import forge.CardPredicates.Presets; import forge.CardPredicates.Presets;
import forge.Command; import forge.Command;
import forge.Counters; import forge.CounterType;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Singletons; import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -139,9 +139,9 @@ public class Upkeep extends Phase {
final Ability upkeepAbility = new Ability(c, "0") { final Ability upkeepAbility = new Ability(c, "0") {
@Override @Override
public void resolve() { public void resolve() {
c.addCounter(Counters.AGE, 1); c.addCounter(CounterType.AGE, 1);
StringBuilder rs = new StringBuilder("R"); StringBuilder rs = new StringBuilder("R");
for(int ageCounters = c.getCounters(Counters.AGE); ageCounters > 1; ageCounters-- ) for(int ageCounters = c.getCounters(CounterType.AGE); ageCounters > 1; ageCounters-- )
rs.append(" R"); rs.append(" R");
Map<String, String> produced = new HashMap<String, String>(); Map<String, String> produced = new HashMap<String, String>();
produced.put("Produced", rs.toString()); produced.put("Produced", rs.toString());
@@ -337,8 +337,8 @@ public class Upkeep extends Phase {
if (ability.startsWith("Cumulative upkeep")) { if (ability.startsWith("Cumulative upkeep")) {
final String[] k = ability.split(":"); final String[] k = ability.split(":");
c.addCounter(Counters.AGE, 1); c.addCounter(CounterType.AGE, 1);
cost = CardFactoryUtil.multiplyCost(k[1], c.getCounters(Counters.AGE)); cost = CardFactoryUtil.multiplyCost(k[1], c.getCounters(CounterType.AGE));
sb.append("Cumulative upkeep for ").append(c).append("\n"); sb.append("Cumulative upkeep for ").append(c).append("\n");
} }
@@ -1691,7 +1691,7 @@ public class Upkeep extends Phase {
this.revealTopCard(title); this.revealTopCard(title);
} }
if (wantCounter) { if (wantCounter) {
k.addCounter(Counters.P1P1, 1); k.addCounter(CounterType.P1P1, 1);
} }
} // resolve() } // resolve()
@@ -1826,9 +1826,9 @@ public class Upkeep extends Phase {
} }
for (final Card c : list) { for (final Card c : list) {
final int counters = c.getCounters(Counters.TIME); final int counters = c.getCounters(CounterType.TIME);
if (counters > 0) { if (counters > 0) {
c.subtractCounter(Counters.TIME, 1); c.subtractCounter(CounterType.TIME, 1);
} }
} }
} // suspend } // suspend
@@ -1854,7 +1854,7 @@ public class Upkeep extends Phase {
final Ability ability = new Ability(card, "0") { final Ability ability = new Ability(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
card.subtractCounter(Counters.TIME, 1); card.subtractCounter(CounterType.TIME, 1);
} }
}; // ability }; // ability
@@ -1892,11 +1892,11 @@ public class Upkeep extends Phase {
final Ability ability = new Ability(card, "0") { final Ability ability = new Ability(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
final int fadeCounters = card.getCounters(Counters.FADE); final int fadeCounters = card.getCounters(CounterType.FADE);
if (fadeCounters <= 0) { if (fadeCounters <= 0) {
Singletons.getModel().getGame().getAction().sacrifice(card, null); Singletons.getModel().getGame().getAction().sacrifice(card, null);
} else { } else {
card.subtractCounter(Counters.FADE, 1); card.subtractCounter(CounterType.FADE, 1);
} }
} }
}; // ability }; // ability
@@ -2136,7 +2136,7 @@ public class Upkeep extends Phase {
final SpellAbility ability = new Ability(source, "0") { final SpellAbility ability = new Ability(source, "0") {
@Override @Override
public void resolve() { public void resolve() {
final int num = source.getCounters(Counters.FADE); final int num = source.getCounters(CounterType.FADE);
final List<Card> list = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() { final List<Card> list = CardLists.filter(player.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -2221,7 +2221,7 @@ public class Upkeep extends Phase {
blaze = CardLists.filter(blaze, new Predicate<Card>() { blaze = CardLists.filter(blaze, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return c.isLand() && (c.getCounters(Counters.BLAZE) > 0); return c.isLand() && (c.getCounters(CounterType.BLAZE) > 0);
} }
}); });

View File

@@ -26,7 +26,7 @@ import com.google.common.base.Predicate;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.Counters; import forge.CounterType;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
@@ -365,7 +365,7 @@ public class ComputerUtilAttack {
final List<Card> beastions = ai.getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension"); final List<Card> beastions = ai.getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension");
int minCreatures = 7; int minCreatures = 7;
for (final Card beastion : beastions) { for (final Card beastion : beastions) {
final int counters = beastion.getCounters(Counters.QUEST); final int counters = beastion.getCounters(CounterType.QUEST);
minCreatures = Math.min(minCreatures, 7 - counters); minCreatures = Math.min(minCreatures, 7 - counters);
} }
if (this.attackers.size() >= minCreatures) { if (this.attackers.size() >= minCreatures) {
@@ -799,7 +799,7 @@ public class ComputerUtilAttack {
} }
} }
// if enough damage: switch to next planeswalker or player // if enough damage: switch to next planeswalker or player
if (damage >= pw.getCounters(Counters.LOYALTY)) { if (damage >= pw.getCounters(CounterType.LOYALTY)) {
combat.setCurrentDefenderNumber(combat.getCurrentDefenderNumber() - 1); combat.setCurrentDefenderNumber(combat.getCurrentDefenderNumber() - 1);
} }
} }
@@ -892,7 +892,7 @@ public class ComputerUtilAttack {
&& CombatUtil.canBlock(attacker, defender)) { && CombatUtil.canBlock(attacker, defender)) {
numberOfPossibleBlockers += 1; numberOfPossibleBlockers += 1;
if (isWorthLessThanAllKillers && CombatUtil.canDestroyAttacker(attacker, defender, combat, false) if (isWorthLessThanAllKillers && CombatUtil.canDestroyAttacker(attacker, defender, combat, false)
&& !(attacker.hasKeyword("Undying") && attacker.getCounters(Counters.P1P1) == 0)) { && !(attacker.hasKeyword("Undying") && attacker.getCounters(CounterType.P1P1) == 0)) {
canBeKilledByOne = true; // there is a single creature on canBeKilledByOne = true; // there is a single creature on
// the battlefield that can kill // the battlefield that can kill
// the creature // the creature

View File

@@ -27,7 +27,7 @@ import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.CardPredicates; import forge.CardPredicates;
import forge.Counters; import forge.CounterType;
import forge.GameEntity; import forge.GameEntity;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.game.phase.Combat; import forge.game.phase.Combat;
@@ -369,7 +369,7 @@ public class ComputerUtilBlock {
// 3.Blockers that can destroy the attacker and have an upside when dying // 3.Blockers that can destroy the attacker and have an upside when dying
killingBlockers = ComputerUtilBlock.getKillingBlockers(attacker, blockers, combat); killingBlockers = ComputerUtilBlock.getKillingBlockers(attacker, blockers, combat);
for (Card b : killingBlockers) { for (Card b : killingBlockers) {
if ((b.hasKeyword("Undying") && b.getCounters(Counters.P1P1) == 0) if ((b.hasKeyword("Undying") && b.getCounters(CounterType.P1P1) == 0)
|| !b.getSVar("SacMe").equals("")) { || !b.getSVar("SacMe").equals("")) {
blocker = b; blocker = b;
break; break;

View File

@@ -41,7 +41,7 @@ import forge.CardPredicates.Presets;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Preferences; import forge.Constant.Preferences;
import forge.Counters; import forge.CounterType;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
@@ -2858,22 +2858,18 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
}); });
} }
public int getCounterDoublersMagnitude(final Counters type) { public int getCounterDoublersMagnitude(final CounterType type) {
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size(); int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
if(type == Counters.P1P1) { if(type == CounterType.P1P1) {
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size(); counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
} }
return (int) Math.pow(2, counterDoublers); // pow(a,0) = 1; pow(a,1) = a return 1 << counterDoublers;
// ... no worries about size
// = 0
} }
public int getTokenDoublersMagnitude() { public int getTokenDoublersMagnitude() {
final int tokenDoublers = getCardsIn(ZoneType.Battlefield, "Parallel Lives").size() final int tokenDoublers = getCardsIn(ZoneType.Battlefield, "Parallel Lives").size()
+ getCardsIn(ZoneType.Battlefield, "Doubling Season").size(); + getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a return 1 << tokenDoublers; // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size =
// 0
} }
public void onCleanupPhase() { public void onCleanupPhase() {

View File

@@ -35,7 +35,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder; import javax.swing.border.EtchedBorder;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.GameEntity; import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
@@ -257,8 +257,8 @@ public class CardDetailPanel extends JPanel implements CardContainer {
} }
// counter text // counter text
final Counters[] counters = Counters.values(); final CounterType[] counters = CounterType.values();
for (final Counters counter : counters) { for (final CounterType counter : counters) {
if (card.getCounters(counter) != 0) { if (card.getCounters(counter) != 0) {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");

View File

@@ -42,7 +42,7 @@ import forge.CardCharacteristicName;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.CounterType;
import forge.Singletons; import forge.Singletons;
import forge.card.spellability.AbilityManaPart; import forge.card.spellability.AbilityManaPart;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -599,7 +599,7 @@ public final class GuiDisplayUtil {
} else if (info.startsWith("Counters:")) { } else if (info.startsWith("Counters:")) {
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(","); final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
for (final String counter : counterStrings) { for (final String counter : counterStrings) {
c.addCounter(Counters.valueOf(counter), 1); c.addCounter(CounterType.valueOf(counter), 1);
} }
} else if (info.equalsIgnoreCase("SummonSick:True")) { } else if (info.equalsIgnoreCase("SummonSick:True")) {
c.setSickness(true); c.setSickness(true);
@@ -649,7 +649,7 @@ public final class GuiDisplayUtil {
return; return;
} else { } else {
final Card c = o; final Card c = o;
final Counters counter = GuiChoose.oneOrNone("Which type of counter?", Counters.values()); final CounterType counter = GuiChoose.oneOrNone("Which type of counter?", CounterType.values());
if (null == counter) { if (null == counter) {
return; return;
} else { } else {

View File

@@ -37,7 +37,7 @@ import javax.swing.JRootPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import forge.Card; import forge.Card;
import forge.Counters; import forge.CounterType;
import forge.ImageCache; import forge.ImageCache;
import forge.Singletons; import forge.Singletons;
import forge.gui.CardContainer; import forge.gui.CardContainer;
@@ -612,11 +612,11 @@ public class CardPanel extends JPanel implements CardContainer {
if (card.isCreature() && card.isPlaneswalker()) { if (card.isCreature() && card.isPlaneswalker()) {
this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense() + " (" this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense() + " ("
+ String.valueOf(card.getCounters(Counters.LOYALTY)) + ")"); + String.valueOf(card.getCounters(CounterType.LOYALTY)) + ")");
} else if (card.isCreature()) { } else if (card.isCreature()) {
this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense()); this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense());
} else if (card.isPlaneswalker()) { } else if (card.isPlaneswalker()) {
int loyalty = card.getCounters(Counters.LOYALTY); int loyalty = card.getCounters(CounterType.LOYALTY);
if (loyalty == 0) { if (loyalty == 0) {
loyalty = card.getBaseLoyalty(); loyalty = card.getBaseLoyalty();
} }