Search in sources :

Example 16 with DeckCardLists

use of mage.cards.decks.DeckCardLists in project mage by magefree.

the class CardTestPlayerAPIImpl method createPlayer.

protected TestPlayer createPlayer(Game game, TestPlayer player, String name, String deckName) throws GameException {
    player = createNewPlayer(name, game.getRangeOfInfluence());
    player.setTestMode(true);
    logger.debug("Loading deck...");
    DeckCardLists list;
    if (loadedDecks.containsKey(deckName)) {
        list = loadedDecks.get(deckName);
    } else {
        list = DeckImporter.importDeckFromFile(deckName, true);
        loadedDecks.put(deckName, list);
    }
    Deck deck = Deck.load(list, false, false, loadedCardInfo);
    logger.debug("Done!");
    if (deck.getCards().size() < 40) {
        throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
    }
    game.loadCards(deck.getCards(), player.getId());
    game.loadCards(deck.getSideboard(), player.getId());
    game.addPlayer(player, deck);
    // fake match
    currentMatch.addPlayer(player, deck);
    return player;
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) Deck(mage.cards.decks.Deck)

Example 17 with DeckCardLists

use of mage.cards.decks.DeckCardLists in project mage by magefree.

the class DeckTestUtils method buildRandomDeckAndInitCards.

public static DeckCardLists buildRandomDeckAndInitCards(String colors, boolean onlyBasicLands, String allowedSets) {
    Deck deck = buildRandomDeck(colors, onlyBasicLands, allowedSets);
    DeckCardLists deckList = new DeckCardLists();
    for (Card card : deck.getCards()) {
        CardInfo cardInfo = CardRepository.instance.findCard(card.getExpansionSetCode(), card.getCardNumber());
        if (cardInfo != null) {
            deckList.getCards().add(new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode()));
        }
    }
    return deckList;
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) DeckCardInfo(mage.cards.decks.DeckCardInfo) Deck(mage.cards.decks.Deck) DeckCardInfo(mage.cards.decks.DeckCardInfo) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card)

Example 18 with DeckCardLists

use of mage.cards.decks.DeckCardLists in project mage by magefree.

the class RandomTest method test_SeedAndSameRandomDecks.

@Test
public void test_SeedAndSameRandomDecks() {
    RandomUtil.setSeed(123);
    DeckCardLists listSameA = DeckTestUtils.buildRandomDeckAndInitCards("WGUBR", false, "GRN");
    String infoSameA = listSameA.getCards().stream().map(c -> (c.getSetCode() + "-" + c.getCardName())).collect(Collectors.joining(","));
    RandomUtil.setSeed(321);
    DeckCardLists listDifferent = DeckTestUtils.buildRandomDeckAndInitCards("WGUBR", false, "GRN");
    String infoDifferent = listDifferent.getCards().stream().map(c -> (c.getSetCode() + "-" + c.getCardName())).collect(Collectors.joining(","));
    RandomUtil.setSeed(123);
    DeckCardLists listSameB = DeckTestUtils.buildRandomDeckAndInitCards("WGUBR", false, "GRN");
    String infoSameB = listSameB.getCards().stream().map(c -> (c.getSetCode() + "-" + c.getCardName())).collect(Collectors.joining(","));
    Assert.assertEquals("same seed must have same deck", infoSameA, infoSameB);
    Assert.assertNotEquals("different seed must have different deck", infoSameA, infoDifferent);
}
Also used : BufferedImage(java.awt.image.BufferedImage) RangeOfInfluence(mage.constants.RangeOfInfluence) Deck(mage.cards.decks.Deck) MultiplayerAttackOption(mage.constants.MultiplayerAttackOption) Outcome(mage.constants.Outcome) Test(org.junit.Test) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Player(mage.players.Player) File(java.io.File) ArrayList(java.util.ArrayList) java.awt(java.awt) Game(mage.game.Game) List(java.util.List) MulliganType(mage.game.mulligan.MulliganType) HumanPlayer(mage.player.human.HumanPlayer) Ignore(org.junit.Ignore) TwoPlayerDuel(mage.game.TwoPlayerDuel) ImageIO(javax.imageio.ImageIO) PlanarDieRollResult(mage.constants.PlanarDieRollResult) DeckCardLists(mage.cards.decks.DeckCardLists) RandomUtil(mage.util.RandomUtil) Assert(org.junit.Assert) DeckCardLists(mage.cards.decks.DeckCardLists) Test(org.junit.Test)

