mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Added test for bug from #6937 (can cast cards with delve without full payment)
This commit is contained in:
parent
3430013f8d
commit
f69477d8d5
2 changed files with 61 additions and 0 deletions
|
@ -2,7 +2,9 @@ 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.player.TestPlayer;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
|
||||
|
||||
/**
|
||||
|
@ -81,4 +83,44 @@ public class DelveTest extends CardTestPlayerBaseWithAIHelps {
|
|||
|
||||
assertPermanentCount(playerA, "Ethereal Forager", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test_CheatWithCancel() {
|
||||
// possible bug: users can start to pay delve special action with nothing (done button) and gets no mana cast
|
||||
// https://github.com/magefree/mage/issues/6937
|
||||
|
||||
disableManaAutoPayment(playerA);
|
||||
removeAllCardsFromHand(playerA);
|
||||
|
||||
// Delve (Each card you exile from your graveyard while casting this spell pays for {1}.)
|
||||
// Draw 3 Cards
|
||||
addCard(Zone.HAND, playerA, "Treasure Cruise", 1); // {7}{U} sorcery
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
|
||||
addCard(Zone.GRAVEYARD, playerA, "Balduvian Bears", 7); // delve pay
|
||||
|
||||
// user case:
|
||||
// 1. Use mana from land (fill mana pool)
|
||||
// 2. Use delve as special action
|
||||
// 3. Press done without real delve pay
|
||||
// 4. All generic cost will be removed and card go to stack for {U} instead {7}{U}
|
||||
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treasure Cruise");
|
||||
//setChoice(playerA, "Blue");
|
||||
setChoice(playerA, "Exile cards"); // delve activate
|
||||
setChoice(playerA, TestPlayer.CHOICE_SKIP);
|
||||
setChoice(playerA, TestPlayer.MANA_CANCEL);
|
||||
|
||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
showGraveyard("hmm", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||
|
||||
// it uses bug with rollback, so test commands restores with rollback too (no strict or commands usage check)
|
||||
//setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
//assertAllCommandsUsed();
|
||||
|
||||
assertHandCount(playerA, 0); // no resolve, so no draw cards (if rollback bug active then it shows 3 cards)
|
||||
}
|
||||
}
|
|
@ -76,6 +76,8 @@ public class TestPlayer implements Player {
|
|||
private static final Logger LOGGER = Logger.getLogger(TestPlayer.class);
|
||||
|
||||
public static final String TARGET_SKIP = "[target_skip]"; // stop/skip targeting
|
||||
public static final String CHOICE_SKIP = "[choice_skip]"; // stop/skip choice
|
||||
public static final String MANA_CANCEL = "[mana_cancel]"; // cancel payment
|
||||
public static final String BLOCK_SKIP = "[block_skip]";
|
||||
public static final String ATTACK_SKIP = "[attack_skip]";
|
||||
public static final String NO_TARGET = "NO_TARGET"; // cast spell or activate ability without target defines
|
||||
|
@ -1909,6 +1911,16 @@ public class TestPlayer implements Player {
|
|||
|
||||
assertAliasSupportInChoices(true);
|
||||
if (!choices.isEmpty()) {
|
||||
|
||||
// skip choices
|
||||
if (choices.get(0).equals(CHOICE_SKIP)) {
|
||||
Assert.assertTrue("found skip choice, but it require more choices, needs "
|
||||
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
|
||||
target.getTargets().size() >= target.getMinNumberOfTargets());
|
||||
choices.remove(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Integer> usedChoices = new ArrayList<>();
|
||||
List<UUID> usedTargets = new ArrayList<>();
|
||||
|
||||
|
@ -3769,6 +3781,13 @@ public class TestPlayer implements Player {
|
|||
if (!computerPlayer.getManaPool().isAutoPayment()) {
|
||||
if (!choices.isEmpty()) {
|
||||
// manual pay by mana clicks/commands
|
||||
|
||||
// simulate cancel on mana payment (e.g. user press on cancel button)
|
||||
if (choices.get(0).equals(MANA_CANCEL)) {
|
||||
choices.remove(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
String choice = choices.get(0);
|
||||
boolean choiceUsed = false;
|
||||
boolean choiceRemoved = false;
|
||||
|
|
Loading…
Reference in a new issue