getBattlefield directly, not via getState

This commit is contained in:
xenohedron 2024-06-02 18:14:23 -04:00
parent 7a76a3b005
commit d8be015c65
40 changed files with 47 additions and 50 deletions

View file

@ -83,7 +83,7 @@ class AetherspoutsEffect extends OneShotEffect {
do {
List<Permanent> permanentsToTop = new ArrayList<>();
List<Permanent> permanentsToBottom = new ArrayList<>();
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source, game)) {
if (permanent.isOwnedBy(player.getId())) {
if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", source, game)) {
permanentsToTop.add(permanent);

View file

@ -69,7 +69,7 @@ class BlinkmothUrnEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (player != null && sourcePermanent != null) {
player.getManaPool().addMana(Mana.ColorlessMana(
game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).
size()), game, source, false);
return true;
}

View file

@ -63,7 +63,7 @@ class BloodSunEffect extends ContinuousEffectImpl {
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source, game)) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
List<Ability> toRemove = new ArrayList<>();

View file

@ -83,7 +83,7 @@ class CalmingVerseEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (game.getState().getBattlefield().countAll(untappedLandFilter, controller.getId(), game) > 0) {
if (game.getBattlefield().countAll(untappedLandFilter, controller.getId(), game) > 0) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(controlledEnchantmentsFilter, source.getControllerId(), source, game)) {
permanent.destroy(source, game, false);
}

View file

@ -57,7 +57,7 @@ class ChandrasIgnitionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.getPower().getValue() > 0) {
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) {
if (!creature.getId().equals(targetCreature.getId())) {
creature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), source, game, false, true);
}

View file

@ -64,7 +64,7 @@ class ChoiceOfDamnationsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
int numberPermanents = game.getState().getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game);
int numberPermanents = game.getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game);
// AI hint
int amount;

View file

@ -66,7 +66,7 @@ class CompellingDeterrenceEffect extends OneShotEffect {
game.getState().processAction(game);
FilterPermanent zombieFilter = new FilterPermanent();
zombieFilter.add(SubType.ZOMBIE.getPredicate());
if (game.getState().getBattlefield().countAll(zombieFilter, controller.getId(), game) > 0) {
if (game.getBattlefield().countAll(zombieFilter, controller.getId(), game) > 0) {
player.discard(1, false, false, source, game);
}
return true;

View file

@ -123,7 +123,7 @@ public final class Conspiracy extends CardImpl {
}
}
// creatures you control
List<Permanent> permanents = game.getState().getBattlefield().getAllActivePermanents(controller.getId());
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(controller.getId());
for (Permanent permanent : permanents) {
if (permanent.isCreature(game)) {
permanent.removeAllCreatureTypes(game);

View file

@ -84,9 +84,9 @@ class DauntlessDismantlerEffect extends OneShotEffect {
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, source.getManaCostsToPay().getX()));
boolean destroyed = false;
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
destroyed |= permanent.destroy(source, game);
}
return destroyed;
}
}
}

View file

@ -66,7 +66,7 @@ class DecreeOfPainEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int destroyedCreature = 0;
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
if (creature.destroy(source, game, true)) {
destroyedCreature++;
}

View file

