[C15] Added Myriad keyword.

This commit is contained in:
LevelX2 2015-11-08 11:51:36 +01:00
parent 7572c756c4
commit 6f2d3a18c0
12 changed files with 300 additions and 64 deletions

View file

@ -0,0 +1,123 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.multiplayer;
import java.io.FileNotFoundException;
import mage.constants.MultiplayerAttackOption;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.constants.Zone;
import mage.game.FreeForAll;
import mage.game.Game;
import mage.game.GameException;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestMultiPlayerBase;
/**
*
* @author LevelX2
*/
public class MyriadTest extends CardTestMultiPlayerBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, 0, 40);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, playerA, "PlayerA");
playerB = createPlayer(game, playerB, "PlayerB");
playerC = createPlayer(game, playerC, "PlayerC");
playerD = createPlayer(game, playerD, "PlayerD");
return game;
}
/**
* Tests Myriad multiplayer effects Player order: A -> D -> C -> B
*/
@Test
public void CallerOfThePackTest() {
// Trample
// Myriad (Whenever this creature attacks, for each opponent other than the defending player, put a token that's a copy of this creature onto the battlefield tapped and attacking that player or a planeswalker he or she controls. Exile those tokens at the end of combat.)
addCard(Zone.BATTLEFIELD, playerD, "Caller of the Pack"); // 8/6
attack(2, playerD, "Caller of the Pack", playerA);
setStopAt(2, PhaseStep.DECLARE_BLOCKERS);
execute();
assertPermanentCount(playerD, "Caller of the Pack", 3);
}
@Test
public void CallerOfThePackTestExile() {
// Trample
// Myriad (Whenever this creature attacks, for each opponent other than the defending player, put a token that's a copy of this creature onto the battlefield tapped and attacking that player or a planeswalker he or she controls. Exile those tokens at the end of combat.)
addCard(Zone.BATTLEFIELD, playerD, "Caller of the Pack"); // 8/6
attack(2, playerD, "Caller of the Pack", playerA);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertPermanentCount(playerD, "Caller of the Pack", 1);
assertLife(playerA, 32);
assertLife(playerB, 32);
assertLife(playerC, 32);
assertLife(playerD, 40);
}
@Test
public void CallerOfThePackTestExilePlaneswalker() {
// Trample
// Myriad (Whenever this creature attacks, for each opponent other than the defending player, put a token that's a copy of this creature onto the battlefield tapped and attacking that player or a planeswalker he or she controls. Exile those tokens at the end of combat.)
addCard(Zone.BATTLEFIELD, playerD, "Caller of the Pack"); // 8/6
// +1: You gain 2 life.
// -1: Put a +1/+1 counter on each creature you control. Those creatures gain vigilance until end of turn.
// -6: Put a white Avatar creature token onto the battlefield. It has "This creature's power and toughness are each equal to your life total."
addCard(Zone.BATTLEFIELD, playerA, "Ajani Goldmane");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1:");
attack(2, playerD, "Caller of the Pack", playerC);
addTarget(playerD, "Ajani Goldmane");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertPermanentCount(playerD, "Caller of the Pack", 1);
assertGraveyardCount(playerA, "Ajani Goldmane", 1);
assertLife(playerA, 42);
assertLife(playerB, 32);
assertLife(playerC, 32);
assertLife(playerD, 40);
}
}

View file

@ -1,22 +1,18 @@
package org.mage.test.serverside.base;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.cards.decks.importer.DeckImporterUtil;
import java.io.FileNotFoundException;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.game.*;
import mage.game.permanent.Permanent;
import mage.players.Player;
import org.junit.Assert;
import mage.game.FreeForAll;
import mage.game.Game;
import mage.game.GameException;
import org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl;
import java.io.File;
import java.io.FileNotFoundException;
/**
* Base class for testing single cards and effects in multiplayer game.
* For PvP games {@see CardTestPlayerBase}
* Base class for testing single cards and effects in multiplayer game. For PvP
* games {
*
* @see CardTestPlayerBase}
*
* @author magenoxx_at_gmail.com
*/
@ -25,12 +21,12 @@ public abstract class CardTestMultiPlayerBase extends CardTestPlayerAPIImpl {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
Game game = new FreeForAll(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0, 20);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, playerA, "PlayerA");
playerB = createPlayer(game, playerB, "PlayerB");
playerC = createPlayer(game, playerC, "PlayerC");
playerD = createPlayer(game, playerD, "PlayerD");
return game;
}
}

View file

