diff --git a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java index 63460382ab2..985256280ea 100644 --- a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java +++ b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java @@ -4,10 +4,10 @@ import mage.MageIdentifier; import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; -import mage.abilities.keyword.FlashbackAbility; import mage.abilities.keyword.FlyingAbility; import mage.cards.Card; import mage.cards.CardImpl; @@ -80,18 +80,37 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - if (source instanceof FlashbackAbility - || !affectedControllerId.equals(source.getControllerId()) + throw new IllegalArgumentException("Wrong code usage: can't call applies method on empty affectedAbility"); + } + + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { + // Only during your turn + if (!playerId.equals(source.getControllerId()) + || !game.isActivePlayer(source.getControllerId())) { + return false; + } + // Only if source is this. + if (!playerId.equals(source.getControllerId()) || !game.isActivePlayer(source.getControllerId())) { return false; } Card card = game.getCard(objectId); + // Only for cards in your graveyard if (card == null - || !card.isInstantOrSorcery(game) - || !game.getState().getZone(objectId).equals(Zone.GRAVEYARD) + || !game.getState().getZone(card.getMainCard().getId()).equals(Zone.GRAVEYARD) || !card.isOwnedBy(source.getControllerId())) { return false; } + SpellAbility spell = (SpellAbility) affectedAbility; + if (spell == null || spell.getManaCosts().isEmpty()) { + return false; // prevent casting cards without mana cost? + } + Card cardToCheck = spell.getCharacteristics(game); + if (!cardToCheck.isInstantOrSorcery(game)) { + return false; + } + // check if not already a card was cast this turn with this ability KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class); return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/c17/KessDissidentMageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/c17/KessDissidentMageTest.java index 36684010cc0..734173a1726 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/c17/KessDissidentMageTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/c17/KessDissidentMageTest.java @@ -2,7 +2,6 @@ package org.mage.test.cards.single.c17; import mage.constants.PhaseStep; import mage.constants.Zone; -import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -129,7 +128,6 @@ public class KessDissidentMageTest extends CardTestPlayerBase { } @Test - @Ignore("failing, see issue #11924") public void testKessCastAdventureAfterDeath() { addCard(Zone.BATTLEFIELD, playerA, kess); addCard(Zone.GRAVEYARD, playerA, lifegain); @@ -151,6 +149,7 @@ public class KessDissidentMageTest extends CardTestPlayerBase { checkPlayableAbility("creature", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + unicorn, false); checkPlayableAbility("adventure", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + rider, true); castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, rider); + setChoice(playerA, "Kess, Dissident Mage"); // Test sees 2 ways to cast the Adventure, actual game only shows the one. checkPlayableAbility("already used", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast " + lifegain, false);