From 2f4b6ca71352b7fd82da7acc6d77454c71515fa0 Mon Sep 17 00:00:00 2001 From: Ben Dawes Date: Sat, 27 Jan 2018 11:51:16 +0000 Subject: [PATCH] BecomeCreatureAllEffect used to always calculate the permanent set to apply to every time it is applied Now we calculate it either at init-time (for abilities with affected object sets) OR at apply-time (Static abilities etc.) --- .../continuous/BecomesCreatureAllEffect.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java index d78d9a26ef..ce9b5c41a4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java @@ -27,6 +27,7 @@ */ package mage.abilities.effects.common.continuous; +import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffectImpl; @@ -40,6 +41,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; +import java.util.HashSet; +import java.util.Set; + /** * @author LevelX2 * @@ -64,6 +68,16 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { this.filter = effect.filter.copy(); } + @Override + public void init(Ability source, Game game) { + super.init(source, game); + if (this.affectedObjectsSet) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + affectedObjectList.add(new MageObjectReference(perm, game)); + } + } + } + @Override public BecomesCreatureAllEffect copy() { return new BecomesCreatureAllEffect(this); @@ -71,7 +85,15 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + Set affectedPermanents = new HashSet<>(); + if (this.affectedObjectsSet) { + for(MageObjectReference ref : affectedObjectList) { + affectedPermanents.add(ref.getPermanent(game)); + } + } else { + affectedPermanents = new HashSet<>(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); + } + for(Permanent permanent : affectedPermanents) { if (permanent != null) { switch (layer) { case TypeChangingEffects_4: