Esempio n. 1
0
  /**
   * 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, allowedColors, genDialog.isSingleton());

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