From a5eb02515571727b53e95604f1db4d11090e4d52 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Tue, 23 Nov 2021 00:55:24 +0400 Subject: [PATCH] * Sneak Attack - fixed that it doesn't give haste to MDF cards (#8474); --- Mage.Sets/src/mage/cards/s/SneakAttack.java | 3 +- .../ModalDoubleFacesCardsTest.java | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/s/SneakAttack.java b/Mage.Sets/src/mage/cards/s/SneakAttack.java index 9d0d750818..1f832a7ab5 100644 --- a/Mage.Sets/src/mage/cards/s/SneakAttack.java +++ b/Mage.Sets/src/mage/cards/s/SneakAttack.java @@ -22,6 +22,7 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCardInHand; import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; import java.util.UUID; @@ -80,7 +81,7 @@ class SneakAttackEffect extends OneShotEffect { if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { return false; } - Permanent permanent = game.getPermanent(card.getId()); + Permanent permanent = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId()); if (permanent == null) { return true; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/modaldoublefaces/ModalDoubleFacesCardsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/modaldoublefaces/ModalDoubleFacesCardsTest.java index c15e584363..5102c3debc 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/cost/modaldoublefaces/ModalDoubleFacesCardsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/modaldoublefaces/ModalDoubleFacesCardsTest.java @@ -1,5 +1,6 @@ package org.mage.test.cards.cost.modaldoublefaces; +import mage.abilities.keyword.HasteAbility; import mage.cards.Card; import mage.cards.ModalDoubleFacesCard; import mage.constants.PhaseStep; @@ -970,4 +971,33 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Valki, God of Lies", 0); assertPermanentCount(playerA, "Birgi, God of Storytelling", 1); } + + @Test + public void test_FindMovedPermanentByCard() { + // original problem: you must be able to find a card after move it to battlefield + // https://github.com/magefree/mage/issues/8474 + + // {R}: You may put a creature card from your hand onto the battlefield. That creature gains haste. + // Sacrifice the creature at the beginning of the next end step. + addCard(Zone.BATTLEFIELD, playerA, "Sneak Attack"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + // + addCard(Zone.HAND, playerA, "Akoum Warrior", 1); + + // move + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}:"); + setChoice(playerA, true); // yes, activate + setChoice(playerA, "Akoum Warrior"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + checkPermanentCount("after move", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akoum Warrior", 1); + checkAbility("must have haste after etb", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akoum Warrior", HasteAbility.class, true); + + // must sacrifice + checkPermanentCount("after sacrifice", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Akoum Warrior", 0); + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } } \ No newline at end of file