From ad637a29445128ab1e305e744f7aea069169bfa2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 14 Mar 2016 13:41:12 +0100 Subject: [PATCH] * Fixed CAST_SPELL_LATE event (e.g. used by Reflector Mage) to only fire for cast events. --- .../cards/single/ogw/ThoughtKnotSeerTest.java | 65 ++++++++++--------- .../main/java/mage/abilities/AbilityImpl.java | 3 +- .../LeavesBattlefieldTriggeredAbility.java | 2 +- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/ogw/ThoughtKnotSeerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/ogw/ThoughtKnotSeerTest.java index fa35e6c80ed..4252599d77a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/ogw/ThoughtKnotSeerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/ogw/ThoughtKnotSeerTest.java @@ -13,54 +13,55 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; public class ThoughtKnotSeerTest extends CardTestPlayerBase { - + /** - * Reported bug - * I bounced a Thought-Knot Seer my opponent controlled with enter the battlefield ability of a Reflector Mage. - * I should have drawn a card since the Thought-Knot Seer left the battlefield but I didn't. + * Reported bug I bounced a Thought-Knot Seer my opponent controlled with + * enter the battlefield ability of a Reflector Mage. I should have drawn a + * card since the Thought-Knot Seer left the battlefield but I didn't. */ @Test public void testThoughtKnotSeerBouncedReflectorMage() { - // {1}{W}{U} When Reflector Mage enters the battlefield, return target creature an opponent controls to its owner's hand. + // {1}{W}{U} When Reflector Mage enters the battlefield, return target creature an opponent controls to its owner's hand. // That creature's owner can't cast spells with the same name as that creature until your next turn. - addCard(Zone.HAND, playerA, "Reflector Mage"); // 2/3 - addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); - addCard(Zone.BATTLEFIELD, playerA, "Island", 2); - + addCard(Zone.HAND, playerA, "Reflector Mage"); // 2/3 + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + // {3}{<>} 4/4 // When Thought-Knot Seer enters the battlefield, target opponent reveals his or her hand. You choose a nonland card from it and exile that card. // When Thought-Knot Seer leaves the battlefield, target opponent draws a card. addCard(Zone.BATTLEFIELD, playerB, "Thought-Knot Seer"); addCard(Zone.BATTLEFIELD, playerB, "Wastes", 4); - + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Reflector Mage"); addTarget(playerA, "Thought-Knot Seer"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertHandCount(playerB, "Thought-Knot Seer", 1); - Set hand = playerA.getHand().getCards(currentGame); + assertPermanentCount(playerA, "Reflector Mage", 1); + assertHandCount(playerB, "Thought-Knot Seer", 1); assertHandCount(playerA, 1); // should have drawn a card from Thought-Knot Seer leaving } - + /** - * Simple bounce test on Thought-Knot Seer to differentiate between this and Reflector Mage issue + * Simple bounce test on Thought-Knot Seer to differentiate between this and + * Reflector Mage issue */ @Test public void testThoughtKnotSeerBouncedUnsummon() { // {U} Return target creature to its owner's hand. addCard(Zone.HAND, playerA, "Unsummon"); - addCard(Zone.BATTLEFIELD, playerA, "Island", 2); - + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + // {3}{<>} 4/4 // When Thought-Knot Seer enters the battlefield, target opponent reveals his or her hand. You choose a nonland card from it and exile that card. // When Thought-Knot Seer leaves the battlefield, target opponent draws a card. addCard(Zone.BATTLEFIELD, playerB, "Thought-Knot Seer"); addCard(Zone.BATTLEFIELD, playerB, "Wastes", 4); - + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Unsummon"); addTarget(playerA, "Thought-Knot Seer"); @@ -68,54 +69,54 @@ public class ThoughtKnotSeerTest extends CardTestPlayerBase { execute(); assertGraveyardCount(playerA, "Unsummon", 1); - assertHandCount(playerB, "Thought-Knot Seer", 1); + assertHandCount(playerB, "Thought-Knot Seer", 1); Set hand = playerA.getHand().getCards(currentGame); assertHandCount(playerA, 1); // should have drawn a card from Thought-Knot Seer leaving } - + /** - * + * */ @Test public void testThoughtKnotSeerDestroyed() { // {1}{B} Destroy target nonblack creature. - addCard(Zone.HAND, playerA, "Doom Blade"); - addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); - + addCard(Zone.HAND, playerA, "Doom Blade"); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + // {3}{<>} 4/4 // When Thought-Knot Seer enters the battlefield, target opponent reveals his or her hand. You choose a nonland card from it and exile that card. // When Thought-Knot Seer leaves the battlefield, target opponent draws a card. addCard(Zone.BATTLEFIELD, playerB, "Thought-Knot Seer"); addCard(Zone.BATTLEFIELD, playerB, "Wastes", 4); - + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Doom Blade"); addTarget(playerA, "Thought-Knot Seer"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertGraveyardCount(playerB, "Thought-Knot Seer", 1); + assertGraveyardCount(playerB, "Thought-Knot Seer", 1); Set hand = playerA.getHand().getCards(currentGame); assertHandCount(playerA, 1); // should have drawn a card from Thought-Knot Seer leaving } - + /** - * + * */ @Test public void testThoughtKnotSeerExiled() { // {W} Exile target creature. Its controller may search his or her library for a basic land card, put that card onto the battlefield tapped, then shuffle his or her library. - addCard(Zone.HAND, playerA, "Path to Exile"); - addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); - + addCard(Zone.HAND, playerA, "Path to Exile"); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); + // {3}{<>} 4/4 // When Thought-Knot Seer enters the battlefield, target opponent reveals his or her hand. You choose a nonland card from it and exile that card. // When Thought-Knot Seer leaves the battlefield, target opponent draws a card. addCard(Zone.BATTLEFIELD, playerB, "Thought-Knot Seer"); addCard(Zone.BATTLEFIELD, playerB, "Wastes", 4); - + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Path to Exile"); addTarget(playerA, "Thought-Knot Seer"); @@ -127,4 +128,4 @@ public class ThoughtKnotSeerTest extends CardTestPlayerBase { Set hand = playerA.getHand().getCards(currentGame); assertHandCount(playerA, 1); // should have drawn a card from Thought-Knot Seer leaving } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 90344ee1b63..9dd6cc256ee 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -315,7 +315,8 @@ public abstract class AbilityImpl implements Ability { VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller); String announceString = handleOtherXCosts(game, controller); // For effects from cards like Void Winnower x costs have to be set - if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) { + if (this.getAbilityType().equals(AbilityType.SPELL) + && game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) { return false; } for (Mode mode : this.getModes().getSelectedModes()) { diff --git a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldTriggeredAbility.java index 23a867af0dd..a333f2346cd 100644 --- a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldTriggeredAbility.java @@ -40,7 +40,7 @@ import mage.game.events.ZoneChangeEvent; public class LeavesBattlefieldTriggeredAbility extends ZoneChangeTriggeredAbility { public LeavesBattlefieldTriggeredAbility(Effect effect, boolean optional) { - super(Zone.BATTLEFIELD, null, effect, "When {this} leaves the battlefield, ", optional); + super(Zone.ALL, Zone.BATTLEFIELD, null, effect, "When {this} leaves the battlefield, ", optional); } public LeavesBattlefieldTriggeredAbility(LeavesBattlefieldTriggeredAbility ability) {