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;
}
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;
}
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);
}
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());
}
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());
}
Aggregations