mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 04:39:18 -08:00
Refactored ConditionalContinousEffect to support otherwiseEffect
This commit is contained in:
parent
c893fd891e
commit
bc1dcff4fe
2 changed files with 31 additions and 66 deletions
|
|
@ -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<TragicSlip> {
|
|||
|
||||
// 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<TragicSlip> {
|
|||
return new TragicSlip(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TragicSlipEffect extends ContinuousEffectImpl<TragicSlipEffect> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue