diff --git a/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java b/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java index 73b4e312d27..9d4771546fc 100644 --- a/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java +++ b/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java @@ -27,17 +27,21 @@ */ package mage.sets.morningtide; +import java.io.ObjectStreamException; import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.MageSingleton; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.PostResolveEffect; import mage.abilities.effects.common.ClashEffect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.ReturnToHandSpellEffect; +import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; @@ -55,7 +59,9 @@ public class TitansRevenge extends CardImpl { this.color.setRed(true); // Titan's Revenge deals X damage to target creature or player. Clash with an opponent. If you win, return Titan's Revenge to its owner's hand. - this.getSpellAbility().addEffect(new TitansRevengeEffect()); + this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue())); + this.getSpellAbility().addEffect(TitansRevengeReturnToHandSpellEffect.getInstance()); + this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); } @@ -69,33 +75,41 @@ public class TitansRevenge extends CardImpl { } } +class TitansRevengeReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton { + private static final TitansRevengeReturnToHandSpellEffect fINSTANCE = new TitansRevengeReturnToHandSpellEffect(); -class TitansRevengeEffect extends OneShotEffect { + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } - public TitansRevengeEffect() { - super(Outcome.ReturnToHand); - this.staticText = "{this} deals X damage to target creature or player. Clash with an opponent. If you win, return {this} to its owner's hand"; - } + private TitansRevengeReturnToHandSpellEffect() { + staticText = "Clash with an opponent. If you win, return {this} to its owner's hand"; + } - public TitansRevengeEffect(final TitansRevengeEffect effect) { - super(effect); - } + public static TitansRevengeReturnToHandSpellEffect getInstance() { + return fINSTANCE; + } - @Override - public TitansRevengeEffect copy() { - return new TitansRevengeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - new DamageTargetEffect(new ManacostVariableValue(), true).apply(game, source); - if (ClashEffect.getInstance().apply(game, source)) { - source.addEffect(ReturnToHandSpellEffect.getInstance()); - } + @Override + public boolean apply(Game game, Ability source) { return true; } - return false; + + @Override + public TitansRevengeReturnToHandSpellEffect copy() { + return fINSTANCE; + } + + @Override + public boolean isActive(Ability source, Game game) { + return ClashEffect.getInstance().apply(game, source); + } + + @Override + public void postResolve(Card card, Ability source, UUID controllerId, Game game) { + Player controller = game.getPlayer(controllerId); + if (controller != null) { + controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK); + } } } \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/PostResolveEffect.java b/Mage/src/mage/abilities/effects/PostResolveEffect.java index 80f851b03fc..ceb6a078f91 100644 --- a/Mage/src/mage/abilities/effects/PostResolveEffect.java +++ b/Mage/src/mage/abilities/effects/PostResolveEffect.java @@ -52,7 +52,7 @@ public abstract class PostResolveEffect extends OneShotEffect { return true; } - public boolean isActive() { + public boolean isActive(Ability source, Game game) { return true; } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index cc6e3b4bbd5..3856a9427af 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -199,7 +199,7 @@ public class Spell implements StackObject, Card { if (!copiedSpell) { for (Effect effect : ability.getEffects()) { if (effect instanceof PostResolveEffect) { - if (((PostResolveEffect) effect).isActive()) { + if (((PostResolveEffect) effect).isActive(ability, game)) { ((PostResolveEffect) effect).postResolve(card, ability, controllerId, game); return result; }