This commit is contained in:
Ingmar Goudt 2020-12-26 15:26:17 +01:00
commit 34e9c2fdfb
118 changed files with 3090 additions and 1075 deletions

View file

@ -0,0 +1,53 @@
package org.mage.test.AI.basic;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
/**
* @author JayDi85
*/
public class TargetAmountAITest extends CardTestPlayerBaseWithAIHelps {
@Test
public void test_AI_ChooseTargets() {
// Distribute four +1/+1 counters among any number of target creatures.
addCard(Zone.HAND, playerA, "Blessings of Nature", 1); // {4}{G}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
//
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 4); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 4); // 2/2
// ai must choose by special dialog, not full simulation
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blessings of Nature");
setStopAt(1, PhaseStep.END_TURN);
//setStrictChooseMode(true); // ai must choose
execute();
assertAllCommandsUsed();
assertPowerToughness(playerA, "Balduvian Bears", 2 + 4, 2 + 4); // boost one creature (it's just a choose code, so can be different from simulation results)
}
@Test
public void test_AI_SimulateTargets() {
// Distribute four +1/+1 counters among any number of target creatures.
addCard(Zone.HAND, playerA, "Blessings of Nature", 1); // {4}{G}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
//
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 4); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 4); // 2/2
// AI must put creatures on own permanents (all in one creature to boost it)
aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA);
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPowerToughness(playerA, "Balduvian Bears", 2 + 1, 2 + 1); // boost each possible creatures
assertPowerToughness(playerB, "Balduvian Bears", 2, 2); // no boost for enemy
}
}

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.conditional;
import mage.constants.PhaseStep;
@ -7,7 +6,6 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class LegendarySorceryTest extends CardTestPlayerBase {
@ -55,10 +53,13 @@ public class LegendarySorceryTest extends CardTestPlayerBase {
// Flying, first strike, vigilance, trample, haste, protection from black and from red
addCard(Zone.BATTLEFIELD, playerB, "Akroma, Angel of Wrath", 1); // Legendary
// can't cast cause you don't have a legendary creature (only opponent have)
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Urza's Ruinous Blast");
//setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
//assertAllCommandsUsed();
assertGraveyardCount(playerA, "Urza's Ruinous Blast", 0);

View file

@ -0,0 +1,46 @@
package org.mage.test.cards.single.cmr;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class ArchelosLagoonMysticTest extends CardTestPlayerBase {
@Test
public void test_Playable() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2 + 2); // add lands before Archelos, Lagoon Mystic to ignore ETB effects
// As long as Archelos, Lagoon Mystic is tapped, other permanents enter the battlefield tapped.
// As long as Archelos, Lagoon Mystic is untapped, other permanents enter the battlefield untapped.
addCard(Zone.BATTLEFIELD, playerA, "Archelos, Lagoon Mystic", 1);
//
addCard(Zone.HAND, playerA, "Grizzly Bears", 1); // {1}{G}
addCard(Zone.HAND, playerA, "Deranged Outcast", 1); // {1}{G}
// first - untapped
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentTapped("untapped", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Archelos, Lagoon Mystic", false, 1);
checkPermanentTapped("untapped", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", false, 1);
// prepare tapped mystic
attack(1, playerA, "Archelos, Lagoon Mystic", playerB);
checkPermanentTapped("tapped", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Archelos, Lagoon Mystic", true, 1);
// second - tapped
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Deranged Outcast");
waitStackResolved(1, PhaseStep.POSTCOMBAT_MAIN);
checkPermanentTapped("tapped", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Archelos, Lagoon Mystic", true, 1);
checkPermanentTapped("tapped", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Deranged Outcast", true, 1);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
}
}

View file

@ -0,0 +1,54 @@
package org.mage.test.cards.single.inv;
import mage.abilities.keyword.LandwalkAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class TravelersCloakTest extends CardTestPlayerBase {
@Test
public void test_MustHaveLandWalkOfTheChosenType() {
// Enchant creature
// As Traveler's Cloak enters the battlefield, choose a land type.
// When Traveler's Cloak enters the battlefield, draw a card.
// Enchanted creature has landwalk of the chosen type.
addCard(Zone.HAND, playerA, "Traveler's Cloak"); // {2}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
//
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
addCard(Zone.BATTLEFIELD, playerB, "Kitesail Corsair", 1);
// cast and assign landwalk ability to creature
checkAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", LandwalkAbility.class, false);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Traveler's Cloak", "Grizzly Bears");
setChoice(playerA, "Swamp"); // land type for landwalk
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", LandwalkAbility.class, true);
// check that it can't be blocked
attack(1, playerA, "Grizzly Bears");
runCode("check blocking", 1, PhaseStep.DECLARE_BLOCKERS, playerB, (info, player, game) -> {
Permanent blocker = game.getBattlefield().getAllActivePermanents()
.stream()
.filter(p -> p.getName().equals("Kitesail Corsair"))
.findFirst()
.get();
Assert.assertFalse("Grizzly Bears must be protected from blocking by Kitesail Corsair",
game.getCombat().getGroups().get(0).canBlock(blocker, game));
});
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
}
}

View file

@ -9,7 +9,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class ConspicuousSnoopTest extends CardTestPlayerBase {
@Test
public void testTopCardLibraryRevealed(){
public void test_TopCardLibraryRevealed() {
// Play with the top card of your library revealed.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
addCard(Zone.LIBRARY, playerA, "Swamp");
@ -23,43 +23,49 @@ public class ConspicuousSnoopTest extends CardTestPlayerBase {
}
@Test
public void castGoblinSpellsFromLibrary(){
public void test_castGoblinSpellsFromLibrary() {
skipInitShuffling();
removeAllCardsFromLibrary(playerA);
// You may cast Goblin spells from the top of your library.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
addCard(Zone.LIBRARY, playerA, "Goblin Lackey");
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
// Whenever Goblin Lackey deals damage to a player, you may put a Goblin permanent card from your hand onto the battlefield.
addCard(Zone.LIBRARY, playerA, "Atog", 1); // second from top
addCard(Zone.LIBRARY, playerA, "Goblin Lackey", 1); // first from top
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2 * 2);
// Whenever Goblin Lackey deals damage to a player, you may put a Goblin permanent card from your hand onto the battlefield.
checkPlayableAbility("can play goblin", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Goblin Lackey", true);
checkPlayableAbility("can't play non goblin before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Atog", false);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Goblin Lackey");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("can't play non goblin after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Atog", false);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Goblin Lackey", 1);
assertPermanentCount(playerA, "Goblin Lackey", 1);
}
@Test
public void hasActivatedAbilities(){
public void test_hasActivatedAbilities() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
// Play with the top card of your library revealed.
// You may cast Goblin spells from the top of your library.
// As long as the top card of your library is a Goblin card, Conspicuous Snoop has all activated abilities of that card.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
// {R}: Goblin Balloon Brigade gains flying until end of turn.
addCard(Zone.LIBRARY, playerA, "Goblin Balloon Brigade");
addCard(Zone.LIBRARY, playerA, "Goblin Balloon Brigade");
skipInitShuffling();
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertAbilityCount(playerA, "Conspicuous Snoop", ActivatedAbility.class, 3); // (2 X casts + gains flying )
}
}

View file

@ -79,8 +79,6 @@ public class CastSplitCardsWithSpliceTest extends CardTestPlayerBase {
addTarget(playerA, "Bow of Nylea"); // target right
// must used all mana
//showAvaileableMana("after", 1, PhaseStep.POSTCOMBAT_MAIN, playerA);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();

View file

@ -1956,7 +1956,7 @@ public class TestPlayer implements Player {
int index = 0;
for (Map.Entry<String, String> entry : rEffects.entrySet()) {
if (entry.getValue().startsWith(choice)) {
choices.remove(choice);
choices.remove(0);
return index;
}
index++;

View file

@ -14,8 +14,10 @@ import mage.players.Player;
import mage.players.PlayerType;
import mage.server.game.GameFactory;
import mage.server.game.PlayerFactory;
import mage.server.managers.ConfigSettings;
import mage.server.tournament.TournamentFactory;
import mage.server.util.ConfigSettings;
import mage.server.util.ConfigFactory;
import mage.server.util.ConfigWrapper;
import mage.server.util.PluginClassLoader;
import mage.server.util.config.GamePlugin;
import mage.server.util.config.Plugin;
@ -100,7 +102,7 @@ public abstract class MageTestBase {
public static void init() {
Logger.getRootLogger().setLevel(Level.DEBUG);
deleteSavedGames();
ConfigSettings config = ConfigSettings.instance;
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
config.getGameTypes().forEach((gameType) -> {
GameFactory.instance.addGameType(gameType.getName(), loadGameType(gameType), loadPlugin(gameType));
});

View file

@ -23,7 +23,9 @@ import mage.game.permanent.PermanentCard;
import mage.game.tournament.TournamentType;
import mage.players.Player;
import mage.server.game.GameFactory;
import mage.server.util.ConfigSettings;
import mage.server.managers.ConfigSettings;
import mage.server.util.ConfigFactory;
import mage.server.util.ConfigWrapper;
import mage.server.util.PluginClassLoader;
import mage.server.util.config.GamePlugin;
import mage.server.util.config.Plugin;
@ -114,7 +116,7 @@ public abstract class MageTestPlayerBase {
logger.debug("Default charset: " + Charset.defaultCharset());
deleteSavedGames();
ConfigSettings config = ConfigSettings.instance;
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
for (GamePlugin plugin : config.getGameTypes()) {
GameFactory.instance.addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
}