Search in sources :

Example 1 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class ComputerPlayer method addBasicLands.

private static void addBasicLands(Deck deck, String landName, int number) {
    Set<String> landSets = TournamentUtil.getLandSetCodeForDeckSets(deck.getExpansionSetCodes());
    CardCriteria criteria = new CardCriteria();
    if (!landSets.isEmpty()) {
        criteria.setCodes(landSets.toArray(new String[landSets.size()]));
    }
    criteria.rarities(Rarity.LAND).name(landName);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    if (cards.isEmpty()) {
        criteria = new CardCriteria();
        criteria.rarities(Rarity.LAND).name(landName);
        criteria.setCodes("M15");
        cards = CardRepository.instance.findCards(criteria);
    }
    for (int i = 0; i < number; i++) {
        Card land = cards.get(RandomUtil.nextInt(cards.size())).getCard();
        deck.getCards().add(land);
    }
}
Also used : CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo) RateCard(mage.game.draft.RateCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 2 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class AmonkhetCollator method generateBoosterMap.

@Override
protected void generateBoosterMap() {
    super.generateBoosterMap();
    CardRepository.instance.findCards(new CardCriteria().setCodes("MP2").maxCardNumber(30)).stream().forEach(cardInfo -> inBoosterMap.put("MP2_" + cardInfo.getCardNumber(), cardInfo));
}
Also used : CardCriteria(mage.cards.repository.CardCriteria)

Example 3 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class BattleForZendikarCollator method generateBoosterMap.

@Override
protected void generateBoosterMap() {
    super.generateBoosterMap();
    CardRepository.instance.findCards(new CardCriteria().setCodes("EXP").maxCardNumber(25)).stream().forEach(cardInfo -> inBoosterMap.put("EXP_" + cardInfo.getCardNumber(), cardInfo));
}
Also used : CardCriteria(mage.cards.repository.CardCriteria)

Example 4 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class DeckGenerator method generateDeck.

/**
 * Generates all the cards to use in the deck. Adds creatures,
 * non-creatures, lands (including non-basic). Fixes the deck, adjusting for
 * size and color of the cards retrieved.
 *
 * @param deckSize      how big the deck is to generate.
 * @param allowedColors which colors are allowed in the deck.
 * @param setsToUse     which sets to use to retrieve cards for this deck.
 * @return the final deck to use.
 */
private static Deck generateDeck(int deckSize, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) {
    genPool = new DeckGeneratorPool(deckSize, genDialog.getCreaturePercentage(), genDialog.getNonCreaturePercentage(), genDialog.getLandPercentage(), allowedColors, genDialog.isSingleton(), genDialog.isColorless(), genDialog.isAdvanced(), genDialog.getDeckGeneratorCMC());
    final String[] sets = setsToUse.toArray(new String[setsToUse.size()]);
    // Creatures
    final CardCriteria creatureCriteria = new CardCriteria();
    creatureCriteria.setCodes(sets);
    creatureCriteria.notTypes(CardType.LAND);
    creatureCriteria.types(CardType.CREATURE);
    if (!(genDialog.useArtifacts())) {
        creatureCriteria.notTypes(CardType.ARTIFACT);
    }
    // Non-creatures (sorcery, instant, enchantment, artifact etc.)
    final CardCriteria nonCreatureCriteria = new CardCriteria();
    nonCreatureCriteria.setCodes(sets);
    nonCreatureCriteria.notTypes(CardType.LAND);
    nonCreatureCriteria.notTypes(CardType.CREATURE);
    if (!(genDialog.useArtifacts())) {
        nonCreatureCriteria.notTypes(CardType.ARTIFACT);
    }
    // Non-basic land
    final CardCriteria nonBasicLandCriteria = new CardCriteria();
    nonBasicLandCriteria.setCodes(sets);
    nonBasicLandCriteria.types(CardType.LAND);
    nonBasicLandCriteria.notSupertypes(SuperType.BASIC);
    // Generate basic land cards
    Map<String, List<CardInfo>> basicLands = generateBasicLands(setsToUse);
    generateSpells(creatureCriteria, genPool.getCreatureCount());
    generateSpells(nonCreatureCriteria, genPool.getNonCreatureCount());
    generateLands(nonBasicLandCriteria, genPool.getLandCount(), basicLands);
    // Reconstructs the final deck and adjusts for Math rounding and/or missing cards
    return genPool.getDeck();
}
Also used : CardCriteria(mage.cards.repository.CardCriteria)

Example 5 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class DeckGenerator method generateBasicLands.

/**
 * Returns a map of colored mana symbol to basic land cards of that color.
 *
 * @param setsToUse which sets to retrieve basic lands from.
 * @return a map of color to basic lands.
 */
private static Map<String, List<CardInfo>> generateBasicLands(List<String> setsToUse) {
    Set<String> landSets = TournamentUtil.getLandSetCodeForDeckSets(setsToUse);
    CardCriteria criteria = new CardCriteria();
    if (!landSets.isEmpty()) {
        criteria.setCodes(landSets.toArray(new String[landSets.size()]));
    }
    criteria.ignoreSetsWithSnowLands();
    Map<String, List<CardInfo>> basicLandMap = new HashMap<>();
    for (ColoredManaSymbol c : ColoredManaSymbol.values()) {
        String landName = DeckGeneratorPool.getBasicLandName(c.toString());
        criteria.rarities(Rarity.LAND).name(landName);
        List<CardInfo> cards = CardRepository.instance.findCards(criteria);
        if (cards.isEmpty()) {
            // Workaround to get basic lands if lands are not available for the given sets
            criteria.setCodes("M15");
            cards = CardRepository.instance.findCards(criteria);
        }
        basicLandMap.put(landName, cards);
    }
    return basicLandMap;
}
Also used : ColoredManaSymbol(mage.constants.ColoredManaSymbol) CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo)

Aggregations

CardCriteria (mage.cards.repository.CardCriteria)25 CardInfo (mage.cards.repository.CardInfo)14 Card (mage.cards.Card)6 DeckCardInfo (mage.cards.decks.DeckCardInfo)3 Player (mage.players.Player)3 java.util (java.util)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 Choice (mage.choices.Choice)2 ChoiceImpl (mage.choices.ChoiceImpl)2 NaturalOrderCardNumberComparator (mage.client.util.NaturalOrderCardNumberComparator)2 ColoredManaSymbol (mage.constants.ColoredManaSymbol)2 Token (mage.game.permanent.token.Token)2 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1