/** * Constructor for SealedDeck. * * @param poolType a {@link java.lang.String} object. */ private SealedCardPoolGenerator(final LimitedPoolType poolType) { switch (poolType) { case Full: // Choose number of boosters if (!chooseNumberOfBoosters(new UnOpenedProduct(SealedProduct.Template.genericBooster))) { return; } landSetCode = CardEdition.Predicates.getRandomSetWithAllBasicLands(FModel.getMagicDb().getEditions()) .getCode(); break; case Block: case FantasyBlock: List<CardBlock> blocks = new ArrayList<CardBlock>(); Iterable<CardBlock> src = poolType == LimitedPoolType.Block ? FModel.getBlocks() : FModel.getFantasyBlocks(); for (CardBlock b : src) { blocks.add(b); } final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks); if (block == null) { return; } final int nPacks = block.getCntBoostersSealed(); final Stack<String> sets = new Stack<String>(); for (CardEdition edition : block.getSets()) { sets.add(edition.getCode()); } for (String ms : block.getMetaSetNames()) { sets.push(ms); } if (sets.size() > 1) { final List<String> setCombos = getSetCombos(sets, nPacks); if (setCombos == null || setCombos.isEmpty()) { throw new RuntimeException( "Unsupported amount of packs (" + nPacks + ") in a Sealed Deck block!"); } final String p = setCombos.size() > 1 ? SGuiChoose.oneOrNone("Choose packs to play with", setCombos) : setCombos.get(0); if (p == null) { return; } for (String pz : TextUtil.split(p, ',')) { String[] pps = TextUtil.splitWithParenthesis(pz.trim(), ' '); String setCode = pps[pps.length - 1]; int nBoosters = pps.length > 1 ? Integer.parseInt(pps[0]) : 1; while (nBoosters-- > 0) { this.product.add(block.getBooster(setCode)); } } } else { IUnOpenedProduct prod = block.getBooster(sets.get(0)); for (int i = 0; i < nPacks; i++) { this.product.add(prod); } } landSetCode = block.getLandSet().getCode(); break; case Custom: String[] dList; final ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>(); // get list of custom draft files final File dFolder = new File(ForgeConstants.SEALED_DIR); if (!dFolder.exists()) { throw new RuntimeException( "GenerateSealed : folder not found -- folder is " + dFolder.getAbsolutePath()); } if (!dFolder.isDirectory()) { throw new RuntimeException( "GenerateSealed : not a folder -- " + dFolder.getAbsolutePath()); } dList = dFolder.list(); for (final String element : dList) { if (element.endsWith(FILE_EXT)) { final List<String> dfData = FileUtil.readFile(ForgeConstants.SEALED_DIR + element); final CustomLimited cs = CustomLimited.parse(dfData, FModel.getDecks().getCubes()); if (cs.getSealedProductTemplate().getNumberOfCardsExpected() > 5) { // Do not allow too small cubes to be played as 'stand-alone'! customs.add(cs); } } } // present list to user if (customs.isEmpty()) { SOptionPane.showMessageDialog("No custom sealed files found."); return; } final CustomLimited draft = SGuiChoose.oneOrNone("Choose Custom Sealed Pool", customs); if (draft == null) { return; } UnOpenedProduct toAdd = new UnOpenedProduct(draft.getSealedProductTemplate(), draft.getCardPool()); toAdd.setLimitedPool(draft.isSingleton()); if (!chooseNumberOfBoosters(toAdd)) { return; } landSetCode = draft.getLandSetCode(); break; } }