SetPowerToughnessAllEffect - Fixed a bug that the effect did not work correctly for static abilities.

This commit is contained in:
LevelX2 2014-05-23 08:28:14 +02:00
parent c3ceda12f5
commit 90f4c2ea05

View file

@ -29,6 +29,7 @@
package mage.abilities.effects.common.continious; package mage.abilities.effects.common.continious;
import java.util.Locale; import java.util.Locale;
import java.util.UUID;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer; import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -86,8 +87,10 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl<SetPowerTou
@Override @Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (affectedObjectsSet) {
objects.add(perm.getId()); for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
objects.add(perm.getId());
}
} }
if (lockedInPT) { if (lockedInPT) {
power = new StaticValue(power.calculate(game, source)); power = new StaticValue(power.calculate(game, source));
@ -99,8 +102,16 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl<SetPowerTou
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int newPower = power.calculate(game, source); int newPower = power.calculate(game, source);
int newToughness = toughness.calculate(game, source); int newToughness = toughness.calculate(game, source);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (affectedObjectsSet) {
if(objects.contains(permanent.getId())){ for (UUID permanentId :objects) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.getPower().setValue(newPower);
permanent.getToughness().setValue(newToughness);
}
}
} else {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.getPower().setValue(newPower); permanent.getPower().setValue(newPower);
permanent.getToughness().setValue(newToughness); permanent.getToughness().setValue(newToughness);
} }