From 86bf88fb6a694c505a5a40de11275e8718bb1ccb Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 23 Sep 2018 19:01:15 +0200 Subject: [PATCH] * Cankerous Thirst - Fixed spell handling. --- .../src/mage/cards/c/CankerousThirst.java | 70 ++++++++++++++----- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CankerousThirst.java b/Mage.Sets/src/mage/cards/c/CankerousThirst.java index ff27ec3a8d..724a37456d 100644 --- a/Mage.Sets/src/mage/cards/c/CankerousThirst.java +++ b/Mage.Sets/src/mage/cards/c/CankerousThirst.java @@ -1,11 +1,10 @@ - package mage.cards.c; import java.util.UUID; -import mage.abilities.condition.LockedInCondition; +import mage.abilities.Ability; import mage.abilities.condition.common.ManaWasSpentCondition; -import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.InfoEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; @@ -13,8 +12,13 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.ColoredManaSymbol; import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.SecondTargetPointer; +import mage.target.targetpointer.FixedTarget; import mage.watchers.common.ManaSpentToCastWatcher; /** @@ -28,19 +32,9 @@ public final class CankerousThirst extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{B/G}"); // If {B} was spent to cast Cankerous Thirst, you may have target creature get -3/-3 until end of turn. If {G} was spent to cast Cankerous Thirst, you may have target creature get +3/+3 until end of turn. - this.getSpellAbility().addEffect(new ConditionalContinuousEffect( - new BoostTargetEffect(-3, -3, Duration.EndOfTurn), - new LockedInCondition(new ManaWasSpentCondition(ColoredManaSymbol.B)), - "If {B} was spent to cast {this}, you may have target creature get -3/-3 until end of turn")); - - ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn); - effect.setTargetPointer(new SecondTargetPointer()); - this.getSpellAbility().addEffect(new ConditionalContinuousEffect( - effect, - new LockedInCondition(new ManaWasSpentCondition(ColoredManaSymbol.G)), - "If {G} was spent to cast {this}, you may have target creature get +3/+3 until end of turn")); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addEffect(new CankerousThirstEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (1th effect -3/-3)"))); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (2nd effect +3/+3)"))); this.getSpellAbility().addEffect(new InfoEffect("(Do both if {B}{G} was spent.)")); this.getSpellAbility().addWatcher(new ManaSpentToCastWatcher()); } @@ -55,3 +49,45 @@ public final class CankerousThirst extends CardImpl { } } + +class CankerousThirstEffect extends OneShotEffect { + + public CankerousThirstEffect() { + super(Outcome.Benefit); + this.staticText = "If {B} was spent to cast {this}, you may have target creature get -3/-3 until end of turn. If {G} was spent to cast {this}, you may have target creature get +3/+3 until end of turn"; + } + + public CankerousThirstEffect(final CankerousThirstEffect effect) { + super(effect); + } + + @Override + public CankerousThirstEffect copy() { + return new CankerousThirstEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (new ManaWasSpentCondition(ColoredManaSymbol.B).apply(game, source)) { + Permanent targetCreature1 = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (targetCreature1 != null && controller.chooseUse(Outcome.UnboostCreature, "Let " + targetCreature1.getIdName() + " get -3/-3 until end of turn?", source, game)) { + ContinuousEffect effect = new BoostTargetEffect(-3, -3, Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(targetCreature1, game)); + game.addEffect(effect, source); + } + } + if (new ManaWasSpentCondition(ColoredManaSymbol.G).apply(game, source)) { + Permanent targetCreature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + if (targetCreature2 != null && controller.chooseUse(Outcome.UnboostCreature, "Let " + targetCreature2.getIdName() + " get +3/+3 until end of turn?", source, game)) { + ContinuousEffect effect = new BoostTargetEffect(+3, +3, Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(targetCreature2, game)); + game.addEffect(effect, source); + } + } + return true; + } + return false; + } +}