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

View File

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

View File

@@ -848,7 +848,7 @@ public class GameAction {
this.moveToPlay(c);
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
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 Counters m1Counter = Counters.M1M1;
int plusOneCounters = c.getCounters(Counters.P1P1);
int minusOneCounters = c.getCounters(Counters.M1M1);
final CounterType p1Counter = CounterType.P1P1;
final CounterType m1Counter = CounterType.M1M1;
int plusOneCounters = c.getCounters(CounterType.P1P1);
int minusOneCounters = c.getCounters(CounterType.M1M1);
if (plusOneCounters == minusOneCounters) {
c.getCounters().remove(m1Counter);
@@ -1253,7 +1253,7 @@ public class GameAction {
for (int i = 0; i < list.size(); i++) {
c = list.get(i);
if (c.getCounters(Counters.LOYALTY) <= 0) {
if (c.getCounters(CounterType.LOYALTY) <= 0) {
Singletons.getModel().getGame().getAction().moveToGraveyard(c);
}
@@ -1467,9 +1467,9 @@ public class GameAction {
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);
@@ -1494,7 +1494,7 @@ public class GameAction {
if (game.getZoneOf(persistCard).is(ZoneType.Graveyard)) {
final PlayerZone ownerPlay = persistCard.getOwner().getZone(ZoneType.Battlefield);
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)) {
final PlayerZone ownerPlay = undyingCard.getOwner().getZone(ZoneType.Battlefield);
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) {
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)
: CardFactoryUtil.xCount(source, source.getSVar(amountString));
String plural = amount > 1 ? "s" : "";
@@ -724,9 +724,9 @@ public final class GameActionUtil {
final Ability ability2 = new Ability(c, "0") {
@Override
public void resolve() {
Counters counter = Counters.P1P1;
CounterType counter = CounterType.P1P1;
if (kw.contains("+2/+2")) {
counter = Counters.P2P2;
counter = CounterType.P2P2;
}
if (thisCard.isInPlay()) {
thisCard.addCounter(counter, 1);

View File

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

View File

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

View File

@@ -6,7 +6,7 @@ import com.google.common.base.Predicate;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.card.abilityfactory.SpellAiLogic;
import forge.card.cardfactory.CardFactoryUtil;
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>() {
@Override
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)) {
return true;
}
@@ -34,7 +34,7 @@ public class CountersProliferateAi extends SpellAiLogic {
List<Card> hperms = CardLists.filter(ai.getOpponent().getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
@Override
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)) {
return true;
}

View File

@@ -8,7 +8,7 @@ import com.google.common.base.Predicate;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic;
@@ -141,7 +141,7 @@ public class CountersPutAi extends SpellAiLogic {
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
// activating this ability.

View File

@@ -3,7 +3,7 @@ package forge.card.abilityfactory.ai;
import java.util.Random;
import forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.SpellAiLogic;
import forge.card.cost.Cost;
@@ -73,7 +73,7 @@ public class CountersRemoveAi extends SpellAiLogic {
}
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) {
return false;
}

View File

@@ -8,7 +8,7 @@ import com.google.common.base.Predicate;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic;
@@ -75,7 +75,7 @@ public class DestroyAi extends SpellAiLogic {
list = CardLists.filter(list, new Predicate<Card>() {
@Override
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 forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellAiLogic;
@@ -121,7 +121,7 @@ public class LifeSetAi extends SpellAiLogic {
}
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;
}

View File

@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.SpellAbility;
@@ -30,7 +30,7 @@ public class CountersMoveEffect extends SpellEffect {
}
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);
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) {
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);
Card source = null;
@@ -74,7 +74,7 @@ public class CountersMoveEffect extends SpellEffect {
if (source.getCounters(cType) >= amount) {
if (!dest.hasKeyword("CARDNAME can't have counters placed on it.")
&& !(dest.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && cType
.equals(Counters.M1M1))) {
.equals(CounterType.M1M1))) {
dest.addCounter(cType, amount);
source.subtractCounter(cType, amount);
}

View File

@@ -9,7 +9,7 @@ import com.google.common.collect.Lists;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.SpellEffect;
import forge.card.cardfactory.CardFactoryUtil;
@@ -71,14 +71,14 @@ public class CountersProliferateEffect extends SpellEffect {
}
unchosen.remove(card);
final ArrayList<String> choices = new ArrayList<String>();
for (final Counters c1 : Counters.values()) {
for (final CounterType c1 : CounterType.values()) {
if (card.getCounters(c1) != 0) {
choices.add(c1.getName());
}
}
if (choices.size() > 0) {
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);
}
}
@@ -104,7 +104,7 @@ public class CountersProliferateEffect extends SpellEffect {
final Predicate<Card> predProliferate = new Predicate<Card>() {
@Override
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())) {
return true;
}
@@ -150,7 +150,7 @@ public class CountersProliferateEffect extends SpellEffect {
// add a counter of one counter type, if it would benefit the
// computer
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()))
{
c.addCounter(c1.getKey(), 1);

View File

@@ -4,7 +4,7 @@ import java.util.List;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
@@ -19,7 +19,7 @@ public class CountersPutAllEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) {
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 String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
@@ -55,10 +55,10 @@ public class CountersPutAllEffect extends SpellEffect {
for (final Card tgtCard : cards) {
if (Singletons.getModel().getGame().getZoneOf(tgtCard).is(ZoneType.Battlefield)) {
tgtCard.addCounter(Counters.valueOf(type), counterAmount);
tgtCard.addCounter(CounterType.valueOf(type), counterAmount);
} else {
// 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 forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
@@ -22,7 +22,7 @@ public class CountersPutEffect extends SpellEffect {
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);
sb.append("Put ");
if (sa.hasParam("UpTo")) {
@@ -86,16 +86,16 @@ public class CountersPutEffect extends SpellEffect {
for (final Card tgtCard : tgtCards) {
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
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);
if (zone == null) {
// Do nothing, token disappeared
} else if (zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
tgtCard.addCounter(Counters.valueOf(type), counterAmount);
tgtCard.addCounter(CounterType.valueOf(type), counterAmount);
} else {
// 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.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
@@ -18,7 +18,7 @@ public class CountersRemoveAllEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) {
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 String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
String amountString = Integer.toString(amount);
@@ -59,10 +59,10 @@ public class CountersRemoveAllEffect extends SpellEffect {
for (final Card tgtCard : cards) {
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 forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
@@ -37,7 +37,7 @@ public class CountersRemoveEffect extends SpellEffect {
}
}
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) {
sb.append("s");
@@ -73,18 +73,18 @@ public class CountersRemoveEffect extends SpellEffect {
if ((tgt == null) || tgtCard.canBeTargetedBy(sa)) {
final Zone zone = Singletons.getModel().getGame().getZoneOf(tgtCard);
if (sa.getParam("CounterNum").equals("All")) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type));
counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
}
if (type.matches("Any")) {
while (counterAmount > 0 && tgtCard.getNumberOfCounters() > 0) {
final Map<Counters, Integer> tgtCounters = tgtCard.getCounters();
Counters chosenType = null;
final Map<CounterType, Integer> tgtCounters = tgtCard.getCounters();
CounterType chosenType = null;
int chosenAmount;
if (sa.getActivatingPlayer().isHuman()) {
final ArrayList<Counters> typeChoices = new ArrayList<Counters>();
final ArrayList<CounterType> typeChoices = new ArrayList<CounterType>();
// get types of counters
for (Counters key : tgtCounters.keySet()) {
for (CounterType key : tgtCounters.keySet()) {
if (tgtCounters.get(key) > 0) {
typeChoices.add(key);
}
@@ -116,7 +116,7 @@ public class CountersRemoveEffect extends SpellEffect {
// find first nonzero counter on target
for (Object key : tgtCounters.keySet()) {
if (tgtCounters.get(key) > 0) {
chosenType = (Counters) key;
chosenType = (CounterType) key;
break;
}
}
@@ -147,13 +147,13 @@ public class CountersRemoveEffect extends SpellEffect {
counterAmount = Integer.parseInt(o);
}
}
tgtCard.subtractCounter(Counters.valueOf(type), counterAmount);
tgtCard.subtractCounter(CounterType.valueOf(type), counterAmount);
if (rememberRemoved) {
if (counterAmount > tgtCard.getCounters(Counters.valueOf(type))) {
counterAmount = tgtCard.getCounters(Counters.valueOf(type));
if (counterAmount > tgtCard.getCounters(CounterType.valueOf(type))) {
counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
}
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.CardPredicates;
import forge.Constant;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
@@ -191,7 +191,7 @@ public class ManaEffect extends SpellEffect {
final String deplete = sa.getParam("Deplete");
if (deplete != null) {
final int num = card.getCounters(Counters.getType(deplete));
final int num = card.getCounters(CounterType.getType(deplete));
if (num == 0) {
sa.setUndoable(false);
Singletons.getModel().getGame().getAction().sacrifice(card, null);

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ import forge.Card;
import forge.CardLists;
import forge.Command;
import forge.Counters;
import forge.CounterType;
import forge.GameActionUtil;
import forge.Singletons;
import forge.card.cost.Cost;
@@ -178,7 +178,7 @@ class CardFactoryLands {
this.inPlay.clear();
this.inPlay.addAll(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield));
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.Command;
import forge.Counters;
import forge.CounterType;
import forge.card.replacement.ReplacementHandler;
/**
@@ -44,7 +44,7 @@ public class CardFactoryPlaneswalkers {
public static void buildCard(final Card card) {
// All Planeswalkers set their loyality in the beginning
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);
}

View File

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

View File

@@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.regex.Pattern;
import forge.Card;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.CardManaCost;
import forge.card.mana.ManaCost;
@@ -216,7 +216,7 @@ public class Cost {
final String description = splitStr.length > 3 ? splitStr[3] : null;
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)) {
@@ -227,7 +227,7 @@ public class Cost {
final String type = splitStr.length > 2 ? splitStr[2] : "CARDNAME";
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

View File

@@ -22,7 +22,7 @@ import java.util.List;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
@@ -38,7 +38,7 @@ import forge.view.ButtonUtil;
*/
public class CostPutCounter extends CostPartWithList {
// Put Counter doesn't really have a "Valid" portion of the cost
private final Counters counter;
private final CounterType counter;
private int lastPaidAmount = 0;
/**
@@ -46,7 +46,7 @@ public class CostPutCounter extends CostPartWithList {
*
* @return the counter
*/
public final Counters getCounter() {
public final CounterType getCounter() {
return this.counter;
}
@@ -72,7 +72,7 @@ public class CostPutCounter extends CostPartWithList {
* @param 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.setAmount(amount);
this.counter = cntr;
@@ -133,7 +133,7 @@ public class CostPutCounter extends CostPartWithList {
return false;
}
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;
}
} else {

View File

@@ -23,7 +23,7 @@ import java.util.List;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
@@ -45,7 +45,7 @@ public class CostRemoveCounter extends CostPartWithList {
// Counter is tough),
// Quillspike, Rift Elemental, Sage of Fables, Spike Rogue
private final Counters counter;
private final CounterType counter;
private int lastPaidAmount = 0;
private ZoneType zone;
@@ -54,7 +54,7 @@ public class CostRemoveCounter extends CostPartWithList {
*
* @return the counter
*/
public final Counters getCounter() {
public final CounterType getCounter() {
return this.counter;
}
@@ -95,7 +95,7 @@ public class CostRemoveCounter extends CostPartWithList {
* the description
* @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);
this.setReusable(true);
@@ -157,7 +157,7 @@ public class CostRemoveCounter extends CostPartWithList {
*/
@Override
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();
if (this.getThis()) {

View File

@@ -23,7 +23,7 @@ import java.util.Random;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.mana.ManaCost;
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
// through here
// 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 int currentNum = source.getCounters(type);
if (!part.getThis()) {
@@ -287,9 +287,9 @@ public class CostUtil {
for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostPutCounter) {
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;
}
}

View File

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

View File

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

View File

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

View File

@@ -25,7 +25,7 @@ import com.google.common.base.Predicate;
import forge.Card;
import forge.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
@@ -217,7 +217,7 @@ public class EndOfTurn extends Phase {
list = CardLists.filter(list, new Predicate<Card>() {
@Override
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.CardPredicates.Presets;
import forge.Counters;
import forge.CounterType;
import forge.GameActionUtil;
import forge.GameEntity;
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
c.subtractCounter(Counters.WIND, 1);
c.subtractCounter(CounterType.WIND, 1);
} else {
c.untap();
}

View File

@@ -31,7 +31,7 @@ import forge.CardLists;
import forge.CardPredicates;
import forge.CardPredicates.Presets;
import forge.Command;
import forge.Counters;
import forge.CounterType;
import forge.GameActionUtil;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
@@ -139,9 +139,9 @@ public class Upkeep extends Phase {
final Ability upkeepAbility = new Ability(c, "0") {
@Override
public void resolve() {
c.addCounter(Counters.AGE, 1);
c.addCounter(CounterType.AGE, 1);
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");
Map<String, String> produced = new HashMap<String, String>();
produced.put("Produced", rs.toString());
@@ -337,8 +337,8 @@ public class Upkeep extends Phase {
if (ability.startsWith("Cumulative upkeep")) {
final String[] k = ability.split(":");
c.addCounter(Counters.AGE, 1);
cost = CardFactoryUtil.multiplyCost(k[1], c.getCounters(Counters.AGE));
c.addCounter(CounterType.AGE, 1);
cost = CardFactoryUtil.multiplyCost(k[1], c.getCounters(CounterType.AGE));
sb.append("Cumulative upkeep for ").append(c).append("\n");
}
@@ -1691,7 +1691,7 @@ public class Upkeep extends Phase {
this.revealTopCard(title);
}
if (wantCounter) {
k.addCounter(Counters.P1P1, 1);
k.addCounter(CounterType.P1P1, 1);
}
} // resolve()
@@ -1826,9 +1826,9 @@ public class Upkeep extends Phase {
}
for (final Card c : list) {
final int counters = c.getCounters(Counters.TIME);
final int counters = c.getCounters(CounterType.TIME);
if (counters > 0) {
c.subtractCounter(Counters.TIME, 1);
c.subtractCounter(CounterType.TIME, 1);
}
}
} // suspend
@@ -1854,7 +1854,7 @@ public class Upkeep extends Phase {
final Ability ability = new Ability(card, "0") {
@Override
public void resolve() {
card.subtractCounter(Counters.TIME, 1);
card.subtractCounter(CounterType.TIME, 1);
}
}; // ability
@@ -1892,11 +1892,11 @@ public class Upkeep extends Phase {
final Ability ability = new Ability(card, "0") {
@Override
public void resolve() {
final int fadeCounters = card.getCounters(Counters.FADE);
final int fadeCounters = card.getCounters(CounterType.FADE);
if (fadeCounters <= 0) {
Singletons.getModel().getGame().getAction().sacrifice(card, null);
} else {
card.subtractCounter(Counters.FADE, 1);
card.subtractCounter(CounterType.FADE, 1);
}
}
}; // ability
@@ -2136,7 +2136,7 @@ public class Upkeep extends Phase {
final SpellAbility ability = new Ability(source, "0") {
@Override
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>() {
@Override
public boolean apply(final Card c) {
@@ -2221,7 +2221,7 @@ public class Upkeep extends Phase {
blaze = CardLists.filter(blaze, new Predicate<Card>() {
@Override
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.CardLists;
import forge.Counters;
import forge.CounterType;
import forge.GameEntity;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil;
@@ -365,7 +365,7 @@ public class ComputerUtilAttack {
final List<Card> beastions = ai.getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension");
int minCreatures = 7;
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);
}
if (this.attackers.size() >= minCreatures) {
@@ -799,7 +799,7 @@ public class ComputerUtilAttack {
}
}
// 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);
}
}
@@ -892,7 +892,7 @@ public class ComputerUtilAttack {
&& CombatUtil.canBlock(attacker, defender)) {
numberOfPossibleBlockers += 1;
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
// the battlefield that can kill
// the creature

View File

@@ -27,7 +27,7 @@ import forge.Card;
import forge.CardLists;
import forge.CardPredicates;
import forge.Counters;
import forge.CounterType;
import forge.GameEntity;
import forge.card.cardfactory.CardFactoryUtil;
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
killingBlockers = ComputerUtilBlock.getKillingBlockers(attacker, blockers, combat);
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("")) {
blocker = b;
break;

View File

@@ -41,7 +41,7 @@ import forge.CardPredicates.Presets;
import forge.CardUtil;
import forge.Constant;
import forge.Constant.Preferences;
import forge.Counters;
import forge.CounterType;
import forge.GameActionUtil;
import forge.GameEntity;
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();
if(type == Counters.P1P1) {
if(type == CounterType.P1P1) {
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
}
return (int) Math.pow(2, counterDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size
// = 0
return 1 << counterDoublers;
}
public int getTokenDoublersMagnitude() {
final int tokenDoublers = getCardsIn(ZoneType.Battlefield, "Parallel Lives").size()
+ getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a
// ... no worries about size =
// 0
return 1 << tokenDoublers; // pow(a,0) = 1; pow(a,1) = a
}
public void onCleanupPhase() {

View File

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

View File

@@ -42,7 +42,7 @@ import forge.CardCharacteristicName;
import forge.CardUtil;
import forge.Constant;
import forge.Counters;
import forge.CounterType;
import forge.Singletons;
import forge.card.spellability.AbilityManaPart;
import forge.card.spellability.SpellAbility;
@@ -599,7 +599,7 @@ public final class GuiDisplayUtil {
} else if (info.startsWith("Counters:")) {
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
for (final String counter : counterStrings) {
c.addCounter(Counters.valueOf(counter), 1);
c.addCounter(CounterType.valueOf(counter), 1);
}
} else if (info.equalsIgnoreCase("SummonSick:True")) {
c.setSickness(true);
@@ -649,7 +649,7 @@ public final class GuiDisplayUtil {
return;
} else {
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) {
return;
} else {

View File

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