Example 19 with DeckCardLists

use of mage.cards.decks.DeckCardLists in project mage by magefree.

the class CodDeckImportTest method testImport.

@Test
public void testImport() {
    CodDeckImporter importer = new CodDeckImporter() {

        @Override
        public CardLookup getCardLookup() {
            return LOOKUP;
        }
    };
    StringBuilder errors = new StringBuilder();
    DeckCardLists deck = importer.importDeck(Paths.get("src", "test", "data", "importer", "testdeck.cod").toString(), errors, false);
    assertEquals("Deck Name", deck.getName());
    TestDeckChecker.checker().addMain("Forest", 12).addMain("Razorverge Thicket", 100).addMain("Avacyn's Pilgrim", 1).addSide("War Priest of Thune", 3).verify(deck, 113, 3);
    assertEquals("Could not find card: '@#$NOT A REAL CARD NAME@#$'\n", errors.toString());
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) Test(org.junit.Test)

Example 20 with DeckCardLists

use of mage.cards.decks.DeckCardLists in project mage by magefree.

the class DraftLogImporterTest method testImport.

@Test
public void testImport() {
    StringBuilder errors = new StringBuilder();
    DraftLogImporter importer = new DraftLogImporter() {

        @Override
        public CardLookup getCardLookup() {
            return LOOKUP;
        }
    };
    DeckCardLists deck = importer.importDeck(Paths.get("src", "test", "data", "importer", "testdeck.draft").toString(), errors, false);
    TestDeckChecker.checker().addMain("Raging Ravine", 1).addMain("Fiery Temper", 1).addMain("Wild Mongrel", 1).addMain("Wild Mongrel", 1).addMain("Shielding Plax", 1).addMain("Wild Mongrel", 1).addMain("Basking Rootwalla", 1).addMain("Wild Mongrel", 1).addMain("Arena Athlete", 1).addMain("Undying Rage", 1).addMain("Molten Birth", 1).addMain("Shed Weakness", 1).addMain("Pulse of Murasa", 1).addMain("Just the Wind", 1).addMain("Stitcher's Apprentice", 1).addMain("Life from the Loam", 1).addMain("Satyr Wayfinder", 1).addMain("Mad Prophet", 1).addMain("Wild Mongrel", 1).addMain("Wickerbough Elder", 1).addMain("Basking Rootwalla", 1).addMain("Satyr Wayfinder", 1).addMain("Brawn", 1).addMain("Myr Servitor", 1).addMain("Terramorphic Expanse", 1).addMain("Foil", 1).addMain("Flight of Fancy", 1).addMain("Mark of the Vampire", 1).addMain("Repel the Darkness", 1).addMain("Golgari Charm", 1).addMain("Raid Bombardment", 1).addMain("Reckless Wurm", 1).addMain("Satyr Wayfinder", 1).addMain("Kodama's Reach", 1).addMain("Last Gasp", 1).addMain("Wild Mongrel", 1).addMain("Myr Servitor", 1).addMain("Raid Bombardment", 1).addMain("Treasure Cruise", 1).addMain("Bloodflow Connoisseur", 1).addMain("Treasure Cruise", 1).addMain("Hyena Umbra", 1).addMain("Kodama's Reach", 1).addMain("Just the Wind", 1).addMain("Flight of Fancy", 1).verify(deck, 45, 0);
    assertEquals("", errors.toString());
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) Test(org.junit.Test)

Aggregations

DeckCardLists (mage.cards.decks.DeckCardLists)23 Test (org.junit.Test)14 DeckCardInfo (mage.cards.decks.DeckCardInfo)5 File (java.io.File)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Deck (mage.cards.decks.Deck)3 MatchOptions (mage.game.match.MatchOptions)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CardInfo (mage.cards.repository.CardInfo)2 Ignore (org.junit.Ignore)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 java.awt (java.awt)1 BufferedImage (java.awt.image.BufferedImage)1 FileReader (java.io.FileReader)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 SecureRandom (java.security.SecureRandom)1 List (java.util.List)1 Scanner (java.util.Scanner)1