mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
refactor: fixed that TargetCard doesn't work with Zone.ALL;
This commit is contained in:
parent
bfceb07c58
commit
450f7bd907
13 changed files with 257 additions and 38 deletions
|
|
@ -2,13 +2,15 @@ package org.mage.test.cards.asthough;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.player.ai.ComputerPlayer7;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class PlayTopCardFromLibraryTest extends CardTestPlayerBase {
|
||||
public class PlayTopCardFromLibraryTest extends CardTestPlayerBaseWithAIHelps {
|
||||
|
||||
/*
|
||||
Bolas's Citadel
|
||||
|
|
@ -218,4 +220,146 @@ public class PlayTopCardFromLibraryTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, "Balduvian Bears", 0);
|
||||
assertPermanentCount(playerA, "Balduvian Bears", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_NoCards_Manual() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Forest", 1);
|
||||
addCard(Zone.LIBRARY, playerB, "Forest", 1);
|
||||
|
||||
// nothing to free cast
|
||||
attack(1, playerA, "Etali, Primal Storm");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_NoCards_AI() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Forest", 1);
|
||||
addCard(Zone.LIBRARY, playerB, "Forest", 1);
|
||||
|
||||
// ai must attack and nothing to free cast
|
||||
attack(1, playerA, "Etali, Primal Storm");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_OneCard_Manual() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Lightning Bolt", 1);
|
||||
addCard(Zone.LIBRARY, playerB, "Forest", 1);
|
||||
|
||||
attack(1, playerA, "Etali, Primal Storm");
|
||||
setChoice(playerA, true); // use free cast
|
||||
addTarget(playerA, playerB); // to damage
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6 - 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_OneCard_AI() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Lightning Bolt", 1);
|
||||
addCard(Zone.LIBRARY, playerB, "Forest", 1);
|
||||
|
||||
// ai must attack and free cast bolt to opponent's
|
||||
aiPlayStep(1, PhaseStep.DECLARE_ATTACKERS, playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6 - 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_MultipleCards_Manual() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Lightning Bolt", 1); // 3 damage
|
||||
addCard(Zone.LIBRARY, playerB, "Cleansing Screech", 1); // 4 damage
|
||||
|
||||
// choose cards one by one
|
||||
attack(1, playerA, "Etali, Primal Storm");
|
||||
// first card
|
||||
setChoice(playerA, "Cleansing Screech");
|
||||
setChoice(playerA, true); // use free
|
||||
addTarget(playerA, playerB);
|
||||
// last card (auto-chosen)
|
||||
setChoice(playerA, true); // use free
|
||||
addTarget(playerA, playerB);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6 - 4 - 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtaliPrimalStorm_MultipleCards_AI() {
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
removeAllCardsFromLibrary(playerB);
|
||||
|
||||
// Whenever Etali, Primal Storm attacks, exile the top card of each player's library,
|
||||
// then you may cast any number of nonland cards exiled this way without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Etali, Primal Storm", 1); // 6/6
|
||||
//
|
||||
addCard(Zone.LIBRARY, playerA, "Lightning Bolt", 1); // 3 damage
|
||||
addCard(Zone.LIBRARY, playerB, "Cleansing Screech", 1); // 4 damage
|
||||
|
||||
// ai must attack and free cast two cards
|
||||
// possible bug 1: game freeze due wrong dialog/selection logic
|
||||
// possible bug 2: TargetCard can't find ALL zone
|
||||
aiPlayStep(1, PhaseStep.DECLARE_ATTACKERS, playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 20 - 6 - 4 - 3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,12 +183,13 @@ public class ExileAndReturnUnderYourControlTest extends CardTestPlayerBase {
|
|||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Villainous Wealth", playerB);
|
||||
setChoice(playerA, "X=3");
|
||||
|
||||
// first card
|
||||
setChoice(playerA, "Mox Emerald");
|
||||
setChoice(playerA, "Yes");
|
||||
|
||||
// second card
|
||||
setChoice(playerA, "Mox Sapphire");
|
||||
setChoice(playerA, "Yes");
|
||||
|
||||
// last card
|
||||
// Quicken is auto-chosen since it's the last of the 3 cards. Only need to say Yes to casting for free.
|
||||
setChoice(playerA, "Yes");
|
||||
|
||||
|
|
|
|||
|
|
@ -2102,12 +2102,12 @@ public class TestPlayer implements Player {
|
|||
return "Ability: null";
|
||||
}
|
||||
|
||||
private String getInfo(Target target, Ability source, Game game) {
|
||||
private String getInfo(Target target, Ability source, Game game, Cards cards) {
|
||||
if (target == null) {
|
||||
return "Target: null";
|
||||
}
|
||||
UUID abilityControllerId = target.getAffectedAbilityControllerId(this.getId());
|
||||
Set<UUID> possibleTargets = target.possibleTargets(abilityControllerId, source, game);
|
||||
Set<UUID> possibleTargets = target.possibleTargets(abilityControllerId, source, game, cards);
|
||||
|
||||
return "Target: selected " + target.getSize() + ", possible " + possibleTargets.size()
|
||||
+ ", " + target.getClass().getSimpleName() + ": " + target.getMessage(game);
|
||||
|
|
@ -2480,7 +2480,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(source, game) + "\n" + getInfo(target, source, game));
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(source, game) + "\n" + getInfo(target, source, game, null));
|
||||
return computerPlayer.choose(outcome, target, source, game, options);
|
||||
}
|
||||
|
||||
|
|
@ -2806,7 +2806,7 @@ public class TestPlayer implements Player {
|
|||
Assert.fail(message);
|
||||
}
|
||||
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game));
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game, null));
|
||||
return computerPlayer.chooseTarget(outcome, target, source, game);
|
||||
}
|
||||
|
||||
|
|
@ -2849,7 +2849,7 @@ public class TestPlayer implements Player {
|
|||
LOGGER.warn("Wrong target");
|
||||
}
|
||||
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game));
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game, cards));
|
||||
return computerPlayer.chooseTarget(outcome, cards, target, source, game);
|
||||
}
|
||||
|
||||
|
|
@ -4320,7 +4320,7 @@ public class TestPlayer implements Player {
|
|||
assertWrongChoiceUsage(choices.size() > 0 ? choices.get(0) : "empty list");
|
||||
}
|
||||
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(source, game) + "\n" + getInfo(target, source, game));
|
||||
this.chooseStrictModeFailed("choice", game, getInfo(source, game) + "\n" + getInfo(target, source, game, cards));
|
||||
return computerPlayer.choose(outcome, cards, target, source, game);
|
||||
}
|
||||
|
||||
|
|
@ -4407,7 +4407,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game));
|
||||
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "\n" + getInfo(target, source, game, null));
|
||||
return computerPlayer.chooseTargetAmount(outcome, target, source, game);
|
||||
}
|
||||
|
||||
|
|
@ -4756,7 +4756,7 @@ public class TestPlayer implements Player {
|
|||
Assert.fail(String.format("Found wrong choice command (%s):\n%s\n%s\n%s",
|
||||
reason,
|
||||
lastChoice,
|
||||
getInfo(target, source, game),
|
||||
getInfo(target, source, game, null),
|
||||
getInfo(source, game)
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue