Merge pull request #7584 from weirddan455/cascade

Implemented updated Cascade ruling 702.84a
This commit is contained in:
Oleg Agafonov 2021-02-22 23:03:56 +01:00 committed by GitHub
commit 39f6b69391
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 201 additions and 45 deletions

View file

@ -10,6 +10,7 @@ import mage.util.CardUtil;
import mage.util.ManaUtil;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.player.TestPlayer;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
@ -797,4 +798,69 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase {
execute();
assertAllCommandsUsed();
}
@Test
public void test_Cascade_ValkiGodOfLies() {
// https://magic.wizards.com/en/articles/archive/news/february-15-2021-banned-and-restricted-announcement
// For example, if you cast Bloodbraid Elf and exile Valki, God of Lies from your library,
// you'll be able to cast Valki but not Tibalt, Cosmic Impostor. On the other hand, if you
// exile Cosima, God of the Voyage, you may cast either Cosima or The Omenkeel, as each face
// has a lesser converted mana cost than Bloodbraid Elf.
removeAllCardsFromLibrary(playerA);
skipInitShuffling();
// Cascade
addCard(Zone.HAND, playerA, "Bloodbraid Elf"); // {2}{R}{G}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
//
addCard(Zone.LIBRARY, playerA, "Swamp", 2);
addCard(Zone.LIBRARY, playerA, "Valki, God of Lies", 1);
addCard(Zone.LIBRARY, playerA, "Island", 2);
// play elf with cascade
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bloodbraid Elf");
setChoice(playerA, "Yes"); // use free cast
//setChoice(playerA, "Cast Valki, God of Lies"); possible bug: you can see two spell abilities to choose, but only one allows here
setChoice(playerA, TestPlayer.CHOICE_SKIP); // no choices for valki's etb exile
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Valki, God of Lies", 1);
}
@Test
public void test_Cascade_CosimaGodOfTheVoyage() {
// https://magic.wizards.com/en/articles/archive/news/february-15-2021-banned-and-restricted-announcement
// For example, if you cast Bloodbraid Elf and exile Valki, God of Lies from your library,
// you'll be able to cast Valki but not Tibalt, Cosmic Impostor. On the other hand, if you
// exile Cosima, God of the Voyage, you may cast either Cosima or The Omenkeel, as each face
// has a lesser converted mana cost than Bloodbraid Elf.
removeAllCardsFromLibrary(playerA);
skipInitShuffling();
// Cascade
addCard(Zone.HAND, playerA, "Bloodbraid Elf"); // {2}{R}{G}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
//
addCard(Zone.LIBRARY, playerA, "Swamp", 2);
addCard(Zone.LIBRARY, playerA, "Cosima, God of the Voyage", 1);
addCard(Zone.LIBRARY, playerA, "Island", 2);
// play elf with cascade
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bloodbraid Elf");
setChoice(playerA, "Yes"); // use free cast
setChoice(playerA, "Cast The Omenkeel"); // can cast any side here
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "The Omenkeel", 1);
}
}

View file

@ -3777,6 +3777,21 @@ public class TestPlayer implements Player {
) {
assertAliasSupportInChoices(false);
if (!choices.isEmpty()) {
// skip choices
if (choices.get(0).equals(CHOICE_SKIP)) {
choices.remove(0);
if (cards.isEmpty()) {
// cancel button forced in GUI on no possible choices
return false;
} else {
Assert.assertTrue("found skip choice, but it require more choices, needs "
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
target.getTargets().size() >= target.getMinNumberOfTargets());
return true;
}
}
for (String choose2 : choices) {
// TODO: More targetting to fix
String[] targetList = choose2.split("\\^");