1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 01:01:05 -09:00

Added and fixed tests for Meddling Mage from

This commit is contained in:
Oleg Agafonov 2020-06-12 10:15:55 +04:00
parent 9ebdad04ab
commit 8902fb1002
4 changed files with 244 additions and 48 deletions
Mage.Tests/src/test/java/org/mage/test
cards
abilities
restriction
player

View file

@ -25,7 +25,6 @@ public class ChaosWandTest extends CardTestPlayerBase {
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{4}, {T}: ");
addTarget(playerA, playerB);
setChoice(playerA, "Yes"); // cast for free
setChoice(playerA, "Cast Blood Tithe");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);

View file

@ -223,7 +223,6 @@ public class SuspendTest extends CardTestPlayerBase {
checkExileCount("after counter", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 1);
// 3 time counters removes on upkeep (3, 5, 7) and cast again
setChoice(playerA, "Cast");
addTarget(playerA, playerB);
checkLife("after suspend", 7, PhaseStep.PRECOMBAT_MAIN, playerB, 20 - 3);
checkGraveyardCount("after suspend", 7, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 1);
@ -258,7 +257,6 @@ public class SuspendTest extends CardTestPlayerBase {
checkExileCount("after counter", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wear // Tear", 1);
// 3 time counters removes on upkeep (3, 5, 7) and cast again
setChoice(playerA, "Cast Wear");
addTarget(playerA, "Bident of Thassa");
checkPermanentCount("after suspend", 7, PhaseStep.PRECOMBAT_MAIN, playerB, "Bident of Thassa", 0);
checkPermanentCount("after suspend", 7, PhaseStep.PRECOMBAT_MAIN, playerB, "Bow of Nylea", 1);

View file

@ -0,0 +1,195 @@
package org.mage.test.cards.restriction;
import mage.constants.EmptyNames;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class MeddlingMageTest extends CardTestPlayerBase {
//As Meddling Mage enters the battlefield, choose a nonland card name. Spells with the chosen name can't be cast.
@Test
public void testMeddlingMageDefaultScenario() {
addCard(Zone.HAND, playerA, "Meddling Mage");
addCard(Zone.HAND, playerA, "Savannah Lions");
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Savannah Lions", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Savannah Lions"); // name a spell that can't be cast
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Savannah Lions", false);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertPermanentCount(playerA, "Savannah Lions", 0);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Savannah Lions", 1);
}
@Test
public void testMeddlingMageIsochronScepterScenario() {
addCard(Zone.HAND, playerA, "Meddling Mage");
addCard(Zone.HAND, playerA, "Isochron Scepter");
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Lightning Bolt"); // name a spell that can't be cast
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Isochron Scepter");
setChoice(playerA, "Yes"); // use imprint
setChoice(playerA, "Lightning Bolt"); // target for imprint
// copy and cast imprinted card
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{2}, {T}:");
setChoice(playerA, "Yes"); // create copy
setChoice(playerA, "Yes"); // cast copy
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertPermanentCount(playerA, "Isochron Scepter", 1);
assertExileCount("Lightning Bolt", 1);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
@Test
public void testMeddlingMageFaceDownCreature() {
addCard(Zone.HAND, playerA, "Meddling Mage");
addCard(Zone.HAND, playerA, "Ainok Tracker"); // red morph creature to prevent it casting from Islands and Plains
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Ainok Tracker"); // name a spell that can't be cast
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ainok Tracker");
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Ainok Tracker", 0);
}
@Test
public void testMeddlingMageFuseCardStopAndCastWell() {
addCard(Zone.HAND, playerA, "Meddling Mage");
// Create a 3/3 green Centaur creature token.
// You gain 2 life for each creature you control.
addCard(Zone.HAND, playerA, "Alive // Well"); // {3}{G} // {W}
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Well"); // name a spell that can't be cast
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Alive", true);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Well", false);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "fused Alive // Well", false);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Alive // Well", 1);
assertLife(playerA, 20);
}
@Test
public void testMeddlingMageFuseCardStopAliveAndCastWell() {
addCard(Zone.HAND, playerA, "Meddling Mage");
// Create a 3/3 green Centaur creature token.
// You gain 2 life for each creature you control.
addCard(Zone.HAND, playerA, "Alive // Well"); // {3}{G} // {W}
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Alive"); // name a spell that can't be cast
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Alive", false);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Well", true);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "fused Alive // Well", false);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Well");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Alive // Well", 0);
assertLife(playerA, 22);
}
@Test
public void testMeddlingMageFuseCardStopAliveAndCastFused() {
addCard(Zone.HAND, playerA, "Meddling Mage");
// Create a 3/3 green Centaur creature token.
// You gain 2 life for each creature you control.
addCard(Zone.HAND, playerA, "Alive // Well"); // {3}{G} // {W}
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Meddling Mage");
setChoice(playerA, "Alive"); // name a spell that can't be cast
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Alive", false);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Well", true);
checkPlayableAbility("all", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "fused Alive // Well", false);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Alive // Well", 1);
assertLife(playerA, 20);
}
}

View file

@ -1,10 +1,5 @@
package org.mage.test.player;
import java.io.Serializable;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import mage.MageItem;
import mage.MageObject;
import mage.MageObjectReference;
@ -62,6 +57,13 @@ import mage.util.CardUtil;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Ignore;
import java.io.Serializable;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl.*;
/**
@ -1444,7 +1446,7 @@ public class TestPlayer implements Player {
UUID defenderId = null;
boolean mustAttackByAction = false;
boolean madeAttackByAction = false;
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext();) {
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext(); ) {
PlayerAction action = it.next();
// aiXXX commands
@ -3833,12 +3835,14 @@ public class TestPlayer implements Player {
@Override
public SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana) {
String allInfo = "";
assertAliasSupportInChoices(false);
Map<UUID, ActivatedAbility> useable = PlayerImpl.getSpellAbilities(this.getId(), card, game.getState().getZone(card.getId()), game);
allInfo = useable.values().stream().map(Object::toString).collect(Collectors.joining("\n"));
String allInfo = useable.values().stream().map(Object::toString).collect(Collectors.joining("\n"));
if (useable.size() == 1) {
return (SpellAbility) useable.values().iterator().next();
}
assertAliasSupportInChoices(false);
if (!choices.isEmpty()) {
for (ActivatedAbility ability : useable.values()) {
if (ability.toString().startsWith(choices.get(0))) {