Like open, can define whether is human or not. @param isHuman boolean, is human player? @param partialities known partialities for the AI. @return List, list of cards.
(final boolean isHuman, final boolean allowCancel)
| 80 | * @return List, list of cards. |
| 81 | */ |
| 82 | public List<PaperCard> open(final boolean isHuman, final boolean allowCancel) { |
| 83 | if (metaSets.isEmpty()) { |
| 84 | throw new RuntimeException("Empty UnOpenedMetaset, cannot generate booster."); |
| 85 | } |
| 86 | |
| 87 | switch (operation) { |
| 88 | case ChooseOne: |
| 89 | if (isHuman) { |
| 90 | final MetaSet ms; |
| 91 | if (allowCancel) { |
| 92 | ms = SGuiChoose.oneOrNone("Choose Booster", metaSets); |
| 93 | if (ms == null) { |
| 94 | return null; |
| 95 | } |
| 96 | } |
| 97 | else { |
| 98 | ms = SGuiChoose.one("Choose Booster", metaSets); |
| 99 | } |
| 100 | return ms.getBooster().get(); |
| 101 | } |
| 102 | |
| 103 | //$FALL-THROUGH$ |
| 104 | case RandomOne: // AI should fall though here from the case above |
| 105 | int selected = MyRandom.getRandom().nextInt(metaSets.size()); |
| 106 | final IUnOpenedProduct newBooster = metaSets.get(selected).getBooster(); |
| 107 | return newBooster.get(); |
| 108 | |
| 109 | case SelectAll: |
| 110 | List<PaperCard> allCards = new ArrayList<>(); |
| 111 | for (MetaSet ms : metaSets) { |
| 112 | allCards.addAll(ms.getBooster().get()); |
| 113 | } |
| 114 | return allCards; |
| 115 | } |
| 116 | throw new IllegalStateException("Got wrong operation type in unopenedMeta - execution should never reach this point"); |
| 117 | } |
| 118 | |
| 119 | public static UnOpenedMeta choose(final String desc) { |
| 120 | return new UnOpenedMeta(desc, JoinOperation.ChooseOne); |
no test coverage detected