mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
* Buyback abilities - fixed that AI can't cast cards with buyback for normal cost (AI don't use buyback now);
This commit is contained in:
parent
1ae9fc883e
commit
bcb37992cc
2 changed files with 30 additions and 5 deletions
|
|
@ -1,13 +1,12 @@
|
||||||
|
|
||||||
package org.mage.test.cards.abilities.keywords;
|
package org.mage.test.cards.abilities.keywords;
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class BuybackTest extends CardTestPlayerBase {
|
public class BuybackTest extends CardTestPlayerBase {
|
||||||
|
|
@ -16,7 +15,7 @@ public class BuybackTest extends CardTestPlayerBase {
|
||||||
* Tests boosting on being blocked
|
* Tests boosting on being blocked
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNormal() {
|
public void testNormal_User() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
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.)
|
// 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}
|
addCard(Zone.HAND, playerA, "Elvish Fury", 1); // Instant {G}
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elvish Fury", "Silvercoat Lion");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elvish Fury", "Silvercoat Lion");
|
||||||
|
setChoice(playerA, "Yes"); // use buyback
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
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);
|
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4);
|
||||||
assertHandCount(playerA, "Elvish Fury", 1);
|
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 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.
|
* it fizzled (by failing to target) when it should go to graveyard.
|
||||||
*
|
* <p>
|
||||||
* "Q: If I pay a spell's buyback cost, but it fizzles, do I get the card
|
* "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
|
* 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
|
* during the spell's resolution. So if it never resolves (i.e., something
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,9 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS
|
||||||
Player player = game.getPlayer(ability.getControllerId());
|
Player player = game.getPlayer(ability.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
this.resetBuyback(game);
|
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);
|
activateBuyback(game, true);
|
||||||
for (Iterator it = ((Costs) buybackCost).iterator(); it.hasNext(); ) {
|
for (Iterator it = ((Costs) buybackCost).iterator(); it.hasNext(); ) {
|
||||||
Cost cost = (Cost) it.next();
|
Cost cost = (Cost) it.next();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue