MCPcopy Create free account
hub / github.com/Card-Forge/forge / open

Method open

forge-gui/src/main/java/forge/model/UnOpenedMeta.java:82–117  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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);

Callers 12

getMethod · 0.95
EditorMainWindowMethod · 0.45
write_combo_fileFunction · 0.45
write_card_fileFunction · 0.45
read_weighted_rowsFunction · 0.45
write_weighted_tsvFunction · 0.45
read_existing_rowsFunction · 0.45
write_tsvFunction · 0.45
getCardPoolMethod · 0.45
registerErrorHandlingMethod · 0.45
restartAndUpdateMethod · 0.45
extractUpdateMethod · 0.45

Calls 9

oneOrNoneMethod · 0.95
oneMethod · 0.95
getBoosterMethod · 0.95
getRandomMethod · 0.95
getMethod · 0.95
isEmptyMethod · 0.65
getMethod · 0.65
sizeMethod · 0.65
addAllMethod · 0.45

Tested by

no test coverage detected