diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java index 7c63bb7b899..57342b4f30a 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java @@ -48,89 +48,96 @@ public class BoostControlledEffect extends ContinuousEffectImpl { - private DynamicValue power; - private DynamicValue toughness; + private DynamicValue power; + private DynamicValue toughness; + private boolean lockedIn; - public BoostSourceEffect(int power, int toughness, Duration duration) { - this(new StaticValue(power), new StaticValue(toughness), duration); - } - - public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration) { - super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); - this.power = power; - this.toughness = toughness; - setText(); + public BoostSourceEffect(int power, int toughness, Duration duration) { + this(new StaticValue(power), new StaticValue(toughness), duration, false); } - public BoostSourceEffect(final BoostSourceEffect effect) { - super(effect); - this.power = effect.power.clone(); - this.toughness = effect.toughness.clone(); - } + public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration) { + this(power, toughness, duration, false); + } - @Override - public BoostSourceEffect copy() { - return new BoostSourceEffect(this); - } + /** + * @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves + */ + public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) { + super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); + this.power = power; + this.toughness = toughness; + this.lockedIn = lockedIn; + setText(); + } - @Override - public boolean apply(Game game, Ability source) { - Permanent target = game.getPermanent(source.getSourceId()); - if (target != null) { - target.addPower(power.calculate(game, source)); - target.addToughness(toughness.calculate(game, source)); - return true; - } - return false; - } + public BoostSourceEffect(final BoostSourceEffect effect) { + super(effect); + this.power = effect.power.clone(); + this.toughness = effect.toughness.clone(); + this.lockedIn = effect.lockedIn; + } - public void setRule(String value) { - staticText = value; - } + @Override + public BoostSourceEffect copy() { + return new BoostSourceEffect(this); + } - private void setText() { - StringBuilder sb = new StringBuilder(); - sb.append("{this} gets "); + @Override + public void init(Ability source, Game game) { + super.init(source, game); + if (lockedIn) { + power = new StaticValue(power.calculate(game, source)); + toughness = new StaticValue(toughness.calculate(game, source)); + } + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent target = game.getPermanent(source.getSourceId()); + if (target != null) { + target.addPower(power.calculate(game, source)); + target.addToughness(toughness.calculate(game, source)); + return true; + } + return false; + } + + public void setRule(String value) { + staticText = value; + } + + private void setText() { + StringBuilder sb = new StringBuilder(); + sb.append("{this} gets "); String p = power.toString(); if(!p.startsWith("-")) sb.append("+"); @@ -99,8 +118,8 @@ public class BoostSourceEffect extends ContinuousEffectImpl { sb.append("+"); } sb.append(t); - if (duration != Duration.WhileOnBattlefield) - sb.append(" ").append(duration.toString()); + if (duration != Duration.WhileOnBattlefield) + sb.append(" ").append(duration.toString()); String message = power.getMessage(); if (message.length() == 0) message = toughness.getMessage(); @@ -108,7 +127,7 @@ public class BoostSourceEffect extends ContinuousEffectImpl { sb.append(" for each "); } sb.append(message); - staticText = sb.toString(); - } + staticText = sb.toString(); + } } diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java index 787c4f07e26..340da3b6a2b 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostTargetEffect.java @@ -49,37 +49,31 @@ public class BoostTargetEffect extends ContinuousEffectImpl { private DynamicValue power; private DynamicValue toughness; - // if true, all dynamic values should be calculated once - protected boolean isLockedIn = false; - + private boolean lockedIn; + public BoostTargetEffect(int power, int toughness, Duration duration) { - this(new StaticValue(power), new StaticValue(toughness), duration); + this(new StaticValue(power), new StaticValue(toughness), duration, false); } public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration) { - super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); - this.power = power; - this.toughness = toughness; + this(power, toughness, duration, false); } + /** - * @param power power value to boost - * @param toughness toughness value to boost - * @param duration how long does the effecct apply - * @param continuousCalculation true = power and toughness will be calculated continuously - * false = power and toughness will be calculated once during resolution + * @param lockedIn if true, power and toughness will be calculated only once, when the ability resolves */ - public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean isLockedIn) { + public BoostTargetEffect(DynamicValue power, DynamicValue toughness, Duration duration, boolean lockedIn) { super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); this.power = power; this.toughness = toughness; - this.isLockedIn = isLockedIn; + this.lockedIn = lockedIn; } public BoostTargetEffect(final BoostTargetEffect effect) { super(effect); this.power = effect.power.clone(); this.toughness = effect.toughness.clone(); - this.isLockedIn = effect.isLockedIn; + this.lockedIn = effect.lockedIn; } @Override @@ -89,11 +83,11 @@ public class BoostTargetEffect extends ContinuousEffectImpl { @Override public void init(Ability source, Game game) { - super.init(source, game); - if (isLockedIn) { - power = new StaticValue(power.calculate(game, source)); - toughness = new StaticValue(toughness.calculate(game, source)); - } + super.init(source, game); + if (lockedIn) { + power = new StaticValue(power.calculate(game, source)); + toughness = new StaticValue(toughness.calculate(game, source)); + } } @Override @@ -132,7 +126,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl { } sb.append(t); if (duration != Duration.WhileOnBattlefield) - sb.append(" ").append(duration.toString()); + sb.append(" ").append(duration.toString()); String message = power.getMessage(); if (message.length() > 0) { sb.append(" for each "); @@ -140,8 +134,4 @@ public class BoostTargetEffect extends ContinuousEffectImpl { sb.append(message); return sb.toString(); } - - public void setLockedIn(boolean isLockedIn) { - this.isLockedIn =isLockedIn; - } }