From d895f6ccc098ab981cb454fc8a975b926a7c8da9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 13 Jan 2019 20:23:22 -0500 Subject: [PATCH] fixed Code of Constraint not preventing untap when cast during main phase --- .../src/mage/cards/c/CodeOfConstraint.java | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CodeOfConstraint.java b/Mage.Sets/src/mage/cards/c/CodeOfConstraint.java index 95330ab9a3..f548ade278 100644 --- a/Mage.Sets/src/mage/cards/c/CodeOfConstraint.java +++ b/Mage.Sets/src/mage/cards/c/CodeOfConstraint.java @@ -1,15 +1,17 @@ package mage.cards.c; +import mage.abilities.Ability; import mage.abilities.condition.common.AddendumCondition; -import mage.abilities.decorator.ConditionalContinuousEffect; -import mage.abilities.decorator.ConditionalOneShotEffect; -import mage.abilities.effects.common.DontUntapInControllersNextUntapStepSourceEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; @@ -30,16 +32,7 @@ public final class CodeOfConstraint extends CardImpl { this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); // Addendum — If you cast this spell during your main phase, tap that creature and it doesn't untap during its controller's next untap step. - this.getSpellAbility().addEffect(new ConditionalOneShotEffect( - new TapTargetEffect(), AddendumCondition.instance, - "
Addendum — If you cast this spell " + - "during your main phase, tap that creature" - )); - this.getSpellAbility().addEffect(new ConditionalContinuousEffect( - new DontUntapInControllersNextUntapStepSourceEffect(), - AddendumCondition.instance, "and it doesn't untap " + - "during its controller's next untap step." - )); + this.getSpellAbility().addEffect(new CodeOfConstraintEffect()); } private CodeOfConstraint(final CodeOfConstraint card) { @@ -51,3 +44,30 @@ public final class CodeOfConstraint extends CardImpl { return new CodeOfConstraint(this); } } + +class CodeOfConstraintEffect extends OneShotEffect { + + CodeOfConstraintEffect() { + super(Outcome.Benefit); + staticText = "
Addendum — If you cast this spell during your main phase, " + + "tap that creature and it doesn't untap during its controller's next untap step."; + } + + private CodeOfConstraintEffect(final CodeOfConstraintEffect effect) { + super(effect); + } + + @Override + public CodeOfConstraintEffect copy() { + return new CodeOfConstraintEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (AddendumCondition.instance.apply(game, source)) { + new TapTargetEffect().apply(game, source); + game.addEffect(new DontUntapInControllersNextUntapStepTargetEffect(), source); + } + return true; + } +} \ No newline at end of file