Fixed bug of Mutilate and Ichor Explosion not locking in the dynamic values.

This commit is contained in:
LevelX2 2013-05-30 09:26:20 +02:00
parent c8a5596510
commit d178a774f3
2 changed files with 25 additions and 13 deletions

View file

@ -28,16 +28,17 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.continious.BoostAllEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
@ -57,7 +58,8 @@ public class IchorExplosion extends CardImpl<IchorExplosion> {
// As an additional cost to cast Ichor Explosion, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
// All creatures get -X/-X until end of turn, where X is the sacrificed creature's power.
this.getSpellAbility().addEffect(new BoostAllEffect(new IchorExplosionDynamicValue(), new IchorExplosionDynamicValue(), Constants.Duration.EndOfTurn));
DynamicValue xValue = new IchorExplosionDynamicValue();
this.getSpellAbility().addEffect(new BoostAllEffect(xValue, xValue, Duration.EndOfTurn, new FilterCreaturePermanent(), false, null, true));
}
@ -78,7 +80,7 @@ class IchorExplosionDynamicValue implements DynamicValue {
if (sourceCard != null) {
for (Object cost: sourceAbility.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
Permanent p = (Permanent) game.getLastKnownInformation(((SacrificeTargetCost) cost).getPermanents().get(0).getId(), Constants.Zone.BATTLEFIELD);
Permanent p = (Permanent) game.getLastKnownInformation(((SacrificeTargetCost) cost).getPermanents().get(0).getId(), Zone.BATTLEFIELD);
return -1 * p.getPower().getValue();
}
}

View file

@ -50,6 +50,7 @@ public class BoostAllEffect extends ContinuousEffectImpl<BoostAllEffect> {
protected DynamicValue toughness;
protected boolean excludeSource;
protected FilterCreaturePermanent filter;
protected boolean lockedInPT;
public BoostAllEffect(int power, int toughness, Duration duration) {
this(power, toughness, duration, new FilterCreaturePermanent(), false);
@ -68,21 +69,26 @@ public class BoostAllEffect extends ContinuousEffectImpl<BoostAllEffect> {
}
public BoostAllEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, isCanKill(toughness) ? Outcome.UnboostCreature : Outcome.BoostCreature);
this.power = power;
this.toughness = toughness;
this.filter = filter;
this.excludeSource = excludeSource;
setText();
this(power, toughness, duration, filter, excludeSource, null);
}
public BoostAllEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource, String rule) {
this(power, toughness, duration, filter, excludeSource, null, false);
}
public BoostAllEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource, String rule, boolean lockedInPT) {
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, isCanKill(toughness) ? Outcome.UnboostCreature : Outcome.BoostCreature);
this.power = power;
this.toughness = toughness;
this.filter = filter;
this.excludeSource = excludeSource;
this.staticText = rule;
this.lockedInPT = lockedInPT;
if (rule == null) {
setText();
} else {
this.staticText = rule;
}
}
public BoostAllEffect(final BoostAllEffect effect) {
@ -91,7 +97,7 @@ public class BoostAllEffect extends ContinuousEffectImpl<BoostAllEffect> {
this.toughness = effect.toughness;
this.filter = effect.filter.copy();
this.excludeSource = effect.excludeSource;
this.staticText = effect.staticText;
this.lockedInPT = effect.lockedInPT;
}
@Override
@ -109,6 +115,10 @@ public class BoostAllEffect extends ContinuousEffectImpl<BoostAllEffect> {
}
}
}
if (lockedInPT) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
}
}
@Override