@ -55,13 +55,13 @@ public abstract class CardTestPlayerBaseAI extends CardTestPlayerAPIImpl {
}
@Override
protected TestPlayer createPlayer(String name) {
protected TestPlayer createPlayer(String name, RangeOfInfluence rangeOfInfluence) {
if (name.equals("PlayerA")) {
TestPlayer testPlayer = new TestPlayer(new ComputerPlayer7("PlayerA", RangeOfInfluence.ONE, skill));
testPlayer.setAIPlayer(true);
return testPlayer;
}
return super.createPlayer(name);
return super.createPlayer(name, rangeOfInfluence);
}
public void setAISkill(int skill) {

View file

@ -1,15 +1,26 @@
package org.mage.test.serverside.base;
import mage.constants.PhaseStep;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.cards.Card;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.match.MatchType;
import mage.game.permanent.PermanentCard;
import mage.game.tournament.TournamentType;
import mage.player.ai.ComputerPlayer;
import mage.players.Player;
import mage.server.game.GameFactory;
import mage.server.util.ConfigSettings;
@ -22,20 +33,13 @@ import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.mage.test.player.TestPlayer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.player.ai.ComputerPlayer;
/**
* Base class for all tests.
*
* @author ayratn
*/
public abstract class MageTestPlayerBase {
protected static Logger logger = Logger.getLogger(MageTestPlayerBase.class);
public static PluginClassLoader classLoader = new PluginClassLoader();
@ -62,8 +66,7 @@ public abstract class MageTestPlayerBase {
protected static Game currentGame = null;
/**
* Player thats starts the game first.
* By default, it is ComputerA.
* Player thats starts the game first. By default, it is ComputerA.
*/
protected static Player activePlayer = null;
@ -72,6 +75,7 @@ public abstract class MageTestPlayerBase {
protected PhaseStep stopAtStep = PhaseStep.UNTAP;
protected enum ParserState {
INIT,
OPTIONS,
EXPECTED
@ -80,16 +84,11 @@ public abstract class MageTestPlayerBase {
protected ParserState parserState;
/**
* Expected results of the test.
* Read from test case in {@link String} based format:
* Expected results of the test. Read from test case in {@link String} based
* format:
* <p/>
* Example:
* turn:1
* result:won:ComputerA
* life:ComputerA:20
* life:ComputerB:0
* battlefield:ComputerB:Tine Shrike:0
* graveyard:ComputerB:Tine Shrike:1
* Example: turn:1 result:won:ComputerA life:ComputerA:20 life:ComputerB:0
* battlefield:ComputerB:Tine Shrike:0 graveyard:ComputerB:Tine Shrike:1
*/
protected List<String> expectedResults = new ArrayList<>();
@ -259,7 +258,7 @@ public abstract class MageTestPlayerBase {
logger.warn("Init string wasn't parsed: " + line);
}
}
private TestPlayer getPlayer(String name) {
switch (name) {
case "ComputerA":
@ -282,7 +281,7 @@ public abstract class MageTestPlayerBase {
handCards.put(player, hand);
return hand;
}
protected List<Card> getGraveCards(TestPlayer player) {
if (graveyardCards.containsKey(player)) {
return graveyardCards.get(player);
@ -319,7 +318,6 @@ public abstract class MageTestPlayerBase {
return command;
}
private void includeFrom(String line) throws FileNotFoundException {
String[] params = line.split(" ");
if (params.length == 2) {
@ -340,8 +338,8 @@ public abstract class MageTestPlayerBase {
}
}
protected TestPlayer createPlayer(String name) {
return new TestPlayer(new ComputerPlayer(name, RangeOfInfluence.ONE));
protected TestPlayer createPlayer(String name, RangeOfInfluence rangeOfInfluence) {
return new TestPlayer(new ComputerPlayer(name, rangeOfInfluence));
}
}

View file

@ -12,6 +12,7 @@ import mage.cards.repository.CardRepository;
import mage.cards.repository.CardScanner;
import mage.constants.CardType;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
@ -141,7 +142,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
protected TestPlayer createPlayer(Game game, TestPlayer player, String name, String deckName) throws GameException {
player = createNewPlayer(name);
player = createNewPlayer(name, game.getRangeOfInfluence());
player.setTestMode(true);
logger.debug("Loading deck...");
Deck deck = Deck.load(DeckImporterUtil.importDeck(deckName), false, false);
@ -187,8 +188,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
protected TestPlayer createNewPlayer(String playerName) {
return createPlayer(playerName);
protected TestPlayer createNewPlayer(String playerName, RangeOfInfluence rangeOfInfluence) {
return createPlayer(playerName, rangeOfInfluence);
}
protected Player getPlayerFromName(String playerName, String line) {