* Sneak Attack - fixed that it doesn't give haste to MDF cards (#8474);

This commit is contained in:
Oleg Agafonov 2021-11-23 00:55:24 +04:00
parent 30c2de5692
commit a5eb025155
2 changed files with 32 additions and 1 deletions

View file

@ -22,6 +22,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -80,7 +81,7 @@ class SneakAttackEffect extends OneShotEffect {
if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false; return false;
} }
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
if (permanent == null) { if (permanent == null) {
return true; return true;
} }

View file

@ -1,5 +1,6 @@
package org.mage.test.cards.cost.modaldoublefaces; package org.mage.test.cards.cost.modaldoublefaces;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.ModalDoubleFacesCard; import mage.cards.ModalDoubleFacesCard;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
@ -970,4 +971,33 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Valki, God of Lies", 0); assertPermanentCount(playerA, "Valki, God of Lies", 0);
assertPermanentCount(playerA, "Birgi, God of Storytelling", 1); 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();
}
} }