From 6513202c17b249ab879edadd19617d694629b4be Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sun, 24 Jul 2011 15:00:32 -0400 Subject: [PATCH] 3 SOM - Psychic Miasma, Cerebral Eruption, Furnace Celebration --- .../scarsofmirrodin/CerebralEruption.java | 140 ++++++++++++++++++ .../scarsofmirrodin/FurnaceCelebration.java | 97 ++++++++++++ .../sets/scarsofmirrodin/PsychicMiasma.java | 132 +++++++++++++++++ Mage/src/mage/abilities/AbilityImpl.java | 4 +- Mage/src/mage/abilities/SpellAbility.java | 2 +- .../abilities/effects/PostResolveEffect.java | 57 +++++++ .../effects/common/ExileSpellEffect.java | 17 ++- .../common/ReturnToHandSpellEffect.java | 15 +- .../effects/common/ShuffleSpellEffect.java | 16 +- Mage/src/mage/game/stack/Spell.java | 21 +-- Mage/src/mage/players/PlayerImpl.java | 1 + 11 files changed, 472 insertions(+), 30 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/FurnaceCelebration.java create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java create mode 100644 Mage/src/mage/abilities/effects/PostResolveEffect.java diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java new file mode 100644 index 0000000000..dfff067534 --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java @@ -0,0 +1,140 @@ +/* + * 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.sets.scarsofmirrodin; + +import java.util.UUID; +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.cards.Cards; +import mage.cards.CardsImpl; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CerebralEruption extends CardImpl { + + public CerebralEruption(UUID ownerId) { + super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}"); + this.expansionSetCode = "SOM"; + this.color.setRed(true); + this.getSpellAbility().addTarget(new TargetOpponent()); + this.getSpellAbility().addEffect(new CerebralEruptionEffect1()); + this.getSpellAbility().addEffect(new CerebralEruptionEffect2()); + } + + public CerebralEruption(final CerebralEruption card) { + super(card); + } + + @Override + public CerebralEruption copy() { + return new CerebralEruption(this); + } + +} + +class CerebralEruptionEffect1 extends OneShotEffect { + + private static FilterPermanent filter = new FilterCreaturePermanent(); + + public CerebralEruptionEffect1() { + 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."; + } + + public CerebralEruptionEffect1(final CerebralEruptionEffect1 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player != null && player.getLibrary().size() > 0) { + Card card = player.getLibrary().getFromTop(game); + Cards cards = new CardsImpl(); + cards.add(card); + player.revealCards("Cerebral Eruption", cards, game); + game.getState().setValue(source.getId().toString(), card); + int damage = card.getManaCost().convertedManaCost(); + player.damage(damage, source.getId(), game, false, true); + for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) { + perm.damage(damage, source.getId(), game, true, false); + } + return true; + } + return false; + } + + @Override + public CerebralEruptionEffect1 copy() { + return new CerebralEruptionEffect1(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.getId().toString()); + if (revealed != null && revealed.getCardType().contains(CardType.LAND)) { + card.moveToZone(Zone.HAND, source.getId(), game, false); + } + else { + card.moveToZone(Zone.GRAVEYARD, source.getId(), 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/FurnaceCelebration.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/FurnaceCelebration.java new file mode 100644 index 0000000000..de4d7c010a --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/FurnaceCelebration.java @@ -0,0 +1,97 @@ +/* + * 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.sets.scarsofmirrodin; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.common.TargetCreatureOrPlayer; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class FurnaceCelebration extends CardImpl { + + public FurnaceCelebration(UUID ownerId) { + super(ownerId, 90, "Furnace Celebration", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}{R}"); + this.expansionSetCode = "SOM"; + this.color.setRed(true); + this.addAbility(new FurnaceCelebrationAbility()); + } + + public FurnaceCelebration(final FurnaceCelebration card) { + super(card); + } + + @Override + public FurnaceCelebration copy() { + return new FurnaceCelebration(this); + } + +} + +class FurnaceCelebrationAbility extends TriggeredAbilityImpl { + + public FurnaceCelebrationAbility() { + super(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageTargetEffect(2), new ManaCostsImpl("{2}"))); + this.addTarget(new TargetCreatureOrPlayer()); + } + + public FurnaceCelebrationAbility(final FurnaceCelebrationAbility ability) { + super(ability); + } + + @Override + public FurnaceCelebrationAbility copy() { + return new FurnaceCelebrationAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && event.getPlayerId().equals(this.getControllerId()) && !event.getTargetId().equals(sourceId)) { + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever you sacrifice another permanent, " + super.getRule(); + } + + +} \ 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 new file mode 100644 index 0000000000..aaae3e3227 --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java @@ -0,0 +1,132 @@ +/* + * 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.sets.scarsofmirrodin; + +import java.util.UUID; +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; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class PsychicMiasma extends CardImpl { + + public PsychicMiasma(UUID ownerId) { + super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}"); + this.expansionSetCode = "SOM"; + this.color.setBlack(true); + this.getSpellAbility().addTarget(new TargetPlayer()); + PsychicMiasmaEffect1 effect1 = new PsychicMiasmaEffect1(); + this.getSpellAbility().addEffect(effect1); + this.getSpellAbility().addEffect(new PsychicMiasmaEffect2()); + } + + public PsychicMiasma(final PsychicMiasma card) { + super(card); + } + + @Override + public PsychicMiasma copy() { + return new PsychicMiasma(this); + } + +} + +class PsychicMiasmaEffect1 extends OneShotEffect { + + public PsychicMiasmaEffect1() { + super(Outcome.Discard); + staticText = "Target player discards a card."; + } + + public PsychicMiasmaEffect1(final PsychicMiasmaEffect1 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(targetPointer.getFirst(source)); + if (player != null) { + TargetDiscard target = new TargetDiscard(player.getId()); + player.choose(Outcome.Discard, target, game); + Card card = player.getHand().get(target.getFirstTarget(), game); + if (card != null) { + player.discard(card, source, game); + game.getState().setValue(source.getId().toString(), card); + return true; + } + } + return false; + } + + @Override + public PsychicMiasmaEffect1 copy() { + return new PsychicMiasmaEffect1(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.getId().toString()); + if (discard != null && discard.getCardType().contains(CardType.LAND)) { + card.moveToZone(Zone.HAND, source.getId(), game, false); + } + else { + card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false); + } + } + +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 8afa9da821..102c7bb621 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -47,6 +47,7 @@ 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.choices.Choice; import mage.choices.Choices; import mage.game.Game; @@ -134,7 +135,8 @@ public abstract class AbilityImpl> implements Ability { if (checkIfClause(game)) { for (Effect effect: getEffects()) { if (effect instanceof OneShotEffect) { - result &= effect.apply(game, this); + if (!(effect instanceof PostResolveEffect)) + result &= effect.apply(game, this); } else { game.addEffect((ContinuousEffect) effect, this); diff --git a/Mage/src/mage/abilities/SpellAbility.java b/Mage/src/mage/abilities/SpellAbility.java index d50a488e78..cc5eae8048 100644 --- a/Mage/src/mage/abilities/SpellAbility.java +++ b/Mage/src/mage/abilities/SpellAbility.java @@ -103,5 +103,5 @@ public class SpellAbility extends ActivatedAbilityImpl { spell.id = UUID.randomUUID(); return spell; } - + } diff --git a/Mage/src/mage/abilities/effects/PostResolveEffect.java b/Mage/src/mage/abilities/effects/PostResolveEffect.java new file mode 100644 index 0000000000..5f16a4c84f --- /dev/null +++ b/Mage/src/mage/abilities/effects/PostResolveEffect.java @@ -0,0 +1,57 @@ +/* + * 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 abstract void postResolve(Card card, Ability source, UUID controllerId, Game game); + +} diff --git a/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java b/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java index d714e1b1c8..e1b0c25863 100644 --- a/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ExileSpellEffect.java @@ -29,16 +29,19 @@ package mage.abilities.effects.common; import java.io.ObjectStreamException; +import java.util.UUID; import mage.Constants.Outcome; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.PostResolveEffect; +import mage.cards.Card; import mage.game.Game; /** * * @author BetaSteward_at_googlemail.com */ -public class ExileSpellEffect extends OneShotEffect { +public class ExileSpellEffect extends PostResolveEffect { private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect(); @@ -47,7 +50,6 @@ public class ExileSpellEffect extends OneShotEffect { } private ExileSpellEffect() { - super(Outcome.Exile); staticText = "Exile {this}"; } @@ -55,14 +57,13 @@ public class ExileSpellEffect extends OneShotEffect { return fINSTANCE; } - @Override - public boolean apply(Game game, Ability source) { - //this effect is applied when a spell resolves - see Spell.java - return true; - } - @Override public ExileSpellEffect copy() { return fINSTANCE; } + + @Override + public void postResolve(Card card, Ability source, UUID controllerId, Game game) { + game.getExile().getPermanentExile().add(card); + } } diff --git a/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java index 2a85985994..bdc33ee5c1 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnToHandSpellEffect.java @@ -1,17 +1,21 @@ package mage.abilities.effects.common; +import java.util.UUID; import mage.Constants; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; import mage.game.Game; import java.io.ObjectStreamException; +import mage.Constants.Zone; +import mage.abilities.effects.PostResolveEffect; /** * * @author Loki */ -public class ReturnToHandSpellEffect extends OneShotEffect { +public class ReturnToHandSpellEffect extends PostResolveEffect { private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect(); private Object readResolve() throws ObjectStreamException { @@ -19,7 +23,6 @@ public class ReturnToHandSpellEffect extends OneShotEffect { +public class ShuffleSpellEffect extends PostResolveEffect { private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect(); @@ -48,7 +53,6 @@ public class ShuffleSpellEffect extends OneShotEffect { } private ShuffleSpellEffect() { - super(Outcome.Exile); staticText = "Shuffle {this} into its owner's library"; } @@ -58,7 +62,6 @@ public class ShuffleSpellEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - //this effect is applied when a spell resolves - see Spell.java return true; } @@ -66,4 +69,11 @@ public class ShuffleSpellEffect extends OneShotEffect { public ShuffleSpellEffect copy() { return fINSTANCE; } + + @Override + public void postResolve(Card card, Ability source, UUID controllerId, Game game) { + card.moveToZone(Zone.LIBRARY, source.getId(), game, false); + Player player = game.getPlayer(card.getOwnerId()); + if (player != null) player.shuffleLibrary(game); + } } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index c06bd2931a..c7019b172e 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -30,8 +30,6 @@ package mage.game.stack; import mage.Mana; import mage.abilities.SpellAbility; -import mage.abilities.effects.common.ReturnToHandSpellEffect; -import mage.abilities.effects.common.ShuffleSpellEffect; import mage.game.*; import java.util.List; import java.util.UUID; @@ -45,7 +43,8 @@ import mage.abilities.Abilities; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; -import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.PostResolveEffect; import mage.abilities.keyword.KickerAbility; import mage.cards.Card; import mage.game.events.GameEvent; @@ -88,17 +87,13 @@ public class Spell> implements StackObject, Card { result = true; if (!copiedSpell) { - if (ability.getEffects().contains(ExileSpellEffect.getInstance())) - game.getExile().getPermanentExile().add(card); - else if (ability.getEffects().contains(ShuffleSpellEffect.getInstance())) { - card.moveToZone(Zone.LIBRARY, ability.getId(), game, false); - Player player = game.getPlayer(controllerId); - if (player != null) player.shuffleLibrary(game); - } else if (ability.getEffects().contains(ReturnToHandSpellEffect.getInstance())) { - card.moveToZone(Zone.HAND, ability.getId(), game, false); - } else { - card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false); + for (Effect effect: ability.getEffects()) { + if (effect instanceof PostResolveEffect) { + ((PostResolveEffect)effect).postResolve(card, ability, controllerId, game); + return result; + } } + card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false); } return result; diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 1641c2b664..7deb7a84ba 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -343,6 +343,7 @@ public abstract class PlayerImpl> implements Player, Ser //20100716 - 701.7 removeFromHand(card, game); card.moveToZone(Zone.GRAVEYARD, source==null?null:source.getId(), game, false); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source==null?null:source.getId(), playerId)); return true; }