Make the Counters API for card and permanent consistent.

This commit is contained in:
Samuel Sandeen 2016-09-03 10:33:54 -04:00
parent 277dc19fec
commit 148f633672
176 changed files with 272 additions and 277 deletions

View file

@ -246,14 +246,14 @@ public class CardView extends SimpleCardView {
if (card instanceof Permanent) {
this.mageObjectType = MageObjectType.PERMANENT;
Permanent permanent = (Permanent) card;
this.loyalty = Integer.toString(permanent.getCounters().getCount(CounterType.LOYALTY));
this.loyalty = Integer.toString(permanent.getCounters(game).getCount(CounterType.LOYALTY));
this.pairedCard = permanent.getPairedCard() != null ? permanent.getPairedCard().getSourceId() : null;
if (!permanent.getControllerId().equals(permanent.getOwnerId())) {
controlledByOwner = false;
}
if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) {
if (game != null && permanent.getCounters(game) != null && !permanent.getCounters(game).isEmpty()) {
counters = new ArrayList<>();
for (Counter counter : permanent.getCounters().values()) {
for (Counter counter : permanent.getCounters(game).values()) {
counters.add(new CounterView(counter));
}
}
@ -348,7 +348,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.PERMANENT;
this.power = Integer.toString(object.getPower().getValue());
this.toughness = Integer.toString(object.getToughness().getValue());
this.loyalty = Integer.toString(((Permanent) object).getCounters().getCount(CounterType.LOYALTY));
this.loyalty = Integer.toString(((Permanent) object).getCounters((Game)null).getCount(CounterType.LOYALTY));
} else {
this.power = object.getPower().toString();
this.toughness = object.getToughness().toString();

View file

@ -64,8 +64,8 @@ public class ArtificialScoringSystem {
public static int getVariablePermanentScore(final Game game, final Permanent permanent) {
int score = permanent.getCounters().getCount(CounterType.CHARGE) * 30;
score += permanent.getCounters().getCount(CounterType.LEVEL) * 30;
int score = permanent.getCounters(game).getCount(CounterType.CHARGE) * 30;
score += permanent.getCounters(game).getCount(CounterType.LEVEL) * 30;
score -= permanent.getDamage() * 2;
if (!canTap(permanent)) {
score += getTappedScore(permanent);

View file

@ -30,7 +30,7 @@ public class LevelUpOptimizer extends BaseTreeOptimizer {
if (permanent != null && permanent instanceof PermanentCard) {
PermanentCard leveler = (PermanentCard) permanent;
// check already existing Level counters and compare to maximum that make sense
if (permanent.getCounters().getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) {
if (permanent.getCounters(game).getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) {
removeAbility(ability);
}
}

View file

@ -68,7 +68,7 @@ public class CombatSimulator implements Serializable {
}
else {
Permanent permanent = game.getPermanent(defenderId);
simCombat.planeswalkerLoyalty.put(defenderId, permanent.getCounters().getCount(CounterType.LOYALTY));
simCombat.planeswalkerLoyalty.put(defenderId, permanent.getCounters(game).getCount(CounterType.LOYALTY));
}
}
return simCombat;

View file

@ -111,7 +111,7 @@ public class GameStateEvaluator {
if (!(ability instanceof ManaAbility) && ability.canActivate(ability.getControllerId(), game))
value += ability.getEffects().size();
}
for (Counter counter: permanent.getCounters().values()) {
for (Counter counter: permanent.getCounters(game).values()) {
if (!(counter instanceof BoostCounter)) {
value += counter.getCount();
}

View file

@ -116,7 +116,7 @@ class AvenEffect extends ContinuousEffectImpl {
@Override
public boolean isInactive(Ability source, Game game) {
Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source));
if (creature != null && creature.getCounters().getCount(CounterType.FEATHER) < 1) {
if (creature != null && creature.getCounters(game).getCount(CounterType.FEATHER) < 1) {
return true;
}
return false;
@ -160,7 +160,7 @@ class AvenEffect2 extends ContinuousEffectImpl {
@Override
public boolean isInactive(Ability source, Game game) {
Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source));
if (creature != null && creature.getCounters().getCount(CounterType.FEATHER) < 1) {
if (creature != null && creature.getCounters(game).getCount(CounterType.FEATHER) < 1) {
return true;
}
return false;

View file

@ -141,7 +141,7 @@ class MakeshiftMannequinGainAbilityEffect extends ContinuousEffectImpl {
@Override
public boolean isInactive(Ability source, Game game) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
return permanent == null || permanent.getCounters().getCount(CounterType.MANNEQUIN) < 1;
return permanent == null || permanent.getCounters(game).getCount(CounterType.MANNEQUIN) < 1;
}
@Override

View file

@ -117,7 +117,7 @@ class DescentIntoMadnessEffect extends OneShotEffect {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent != null && controller != null) {
int count = sourcePermanent.getCounters().getCount(CounterType.DESPAIR);
int count = sourcePermanent.getCounters(game).getCount(CounterType.DESPAIR);
if (count > 0) {
// select the permanents and hand cards in turn order
LinkedList<UUID> selectedObjects = new LinkedList<>();

View file

@ -94,7 +94,7 @@ class HeraldOfWarCostReductionEffect extends CostModificationEffectImpl {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
CardUtil.adjustCost(spellAbility, amount);
return true;

View file

@ -91,7 +91,7 @@ class OtherworldAtlasDrawEffect extends OneShotEffect {
Player sourcePlayer = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int amount = permanent.getCounters().getCount(CounterType.CHARGE);
int amount = permanent.getCounters(game).getCount(CounterType.CHARGE);
if (amount > 0) {
for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) {
Player player = game.getPlayer(playerId);

View file

@ -119,7 +119,7 @@ class UndergrowthChampionPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
preventDamageAction(event, source, game);
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -93,7 +93,7 @@ class AstralCornucopiaManaAbility extends ManaAbility {
netMana.clear();
Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName());
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
if (counters > 0) {
netMana.add(new Mana(0, 0, 0, 0, 0, 0, counters, 0));
}
@ -132,7 +132,7 @@ class AstralCornucopiaManaEffect extends ManaEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (choice.getChoice() != null) {
String color = choice.getChoice();
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName());
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
switch (color) {
case "Red":
computedMana.setRed(counters);

View file

@ -188,7 +188,7 @@ class HankyuCountersSourceCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent equipment = game.getPermanent(this.effectGivingEquipmentId);
if (equipment != null ) {
this.removedCounters = equipment.getCounters().getCount(CounterType.AIM);
this.removedCounters = equipment.getCounters(game).getCount(CounterType.AIM);
if (this.removedCounters > 0) {
equipment.removeCounters("aim", this.removedCounters, game);
}

View file

@ -112,7 +112,7 @@ class PiousKitsuneEffect extends OneShotEffect {
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int life = permanent.getCounters().getCount(CounterType.DEVOTION);
int life = permanent.getCounters(game).getCount(CounterType.DEVOTION);
if (life > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {

View file

@ -131,7 +131,7 @@ class DarkDepthsAbility extends StateTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(getSourceId());
return permanent != null && permanent.getCounters().getCount(CounterType.ICE) == 0;
return permanent != null && permanent.getCounters(game).getCount(CounterType.ICE) == 0;
}
@Override

View file

@ -128,7 +128,7 @@ class HibernationsEndEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && player != null) {
int newConvertedCost = sourcePermanent.getCounters().getCount("age");
int newConvertedCost = sourcePermanent.getCounters(game).getCount("age");
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.add(new CardTypePredicate(CardType.CREATURE));

View file

@ -117,7 +117,7 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
Ability spellAbility = (SpellAbility) abilityToModify;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && spellAbility != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
CardUtil.reduceCost(spellAbility, amount);
return true;

View file

@ -123,7 +123,7 @@ class VishKalBloodArbiterCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
this.amount = permanent.getCounters().getCount(name);
this.amount = permanent.getCounters(game).getCount(name);
permanent.removeCounters(name, amount, game);
this.paid = true;
}

View file

@ -112,7 +112,7 @@ public class MarathWillOfTheWild extends CardImpl {
if (ability instanceof SimpleActivatedAbility && ability.getModes().size() == 3) {
Permanent sourcePermanent = game.getPermanent(ability.getSourceId());
if (sourcePermanent != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
for (VariableCost cost: ability.getManaCostsToPay().getVariableCosts()) {
if (cost instanceof VariableManaCost) {
@ -192,7 +192,7 @@ class MarathWillOfTheWildRemoveCountersCost extends CostImpl {
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.getCounters().getCount(CounterType.P1P1) > 0) {
if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true;
}
return false;
@ -202,7 +202,7 @@ class MarathWillOfTheWildRemoveCountersCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int amount = new ManacostVariableValue().calculate(game, ability, null);
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.getCounters().getCount(CounterType.P1P1) >= amount) {
if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) >= amount) {
permanent.removeCounters(CounterType.P1P1.getName(), amount, game);
this.paid = true;
}

View file

@ -129,7 +129,7 @@ class PhantomNantukoPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -101,7 +101,7 @@ class PlagueBoilerEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) {
if (!sourcePermanent.getCounters().containsKey(CounterType.PLAGUE) || controller.chooseUse(outcome, "Put a plague counter on? (No removes one)", source, game)) {
if (!sourcePermanent.getCounters(game).containsKey(CounterType.PLAGUE) || controller.chooseUse(outcome, "Put a plague counter on? (No removes one)", source, game)) {
return new AddCountersSourceEffect(CounterType.PLAGUE.createInstance(), true).apply(game, source);
} else {
return new RemoveCounterSourceEffect(CounterType.PLAGUE.createInstance()).apply(game, source);
@ -135,7 +135,7 @@ class PlagueBoilerTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId()) && event.getData().equals(CounterType.PLAGUE.getName())) {
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
if (sourcePermanent != null && sourcePermanent.getCounters().getCount(CounterType.PLAGUE) >= 3) {
if (sourcePermanent != null && sourcePermanent.getCounters(game).getCount(CounterType.PLAGUE) >= 3) {
return true;
}
}

View file

@ -90,8 +90,8 @@ class AEtherSnapEffect extends OneShotEffect {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
if (permanent instanceof PermanentToken) {
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
} else if (!permanent.getCounters().isEmpty()) {
Counters counters = permanent.getCounters().copy();
} else if (!permanent.getCounters(game).isEmpty()) {
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter, game);
}

View file

@ -106,7 +106,7 @@ class BloodsporeThrinaxEntersBattlefieldEffect extends ReplacementEffectImpl {
Permanent sourceCreature = game.getPermanent(source.getSourceId());
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourceCreature != null && creature != null) {
int amount = sourceCreature.getCounters().getCount(CounterType.P1P1);
int amount = sourceCreature.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
creature.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -101,7 +101,7 @@ class ThiefOfBloodEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
int countersRemoved = 0;
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
Counters counters = permanent.getCounters().copy();
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter.getName(), counter.getCount(), game);
countersRemoved += counter.getCount();

View file

@ -140,7 +140,7 @@ class GwafaHazidProfiteerEffect2 extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getCounters().containsKey(CounterType.BRIBERY);
return permanent.getCounters(game).containsKey(CounterType.BRIBERY);
}
@Override

View file

@ -148,7 +148,7 @@ class JarOfEyeballsCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getSourceId());
if (permanent != null) {
this.removedCounters = permanent.getCounters().getCount(CounterType.EYEBALL);
this.removedCounters = permanent.getCounters(game).getCount(CounterType.EYEBALL);
if (this.removedCounters > 0) {
permanent.removeCounters(CounterType.EYEBALL.createInstance(this.removedCounters), game);
}

View file

@ -101,7 +101,7 @@ class AEtherVialEffect extends OneShotEffect {
return false;
}
}
int count = permanent.getCounters().getCount(CounterType.CHARGE);
int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
FilterCreatureCard filter = new FilterCreatureCard("creature card with converted mana cost equal to " + count);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, count));

View file

@ -90,7 +90,7 @@ class DarksteelReactorStateTriggeredAbility extends StateTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(this.getSourceId());
if(permanent != null && permanent.getCounters().getCount(CounterType.CHARGE) >= 20){
if(permanent != null && permanent.getCounters(game).getCount(CounterType.CHARGE) >= 20){
return true;
}
return false;

View file

@ -114,7 +114,7 @@ class CytoplastRootKinEffect extends OneShotEffect {
if (sourcePermanent != null
&& targetPermanent != null
&& !sourcePermanent.getId().equals(targetPermanent.getId())
&& targetPermanent.getCounters().getCount(CounterType.P1P1) > 0) {
&& targetPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
targetPermanent.removeCounters(CounterType.P1P1.createInstance(), game);
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game);
return true;

View file

@ -89,7 +89,7 @@ class BredForTheHuntTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters().getCount(CounterType.P1P1) > 0) {
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true;
}
}

View file

@ -93,7 +93,7 @@ class TakeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
int numberCounters = creature.getCounters().getCount(CounterType.P1P1);
int numberCounters = creature.getCounters(game).getCount(CounterType.P1P1);
if (numberCounters > 0) {
creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game);
Player controller = game.getPlayer(source.getControllerId());

View file

@ -107,7 +107,7 @@ class VorelOfTheHullCladeEffect extends OneShotEffect {
if (target == null) {
return false;
}
for (Counter counter : target.getCounters().values()) {
for (Counter counter : target.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount());
target.addCounters(newCounter, game);
}

View file

@ -111,7 +111,7 @@ class CountersOnControlledCount implements DynamicValue {
Permanent enchantment = game.getPermanent(sourceAbility.getSourceId());
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, sourceAbility.getControllerId(), game)) {
if (!permanent.getId().equals(enchantment.getAttachedTo())) {
count += permanent.getCounters().getCount(CounterType.P1P1);
count += permanent.getCounters(game).getCount(CounterType.P1P1);
}
}
return count;

View file

@ -131,7 +131,7 @@ class MythRealizedSetPTEffect extends ContinuousEffectImpl {
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(source.getSourceObject(game), game).refersTo(permanent, game)) {
int amount = permanent.getCounters().getCount(CounterType.LORE);
int amount = permanent.getCounters(game).getCount(CounterType.LORE);
permanent.getPower().setValue(amount);
permanent.getToughness().setValue(amount);
return true;

View file

@ -104,7 +104,7 @@ class ServantOfTheScaleEffect extends OneShotEffect {
if (sourcePermanent != null && controller != null &&
(sourcePermanent.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter() // Token
|| sourcePermanent.getZoneChangeCounter(game) + 1 == source.getSourceObjectZoneChangeCounter())) { // PermanentCard
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount));
effect.setTargetPointer(targetPointer);

View file

@ -139,7 +139,7 @@ class IdentityThiefEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null && sourcePermanent != null) {
Permanent permanentReset = permanent.copy();
permanentReset.getCounters().clear();
permanentReset.getCounters(game).clear();
permanentReset.getPower().resetToBaseValue();
permanentReset.getToughness().resetToBaseValue();
CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, permanentReset, source.getSourceId());

View file

@ -96,7 +96,7 @@ class NoosegrafMobEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null && permanent.getCounters().getCount(CounterType.P1P1) > 0) {
if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
Effect effect = new CreateTokenEffect(new ZombieToken());
return effect.apply(game, source);

View file

@ -98,7 +98,7 @@ class GilderBairnEffect extends OneShotEffect {
if (target == null) {
return false;
}
for (Counter counter : target.getCounters().values()) {
for (Counter counter : target.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount());
target.addCounters(newCounter, game);
}

View file

@ -103,7 +103,7 @@ class NecroskitterTriggeredAbility extends TriggeredAbilityImpl {
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
Permanent permanent = zEvent.getTarget();
if (permanent != null
&& permanent.getCounters().containsKey(CounterType.M1M1)
&& permanent.getCounters(game).containsKey(CounterType.M1M1)
&& game.getOpponents(controllerId).contains(permanent.getControllerId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())));

View file

@ -104,7 +104,7 @@ class SpikeCannibalEffect extends OneShotEffect {
if (sourcePermanent != null) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (creature != sourcePermanent) {
int numberCounters = creature.getCounters().getCount(CounterType.P1P1);
int numberCounters = creature.getCounters(game).getCount(CounterType.P1P1);
if (numberCounters > 0) {
creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game);
countersRemoved += numberCounters;

View file

@ -111,7 +111,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (fromPermanent != null && fromPermanent.getCounters().getCount(CounterType.P1P1) > 0) {
if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (toPermanent != null) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -99,7 +99,7 @@ class EngineeredExplosivesEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if(engineeredExplosives != null && engineeredExplosives instanceof Permanent){
int count = ((Permanent)engineeredExplosives).getCounters().getCount(CounterType.CHARGE);
int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if(permanent.getConvertedManaCost() == count){
permanent.destroy(source.getSourceId(), game, false);

View file

@ -100,7 +100,7 @@ class AvianAddCountersSourceEffect extends AddCountersSourceEffect {
@Override
public boolean apply(Game game, Ability source) {
//record how many counters
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters();
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(game);
int countersWas = permCounters.getCount(CounterType.P1P0);
if (countersWas < 4){
super.apply(game, source);

View file

@ -97,7 +97,7 @@ class CoalitionRelicEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (sourcePermanent != null && player != null) {
int chargeCounters = sourcePermanent.getCounters().getCount(CounterType.CHARGE);
int chargeCounters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
sourcePermanent.removeCounters(CounterType.CHARGE.createInstance(chargeCounters), game);
Mana mana = new Mana();
ChoiceColor choice = new ChoiceColor();

View file

@ -138,7 +138,7 @@ public class DustOfMoments extends CardImpl {
if (permFilter.match(card, game)) {
final String counterName = counter.getName();
if (shouldRemoveCounters()) {
final Counter existingCounterOfSameType = card.getCounters().get(counterName);
final Counter existingCounterOfSameType = card.getCounters(game).get(counterName);
final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount());
final Counter modifiedCounter = new Counter(counterName, countersToRemove);
card.removeCounters(modifiedCounter, game);

View file

@ -104,7 +104,7 @@ class LostAuramancersAbility extends PutIntoGraveFromBattlefieldSourceTriggeredA
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (!permanent.getCounters().containsKey(CounterType.TIME) || permanent.getCounters().getCount(CounterType.TIME) == 0) {
if (!permanent.getCounters(game).containsKey(CounterType.TIME) || permanent.getCounters(game).getCount(CounterType.TIME) == 0) {
return true;
}
}

View file

@ -45,7 +45,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
/**
@ -114,7 +113,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) {
return false;
}
int amountCounters = fromPermanent.getCounters().getCount(CounterType.P1P1);
int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1);
if (amountCounters > 0) {
int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game);
if (amountToMove > 0) {

View file

@ -101,7 +101,7 @@ class MoveCounterFromSourceToTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && sourcePermanent.getCounters().getCount(CounterType.P1P1) > 0) {
if (sourcePermanent != null && sourcePermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
sourcePermanent.removeCounters(CounterType.P1P1.createInstance(), game);

View file

@ -100,7 +100,7 @@ class EssenceOfTheWildEffect extends ReplacementEffectImpl {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null) {
Permanent permanentReset = sourceObject.copy();
permanentReset.getCounters().clear();
permanentReset.getCounters(game).clear();
permanentReset.getPower().resetToBaseValue();
permanentReset.getToughness().resetToBaseValue();
game.addEffect(new CopyEffect(Duration.Custom, permanentReset, event.getTargetId()), source);

View file

@ -112,7 +112,7 @@ class GarrukRelentlessTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(sourceId)) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && !permanent.isTransformed() && permanent.getCounters().getCount(CounterType.LOYALTY) <= 2) {
if (permanent != null && !permanent.isTransformed() && permanent.getCounters(game).getCount(CounterType.LOYALTY) <= 2) {
return true;
}
}

View file

@ -173,7 +173,7 @@ class GutterGrimeCounters implements DynamicValue {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent p = game.getPermanent(sourceId);
if (p != null) {
return p.getCounters().getCount(CounterType.SLIME);
return p.getCounters(game).getCount(CounterType.SLIME);
}
return 0;
}

View file

@ -96,8 +96,8 @@ class LudevicsTestSubjectEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
if (p.getCounters().getCount(CounterType.HATCHLING) >= 5) {
p.removeCounters(CounterType.HATCHLING.getName(), p.getCounters().getCount(CounterType.HATCHLING), game);
if (p.getCounters(game).getCount(CounterType.HATCHLING) >= 5) {
p.removeCounters(CounterType.HATCHLING.getName(), p.getCounters(game).getCount(CounterType.HATCHLING), game);
TransformSourceEffect effect = new TransformSourceEffect(true);
return effect.apply(game, source);
}

View file

@ -104,7 +104,7 @@ class SageOfHoursCost extends CostImpl {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getSourceId());
if (permanent != null) {
this.removedCounters = permanent.getCounters().getCount(CounterType.P1P1);
this.removedCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
if (this.removedCounters > 0) {
permanent.removeCounters(CounterType.P1P1.createInstance(this.removedCounters), game);
}

View file

@ -93,7 +93,7 @@ class SolidarityOfHeroesEffect extends OneShotEffect {
for (UUID targetId: getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
int existingCounters = permanent.getCounters().getCount(CounterType.P1P1);
int existingCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
if (existingCounters > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), game);
}

View file

@ -136,7 +136,7 @@ class PhantomCentaurPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -127,7 +127,7 @@ class PhantomFlockPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -131,7 +131,7 @@ class PhantomNishobaPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -126,7 +126,7 @@ class PhantomNomadPreventionEffect extends PreventionEffectImpl {
}
}
if(removeCounter && permanent.getCounters().containsKey(CounterType.P1P1)) {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -122,7 +122,7 @@ class PhantomTigerPreventionEffect extends PreventionEffectImpl {
}
}
if (removeCounter && permanent.getCounters().getCount(CounterType.P1P1) > 0) {
if (removeCounter && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
sb.append("Removed a +1/+1 counter ");

View file

@ -83,7 +83,7 @@ class TargetHasCounterCondition implements Condition {
if (!source.getTargets().isEmpty()) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
return permanent.getCounters().containsKey(counterType);
return permanent.getCounters(game).containsKey(counterType);
}
}
return false;

View file

@ -89,7 +89,7 @@ class RiteOfTheSerpentEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
if (targetCreature.getCounters().containsKey(CounterType.P1P1)) {
if (targetCreature.getCounters(game).containsKey(CounterType.P1P1)) {
new CreateTokenEffect(new SnakeToken("KTK")).apply(game, source);
}
return true;

View file

@ -125,7 +125,7 @@ class BeastAddCountersSourceEffect extends AddCountersSourceEffect {
@Override
public boolean apply(Game game, Ability source) {
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters();
Counters permCounters = game.getPermanent(source.getSourceId()).getCounters(game);
int countersWas = permCounters.getCount(CounterType.P1P0);
if (countersWas < 7){
super.apply(game, source);

View file

@ -105,7 +105,7 @@ class AquitectsWillEffect extends BecomesBasicLandTargetEffect {
if (land == null) {
// if permanent left battlefield the effect can be removed because it was only valid for that object
this.discard();
} else if (land.getCounters().getCount(CounterType.FLOOD) > 0) {
} else if (land.getCounters(game).getCount(CounterType.FLOOD) > 0) {
// only if Flood counter is on the object it becomes an Island.(it would be possible to remove and return the counters with e.g. Fate Transfer if the land becomes a creature too)
super.apply(layer, sublayer, source, game);
}

View file

@ -122,7 +122,7 @@ class AshlingThePilgrimEffect extends OneShotEffect {
}
info.activations++;
if (info.activations == 3) {
int damage = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int damage = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (damage > 0) {
sourcePermanent.removeCounters(CounterType.P1P1.getName(), damage, game);
return new DamageEverythingEffect(damage, new FilterCreaturePermanent()).apply(game, source);

View file

@ -100,7 +100,7 @@ public class PhylacteryLich extends CardImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(controllerId)) {
if (perm.getCounters().getCount("phylactery") > 0) {
if (perm.getCounters(game).getCount("phylactery") > 0) {
return false;
}
}

View file

@ -103,7 +103,7 @@ class PrimordialHydraDoubleEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
int amount = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
sourcePermanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -96,7 +96,7 @@ class SlumberingDragonEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) {
if (permanent.getCounters().getCount(CounterType.P1P1) >= 5) {
if (permanent.getCounters(game).getCount(CounterType.P1P1) >= 5) {
return false;
}
return true;

View file

@ -154,7 +154,7 @@ class BoostCreatureEffectEffect extends ContinuousEffectImpl {
if (subtype != null) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (perm.hasSubtype(subtype, game)) {
int boost = permanent.getCounters().getCount(CounterType.CHARGE);
int boost = permanent.getCounters(game).getCount(CounterType.CHARGE);
perm.addPower(boost);
perm.addToughness(boost);
}

View file

@ -108,7 +108,7 @@ class KalonianHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
int existingCounters = permanent.getCounters().getCount(CounterType.P1P1);
int existingCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
if (existingCounters > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), game);
}

View file

@ -101,7 +101,7 @@ class ChasmSkulkerEffect extends OneShotEffect {
if (controller != null) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent != null) {
int counters = permanent.getCounters().getCount(CounterType.P1P1);
int counters = permanent.getCounters(game).getCount(CounterType.P1P1);
if (counters > 0) {
return new CreateTokenEffect(new ChasmSkulkerSquidToken(), counters).apply(game, source);
}

View file

@ -105,7 +105,7 @@ class YisanTheWandererBardEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null) {
int newConvertedCost = sourcePermanent.getCounters().getCount("verse");
int newConvertedCost = sourcePermanent.getCounters(game).getCount("verse");
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.add(new CardTypePredicate(CardType.CREATURE));

View file

@ -93,7 +93,7 @@ class PowderKegEffect extends OneShotEffect {
}
}
int count = p.getCounters().getCount(CounterType.FUSE);
int count = p.getCounters(game).getCount(CounterType.FUSE);
for (Permanent perm: game.getBattlefield().getAllActivePermanents()) {
if (perm.getConvertedManaCost() == count && ((perm.getCardType().contains(CardType.ARTIFACT))
|| (perm.getCardType().contains(CardType.CREATURE)))) {

View file

@ -158,7 +158,7 @@ public class DivineIntervention extends CardImpl {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
if (game.getState().getZone(sourcePermanent.getId()) == Zone.BATTLEFIELD && sourcePermanent.getCounters().getCount(CounterType.INTERVENTION) == 0) {
if (game.getState().getZone(sourcePermanent.getId()) == Zone.BATTLEFIELD && sourcePermanent.getCounters(game).getCount(CounterType.INTERVENTION) == 0) {
game.setDraw(controller.getId());
for (UUID player : game.getOpponents(controller.getId())) {

View file

@ -93,7 +93,7 @@ class CycloneEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
int total = permanent.getCounters().getCount(CounterType.WIND);
int total = permanent.getCounters(game).getCount(CounterType.WIND);
String greens = "";

View file

@ -91,7 +91,7 @@ class BlackMarketEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (sourcePermanent != null && player != null) {
int chargeCounters = sourcePermanent.getCounters().getCount(CounterType.CHARGE);
int chargeCounters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
if (chargeCounters > 0){
player.getManaPool().addMana(Mana.BlackMana(chargeCounters), game, source);
return true;

View file

@ -101,7 +101,7 @@ class AltarOfShadowsEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (sourcePermanent != null && player != null) {
int chargeCounters = sourcePermanent.getCounters().getCount(CounterType.CHARGE);
int chargeCounters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
if (chargeCounters > 0){
player.getManaPool().addMana(Mana.BlackMana(chargeCounters), game, source);
return true;

View file

@ -97,7 +97,7 @@ class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
Permanent chalice = game.getPermanent(getSourceId());
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && chalice != null && spell.getConvertedManaCost() == chalice.getCounters().getCount(CounterType.CHARGE)) {
if (spell != null && chalice != null && spell.getConvertedManaCost() == chalice.getCounters(game).getCount(CounterType.CHARGE)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}

View file

@ -127,7 +127,7 @@ class JinxedChokerDynamicValue implements DynamicValue {
int count = 0;
if (permanent != null){
count = permanent.getCounters().getCount(CounterType.CHARGE);
count = permanent.getCounters(game).getCount(CounterType.CHARGE);
}
return count;
}
@ -169,7 +169,7 @@ class JinxedChokerCounterEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) {
if (!sourcePermanent.getCounters().containsKey(CounterType.CHARGE) || controller.chooseUse(outcome, "Put a charge counter on? (No removes one)", source, game)) {
if (!sourcePermanent.getCounters(game).containsKey(CounterType.CHARGE) || controller.chooseUse(outcome, "Put a charge counter on? (No removes one)", source, game)) {
return new AddCountersSourceEffect(CounterType.CHARGE.createInstance(), true).apply(game, source);
} else {
return new RemoveCounterSourceEffect(CounterType.CHARGE.createInstance()).apply(game, source);

View file

@ -90,13 +90,13 @@ class OblivionStoneEffect extends OneShotEffect {
@java.lang.Override
public boolean apply(Game game, Ability source) {
for (Permanent p : game.getBattlefield().getAllActivePermanents()) {
if (!(p.getCardType().contains(CardType.LAND) || p.getCounters().containsKey(CounterType.FATE))) {
if (!(p.getCardType().contains(CardType.LAND) || p.getCounters(game).containsKey(CounterType.FATE))) {
p.destroy(source.getSourceId(), game, false);
}
}
for (Permanent p : game.getBattlefield().getAllActivePermanents()) {
if (p.getCounters().containsKey(CounterType.FATE)) {
p.removeCounters(CounterType.FATE.getName(), p.getCounters().getCount(CounterType.FATE), game);
if (p.getCounters(game).containsKey(CounterType.FATE)) {
p.removeCounters(CounterType.FATE.getName(), p.getCounters(game).getCount(CounterType.FATE), game);
}
}
return true;

View file

@ -92,7 +92,7 @@ class AllCountersCount implements DynamicValue {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId());
if(sourcePermanent != null) {
int total = 0;
for(Counter counter : sourcePermanent.getCounters().values()) {
for(Counter counter : sourcePermanent.getCounters(game).values()) {
total += counter.getCount();
}
return total;

View file

@ -157,7 +157,7 @@ class OonasBlackguardTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters().getCount(CounterType.P1P1) > 0) {
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters(game).getCount(CounterType.P1P1) > 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}

View file

@ -103,7 +103,7 @@ class TangleWireEffect extends OneShotEffect {
}
int targetCount = game.getBattlefield().countAll(filter, player.getId(), game);
int counterCount = permanent.getCounters().getCount(CounterType.FADE);
int counterCount = permanent.getCounters(game).getCount(CounterType.FADE);
int amount = Math.min(counterCount, targetCount);
Target target = new TargetControlledPermanent(amount, amount, filter, true);

View file

@ -110,7 +110,7 @@ class GremlinMineEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (player != null && permanent != null) {
int existingCount = permanent.getCounters().getCount(CounterType.CHARGE);
int existingCount = permanent.getCounters(game).getCount(CounterType.CHARGE);
if (existingCount > 0) {
Choice choice = new ChoiceImpl();

View file

@ -99,14 +99,14 @@ class HexParasiteEffect extends OneShotEffect {
if (permanent != null && player != null) {
int toRemove = source.getManaCostsToPay().getX();
int removed = 0;
String[] counterNames = permanent.getCounters().keySet().toArray(new String[0]);
String[] counterNames = permanent.getCounters(game).keySet().toArray(new String[0]);
for (String counterName : counterNames) {
if (player.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", source, game)) {
if (permanent.getCounters().get(counterName).getCount() == 1 || toRemove == 1) {
if (permanent.getCounters(game).get(counterName).getCount() == 1 || toRemove == 1) {
permanent.removeCounters(counterName, 1, game);
removed++;
} else {
int amount = player.getAmount(1, Math.min(permanent.getCounters().get(counterName).getCount(), toRemove - removed), "How many?", game);
int amount = player.getAmount(1, Math.min(permanent.getCounters(game).get(counterName).getCount(), toRemove - removed), "How many?", game);
if (amount > 0) {
removed += amount;
permanent.removeCounters(counterName, amount, game);

View file

@ -114,7 +114,7 @@ class ShrineOfPiercingVisionEffect extends OneShotEffect {
if (player == null || permanent == null) {
return false;
}
int count = permanent.getCounters().getCount(CounterType.CHARGE);
int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
Cards cards = new CardsImpl();
count = Math.min(player.getLibrary().size(), count);

View file

@ -102,7 +102,7 @@ class GladehartCavalryTriggeredAbility extends TriggeredAbilityImpl {
if (permanent != null
&& permanent.getControllerId().equals(this.getControllerId())
&& permanent.getCardType().contains(CardType.CREATURE)
&& permanent.getCounters().getCount(CounterType.P1P1) > 0) {
&& permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
return true;
}
}

View file

@ -122,7 +122,7 @@ class BombSquadTriggeredAbility extends TriggeredAbilityImpl {
if (event.getData().equals(CounterType.FUSE.getName())) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && filter.match(permanent, game)) {
if (4 <= permanent.getCounters().getCount(CounterType.FUSE)) {
if (4 <= permanent.getCounters(game).getCount(CounterType.FUSE)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent.getId()));
}
@ -159,7 +159,7 @@ class BombSquadDamgeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
creature.removeCounters(CounterType.FUSE.getName(), creature.getCounters().getCount(CounterType.FUSE), game);
creature.removeCounters(CounterType.FUSE.getName(), creature.getCounters(game).getCount(CounterType.FUSE), game);
creature.destroy(source.getSourceId(), game, false);
}
if (creature == null) {

View file

@ -134,7 +134,7 @@ class DelayingShieldUpkeepEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
int numCounters = permanent.getCounters().getCount(CounterType.DELAY);
int numCounters = permanent.getCounters(game).getCount(CounterType.DELAY);
permanent.removeCounters(CounterType.DELAY.createInstance(numCounters), game);
for (int i = numCounters; i > 0; i--) {
if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {

View file

@ -155,7 +155,7 @@ public class Aurification extends CardImpl {
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE)) {
if (permanent != null){
permanent.getCounters().removeAllCounters(CounterType.GOLD);
permanent.getCounters(game).removeAllCounters(CounterType.GOLD);
}
}
return true;

View file

@ -124,7 +124,7 @@ class P1P1CountersOnControlledCreaturesCount implements DynamicValue {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int count = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), sourceAbility.getControllerId(), game)) {
count += permanent.getCounters().getCount(CounterType.P1P1);
count += permanent.getCounters(game).getCount(CounterType.P1P1);
}
return count;
}

View file

@ -103,7 +103,7 @@ class NecroplasmEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && sourcePermanent != null) {
int numCounters = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ConvertedManaCostPredicate(ComparisonType.Equal, numCounters));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {

View file

@ -129,7 +129,7 @@ class AzorsElocutorsEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.addCounters(new Counter("filibuster"), game);
if (permanent.getCounters().getCount("filibuster") > 4) {
if (permanent.getCounters(game).getCount("filibuster") > 4) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.won(game);

View file

@ -99,7 +99,7 @@ class SphinxBoneWandEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), game);
int amount = sourcePermanent.getCounters().getCount(CounterType.CHARGE);
int amount = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {

View file

@ -130,7 +130,7 @@ class ThoughtGorgerEffectLeaves extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent thoughtGorgerLastState = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
int numberCounters = thoughtGorgerLastState.getCounters().getCount(CounterType.P1P1);
int numberCounters = thoughtGorgerLastState.getCounters(game).getCount(CounterType.P1P1);
if (player != null) {
player.drawCards(numberCounters, game);
return true;

View file

@ -92,7 +92,7 @@ class CullingDaisEffect extends OneShotEffect {
Permanent p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
Player player = game.getPlayer(source.getControllerId());
if (p != null && player != null) {
int count = p.getCounters().getCount(CounterType.CHARGE);
int count = p.getCounters(game).getCount(CounterType.CHARGE);
player.drawCards(count, game);
return true;
}

View file

@ -83,7 +83,7 @@ class GrindclockEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int amount = game.getPermanent(source.getSourceId()).getCounters().getCount(CounterType.CHARGE);
int amount = game.getPermanent(source.getSourceId()).getCounters(game).getCount(CounterType.CHARGE);
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
targetPlayer.moveCards(targetPlayer.getLibrary().getTopCards(game, amount), Zone.GRAVEYARD, source, game);

View file

@ -135,7 +135,7 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent perm = it.next().getPermanent(game);
if (perm != null) {
if (perm.getCounters().getCount(CounterType.AWAKENING) > 0) {
if (perm.getCounters(game).getCount(CounterType.AWAKENING) > 0) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {

View file

@ -94,7 +94,7 @@ public class RatchetBomb extends CardImpl {
}
}
int count = p.getCounters().getCount(CounterType.CHARGE);
int count = p.getCounters(game).getCount(CounterType.CHARGE);
for (Permanent perm: game.getBattlefield().getAllActivePermanents()) {
if (perm.getConvertedManaCost() == count && !(perm.getCardType().contains(CardType.LAND))) {
perm.destroy(source.getSourceId(), game, false);

View file

@ -116,7 +116,7 @@ public class ForgottenAncient extends CardImpl {
return false;
}
int numCounters = sourcePermanent.getCounters().getCount(CounterType.P1P1);
int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
ArrayList<CounterMovement> counterMovements = new ArrayList<>();
do {

View file

@ -92,7 +92,7 @@ class BlowflyInfestationCondition implements Condition {
}
}
if (permanent != null) {
return permanent.getCounters().containsKey(CounterType.M1M1);
return permanent.getCounters(game).containsKey(CounterType.M1M1);
}
return false;
}

Some files were not shown because too many files have changed in this diff Show more