diff --git a/Mage.Sets/src/mage/sets/darkascension/TragicSlip.java b/Mage.Sets/src/mage/sets/darkascension/TragicSlip.java index 7fdbabd3cf2..f4daa06fd2a 100644 --- a/Mage.Sets/src/mage/sets/darkascension/TragicSlip.java +++ b/Mage.Sets/src/mage/sets/darkascension/TragicSlip.java @@ -30,18 +30,11 @@ package mage.sets.darkascension; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; import mage.Constants.Rarity; -import mage.Constants.SubLayer; -import mage.abilities.Ability; -import mage.abilities.condition.Condition; import mage.abilities.condition.common.MorbidCondition; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.decorator.ConditionalContinousEffect; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; -import mage.game.Game; import mage.target.common.TargetCreaturePermanent; /** @@ -58,7 +51,11 @@ public class TragicSlip extends CardImpl { // Target creature gets -1/-1 until end of turn. // Morbid - That creature gets -13/-13 until end of turn instead if a creature died this turn. - this.getSpellAbility().addEffect(new TragicSlipEffect()); + this.getSpellAbility().addEffect(new ConditionalContinousEffect( + new BoostTargetEffect(-13, -13, Duration.EndOfTurn), + new BoostTargetEffect(-1, -1, Duration.EndOfTurn), + MorbidCondition.getInstance(), + "Target creature gets -1/-1 until end of turn. Morbid - That creature gets -13/-13 until end of turn instead if a creature died this turn")); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } @@ -71,53 +68,3 @@ public class TragicSlip extends CardImpl { return new TragicSlip(this); } } - -class TragicSlipEffect extends ContinuousEffectImpl { - - private ContinuousEffect effect; - private ContinuousEffect otherwiseEffect; - private Condition condition; - - public TragicSlipEffect() { - super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); - this.effect = new BoostTargetEffect(-13, -13, Duration.EndOfTurn); - this.otherwiseEffect = new BoostTargetEffect(-1, -1, Duration.EndOfTurn); - this.condition = MorbidCondition.getInstance(); - this.staticText = "Target creature gets -1/-1 until end of turn. Morbid - That creature gets -13/-13 until end of turn instead if a creature died this turn."; - } - - public TragicSlipEffect(final TragicSlipEffect effect) { - super(effect); - this.effect = effect.effect; - this.otherwiseEffect = effect.otherwiseEffect; - this.condition = effect.condition; - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - if (condition.apply(game, source)) { - return effect.apply(layer, sublayer, source, game); - } else { - return otherwiseEffect.apply(layer, sublayer, source, game); - } - } - - @Override - public boolean apply(Game game, Ability source) { - if (condition.apply(game, source)) { - return effect.apply(game, source); - } else { - return otherwiseEffect.apply(game, source); - } - } - - @Override - public boolean hasLayer(Layer layer) { - return effect.hasLayer(layer); - } - - @Override - public TragicSlipEffect copy() { - return new TragicSlipEffect(this); - } -} \ No newline at end of file diff --git a/Mage/src/mage/abilities/decorator/ConditionalContinousEffect.java b/Mage/src/mage/abilities/decorator/ConditionalContinousEffect.java index 480fe1895d5..9ceffa3033a 100644 --- a/Mage/src/mage/abilities/decorator/ConditionalContinousEffect.java +++ b/Mage/src/mage/abilities/decorator/ConditionalContinousEffect.java @@ -15,25 +15,42 @@ import mage.game.Game; public class ConditionalContinousEffect extends ContinuousEffectImpl { protected ContinuousEffect effect; + protected ContinuousEffect otherwiseEffect; protected Condition condition; public ConditionalContinousEffect(ContinuousEffect effect, Condition condition, String text) { + this(effect, null, condition, text); + } + + /** + * Only use this if both effects have the same layers + * + * @param effect + * @param otherwiseEffect + * @param condition + * @param text + */ + public ConditionalContinousEffect(ContinuousEffect effect, ContinuousEffect otherwiseEffect, Condition condition, String text) { super(effect.getDuration(), effect.getLayer(), effect.getSublayer(), effect.getOutcome()); this.effect = effect; + this.otherwiseEffect = otherwiseEffect; this.condition = condition; this.staticText = text; } - public ConditionalContinousEffect(final ConditionalContinousEffect effect) { - super(effect); - this.effect = effect.effect; - this.condition = effect.condition; - } - + public ConditionalContinousEffect(final ConditionalContinousEffect effect) { + super(effect); + this.effect = effect.effect; + this.otherwiseEffect = effect.otherwiseEffect; + this.condition = effect.condition; + } + @Override public boolean apply(Constants.Layer layer, Constants.SubLayer sublayer, Ability source, Game game) { if (condition.apply(game, source)) { return effect.apply(layer, sublayer, source, game); + } else if (otherwiseEffect != null) { + return otherwiseEffect.apply(layer, sublayer, source, game); } return false; } @@ -42,6 +59,8 @@ public class ConditionalContinousEffect extends ContinuousEffectImpl