From 183723465096f81c064184a31f81c72dfa913baf Mon Sep 17 00:00:00 2001 From: drdev Date: Tue, 10 Dec 2013 00:24:21 +0000 Subject: [PATCH] Revert change that prevented a spell moving on the stack until after prerequisites were met --- .../spellability/HumanPlaySpellAbility.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/forge-gui/src/main/java/forge/game/spellability/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/game/spellability/HumanPlaySpellAbility.java index 6b2d8eb2eed..eb9a956f575 100644 --- a/forge-gui/src/main/java/forge/game/spellability/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/game/spellability/HumanPlaySpellAbility.java @@ -18,6 +18,7 @@ package forge.game.spellability; import java.util.ArrayList; + import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Iterables; @@ -31,6 +32,7 @@ import forge.game.cost.CostPartMana; import forge.game.cost.CostPayment; import forge.game.player.Player; import forge.game.player.PlayerController; +import forge.game.zone.Zone; /** *

@@ -52,6 +54,17 @@ public class HumanPlaySpellAbility { public final void playAbility(boolean mayChooseTargets, boolean isFree, boolean skipStack) { final Game game = ability.getActivatingPlayer().getGame(); + // used to rollback + Zone fromZone = null; + int zonePosition = 0; + + final Card c = this.ability.getSourceCard(); + if (this.ability instanceof Spell && !c.isCopiedSpell()) { + fromZone = game.getZoneOf(c); + zonePosition = fromZone.getCards().indexOf(c); + this.ability.setSourceCard(game.getAction().moveToStack(c)); + } + // freeze Stack. No abilities should go onto the stack while I'm filling requirements. game.getStack().freezeStack(); @@ -64,10 +77,10 @@ public class HumanPlaySpellAbility { if (!prerequisitesMet) { if (!ability.isTrigger()) { - rollbackAbility(); + rollbackAbility(fromZone, zonePosition); if (ability.isMadness()) { // if a player failed to play madness cost, move the card to graveyard - game.getAction().moveToGraveyard(ability.getSourceCard()); + game.getAction().moveToGraveyard(c); ability.setMadness(false); } } @@ -131,10 +144,15 @@ public class HumanPlaySpellAbility { } } - private void rollbackAbility() { + private void rollbackAbility(Zone fromZone, int zonePosition) { // cancel ability during target choosing final Game game = ability.getActivatingPlayer().getGame(); + if (fromZone != null) { // and not a copy + // add back to where it came from + game.getAction().moveTo(fromZone, ability.getSourceCard(), zonePosition >= 0 ? Integer.valueOf(zonePosition) : null); + } + clearTargets(ability); this.ability.resetOnceResolved();