[CMR] fixed Akroma's Will - missing copy of new condition in modes (#7210);

Improved compatibility of new modes condition with choose dialogs and test framework;
This commit is contained in:
Oleg Agafonov 2020-11-28 19:49:16 +04:00
parent 64821a50d3
commit 2b78388eab
5 changed files with 131 additions and 32 deletions

View file

@ -0,0 +1,81 @@
package org.mage.test.cards.single.cmr;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestCommanderDuelBase;
/**
* @author JayDi85
*/
public class AkromasWillTest extends CardTestCommanderDuelBase {
@Test
public void test_OneMode() {
// https://github.com/magefree/mage/issues/7210
// Choose one. If you control a commander as you cast this spell, you may choose both.
// * Creatures you control gain flying, vigilance, and double strike until end of turn.
// * Creatures you control gain lifelink, indestructible, and protection from all colors until end of turn.
addCard(Zone.HAND, playerA, "Akroma's Will", 1); // {3}{W}
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
//
addCard(Zone.BATTLEFIELD, playerA, "Kitesail Corsair", 1);
checkAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", FlyingAbility.class, false);
checkAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", LifelinkAbility.class, false);
// cast and use ONE mode only
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma's Will");
setModeChoice(playerA, "1");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", FlyingAbility.class, true);
checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", LifelinkAbility.class, false);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
}
@Test
public void test_MultiModesOnCommander() {
// https://github.com/magefree/mage/issues/7210
// Choose one. If you control a commander as you cast this spell, you may choose both.
// * Creatures you control gain flying, vigilance, and double strike until end of turn.
// * Creatures you control gain lifelink, indestructible, and protection from all colors until end of turn.
addCard(Zone.HAND, playerA, "Akroma's Will", 1); // {3}{W}
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
//
addCard(Zone.COMMAND, playerA, "Balduvian Bears", 1); // {1}{G}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
//
addCard(Zone.BATTLEFIELD, playerA, "Kitesail Corsair", 1);
checkAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", FlyingAbility.class, false);
checkAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", LifelinkAbility.class, false);
// prepare commander
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("commander on battle", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 1);
// cast and use two modes instead one
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma's Will");
setModeChoice(playerA, "2");
setModeChoice(playerA, "1");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", FlyingAbility.class, true);
checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kitesail Corsair", LifelinkAbility.class, true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
}
}

View file

@ -1869,7 +1869,7 @@ public class TestPlayer implements Player {
@Override
public Mode chooseMode(Modes modes, Ability source, Game game) {
if (!modesSet.isEmpty() && modes.getMaxModes() > modes.getSelectedModes().size()) {
if (!modesSet.isEmpty() && modes.getMaxModes(game, source) > modes.getSelectedModes().size()) {
// set mode to null to select less than maximum modes if multiple modes are allowed
if (modesSet.get(0) == null) {
modesSet.remove(0);