Пример #1
0
  protected static Deck buildDeck() {

    String selectedColors = genDialog.getSelectedColors();
    List<ColoredManaSymbol> allowedColors = new ArrayList<>();
    selectedColors = selectedColors != null ? selectedColors.toUpperCase() : getRandomColors("X");
    String format = genDialog.getSelectedFormat();

    List<String> setsToUse = ConstructedFormats.getSetsByFormat(format);
    if (setsToUse.isEmpty()) {
      // Default to using all sets
      setsToUse = ExpansionRepository.instance.getSetCodes();
    }

    int deckSize = genDialog.getDeckSize();

    if (selectedColors.contains("X")) {
      selectedColors = getRandomColors(selectedColors);
    }

    for (int i = 0; i < selectedColors.length(); i++) {
      char c = selectedColors.charAt(i);
      allowedColors.add(ColoredManaSymbol.lookup(c));
    }

    return generateDeck(deckSize, allowedColors, setsToUse);
  }
Пример #2
0
  /**
   * Builds a deck out of the selected block/set/format.
   *
   * @return a path to the generated deck.
   */
  public static String generateDeck() {

    genDialog = new DeckGeneratorDialog();
    if (genDialog.getSelectedColors() != null) {
      Deck deck = buildDeck();
      return genDialog.saveDeck(deck);
    }
    // If the deck couldn't be generated or the user cancelled, repopulate the deck selection with
    // its cached value
    return PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, null);
  }