diff --git a/Mage.Sets/src/mage/sets/alarareborn/VengefulRebirth.java b/Mage.Sets/src/mage/sets/alarareborn/VengefulRebirth.java index 6fe52fb74e..5ff5d755a6 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/VengefulRebirth.java +++ b/Mage.Sets/src/mage/sets/alarareborn/VengefulRebirth.java @@ -35,7 +35,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.game.Game; diff --git a/Mage.Sets/src/mage/sets/avacynrestored/TemporalMastery.java b/Mage.Sets/src/mage/sets/avacynrestored/TemporalMastery.java index ca81dfff8d..07d9b5d138 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/TemporalMastery.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/TemporalMastery.java @@ -27,15 +27,14 @@ */ package mage.sets.avacynrestored; -import mage.constants.CardType; -import mage.constants.Rarity; +import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect; import mage.abilities.keyword.MiracleAbility; import mage.cards.CardImpl; - -import java.util.UUID; +import mage.constants.CardType; +import mage.constants.Rarity; /** * @author noxx diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HanabiBlast.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HanabiBlast.java index bfa4c9c19f..ccb65b8921 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/HanabiBlast.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HanabiBlast.java @@ -34,7 +34,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.discard.DiscardControllerEffect; -import mage.abilities.effects.postresolve.ReturnToHandSpellEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; import mage.cards.CardImpl; import mage.target.common.TargetCreatureOrPlayer; diff --git a/Mage.Sets/src/mage/sets/commander/SpellCrumple.java b/Mage.Sets/src/mage/sets/commander/SpellCrumple.java index 217e5d55af..8672d70ff5 100644 --- a/Mage.Sets/src/mage/sets/commander/SpellCrumple.java +++ b/Mage.Sets/src/mage/sets/commander/SpellCrumple.java @@ -32,7 +32,7 @@ import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; -import mage.abilities.effects.postresolve.ReturnToLibrarySpellEffect; +import mage.abilities.effects.common.ReturnToLibrarySpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/commander2014/NecromanticSelection.java b/Mage.Sets/src/mage/sets/commander2014/NecromanticSelection.java index 078a199c72..d369e2fbb0 100644 --- a/Mage.Sets/src/mage/sets/commander2014/NecromanticSelection.java +++ b/Mage.Sets/src/mage/sets/commander2014/NecromanticSelection.java @@ -34,7 +34,7 @@ import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; diff --git a/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java b/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java index b600ae6513..a25a4fb7cf 100644 --- a/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java +++ b/Mage.Sets/src/mage/sets/conflux/ViewFromAbove.java @@ -27,29 +27,31 @@ */ package mage.sets.conflux; +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.ReturnToHandSpellEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.ObjectColor; -import mage.abilities.Ability; -import mage.abilities.effects.PostResolveEffect; -import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; -import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; import mage.target.common.TargetCreaturePermanent; -import java.util.UUID; - /** * * @author North */ public class ViewFromAbove extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("white permanent you control"); + static { + filter.add(new ColorPredicate(ObjectColor.WHITE)); + } public ViewFromAbove(UUID ownerId) { super(ownerId, 38, "View from Above", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}"); @@ -61,7 +63,10 @@ public class ViewFromAbove extends CardImpl { this.getSpellAbility().addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); // If you control a white permanent, return View from Above to its owner's hand. - this.getSpellAbility().addEffect(new ViewFromAboveEffect()); + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + ReturnToHandSpellEffect.getInstance(), + new PermanentsOnTheBattlefieldCondition(filter), + "If you control a white permanent, return {this} to its owner's hand")); } public ViewFromAbove(final ViewFromAbove card) { @@ -73,31 +78,3 @@ public class ViewFromAbove extends CardImpl { return new ViewFromAbove(this); } } - -class ViewFromAboveEffect extends PostResolveEffect { - - public ViewFromAboveEffect() { - this.staticText = "If you control a white permanent, return {this} to its owner's hand"; - } - - public ViewFromAboveEffect(final ViewFromAboveEffect effect) { - super(effect); - } - - @Override - public ViewFromAboveEffect copy() { - return new ViewFromAboveEffect(this); - } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - FilterPermanent filter = new FilterPermanent("white permanent"); - filter.add(new ColorPredicate(ObjectColor.WHITE)); - - if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - } else { - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false); - } - } -} diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/VolcanicVision.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/VolcanicVision.java index b287269d7c..350cc728fa 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/VolcanicVision.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/VolcanicVision.java @@ -30,7 +30,7 @@ package mage.sets.dragonsoftarkir; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java b/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java index a0135d167a..485566f562 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java +++ b/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java @@ -35,7 +35,7 @@ import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredA import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileTargetEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/fatereforged/TemporalTrespass.java b/Mage.Sets/src/mage/sets/fatereforged/TemporalTrespass.java index bb9f9622a2..1238ca35e4 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/TemporalTrespass.java +++ b/Mage.Sets/src/mage/sets/fatereforged/TemporalTrespass.java @@ -29,7 +29,7 @@ package mage.sets.fatereforged; import java.util.UUID; import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.keyword.DelveAbility; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfCreation.java b/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfCreation.java index b7a8157a47..eae11f5dee 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfCreation.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfCreation.java @@ -28,12 +28,12 @@ package mage.sets.fifthdawn; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.permanent.token.InsectToken; diff --git a/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfTomorrows.java b/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfTomorrows.java index 51665daff1..fd482505c6 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfTomorrows.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/BeaconOfTomorrows.java @@ -33,7 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.game.Game; import mage.game.turn.TurnMod; diff --git a/Mage.Sets/src/mage/sets/fifthedition/Recall.java b/Mage.Sets/src/mage/sets/fifthedition/Recall.java index 2056b4426b..31793865e2 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/Recall.java +++ b/Mage.Sets/src/mage/sets/fifthedition/Recall.java @@ -30,7 +30,7 @@ package mage.sets.fifthedition; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/guildpact/SpelltitheEnforcer.java b/Mage.Sets/src/mage/sets/guildpact/SpelltitheEnforcer.java index 659fc50fd4..61db2d01e0 100644 --- a/Mage.Sets/src/mage/sets/guildpact/SpelltitheEnforcer.java +++ b/Mage.Sets/src/mage/sets/guildpact/SpelltitheEnforcer.java @@ -29,21 +29,12 @@ package mage.sets.guildpact; import java.util.UUID; import mage.MageInt; -import mage.MageObject; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.SpellCastOpponentTriggeredAbility; -import mage.abilities.costs.Cost; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.Effects; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.abilities.effects.common.SacrificeEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.SetTargetPointer; import mage.constants.Zone; @@ -51,7 +42,6 @@ import mage.filter.FilterPermanent; import mage.filter.FilterSpell; import mage.game.Game; import mage.players.Player; -import mage.util.CardUtil; /** * @@ -70,8 +60,7 @@ public class SpelltitheEnforcer extends CardImpl { // Whenever an opponent casts a spell, that player sacrifices a permanent unless he or she pays {1}. this.addAbility(new SpellCastOpponentTriggeredAbility( Zone.BATTLEFIELD, - new DoUnlessTargetPaysEffect(new SacrificeEffect(new FilterPermanent(), 1, "that player"), new GenericManaCost(1), - "Pay {1}? (otherwise sacrifice a permanent)"), + new SpelltitheEnforcerEffect(), new FilterSpell(), false, SetTargetPointer.PLAYER @@ -88,87 +77,32 @@ public class SpelltitheEnforcer extends CardImpl { } } -class DoUnlessTargetPaysEffect extends OneShotEffect { - protected Effects executingEffects = new Effects(); - private final Cost cost; - private String chooseUseText; - - public DoUnlessTargetPaysEffect(Effect effect, Cost cost) { - this(effect, cost, null); +class SpelltitheEnforcerEffect extends SacrificeEffect { + + SpelltitheEnforcerEffect() { + super(new FilterPermanent("permanent to sacrifice"), 1, "that player"); + this.staticText = "that player sacrifices a permanent unless he or she pays {1}"; } - - public DoUnlessTargetPaysEffect(Effect effect, Cost cost, String chooseUseText) { - super(Outcome.Benefit); - this.executingEffects.add(effect); - this.cost = cost; - this.chooseUseText = chooseUseText; - } - - public DoUnlessTargetPaysEffect(final DoUnlessTargetPaysEffect effect) { + + SpelltitheEnforcerEffect(final SpelltitheEnforcerEffect effect) { super(effect); - this.executingEffects = effect.executingEffects.copy(); - this.cost = effect.cost.copy(); - this.chooseUseText = effect.chooseUseText; } - - public void addEffect(Effect effect) { - executingEffects.add(effect); + + @Override + public SpelltitheEnforcerEffect copy() { + return new SpelltitheEnforcerEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null && targetPlayer != null) { - String message; - if (chooseUseText == null) { - String effectText = executingEffects.getText(source.getModes().getMode()); - message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?"; - } else { - message = chooseUseText; + Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); + if (player != null) { + GenericManaCost cost = new GenericManaCost(1); + if (!cost.pay(source, game, player.getId(), player.getId(), false)) { + super.apply(game, source); } - message = CardUtil.replaceSourceName(message, sourceObject.getLogName()); - boolean result = true; - boolean doEffect = true; - // check if target player is willing to pay - if (cost.canPay(source, source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.chooseUse(Outcome.Detriment, message, game)) { - cost.clearPaid(); - if (cost.pay(source, game, source.getSourceId(), targetPlayer.getId(), false)) { - game.informPlayers(targetPlayer.getName() + " pays the cost to prevent the effect"); - doEffect = false; - } - } - // do the effects player did not pay - if (doEffect) { - for(Effect effect: executingEffects) { - effect.setTargetPointer(this.targetPointer); - if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - result &= effect.apply(game, source); - } - } - else { - game.addEffect((ContinuousEffect) effect, source); - } - } - } - return result; + return true; } return false; } - - @Override - public String getText(Mode mode) { - if (!staticText.isEmpty()) { - return staticText; - } - String effectsText = executingEffects.getText(mode); - return effectsText.substring(0, effectsText.length() -1) + " unless he or she pays " + cost.getText(); - } - - @Override - public DoUnlessTargetPaysEffect copy() { - return new DoUnlessTargetPaysEffect(this); - } } diff --git a/Mage.Sets/src/mage/sets/invasion/Restock.java b/Mage.Sets/src/mage/sets/invasion/Restock.java index d220e0ac5e..34670333b9 100644 --- a/Mage.Sets/src/mage/sets/invasion/Restock.java +++ b/Mage.Sets/src/mage/sets/invasion/Restock.java @@ -29,7 +29,7 @@ package mage.sets.invasion; import java.util.UUID; import mage.abilities.effects.Effect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/PullFromTheDeep.java b/Mage.Sets/src/mage/sets/journeyintonyx/PullFromTheDeep.java index 7e0699fe52..2b4b9b0834 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/PullFromTheDeep.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/PullFromTheDeep.java @@ -29,7 +29,7 @@ package mage.sets.journeyintonyx; import java.util.UUID; import mage.abilities.effects.Effect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/WorstFears.java b/Mage.Sets/src/mage/sets/journeyintonyx/WorstFears.java index 409000fde9..b5ea6bf9a0 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/WorstFears.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/WorstFears.java @@ -28,7 +28,7 @@ package mage.sets.journeyintonyx; import java.util.UUID; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.turn.ControlTargetPlayerNextTurnEffect; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/magic2011/TimeReversal.java b/Mage.Sets/src/mage/sets/magic2011/TimeReversal.java index ce1ff14d33..c002ef0f59 100644 --- a/Mage.Sets/src/mage/sets/magic2011/TimeReversal.java +++ b/Mage.Sets/src/mage/sets/magic2011/TimeReversal.java @@ -34,7 +34,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.CardImpl; import mage.game.Game; import mage.players.Player; diff --git a/Mage.Sets/src/mage/sets/magic2013/Spelltwine.java b/Mage.Sets/src/mage/sets/magic2013/Spelltwine.java index bbe1da7911..de2855426e 100644 --- a/Mage.Sets/src/mage/sets/magic2013/Spelltwine.java +++ b/Mage.Sets/src/mage/sets/magic2013/Spelltwine.java @@ -33,7 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.Zone; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlackSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlackSunsZenith.java index 676e3b6244..e769a14e6a 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlackSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlackSunsZenith.java @@ -34,7 +34,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.constants.Outcome; import mage.counters.CounterType; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlueSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlueSunsZenith.java index 825f730312..55905c84ba 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlueSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlueSunsZenith.java @@ -33,7 +33,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.common.DrawCardTargetEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.target.TargetPlayer; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java index d3dd6d5b08..eb95700b42 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java @@ -33,7 +33,7 @@ import mage.constants.Rarity; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.Outcome; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java index b9f44189d9..40b6523eee 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java @@ -34,7 +34,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect; import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.Card; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/RedSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/RedSunsZenith.java index 8ff63fb341..8902296827 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/RedSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/RedSunsZenith.java @@ -30,7 +30,7 @@ package mage.sets.mirrodinbesieged; import java.util.UUID; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java index a9a2693022..2f399da809 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java @@ -33,7 +33,7 @@ import mage.MageInt; import mage.ObjectColor; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; diff --git a/Mage.Sets/src/mage/sets/modernmasters/PetalsOfInsight.java b/Mage.Sets/src/mage/sets/modernmasters/PetalsOfInsight.java index 85b220b081..3161450de2 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/PetalsOfInsight.java +++ b/Mage.Sets/src/mage/sets/modernmasters/PetalsOfInsight.java @@ -30,7 +30,6 @@ package mage.sets.modernmasters; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; @@ -39,10 +38,8 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; /** * @@ -59,7 +56,6 @@ public class PetalsOfInsight extends CardImpl { // Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards. this.getSpellAbility().addEffect(new PetalsOfInsightEffect()); - this.getSpellAbility().addEffect(new PetalsOfInsightReturnEffect()); } public PetalsOfInsight(final PetalsOfInsight card) { @@ -74,12 +70,12 @@ public class PetalsOfInsight extends CardImpl { class PetalsOfInsightEffect extends OneShotEffect { - public PetalsOfInsightEffect() { + PetalsOfInsightEffect() { super(Outcome.Benefit); - this.staticText = "Look at the top three cards of your library. You may put those cards on the bottom of your library in any order"; + this.staticText = "Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return {this} to its owner's hand. Otherwise, draw three cards"; } - public PetalsOfInsightEffect(final PetalsOfInsightEffect effect) { + PetalsOfInsightEffect(final PetalsOfInsightEffect effect) { super(effect); } @@ -94,32 +90,21 @@ class PetalsOfInsightEffect extends OneShotEffect { if (player == null) { return false; } - Cards cards = new CardsImpl(Zone.PICK); + Cards cards = new CardsImpl(); int count = Math.min(player.getLibrary().size(), 3); for (int i = 0; i < count; i++) { Card card = player.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); - game.setZone(card.getId(), Zone.PICK); } } player.lookAtCards("Petals of Insight", cards, game); if (player.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", game)) { - TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); - while (player.isInGame() && cards.size() > 1) { - player.choose(Outcome.Neutral, cards, target, game); - Card card = cards.get(target.getFirstTarget(), game); - if (card != null) { - cards.remove(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - } - target.clearChosen(); + player.putCardsOnBottomOfLibrary(cards, game, source, true); + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); } - if (cards.size() == 1) { - Card card = cards.get(cards.iterator().next(), game); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - } - game.getState().setValue(source.getSourceId().toString(), Boolean.TRUE); } else { for (UUID cardId: cards) { Card card = game.getCard(cardId); @@ -127,43 +112,8 @@ class PetalsOfInsightEffect extends OneShotEffect { card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); } } - game.getState().setValue(source.getSourceId().toString(), Boolean.FALSE); + player.drawCards(3, game); } return true; } } - -class PetalsOfInsightReturnEffect extends PostResolveEffect { - - public PetalsOfInsightReturnEffect() { - staticText = "If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards"; - } - - public PetalsOfInsightReturnEffect(final PetalsOfInsightReturnEffect effect) { - super(effect); - } - - @Override - public PetalsOfInsightReturnEffect copy() { - return new PetalsOfInsightReturnEffect(this); - } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Player controller = game.getPlayer(controllerId); - if (controller != null) { - Boolean returnToHand = (Boolean) game.getState().getValue(source.getSourceId().toString()); - if (returnToHand == null) { - returnToHand = Boolean.FALSE; - } - if (returnToHand) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - } - else { - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false); - controller.drawCards(3, game); - } - } - - } -} diff --git a/Mage.Sets/src/mage/sets/morningtide/ReleaseTheAnts.java b/Mage.Sets/src/mage/sets/morningtide/ReleaseTheAnts.java index 46ace6ce11..d7310ac153 100644 --- a/Mage.Sets/src/mage/sets/morningtide/ReleaseTheAnts.java +++ b/Mage.Sets/src/mage/sets/morningtide/ReleaseTheAnts.java @@ -29,7 +29,7 @@ package mage.sets.morningtide; import java.util.UUID; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.postresolve.ClashWinReturnToHandSpellEffect; +import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; diff --git a/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java b/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java index 8aaacacbfd..dbd6914a7f 100644 --- a/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java +++ b/Mage.Sets/src/mage/sets/morningtide/TitansRevenge.java @@ -27,22 +27,13 @@ */ 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.PostResolveEffect; -import mage.abilities.effects.common.ClashEffect; +import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.postresolve.ClashWinReturnToHandSpellEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; /** diff --git a/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java b/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java index 9b615aa6c8..ca963a4d41 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java +++ b/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java @@ -29,17 +29,10 @@ package mage.sets.planarchaos; import java.util.UUID; import mage.MageInt; -import mage.MageObject; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.common.SacrificeTargetCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.Effects; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.abilities.effects.common.PutOnLibrarySourceEffect; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; @@ -50,7 +43,6 @@ import mage.filter.common.FilterControlledLandPermanent; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetControlledPermanent; -import mage.util.CardUtil; /** * @@ -69,13 +61,7 @@ public class ShivanWumpus extends CardImpl { this.addAbility(TrampleAbility.getInstance()); // When Shivan Wumpus enters the battlefield, any player may sacrifice a land. If a player does, put Shivan Wumpus on top of its owner's library. - this.addAbility(new EntersBattlefieldTriggeredAbility( - new DoIfAnyPlayerPaysEffect( - new PutOnLibrarySourceEffect(true), - new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent("a land"))), - "Sacrifice a land to return {this} to top of its owners library?"), - false - )); + this.addAbility(new EntersBattlefieldTriggeredAbility(new ShivanWumpusEffect(), false)); } public ShivanWumpus(final ShivanWumpus card) { @@ -88,91 +74,42 @@ public class ShivanWumpus extends CardImpl { } } -class DoIfAnyPlayerPaysEffect extends OneShotEffect { - protected Effects executingEffects = new Effects(); - private final Cost cost; - private String chooseUseText; - - public DoIfAnyPlayerPaysEffect(Effect effect, Cost cost) { - this(effect, cost, null); +class ShivanWumpusEffect extends PutOnLibrarySourceEffect { + + ShivanWumpusEffect() { + super(true); + this.staticText = "any player may sacrifice a land. If a player does, put {this} on top of its owner's library"; } - - public DoIfAnyPlayerPaysEffect(Effect effect, Cost cost, String chooseUseText) { - super(Outcome.Benefit); - this.executingEffects.add(effect); - this.cost = cost; - this.chooseUseText = chooseUseText; - } - - public DoIfAnyPlayerPaysEffect(final DoIfAnyPlayerPaysEffect effect) { + + ShivanWumpusEffect(final ShivanWumpusEffect effect) { super(effect); - this.executingEffects = effect.executingEffects.copy(); - this.cost = effect.cost.copy(); - this.chooseUseText = effect.chooseUseText; } - - public void addEffect(Effect effect) { - executingEffects.add(effect); + + @Override + public ShivanWumpusEffect copy() { + return new ShivanWumpusEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null) { - String message; - if (chooseUseText == null) { - String effectText = executingEffects.getText(source.getModes().getMode()); - message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?"; - } else { - message = chooseUseText; - } - message = CardUtil.replaceSourceName(message, sourceObject.getLogName()); - boolean result = true; - boolean doEffect = false; - // check if any player is willing to pay - for (UUID playerId: controller.getInRange()) { + if (controller != null) { + boolean costPaid = false; + for (UUID playerId : controller.getInRange()) { + Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent())); Player player = game.getPlayer(playerId); - if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, message, game)) { - cost.clearPaid(); - if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { - game.informPlayers(sourceObject.getLogName() + ": " + player.getName() + " pays the cost"); - doEffect = true; - break; - } + if (player != null + && cost.canPay(source, source.getSourceId(), playerId, game) + && player.chooseUse(Outcome.Sacrifice, "Sacrifice a land?", game) + && cost.pay(source, game, source.getSourceId(), playerId, true)) { + costPaid = true; } } - // do the effects if nobody paid - if (doEffect) { - for(Effect effect: executingEffects) { - effect.setTargetPointer(this.targetPointer); - if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - result &= effect.apply(game, source); - } - } - else { - game.addEffect((ContinuousEffect) effect, source); - } - } + if (costPaid) { + super.apply(game, source); } - return result; + return true; } return false; } - - @Override - public String getText(Mode mode) { - if (!staticText.isEmpty()) { - return staticText; - } - // any player may sacrifice a land. If a player does, put Shivan Wumpus on top of its owner's library. - String effectsText = executingEffects.getText(mode); - return "any player may " + cost.getText() + ". If a player does, " + effectsText.substring(0, effectsText.length() -1) ; - } - - @Override - public DoIfAnyPlayerPaysEffect copy() { - return new DoIfAnyPlayerPaysEffect(this); - } } diff --git a/Mage.Sets/src/mage/sets/planechase/BeaconOfUnrest.java b/Mage.Sets/src/mage/sets/planechase/BeaconOfUnrest.java index 698e74d9a9..685bdda8f9 100644 --- a/Mage.Sets/src/mage/sets/planechase/BeaconOfUnrest.java +++ b/Mage.Sets/src/mage/sets/planechase/BeaconOfUnrest.java @@ -29,7 +29,7 @@ package mage.sets.planechase; import java.util.UUID; import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; diff --git a/Mage.Sets/src/mage/sets/returntoravnica/TreasuredFind.java b/Mage.Sets/src/mage/sets/returntoravnica/TreasuredFind.java index f8b49e374e..ebe5537d2f 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/TreasuredFind.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/TreasuredFind.java @@ -30,7 +30,7 @@ package mage.sets.returntoravnica; import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; import mage.target.common.TargetCardInYourGraveyard; diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java index 8a580c43ef..596aaacfe2 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java @@ -27,17 +27,17 @@ */ package mage.sets.scarsofmirrodin; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; @@ -45,8 +45,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetOpponent; -import java.util.UUID; - /** * * @author BetaSteward_at_googlemail.com @@ -57,9 +55,10 @@ public class CerebralEruption extends CardImpl { super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}"); this.expansionSetCode = "SOM"; this.color.setRed(true); + + // Target opponent reveals the top card of his or her library. Cerebral Eruption deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return Cerebral Eruption to its owner's hand. this.getSpellAbility().addTarget(new TargetOpponent()); - this.getSpellAbility().addEffect(new CerebralEruptionEffect1()); - this.getSpellAbility().addEffect(new CerebralEruptionEffect2()); + this.getSpellAbility().addEffect(new CerebralEruptionEffect()); } public CerebralEruption(final CerebralEruption card) { @@ -70,19 +69,18 @@ public class CerebralEruption extends CardImpl { public CerebralEruption copy() { return new CerebralEruption(this); } - } -class CerebralEruptionEffect1 extends OneShotEffect { +class CerebralEruptionEffect extends OneShotEffect { private static FilterPermanent filter = new FilterCreaturePermanent(); - public CerebralEruptionEffect1() { + CerebralEruptionEffect() { super(Outcome.Damage); - staticText = "Target opponent reveals the top card of his or her library. {this} deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls."; + staticText = "Target opponent reveals the top card of his or her library. {this} deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return {this} to its owner's hand"; } - public CerebralEruptionEffect1(final CerebralEruptionEffect1 effect) { + CerebralEruptionEffect(final CerebralEruptionEffect effect) { super(effect); } @@ -100,42 +98,19 @@ class CerebralEruptionEffect1 extends OneShotEffect { for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(damage, source.getSourceId(), game, false, true); } + if (card.getCardType().contains(CardType.LAND)) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); + } + } return true; } return false; } @Override - public CerebralEruptionEffect1 copy() { - return new CerebralEruptionEffect1(this); + public CerebralEruptionEffect copy() { + return new CerebralEruptionEffect(this); } - } - -class CerebralEruptionEffect2 extends PostResolveEffect { - - public CerebralEruptionEffect2() { - staticText = "If a land card is revealed this way, return {this} to its owner's hand"; - } - - public CerebralEruptionEffect2(final CerebralEruptionEffect2 effect) { - super(effect); - } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Card revealed = (Card) game.getState().getValue(source.getSourceId().toString()); - if (revealed != null && revealed.getCardType().contains(CardType.LAND)) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - } - else { - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false); - } - } - - @Override - public CerebralEruptionEffect2 copy() { - return new CerebralEruptionEffect2(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java index aa0477ccfc..c479f2358c 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java @@ -28,19 +28,17 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +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.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; -import mage.cards.Card; -import mage.cards.CardImpl; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetDiscard; /** * @@ -52,10 +50,10 @@ public class PsychicMiasma extends CardImpl { super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}"); this.expansionSetCode = "SOM"; this.color.setBlack(true); + + // Target player discards a card. If a land card is discarded this way, return Psychic Miasma to its owner's hand. this.getSpellAbility().addTarget(new TargetPlayer()); - PsychicMiasmaEffect1 effect1 = new PsychicMiasmaEffect1(); - this.getSpellAbility().addEffect(effect1); - this.getSpellAbility().addEffect(new PsychicMiasmaEffect2()); + this.getSpellAbility().addEffect(new PsychicMiasmaEffect()); } public PsychicMiasma(final PsychicMiasma card) { @@ -69,14 +67,14 @@ public class PsychicMiasma extends CardImpl { } -class PsychicMiasmaEffect1 extends OneShotEffect { +class PsychicMiasmaEffect extends OneShotEffect { - public PsychicMiasmaEffect1() { + PsychicMiasmaEffect() { super(Outcome.Discard); - staticText = "Target player discards a card"; + staticText = "Target player discards a card. If a land card is discarded this way, return {this} to its owner's hand"; } - public PsychicMiasmaEffect1(final PsychicMiasmaEffect1 effect) { + PsychicMiasmaEffect(final PsychicMiasmaEffect effect) { super(effect); } @@ -84,49 +82,19 @@ class PsychicMiasmaEffect1 extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - TargetDiscard target = new TargetDiscard(player.getId()); - player.choose(Outcome.Discard, target, source.getSourceId(), game); - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - player.discard(card, source, game); - game.getState().setValue(source.getSourceId().toString(), card); - return true; + Card discardedCard = player.discardOne(false, source, game); + if (discardedCard != null && discardedCard.getCardType().contains(CardType.LAND)) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); + } } } return false; } @Override - public PsychicMiasmaEffect1 copy() { - return new PsychicMiasmaEffect1(this); + public PsychicMiasmaEffect copy() { + return new PsychicMiasmaEffect(this); } - } - -class PsychicMiasmaEffect2 extends PostResolveEffect { - - public PsychicMiasmaEffect2() { - staticText = "If a land card is discarded this way, return {this} to its owner's hand"; - } - - public PsychicMiasmaEffect2(final PsychicMiasmaEffect2 effect) { - super(effect); - } - - @Override - public PsychicMiasmaEffect2 copy() { - return new PsychicMiasmaEffect2(this); - } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Card discard = (Card) game.getState().getValue(source.getSourceId().toString()); - if (discard != null && discard.getCardType().contains(CardType.LAND)) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - } - else { - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false); - } - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Tyrannize.java b/Mage.Sets/src/mage/sets/shadowmoor/Tyrannize.java index 0df49bbc04..d075c7ddfa 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/Tyrannize.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/Tyrannize.java @@ -28,17 +28,11 @@ package mage.sets.shadowmoor; import java.util.UUID; -import mage.MageObject; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.costs.Cost; import mage.abilities.costs.common.PayLifeCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.Effects; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; -import mage.abilities.effects.common.discard.DiscardHandTargetEffect; +import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -46,7 +40,6 @@ import mage.constants.Rarity; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; -import mage.util.CardUtil; /** * @@ -62,7 +55,7 @@ public class Tyrannize extends CardImpl { // Target player discards his or her hand unless he or she pays 7 life. this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addEffect(new DoUnlessTargetPaysEffect(new DiscardHandTargetEffect(), new PayLifeCost(7), rule)); + this.getSpellAbility().addEffect(new TyrannizeEffect()); } @@ -76,87 +69,36 @@ public class Tyrannize extends CardImpl { } } -class DoUnlessTargetPaysEffect extends OneShotEffect { - protected Effects executingEffects = new Effects(); - private final Cost cost; - private String chooseUseText; - - public DoUnlessTargetPaysEffect(Effect effect, Cost cost) { - this(effect, cost, null); +class TyrannizeEffect extends OneShotEffect { + + TyrannizeEffect() { + super(Outcome.Discard); + this.staticText = "Target player discards his or her hand unless he or she pays 7 life"; } - - public DoUnlessTargetPaysEffect(Effect effect, Cost cost, String chooseUseText) { - super(Outcome.Benefit); - this.executingEffects.add(effect); - this.cost = cost; - this.chooseUseText = chooseUseText; - } - - public DoUnlessTargetPaysEffect(final DoUnlessTargetPaysEffect effect) { + + TyrannizeEffect(final TyrannizeEffect effect) { super(effect); - this.executingEffects = effect.executingEffects.copy(); - this.cost = effect.cost.copy(); - this.chooseUseText = effect.chooseUseText; } - - public void addEffect(Effect effect) { - executingEffects.add(effect); + + @Override + public TyrannizeEffect copy() { + return new TyrannizeEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null && targetPlayer != null) { - String message; - if (chooseUseText == null) { - String effectText = executingEffects.getText(source.getModes().getMode()); - message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?"; - } else { - message = chooseUseText; - } - message = CardUtil.replaceSourceName(message, sourceObject.getLogName()); - boolean result = true; - boolean doEffect = true; - // check if target player is willing to pay - if (cost.canPay(source, source.getSourceId(), targetPlayer.getId(), game) && targetPlayer.chooseUse(Outcome.Detriment, message, game)) { - cost.clearPaid(); - if (cost.pay(source, game, source.getSourceId(), targetPlayer.getId(), false)) { - game.informPlayers(targetPlayer.getName() + " pays the cost to prevent the effect"); - doEffect = false; + Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); + if (player != null) { + Cost cost = new PayLifeCost(7); + if (!cost.canPay(source, source.getSourceId(), player.getId(), game) + || !player.chooseUse(Outcome.LoseLife, "Pay 7 life?", game) + || !cost.pay(source, game, source.getSourceId(), player.getId(), true)) { + for (Card card : player.getHand().getCards(game)) { + player.discard(card, source, game); } } - // do the effects player did not pay - if (doEffect) { - for(Effect effect: executingEffects) { - effect.setTargetPointer(this.targetPointer); - if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - result &= effect.apply(game, source); - } - } - else { - game.addEffect((ContinuousEffect) effect, source); - } - } - } - return result; + return true; } return false; } - - @Override - public String getText(Mode mode) { - if (!staticText.isEmpty()) { - return staticText; - } - String effectsText = executingEffects.getText(mode); - return effectsText.substring(0, effectsText.length() -1) + " unless he or she pays " + cost.getText(); - } - - @Override - public DoUnlessTargetPaysEffect copy() { - return new DoUnlessTargetPaysEffect(this); - } } diff --git a/Mage.Sets/src/mage/sets/tenth/BeaconOfDestruction.java b/Mage.Sets/src/mage/sets/tenth/BeaconOfDestruction.java index d26a59d9f0..16a41b2417 100644 --- a/Mage.Sets/src/mage/sets/tenth/BeaconOfDestruction.java +++ b/Mage.Sets/src/mage/sets/tenth/BeaconOfDestruction.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.target.common.TargetCreatureOrPlayer; diff --git a/Mage.Sets/src/mage/sets/tenth/BeaconOfImmortality.java b/Mage.Sets/src/mage/sets/tenth/BeaconOfImmortality.java index f1a33b8c13..a0a46a020e 100644 --- a/Mage.Sets/src/mage/sets/tenth/BeaconOfImmortality.java +++ b/Mage.Sets/src/mage/sets/tenth/BeaconOfImmortality.java @@ -33,7 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ShuffleSpellEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.CardImpl; import mage.game.Game; import mage.players.Player; diff --git a/Mage.Sets/src/mage/sets/theros/RescueFromTheUnderworld.java b/Mage.Sets/src/mage/sets/theros/RescueFromTheUnderworld.java index 00e2299d9b..1e50ea9d0c 100644 --- a/Mage.Sets/src/mage/sets/theros/RescueFromTheUnderworld.java +++ b/Mage.Sets/src/mage/sets/theros/RescueFromTheUnderworld.java @@ -34,7 +34,7 @@ import mage.abilities.costs.Cost; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.*; diff --git a/Mage.Sets/src/mage/sets/torment/NostalgicDreams.java b/Mage.Sets/src/mage/sets/torment/NostalgicDreams.java index 0caba30576..6845c3fcce 100644 --- a/Mage.Sets/src/mage/sets/torment/NostalgicDreams.java +++ b/Mage.Sets/src/mage/sets/torment/NostalgicDreams.java @@ -31,7 +31,7 @@ import mage.abilities.Ability; import mage.abilities.costs.common.DiscardXTargetCost; import mage.abilities.dynamicvalue.common.GetXValue; import mage.abilities.effects.Effect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/urzassaga/IllGottenGains.java b/Mage.Sets/src/mage/sets/urzassaga/IllGottenGains.java index 76a259f1de..da67c82e8e 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/IllGottenGains.java +++ b/Mage.Sets/src/mage/sets/urzassaga/IllGottenGains.java @@ -30,7 +30,7 @@ package mage.sets.urzassaga; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.discard.DiscardHandAllEffect; import mage.cards.Card; import mage.cards.CardImpl; diff --git a/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java index ff7a1333e9..4df9b51e86 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java +++ b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java @@ -33,7 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.postresolve.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.UntapLandsEffect; import mage.cards.CardImpl; import mage.game.Game; diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index ed9b1df7b5..d929d403eb 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -50,7 +50,6 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.Effects; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.abilities.effects.common.BasicManaEffect; import mage.abilities.effects.common.DynamicManaEffect; import mage.abilities.keyword.FlashbackAbility; @@ -195,20 +194,18 @@ public abstract class AbilityImpl implements Ability { if (checkIfClause(game)) { for (Effect effect: getEffects()) { if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - boolean effectResult = effect.apply(game, this); - result &= effectResult; - if (logger.isDebugEnabled()) { - if (!this.getAbilityType().equals(AbilityType.MANA)) { - if (!effectResult) { - if (this.getSourceId() != null) { - MageObject mageObject = game.getObject(this.getSourceId()); - if (mageObject != null) { - logger.debug("AbilityImpl.resolve: object: " + mageObject.getName()); - } + boolean effectResult = effect.apply(game, this); + result &= effectResult; + if (logger.isDebugEnabled()) { + if (!this.getAbilityType().equals(AbilityType.MANA)) { + if (!effectResult) { + if (this.getSourceId() != null) { + MageObject mageObject = game.getObject(this.getSourceId()); + if (mageObject != null) { + logger.debug("AbilityImpl.resolve: object: " + mageObject.getName()); } - logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode())); } + logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode())); } } } diff --git a/Mage/src/mage/abilities/effects/PostResolveEffect.java b/Mage/src/mage/abilities/effects/PostResolveEffect.java deleted file mode 100644 index ceb6a078f9..0000000000 --- a/Mage/src/mage/abilities/effects/PostResolveEffect.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ -package mage.abilities.effects; - -import java.util.UUID; -import mage.constants.Outcome; -import mage.abilities.Ability; -import mage.cards.Card; -import mage.game.Game; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public abstract class PostResolveEffect extends OneShotEffect { - - public PostResolveEffect() { - super(Outcome.Neutral); - } - - public PostResolveEffect(final PostResolveEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - public boolean isActive(Ability source, Game game) { - return true; - } - - public abstract void postResolve(Card card, Ability source, UUID controllerId, Game game); - -} diff --git a/Mage/src/mage/abilities/effects/postresolve/ClashWinReturnToHandSpellEffect.java b/Mage/src/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java similarity index 72% rename from Mage/src/mage/abilities/effects/postresolve/ClashWinReturnToHandSpellEffect.java rename to Mage/src/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java index 403ac61035..98bc04994d 100644 --- a/Mage/src/mage/abilities/effects/postresolve/ClashWinReturnToHandSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ClashWinReturnToHandSpellEffect.java @@ -25,15 +25,13 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ -package mage.abilities.effects.postresolve; +package mage.abilities.effects.common; -import java.io.ObjectStreamException; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.MageSingleton; -import mage.abilities.effects.PostResolveEffect; -import mage.abilities.effects.common.ClashEffect; +import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -42,42 +40,36 @@ import mage.players.Player; * * @author LevelX2 */ -public class ClashWinReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton { +public class ClashWinReturnToHandSpellEffect extends OneShotEffect implements MageSingleton { private static final ClashWinReturnToHandSpellEffect fINSTANCE = new ClashWinReturnToHandSpellEffect(); - private Object readResolve() throws ObjectStreamException { - return fINSTANCE; - } - - private ClashWinReturnToHandSpellEffect() { - staticText = "Clash with an opponent. If you win, return {this} to its owner's hand"; - } - public static ClashWinReturnToHandSpellEffect getInstance() { return fINSTANCE; } + private ClashWinReturnToHandSpellEffect() { + super(Outcome.ReturnToHand); + staticText = "Clash with an opponent. If you win, return {this} to its owner's hand"; + } + @Override public boolean apply(Game game, Ability source) { - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (ClashEffect.getInstance().apply(game, source)) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); + } + } + return true; + } + return false; } @Override public ClashWinReturnToHandSpellEffect 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); - } - } } diff --git a/Mage/src/mage/abilities/effects/common/DoIfClashWonEffect.java b/Mage/src/mage/abilities/effects/common/DoIfClashWonEffect.java index 16b615a1b6..e33f58311d 100644 --- a/Mage/src/mage/abilities/effects/common/DoIfClashWonEffect.java +++ b/Mage/src/mage/abilities/effects/common/DoIfClashWonEffect.java @@ -34,7 +34,6 @@ import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; @@ -91,9 +90,7 @@ public class DoIfClashWonEffect extends OneShotEffect { executingEffect.setTargetPointer(this.targetPointer); } if (executingEffect instanceof OneShotEffect) { - if (!(executingEffect instanceof PostResolveEffect)) { - return executingEffect.apply(game, source); - } + return executingEffect.apply(game, source); } else { game.addEffect((ContinuousEffect) executingEffect, source); diff --git a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java index 06f6d175af..edae3a4ba2 100644 --- a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java @@ -8,7 +8,6 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.Effects; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; @@ -61,9 +60,7 @@ public class DoIfCostPaid extends OneShotEffect { for(Effect effect: executingEffects) { effect.setTargetPointer(this.targetPointer); if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - result &= effect.apply(game, source); - } + result &= effect.apply(game, source); } else { game.addEffect((ContinuousEffect) effect, source); diff --git a/Mage/src/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java b/Mage/src/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java index a269de4f23..2eb5a07d06 100644 --- a/Mage/src/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java +++ b/Mage/src/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java @@ -36,7 +36,6 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.Effects; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.PostResolveEffect; import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; @@ -106,9 +105,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { for(Effect effect: executingEffects) { effect.setTargetPointer(this.targetPointer); if (effect instanceof OneShotEffect) { - if (!(effect instanceof PostResolveEffect)) { - result &= effect.apply(game, source); - } + result &= effect.apply(game, source); } else { game.addEffect((ContinuousEffect) effect, source); diff --git a/Mage/src/mage/abilities/effects/postresolve/ExileSpellEffect.java b/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java similarity index 73% rename from Mage/src/mage/abilities/effects/postresolve/ExileSpellEffect.java rename to Mage/src/mage/abilities/effects/common/ExileSpellEffect.java index c4e9ebd0d5..01618fd04a 100644 --- a/Mage/src/mage/abilities/effects/postresolve/ExileSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java @@ -26,49 +26,49 @@ * or implied, of BetaSteward_at_googlemail.com. */ -package mage.abilities.effects.postresolve; +package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.MageSingleton; -import mage.abilities.effects.PostResolveEffect; +import mage.abilities.effects.OneShotEffect; import mage.cards.Card; -import mage.game.Game; - -import java.io.ObjectStreamException; -import java.util.UUID; +import mage.constants.Outcome; import mage.constants.Zone; +import mage.game.Game; import mage.players.Player; /** * * @author BetaSteward_at_googlemail.com */ -public class ExileSpellEffect extends PostResolveEffect implements MageSingleton { +public class ExileSpellEffect extends OneShotEffect implements MageSingleton { - private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect(); + private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect(); - private Object readResolve() throws ObjectStreamException { + public static ExileSpellEffect getInstance() { return fINSTANCE; } private ExileSpellEffect() { + super(Outcome.Exile); staticText = "Exile {this}"; } - public static ExileSpellEffect getInstance() { - return fINSTANCE; - } - @Override public ExileSpellEffect copy() { return fINSTANCE; } - + @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Player controller = game.getPlayer(controllerId); - if (controller != null) { - controller.moveCardToExileWithInfo(card, null, "", controllerId, game, Zone.STACK); + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + controller.moveCardToExileWithInfo(spellCard, null, "", source.getSourceId(), game, Zone.STACK); + } + return true; } + return false; } } diff --git a/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java new file mode 100644 index 0000000000..ab34bb72ad --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java @@ -0,0 +1,44 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.MageSingleton; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author Loki + */ +public class ReturnToHandSpellEffect extends OneShotEffect implements MageSingleton { + + private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect(); + + public static ReturnToHandSpellEffect getInstance() { + return fINSTANCE; + } + + private ReturnToHandSpellEffect() { + super(Outcome.Benefit); + staticText = "Return {this} to its owner's hand"; + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); + return true; + } + return false; + } + + @Override + public ReturnToHandSpellEffect copy() { + return fINSTANCE; + } +} diff --git a/Mage/src/mage/abilities/effects/postresolve/ReturnToLibrarySpellEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToLibrarySpellEffect.java similarity index 78% rename from Mage/src/mage/abilities/effects/postresolve/ReturnToLibrarySpellEffect.java rename to Mage/src/mage/abilities/effects/common/ReturnToLibrarySpellEffect.java index a385ae04f8..35e3292023 100644 --- a/Mage/src/mage/abilities/effects/postresolve/ReturnToLibrarySpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnToLibrarySpellEffect.java @@ -25,12 +25,12 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ -package mage.abilities.effects.postresolve; +package mage.abilities.effects.common; -import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.PostResolveEffect; +import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -39,11 +39,12 @@ import mage.players.Player; * * @author LevelX2 */ -public class ReturnToLibrarySpellEffect extends PostResolveEffect { +public class ReturnToLibrarySpellEffect extends OneShotEffect { private final boolean toTop; public ReturnToLibrarySpellEffect(boolean top) { + super(Outcome.Neutral); staticText = "Put {this} on "+ (top ? "top":"the bottom") + " of its owner's library"; this.toTop = top; } @@ -55,19 +56,19 @@ public class ReturnToLibrarySpellEffect extends PostResolveEffect { @Override public boolean apply(Game game, Ability source) { - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, toTop, true); + } + return true; + } + return false; } @Override public ReturnToLibrarySpellEffect copy() { return new ReturnToLibrarySpellEffect(this); } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Player controller = game.getPlayer(controllerId); - if (controller != null) { - controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.STACK, toTop, true); - } - } } diff --git a/Mage/src/mage/abilities/effects/postresolve/ShuffleSpellEffect.java b/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java similarity index 73% rename from Mage/src/mage/abilities/effects/postresolve/ShuffleSpellEffect.java rename to Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java index 49a43c6fff..ef4b9ae1bf 100644 --- a/Mage/src/mage/abilities/effects/postresolve/ShuffleSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java @@ -26,56 +26,53 @@ * or implied, of BetaSteward_at_googlemail.com. */ -package mage.abilities.effects.postresolve; +package mage.abilities.effects.common; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.MageSingleton; -import mage.abilities.effects.PostResolveEffect; +import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; -import java.io.ObjectStreamException; -import java.util.UUID; - /** * * @author nantuko */ -public class ShuffleSpellEffect extends PostResolveEffect implements MageSingleton { +public class ShuffleSpellEffect extends OneShotEffect implements MageSingleton { - private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect(); - - private Object readResolve() throws ObjectStreamException { - return fINSTANCE; - } - - private ShuffleSpellEffect() { - staticText = "Shuffle {this} into its owner's library"; - } + private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect(); public static ShuffleSpellEffect getInstance() { return fINSTANCE; } + private ShuffleSpellEffect() { + super(Outcome.Neutral); + staticText = "Shuffle {this} into its owner's library"; + } + @Override public boolean apply(Game game, Ability source) { - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); + if (spellCard != null) { + Player owner = game.getPlayer(spellCard.getOwnerId()); + if (owner != null) { + controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, true, true); + owner.shuffleLibrary(game); + } + } + return true; + } + return false; } @Override public ShuffleSpellEffect copy() { return fINSTANCE; } - - @Override - public void postResolve(Card card, Ability source, UUID controllerId, Game game) { - Player controller = game.getPlayer(source.getControllerId()); - Player owner = game.getPlayer(card.getOwnerId()); - if (controller != null && owner != null) { - controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.STACK, true, true); - owner.shuffleLibrary(game); - } - } } diff --git a/Mage/src/mage/abilities/effects/postresolve/ReturnToHandSpellEffect.java b/Mage/src/mage/abilities/effects/postresolve/ReturnToHandSpellEffect.java deleted file mode 100644 index 6c65d0950e..0000000000 --- a/Mage/src/mage/abilities/effects/postresolve/ReturnToHandSpellEffect.java +++ /dev/null @@ -1,51 +0,0 @@ -package mage.abilities.effects.postresolve; - -import mage.constants.Zone; -import mage.abilities.Ability; -import mage.abilities.MageSingleton; -import mage.abilities.effects.PostResolveEffect; -import mage.cards.Card; -import mage.game.Game; - -import java.io.ObjectStreamException; -import java.util.UUID; -import mage.players.Player; - -/** - * - * @author Loki - */ -public class ReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton { - private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect(); - - private Object readResolve() throws ObjectStreamException { - return fINSTANCE; - } - - private ReturnToHandSpellEffect() { - staticText = "Return {this} to its owner's hand"; - } - - public static ReturnToHandSpellEffect getInstance() { - return fINSTANCE; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public ReturnToHandSpellEffect copy() { - return fINSTANCE; - } - - @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); - } - } -} - diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 64c1ab0b91..d2f5746bfe 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -44,8 +44,6 @@ import mage.abilities.costs.Cost; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; -import mage.abilities.effects.PostResolveEffect; import mage.abilities.keyword.BestowAbility; import mage.abilities.keyword.MorphAbility; import mage.cards.Card; @@ -64,7 +62,6 @@ import mage.game.permanent.PermanentCard; import mage.players.Player; import mage.target.Target; import mage.target.TargetAmount; -import mage.watchers.Watcher; /** * @@ -204,18 +201,8 @@ public class Spell implements StackObject, Card { index++; } } - if (!isCopiedSpell()) { - for (Effect effect : ability.getEffects()) { - if (effect instanceof PostResolveEffect) { - if (((PostResolveEffect) effect).isActive(ability, game)) { - ((PostResolveEffect) effect).postResolve(card, ability, controllerId, game); - return result; - } - } - } - if (game.getState().getZone(card.getMainCard().getId()) == Zone.STACK) { - card.moveToZone(Zone.GRAVEYARD, ability.getSourceId(), game, false); - } + if (game.getState().getZone(card.getMainCard().getId()) == Zone.STACK) { + card.moveToZone(Zone.GRAVEYARD, ability.getSourceId(), game, false); } return result; }