@ -49,7 +49,7 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source, game)) {
switch (layer) {
case TypeChangingEffects_4:
permanent.addSubType(game, SubType.ZOMBIE);

View file

@ -75,7 +75,7 @@ class ExperimentKrajEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
Permanent perm = game.getPermanent(source.getSourceId());
if (perm != null) {
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
for (Ability ability : creature.getAbilities()) {
if (ability.isActivatedAbility()) {
perm.addAbility(ability, source.getSourceId(), game, true);

View file

@ -62,7 +62,7 @@ class FracturingGustDestroyEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int destroyedPermanents = 0;
for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
if (permanent.destroy(source, game, false)) {
++destroyedPermanents;
}

View file

@ -57,7 +57,7 @@ class FumigateEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int destroyedCreature = 0;
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
if (creature.destroy(source, game, false)) {
destroyedCreature++;
}

View file

@ -58,7 +58,7 @@ class HellfireEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int destroyedCreature = 0;
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES_NON_BLACK, controller.getId(), game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES_NON_BLACK, controller.getId(), game)) {
if (creature.destroy(source, game, false)
&& game.getState().getZone(creature.getId()) == Zone.GRAVEYARD) { // If a commander is replaced to command zone, the creature does not die) {
destroyedCreature++;

View file

@ -84,7 +84,7 @@ class HeroismEffect extends OneShotEffect {
Player player = game.getPlayer(game.getActivePlayerId());
Cost cost = new ManaCostsImpl<>("{2}{R}");
List<Permanent> permanentsToPrevent = new ArrayList<>();
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game)) {
cost.clearPaid();
String message = "Pay " + cost.getText() + "? If you don't, " + permanent.getLogName() + "'s combat damage will be prevented this turn.";
if (player != null) {

View file

@ -100,7 +100,7 @@ class KarnsSylexDestroyEffect extends OneShotEffect {
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
boolean destroyed = false;
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
destroyed |= permanent.destroy(source, game);
}
return destroyed;

View file

@ -85,7 +85,7 @@ class KasminaEnigmaSageGainAbilitiesEffect extends ContinuousEffectImpl {
.stream()
.filter(LoyaltyAbility.class::isInstance)
.collect(Collectors.toList());
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(
for (Permanent permanent : game.getBattlefield().getActivePermanents(
StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER,
source.getControllerId(), source, game
)) {

View file

@ -69,7 +69,7 @@ class LifeAndLimbEffect extends ContinuousEffectImpl {
if (player == null) {
return false;
}
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
switch (layer) {
case TypeChangingEffects_4:
permanent.addCardType(game, CardType.CREATURE);

View file

@ -75,8 +75,7 @@ class ManascapeRefractorGainAbilitiesEffect extends ContinuousEffectImpl {
if (perm == null) {
return false;
}
for (Ability ability : game.getState()
.getBattlefield()
for (Ability ability : game.getBattlefield()
.getActivePermanents(filter, source.getControllerId(), source, game)
.stream()
.map(permanent -> permanent.getAbilities(game))

View file

@ -70,7 +70,7 @@ class MayaelsAriaEffect extends OneShotEffect {
// put a +1/+1 counter on each creature you control if you control a creature with power 5 or greater.
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, 4));
if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) {
if (game.getBattlefield().countAll(filter, controller.getId(), game) > 0) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
@ -80,14 +80,14 @@ class MayaelsAriaEffect extends OneShotEffect {
// Then you gain 10 life if you control a creature with power 10 or greater.
filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, 9));
if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) {
if (game.getBattlefield().countAll(filter, controller.getId(), game) > 0) {
controller.gainLife(10, game, source);
}
// Then you win the game if you control a creature with power 20 or greater.
filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, 19));
if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) {
if (game.getBattlefield().countAll(filter, controller.getId(), game) > 0) {
controller.won(game);
}
return true;

View file

@ -71,7 +71,7 @@ class MoggInfestationEffect extends OneShotEffect {
if (permanent.destroy(source, game, false)) {
if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD
|| (permanent instanceof PermanentToken
&& !game.getState().getBattlefield().containsPermanent(permanent.getId()))) { // If a commander is replaced to command zone, the creature does not die
&& !game.getBattlefield().containsPermanent(permanent.getId()))) { // If a commander is replaced to command zone, the creature does not die
creaturesDied.add(permanent.getId());
}
}

View file

@ -57,7 +57,7 @@ class MultanisDecreeDestroyEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
int enchantmentsDestoyed = 0;
for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) {
if (permanent.destroy(source, game, false)) {
enchantmentsDestoyed++;
}

View file

@ -86,7 +86,7 @@ class NicolBolasDragonGodGainAbilitiesEffect extends ContinuousEffectImpl {
if (perm == null) {
return true;
}
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(
for (Permanent permanent : game.getBattlefield().getActivePermanents(
filter, source.getControllerId(), source, game
)) {
for (Ability ability : permanent.getAbilities()) {

View file

@ -62,7 +62,7 @@ class NulltreadGargantuanEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || !game.getState().getBattlefield().contains(
if (player == null || !game.getBattlefield().contains(
StaticFilters.FILTER_CONTROLLED_CREATURE, source, game, 1
)) {
return false;

View file

@ -65,7 +65,7 @@ class OddOrEvenEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
// Check the number of words in the name (based on number of spaces)
if (creature != null) {
String name = creature.getName();

View file

@ -81,7 +81,7 @@ class OverwhelmingSplendorLoseAbilitiesEffect extends ContinuousEffectImpl {
if (player == null) {
return false;
}
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
permanent.removeAllAbilities(source.getSourceId(), game);

View file

@ -146,7 +146,7 @@ class PatronOfTheVeinExileCreatureEffect extends OneShotEffect {
effect.apply(game, source);
}
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName());
}

View file

@ -61,7 +61,7 @@ class RighteousFuryEffect extends OneShotEffect {
int destroyedCreature = 0;
FilterCreaturePermanent filter = new FilterCreaturePermanent("all tapped creatures");
filter.add(TappedPredicate.TAPPED);
for(Permanent creature: game.getState().getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
for(Permanent creature: game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
if (creature.destroy(source, game, false)) {
destroyedCreature++;
}

View file

@ -72,8 +72,7 @@ class RobaranMercenariesEffect extends ContinuousEffectImpl {
if (perm == null) {
return false;
}
for (Ability ability : game.getState()
.getBattlefield()
for (Ability ability : game.getBattlefield()
.getActivePermanents(filter, source.getControllerId(), source, game)
.stream()
.map(permanent -> permanent.getAbilities(game))

View file

@ -57,7 +57,7 @@ class SeedsOfInnocenceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent artifact : game.getState().getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game)) {
for (Permanent artifact : game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game)) {
Player artifactController = game.getPlayer(artifact.getControllerId());
int cmc = artifact.getManaValue();
if (artifact.destroy(source, game, true)) {

View file

@ -135,8 +135,7 @@ class SharkeyTyrantOfTheShireContinousEffect extends ContinuousEffectImpl {
if (perm == null) {
return false;
}
for (Ability ability : game.getState()
.getBattlefield()
for (Ability ability : game.getBattlefield()
.getActivePermanents(filter, source.getControllerId(), source, game)
.stream()
.map(permanent -> permanent.getAbilities(game))

View file

@ -69,7 +69,7 @@ class SuddenSpoilingEffect extends ContinuousEffectImpl {
if (player == null) {
return;
}
for (Permanent perm : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@ -80,7 +80,7 @@ class SuddenSpoilingEffect extends ContinuousEffectImpl {
if (player == null) {
return false;
}
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
if (affectedObjectList.contains(new MageObjectReference(permanent, game))) {
switch (layer) {
case AbilityAddingRemovingEffects_6:

View file

@ -72,9 +72,9 @@ class ThoughtsOfRuinEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int lands = game.getState().getBattlefield().countAll(filter, playerId, game);
int lands = game.getBattlefield().countAll(filter, playerId, game);
if (amount >= lands) {
permanentsToSacrifice.addAll(game.getState().getBattlefield().getAllActivePermanents(filter, playerId, game));
permanentsToSacrifice.addAll(game.getBattlefield().getAllActivePermanents(filter, playerId, game));
} else {
FilterLandPermanent playerFilter = filter.copy();
playerFilter.add(new ControllerIdPredicate(playerId));

View file

@ -85,7 +85,7 @@ class TidalFlatsEffect extends OneShotEffect {
}
Cost cost = new ManaCostsImpl<>("{1}");
List<Permanent> affectedPermanents = new ArrayList<>();
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
cost.clearPaid();
String message = "Pay " + cost.getText() + " for " + permanent.getLogName() + "? If you don't, creatures " + controller.getLogName() + " controls blocking it gain first strike until end of turn.";
if (player.chooseUse(Outcome.Benefit, message, source, game)) {

View file

@ -68,7 +68,7 @@ class TooGreedilyTooDeepEffect extends OneShotEffect {
game.getState().processAction(game);
Permanent returnedCreature = game.getPermanent(card.getId());
if (returnedCreature != null && returnedCreature.getPower().getValue() > 0) {
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) {
if (!creature.getId().equals(returnedCreature.getId())) {
creature.damage(returnedCreature.getPower().getValue(), returnedCreature.getId(), source, game, false, true);
}

View file

@ -122,7 +122,7 @@ class WhimsOfTheFateEffect extends OneShotEffect {
// add all permanents not targeted yet to the third pile
StringBuilder message = new StringBuilder(currentPlayer.getLogName()).append(" pile 3: ");
for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(currentPlayer.getId())) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(currentPlayer.getId())) {
if (!playerPiles.get(1).contains(permanent.getId()) && !playerPiles.get(2).contains(permanent.getId())) {
playerPiles.get(3).add(permanent.getId());
message.append(permanent.getName()).append(' ');

View file

@ -147,7 +147,7 @@ public class KikiJikiMirrorBreakerTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Silvercoat Lion", 2); // one from Body Double and one from Kiki
Permanent kikiCopy = null;
for (Permanent permanent : currentGame.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, currentGame)) {
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, currentGame)) {
if (permanent.getName().equals("Silvercoat Lion") && (permanent instanceof PermanentToken)) {
kikiCopy = permanent;
break;

View file

@ -347,7 +347,7 @@ public class ModalDoubleFacedCardsTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
Card card = currentGame.getState().getBattlefield().getAllPermanents()
Card card = currentGame.getBattlefield().getAllPermanents()
.stream()
.filter(p -> CardUtil.haveSameNames(p, "Akoum Warrior", currentGame))
.findFirst()
@ -380,7 +380,7 @@ public class ModalDoubleFacedCardsTest extends CardTestPlayerBase {
execute();
assertHandCount(playerA, 0);
Card card = currentGame.getState().getBattlefield().getAllPermanents()
Card card = currentGame.getBattlefield().getAllPermanents()
.stream()
.filter(p -> CardUtil.haveSameNames(p, "Ondu Skyruins", currentGame))
.findFirst()

View file

@ -42,7 +42,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
public void init(Ability source, Game game) {
super.init(source, game);
if (getAffectedObjectsSet() && game.getPlayer(source.getControllerId()) != null) {
for (Permanent perm : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@ -56,7 +56,7 @@ public class SwitchPowerToughnessAllEffect extends ContinuousEffectImpl {
}
if (!getAffectedObjectsSet()) {
game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).forEach(Permanent::switchPowerToughness);
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).forEach(Permanent::switchPowerToughness);
} else {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still gets boost
Permanent creature = it.next().getPermanent(game);