예제 #1
0
 private Deck getFavoriteDeck() {
   Iterable<DeckProxy> decks;
   switch (lstDecks.getGameType()) {
     case Commander:
       decks = DeckProxy.getAllCommanderDecks();
       break;
     case TinyLeaders:
       decks = DeckProxy.getAllTinyLeadersDecks();
       break;
     case Archenemy:
       decks = DeckProxy.getAllSchemeDecks();
       break;
     case Planechase:
       decks = DeckProxy.getAllPlanarDecks();
       break;
     default:
       decks = DeckProxy.getAllConstructedDecks();
       break;
   }
   decks =
       Iterables.filter(
           decks,
           new Predicate<DeckProxy>() {
             @Override
             public boolean apply(final DeckProxy deck) {
               return deck.isFavoriteDeck();
             }
           });
   if (Iterables.isEmpty(decks)) {
     return getGeneratedDeck(); // fall back to generated deck if no favorite decks
   }
   return Aggregates.random(decks).getDeck();
 }
예제 #2
0
 private Deck getGeneratedDeck() {
   switch (lstDecks.getGameType()) {
     case Commander:
       return DeckgenUtil.generateCommanderDeck(isAi, GameType.Commander);
     case TinyLeaders:
       return DeckgenUtil.generateCommanderDeck(isAi, GameType.TinyLeaders);
     case Archenemy:
       return DeckgenUtil.generateSchemeDeck();
     case Planechase:
       return DeckgenUtil.generatePlanarDeck();
     default:
       while (true) {
         switch (Aggregates.random(DeckType.ConstructedOptions)) {
           case PRECONSTRUCTED_DECK:
             return Aggregates.random(
                     DeckProxy.getAllPreconstructedDecks(QuestController.getPrecons()))
                 .getDeck();
           case QUEST_OPPONENT_DECK:
             return Aggregates.random(DeckProxy.getAllQuestEventAndChallenges()).getDeck();
           case COLOR_DECK:
             final List<String> colors = new ArrayList<String>();
             final int count = Aggregates.randomInt(1, 3);
             for (int i = 1; i <= count; i++) {
               colors.add("Random " + i);
             }
             return DeckgenUtil.buildColorDeck(colors, isAi);
           case THEME_DECK:
             return Aggregates.random(DeckProxy.getAllThemeDecks()).getDeck();
           default:
             continue;
         }
       }
   }
 }
예제 #3
0
 private Deck getUserDeck() {
   Iterable<DeckProxy> decks;
   final GameType gameType = lstDecks.getGameType();
   switch (gameType) {
     case Commander:
       decks = DeckProxy.getAllCommanderDecks(DeckFormat.Commander.isLegalDeckPredicate());
       break;
     case TinyLeaders:
       decks = DeckProxy.getAllTinyLeadersDecks(DeckFormat.TinyLeaders.isLegalDeckPredicate());
       break;
     case Archenemy:
       decks = DeckProxy.getAllSchemeDecks(DeckFormat.Archenemy.isLegalDeckPredicate());
       break;
     case Planechase:
       decks = DeckProxy.getAllPlanarDecks(DeckFormat.Planechase.isLegalDeckPredicate());
       break;
     default:
       decks = DeckProxy.getAllConstructedDecks(gameType.getDeckFormat().isLegalDeckPredicate());
       break;
   }
   if (Iterables.isEmpty(decks)) {
     return getGeneratedDeck(); // fall back to generated deck if no decks in filtered list
   }
   return Aggregates.random(decks).getDeck();
 }