From c0df967d1c5e01370c59d5af1fa2cff86a1e356a Mon Sep 17 00:00:00 2001 From: moomarc Date: Tue, 25 Sep 2012 12:51:59 +0000 Subject: [PATCH] - Fixed Armor of Thorns' trigger firing even if cast at sorcery speed or given instant speed casting by something like Vedalken Orrey (10/1/2009 Ruling: The sacrifice occur only if you cast it using its own ability. If you cast it using some other effect (for instance, if it gained flash from Vedalken Orrery), then it won't be sacrificed. ) --- res/cardsfolder/a/armor_of_thorns.txt | 2 +- .../card/trigger/TriggerSpellAbilityCast.java | 25 +++++++++++-------- .../java/forge/game/phase/PhaseHandler.java | 9 +++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/res/cardsfolder/a/armor_of_thorns.txt b/res/cardsfolder/a/armor_of_thorns.txt index 13cde25b443..c83d5890803 100644 --- a/res/cardsfolder/a/armor_of_thorns.txt +++ b/res/cardsfolder/a/armor_of_thorns.txt @@ -4,7 +4,7 @@ Types:Enchantment Aura Text:no text K:You may cast CARDNAME as though it had flash. If you cast it any time a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step. K:Enchant nonblack creature -T:Mode$ SpellCast | ValidCard$ Card.Self | Execute$ TrigDelayedSac | Static$ True | Secondary$ True | TriggerDescription$ If you cast it any time a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step. +T:Mode$ SpellCast | ValidCard$ Card.Self | Execute$ TrigDelayedSac | Static$ True | Secondary$ True | SpellSpeed$ NotSorcerySpeed | TriggerDescription$ If you cast it any time a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step. SVar:TrigDelayedSac:AB$ Animate | Cost$ 0 | Defined$ Self | Triggers$ CleanupTrig | sVars$ Sac | Permanent$ True SVar:CleanupTrig:Mode$ Phase | Phase$ Cleanup | TriggerZones$ Battlefield | Execute$ Sac | TriggerDescription$ At the beginning of the next cleanup step, sacrifice CARDNAME. SVar:Sac:AB$ Sacrifice | Cost$ 0 | Defined$ Self diff --git a/src/main/java/forge/card/trigger/TriggerSpellAbilityCast.java b/src/main/java/forge/card/trigger/TriggerSpellAbilityCast.java index 3bddea95aae..5c574ad76cb 100644 --- a/src/main/java/forge/card/trigger/TriggerSpellAbilityCast.java +++ b/src/main/java/forge/card/trigger/TriggerSpellAbilityCast.java @@ -166,17 +166,22 @@ public class TriggerSpellAbilityCast extends Trigger { } if (this.getMapParams().containsKey("SpellSpeed")) { - if (this.getHostCard().hasKeyword("You may cast CARDNAME as though it had flash. If you cast it any time " - + "a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it " - + "at the beginning of the next cleanup step.") - && (this.getHostCard().hasKeyword("Flash") || this.getHostCard().hasKeyword("HIDDEN Flash") - || this.getHostCard().getController().hasKeyword("You may cast nonland cards as though they had flash."))) { + if (this.getMapParams().get("SpellSpeed").equals("NotSorcerySpeed")) { + boolean notSorcerySpeed = true; + if (PhaseHandler.couldCastSorcery(this.getHostCard().getController(), spellAbility)) { + notSorcerySpeed = false; + } else if (this.getHostCard().hasKeyword("You may cast CARDNAME as though it had flash. If you cast it any time a " + + "sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning" + + " of the next cleanup step.") && !PhaseHandler.couldCastSorcery(this.getHostCard().getController(), spellAbility)) { + boolean instantmentCast = true; // for these cards the trigger must only fire if using their own ability to cast at instant speed - return false; - } - else if (this.getMapParams().get("SpellSpeed").equals("NotSorcerySpeed") - && PhaseHandler.couldCastSorcery(this.getHostCard().getController(), spellAbility)) { - return false; + if (this.getHostCard().hasKeyword("Flash") || this.getHostCard().hasKeyword("HIDDEN Flash") + || this.getHostCard().getController().hasKeyword("You may cast nonland cards as though they had flash.")) { + instantmentCast = false; + } + notSorcerySpeed = instantmentCast; + } + return notSorcerySpeed; } } diff --git a/src/main/java/forge/game/phase/PhaseHandler.java b/src/main/java/forge/game/phase/PhaseHandler.java index 140431523ad..378532aaf6f 100644 --- a/src/main/java/forge/game/phase/PhaseHandler.java +++ b/src/main/java/forge/game/phase/PhaseHandler.java @@ -997,14 +997,19 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { public static boolean couldCastSorcery(final Player player, final SpellAbility sa) { PhaseHandler now = Singletons.getModel().getGameState().getPhaseHandler(); final Card source = sa.getRootSpellAbility().getSourceCard(); + boolean onlyThis = true; if (AllZone.getStack().size() != 0) { for (final Card card : AllZoneUtil.getCardsIn(ZoneType.Stack)) { if (card != source) { - return false; + onlyThis = false; + //System.out.println("StackCard: " + card + " vs SourceCard: " + source); } } } - return now.isPlayerTurn(player) && now.getPhase().isMain(); + //System.out.println("now.isPlayerTurn(player) - " + now.isPlayerTurn(player)); + //System.out.println("now.getPhase().isMain() - " + now.getPhase().isMain()); + //System.out.println("onlyThis - " + onlyThis); + return now.isPlayerTurn(player) && now.getPhase().isMain() && onlyThis; }