From 746c86363fc2a257cfaf8c32fad3be0fe844200a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 19 Aug 2014 15:04:33 +0200 Subject: [PATCH] Fixed a bug that caused mass boost / unboost of spells to be applied to wrong objects. --- .../effects/ContinuousEffectImpl.java | 4 +++- .../common/continious/BoostAllEffect.java | 20 ++++++++++++++++--- .../continious/BoostControlledEffect.java | 2 -- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java index 0538c667f8..813440a189 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java @@ -137,7 +137,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu public void init(Ability source, Game game) { targetPointer.init(game, source); //20100716 - 611.2c - if (AbilityType.ACTIVATED.equals(source.getAbilityType()) || AbilityType.TRIGGERED.equals(source.getAbilityType())) { + if (AbilityType.ACTIVATED.equals(source.getAbilityType()) + || AbilityType.SPELL.equals(source.getAbilityType()) + || AbilityType.TRIGGERED.equals(source.getAbilityType())) { if (layer != null) { switch (layer) { case CopyEffects_1: diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostAllEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostAllEffect.java index ae9bf6365f..93ac5d67c8 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostAllEffect.java @@ -28,6 +28,8 @@ package mage.abilities.effects.common.continious; +import java.util.Iterator; +import java.util.UUID; import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; @@ -123,14 +125,26 @@ public class BoostAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - if (!this.affectedObjectsSet || objects.contains(perm.getId())) { + if (this.affectedObjectsSet) { + for (Iterator it = objects.iterator(); it.hasNext();) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost + UUID permanentId = it.next(); + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null) { + permanent.addPower(power.calculate(game, source, this)); + permanent.addToughness(toughness.calculate(game, source, this)); + } else { + it.remove(); // no longer on the battlefield, remove reference to object + } + } + } else { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { perm.addPower(power.calculate(game, source, this)); perm.addToughness(toughness.calculate(game, source, this)); } } - } + + } return true; } diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java index 94ad57f130..8ecaaa7654 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java @@ -28,9 +28,7 @@ package mage.abilities.effects.common.continious; -import java.util.ArrayList; import java.util.Iterator; -import java.util.List; import java.util.UUID; import mage.constants.Duration; import mage.constants.Layer;