diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BuybackTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BuybackTest.java index bd125841f35..b42c28ce965 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BuybackTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BuybackTest.java @@ -1,13 +1,12 @@ - package org.mage.test.cards.abilities.keywords; import mage.constants.PhaseStep; import mage.constants.Zone; +import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author LevelX2 */ public class BuybackTest extends CardTestPlayerBase { @@ -16,7 +15,7 @@ public class BuybackTest extends CardTestPlayerBase { * Tests boosting on being blocked */ @Test - public void testNormal() { + public void testNormal_User() { addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); // Buyback {4} (You may pay an additional as you cast this spell. If you do, put this card into your hand as it resolves.) @@ -24,9 +23,33 @@ public class BuybackTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Elvish Fury", 1); // Instant {G} castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elvish Fury", "Silvercoat Lion"); + setChoice(playerA, "Yes"); // use buyback + setStrictChooseMode(true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); + + assertPowerToughness(playerA, "Silvercoat Lion", 4, 4); + assertHandCount(playerA, "Elvish Fury", 1); + } + + @Test + @Ignore // TODO: enable test after buyback ability will be supported by AI + public void testNormal_AI() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + // Buyback {4} (You may pay an additional as you cast this spell. If you do, put this card into your hand as it resolves.) + // Target creature gets +2/+2 until end of turn. + addCard(Zone.HAND, playerA, "Elvish Fury", 1); // Instant {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elvish Fury", "Silvercoat Lion"); + //setChoice(playerA, "Yes"); // use buyback - AI must choose + + //setStrictChooseMode(true); - AI must choose + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); assertPowerToughness(playerA, "Silvercoat Lion", 4, 4); assertHandCount(playerA, "Elvish Fury", 1); @@ -35,7 +58,7 @@ public class BuybackTest extends CardTestPlayerBase { /** * It seems that a spell with it's buyback cost paid returned to hand after * it fizzled (by failing to target) when it should go to graveyard. - * + *
* "Q: If I pay a spell's buyback cost, but it fizzles, do I get the card * back anyway? A: If you pay a buyback cost, you would get the card back * during the spell's resolution. So if it never resolves (i.e., something diff --git a/Mage/src/main/java/mage/abilities/keyword/BuybackAbility.java b/Mage/src/main/java/mage/abilities/keyword/BuybackAbility.java index 44d6b685a2a..28817daaf58 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BuybackAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BuybackAbility.java @@ -131,7 +131,9 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS Player player = game.getPlayer(ability.getControllerId()); if (player != null) { this.resetBuyback(game); - if (player.chooseUse(Outcome.Benefit, "Pay " + buybackCost.getText(false) + " ?", ability, game)) { + // TODO: add AI support to find mana available to pay buyback + // canPay checks only single mana available, not total mana usage + if (player.chooseUse(/*Outcome.Benefit*/ Outcome.AIDontUseIt, "Pay " + buybackCost.getText(false) + " ?", ability, game)) { activateBuyback(game, true); for (Iterator it = ((Costs) buybackCost).iterator(); it.hasNext(); ) { Cost cost = (Cost) it.next();