From c896ae24427d03885fbda55f1bb31ee203ea1e48 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 28 May 2015 15:12:00 +0200 Subject: [PATCH] * Deep-Sea Kraken - Fixed that the triggered ability to remove time counters did not work. --- .../mage/sets/timespiral/DeepSeaKraken.java | 3 ++- .../cards/abilities/keywords/SuspendTest.java | 25 +++++++++++++++++++ .../base/impl/CardTestPlayerAPIImpl.java | 24 ++++++++++++++++-- .../counter/RemoveCounterSourceEffect.java | 12 +++++---- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Mage.Sets/src/mage/sets/timespiral/DeepSeaKraken.java b/Mage.Sets/src/mage/sets/timespiral/DeepSeaKraken.java index fea5aba999..28b6e618f4 100644 --- a/Mage.Sets/src/mage/sets/timespiral/DeepSeaKraken.java +++ b/Mage.Sets/src/mage/sets/timespiral/DeepSeaKraken.java @@ -40,6 +40,7 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.TargetController; +import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.FilterSpell; import mage.filter.predicate.permanent.ControllerPredicate; @@ -69,7 +70,7 @@ public class DeepSeaKraken extends CardImpl { this.addAbility(new SuspendAbility(9, new ManaCostsImpl("{2}{U}"), this)); // Whenever an opponent casts a spell, if Deep-Sea Kraken is suspended, remove a time counter from it. this.addAbility(new ConditionalTriggeredAbility( - new SpellCastAllTriggeredAbility(new RemoveCounterSourceEffect(CounterType.TIME.createInstance()), filter, false), SuspendedCondition.getInstance(), + new SpellCastAllTriggeredAbility(Zone.EXILED, new RemoveCounterSourceEffect(CounterType.TIME.createInstance()), filter, false, false), SuspendedCondition.getInstance(), "Whenever an opponent casts a spell, if Deep-Sea Kraken is suspended, remove a time counter from it.", false)); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SuspendTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SuspendTest.java index 36824165d1..16de1ce561 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SuspendTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SuspendTest.java @@ -29,6 +29,7 @@ package org.mage.test.cards.abilities.keywords; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -114,4 +115,28 @@ public class SuspendTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Silvercoat Lion", 1); } + @Test + public void testDeepSeaKraken() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + // Suspend 9-{2}{U} + // Whenever an opponent casts a spell, if Deep-Sea Kraken is suspended, remove a time counter from it. + addCard(Zone.HAND, playerA, "Deep-Sea Kraken",1); + + // Instant {1}{U} + // Counter target spell. If the spell is countered this way, exile it with three time counters on it instead of putting it into its owner's graveyard. If it doesn't have suspend, it gains suspend. (At the beginning of its owner's upkeep, remove a counter from that card. When the last is removed, the player plays it without paying its mana cost. If it's a creature, it has haste.) + addCard(Zone.HAND, playerB, "Lightning Bolt",1); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Suspend"); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertGraveyardCount(playerB, "Lightning Bolt", 1); + assertExileCount("Deep-Sea Kraken", 1); + + assertCounterOnExiledCardCount("Deep-Sea Kraken", CounterType.TIME, 8); // -1 from spell of player B + + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 41f3b08e5b..1a3774626e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -490,12 +490,32 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement break; } } - Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found); - Assert.assertEquals("(Battlefield) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters().getCount(type)); } + /** + * Assert counter count on a card in exile + * + * @param cardName Name of the cards that should be counted. + * @param type Type of the counter that should be counted. + * @param count Expected count. + */ + public void assertCounterOnExiledCardCount(String cardName, CounterType type, int count) throws AssertionError { + Card found = null; + if (found == null) { + for (Card card : currentGame.getExile().getAllCards(currentGame)) { + if (card.getName().equals(cardName)) { + found = card; + break; + } + } + + } + Assert.assertNotNull("There is no such card in the exile, cardName=" + cardName, found); + Assert.assertEquals("(Exile) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters(currentGame).getCount(type)); + } + /** * Assert counter count on a player * diff --git a/Mage/src/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java b/Mage/src/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java index cd27ecfe52..6da3bf9cf0 100644 --- a/Mage/src/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java @@ -60,18 +60,20 @@ public class RemoveCounterSourceEffect extends OneShotEffect { Permanent p = game.getPermanent(source.getSourceId()); if (p != null && p.getCounters().getCount(counter.getName()) >= counter.getCount()) { p.removeCounters(counter.getName(), counter.getCount(), game); - if (!game.isSimulation()) + if (!game.isSimulation()) { game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(" ").append(counter.getName()) - .append(" counter from ").append(p.getName()).toString()); + .append(" counter from ").append(p.getName()).toString()); + } return true; } Card c = game.getCard(source.getSourceId()); if (c != null && c.getCounters(game).getCount(counter.getName()) >= counter.getCount()) { c.removeCounters(counter.getName(), counter.getCount(), game); - if (!game.isSimulation()) + if (!game.isSimulation()) { game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(" ").append(counter.getName()) - .append(" counter from ").append(c.getName()) - .append(" (").append(c.getCounters(game).getCount(counter.getName())).append(" left)").toString()); + .append(" counter from ").append(c.getName()) + .append(" (").append(c.getCounters(game).getCount(counter.getName())).append(" left)").toString()); + } return true; } return false;