From 1e428105d56345267c7fcb01ad1093a5913322fc Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 4 Feb 2021 23:55:59 +1100 Subject: [PATCH 1/2] Adding in Jumpstart Custom --- .../client/dialog/NewTournamentDialog.java | 56 +++++-- .../JumpstartCustomEliminationTournament.java | 43 ++++++ ...pstartCustomEliminationTournamentType.java | 19 +++ Mage.Server/config/config.xml | 5 +- Mage.Server/release/config/config.xml | 1 + .../src/test/resources/config_error.xml | 1 + .../jumpstart/JumpstartPoolGenerator.java | 144 ++++++++++-------- .../mage/game/tournament/LimitedOptions.java | 27 +++- .../mage/game/tournament/TournamentImpl.java | 11 +- 9 files changed, 223 insertions(+), 84 deletions(-) create mode 100644 Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournament.java create mode 100644 Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournamentType.java diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index 4e7933b553..8e34f93df0 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -1,5 +1,13 @@ package mage.client.dialog; +import java.awt.*; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; +import javax.swing.*; import mage.cards.decks.Deck; import mage.cards.decks.DeckFileFilter; import mage.cards.decks.importer.DeckImporter; @@ -26,13 +34,6 @@ import mage.view.TableView; import mage.view.TournamentTypeView; import org.apache.log4j.Logger; -import javax.swing.*; -import java.awt.*; -import java.io.File; -import java.util.List; -import java.util.*; -import java.util.stream.Collectors; - /** * App GUI: create new TOURNEY * @@ -55,6 +56,7 @@ public class NewTournamentDialog extends MageDialog { private boolean isRandom = false; private boolean isRichMan = false; private String cubeFromDeckFilename = ""; + private String jumpstartPacksFilename = ""; private boolean automaticChange = false; public NewTournamentDialog() { @@ -659,6 +661,12 @@ public class NewTournamentDialog extends MageDialog { private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed prepareTourneyView((Integer) this.spnNumPlayers.getValue()); + + jumpstartPacksFilename = ""; + if (cbTournamentType.getSelectedItem().toString().matches(".*Jumpstart.*Custom.*")) { + jumpstartPacksFilename = playerLoadJumpstartPacks(); + } + }//GEN-LAST:event_cbTournamentTypeActionPerformed private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed @@ -777,6 +785,24 @@ public class NewTournamentDialog extends MageDialog { return ""; } + protected String playerLoadJumpstartPacks() { + if (fcSelectDeck == null) { + fcSelectDeck = new JFileChooser(); + fcSelectDeck.setAcceptAllFileFilterUsed(false); + fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("txt", "Jumpstart Packs (*.txt)")); + } + String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", ""); + if (!lastFolder.isEmpty()) { + fcSelectDeck.setCurrentDirectory(new File(lastFolder)); + } + int ret = fcSelectDeck.showDialog(this, "Select Jumpstart Packs file"); + if (ret == JFileChooser.APPROVE_OPTION) { + File file = fcSelectDeck.getSelectedFile(); + return (file.getPath()); + } + return ""; + } + private void cbDraftCubeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDraftCubeActionPerformed cubeFromDeckFilename = ""; if (cbDraftCube.getSelectedItem().toString().equals("Cube From Deck")) { @@ -951,7 +977,7 @@ public class NewTournamentDialog extends MageDialog { private void loadRandomPacks(int version) { String versionStr = prepareVersionStr(version, false); - List packList; + java.util.List packList; String packNames; String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, ""); if (!randomPrefs.isEmpty()) { @@ -1202,6 +1228,18 @@ public class NewTournamentDialog extends MageDialog { tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom()); tOptions.getLimitedOptions().setIsRichMan(tournamentType.isRichMan()); tOptions.getLimitedOptions().setIsJumpstart(tournamentType.isJumpstart()); + + if (tournamentType.isJumpstart()) { + if (!(jumpstartPacksFilename.isEmpty())) { + String jumpstartPacksData = ""; + try { + jumpstartPacksData = new String(Files.readAllBytes(Paths.get(jumpstartPacksFilename))); + } catch (IOException e2) { + JOptionPane.showMessageDialog(MageFrame.getDesktop(), e2.getMessage(), "Error loading Jumpstart Packs data", JOptionPane.ERROR_MESSAGE); + } + tOptions.getLimitedOptions().setJumpstartPacks(jumpstartPacksData); + } + } if (tournamentType.isCubeBooster()) { tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString()); if (!(cubeFromDeckFilename.isEmpty())) { @@ -1220,7 +1258,7 @@ public class NewTournamentDialog extends MageDialog { this.isRandom = tournamentType.isRandom(); this.isRichMan = tournamentType.isRichMan(); tOptions.getLimitedOptions().getSetCodes().clear(); - List selected = randomPackSelector.getSelectedPacks(); + java.util.List selected = randomPackSelector.getSelectedPacks(); Collections.shuffle(selected); int maxPacks = 3 * (players.size() + 1); if (tournamentType.isRichMan()) { diff --git a/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournament.java b/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournament.java new file mode 100644 index 0000000000..6087bd5a63 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournament.java @@ -0,0 +1,43 @@ + + +package mage.tournament; + +import mage.game.tournament.TournamentOptions; +import mage.game.tournament.TournamentSingleElimination; + +public class JumpstartCustomEliminationTournament extends TournamentSingleElimination { + + protected enum TournamentStep { + START, OPEN_BOOSTERS, CONSTRUCT, COMPETE, WINNERS + } + + protected TournamentStep currentStep; + + public JumpstartCustomEliminationTournament(TournamentOptions options) { + super(options); + currentStep = TournamentStep.START; + } + + @Override + public void nextStep() { + switch (currentStep) { + case START: + currentStep = TournamentStep.OPEN_BOOSTERS; + openBoosters(); + break; + case OPEN_BOOSTERS: + currentStep = TournamentStep.CONSTRUCT; + construct(); + break; + case CONSTRUCT: + currentStep = TournamentStep.COMPETE; + runTournament(); + break; + case COMPETE: + currentStep = TournamentStep.WINNERS; + winners(); + end(); + break; + } + } +} diff --git a/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournamentType.java b/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournamentType.java new file mode 100644 index 0000000000..d884677b39 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Tournament.Sealed/src/mage/tournament/JumpstartCustomEliminationTournamentType.java @@ -0,0 +1,19 @@ + + +package mage.tournament; + +import mage.game.tournament.TournamentType; + +public class JumpstartCustomEliminationTournamentType extends TournamentType { + + public JumpstartCustomEliminationTournamentType() { + this.name = "Jumpstart Elimination (Custom)"; + this.maxPlayers = 16; + this.minPlayers = 2; + this.numBoosters = 0; + this.isJumpstart = true; + this.elimination = true; + this.limited = true; + } + +} diff --git a/Mage.Server/config/config.xml b/Mage.Server/config/config.xml index dfdee042ab..0f329b9f2c 100644 --- a/Mage.Server/config/config.xml +++ b/Mage.Server/config/config.xml @@ -95,7 +95,9 @@ + + @@ -106,6 +108,7 @@ + @@ -206,4 +209,4 @@ - \ No newline at end of file + diff --git a/Mage.Server/release/config/config.xml b/Mage.Server/release/config/config.xml index 6dae34c52d..44351b690e 100644 --- a/Mage.Server/release/config/config.xml +++ b/Mage.Server/release/config/config.xml @@ -100,6 +100,7 @@ + diff --git a/Mage.Server/src/test/resources/config_error.xml b/Mage.Server/src/test/resources/config_error.xml index 51a73dee44..046070b441 100644 --- a/Mage.Server/src/test/resources/config_error.xml +++ b/Mage.Server/src/test/resources/config_error.xml @@ -72,6 +72,7 @@ + diff --git a/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java b/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java index 9cd6d15f4e..147ce1e6d7 100644 --- a/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java +++ b/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java @@ -1,5 +1,8 @@ package mage.game.jumpstart; +import com.google.common.base.Charsets; +import com.google.common.io.CharSource; +import com.google.common.io.Resources; import java.io.IOException; import java.io.UncheckedIOException; import java.security.SecureRandom; @@ -7,11 +10,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; - -import com.google.common.base.Charsets; -import com.google.common.io.CharSource; -import com.google.common.io.Resources; - import mage.cards.Card; import mage.cards.decks.Deck; import mage.cards.decks.DeckCardInfo; @@ -20,7 +18,7 @@ import mage.game.GameException; public class JumpstartPoolGenerator { - /** + /** * "Jumpstart is a new way to play Magic that mashes together themes from throughout the history of the game and * lets you skip the deckbuilding part. Grab two boosters, shuffle them into a 40-card deck, and start playing. * The set contains almost 500 reprints but also introduces 37 new cards that were designed to help fill out some @@ -30,7 +28,7 @@ public class JumpstartPoolGenerator { * symbol, while new cards and other reprints will have the Jumpstart symbol. Reprints have a Post-M15 card frame. * The new cards and cards with new art are numbered #1/78 to #78/78 (40 basic lands, TBA common, TBA uncommon, * TBA rare, and TBA mythic rare). The other reprints with the Jumpstart expansion symbol are numbered #79 to 495." - * + * * "Jumpstart is sold in 20-card boosters, and booster boxes contain 24 boosters.[9] All 20 cards in a booster fit a * theme, and most themes are mono-color and have multiple variations of cards included in the pack, totaling 121 * different possible pack contents. Special "Mythic Rare" packs don't have variations at all, but just one possible @@ -42,46 +40,64 @@ public class JumpstartPoolGenerator { * themed land art created for the set. The booster pack is wrapped like a regular pack, but the set of cards is * packed in an additional plastic wrap, with a face card (the "Pack Summary card") that indicates the theme and * the color of the half-deck." - * - * Source: https://mtg.gamepedia.com/Jumpstart - * + * + * Source: https://mtg.gamepedia.com/Jumpstart + * * Announcement: https://magic.wizards.com/en/articles/archive/news/introducing-jumpstart-new-way-play-magic-2020-02-20 * Card Pool: https://magic.wizards.com/en/articles/archive/card-image-gallery/jumpstart * Deck Lists: https://magic.wizards.com/en/articles/archive/feature/jumpstart-decklists-2020-06-18 - */ + */ + private static final String RESOURCE_NAME = "jumpstart/jumpstart.txt"; + private static List JUMPSTART_PACKS; - private static final String RESOURCE_NAME = "jumpstart/jumpstart.txt"; - private static final List JUMPSTART_PACKS; - - static { - try { - CharSource source = Resources.asCharSource(Resources.getResource(RESOURCE_NAME), Charsets.UTF_8); - List packs = new ArrayList<>(); - JumpstartPack pack = new JumpstartPack(); - packs.add(pack); - for (String line : source.readLines()) { - if (line.isEmpty()) { - if (!pack.isEmpty()) { - pack = new JumpstartPack(); + private static void setupPacks(String jumpstartPacks, boolean useDefault) { + try { + CharSource source; + if (useDefault) { + source = Resources.asCharSource(Resources.getResource(RESOURCE_NAME), Charsets.UTF_8); + } else { + source = CharSource.wrap(jumpstartPacks); + } + List packs = new ArrayList<>(); + JumpstartPack pack = new JumpstartPack(); packs.add(pack); - } - } else if (line.startsWith("#")) { - // skip comment - } else { - String[] ls = line.split(" ", 4); - int quantity = Integer.parseInt(ls[0]); - for (int i = 0; i < quantity; i++) { - pack.add(new DeckCardInfo(ls[3], ls[2], ls[1])); - } + for (String line : source.readLines()) { + if (line.isEmpty()) { + if (!pack.isEmpty()) { + pack = new JumpstartPack(); + packs.add(pack); + } + } else if (line.startsWith("#")) { + // skip comment + } else { + String[] ls = line.split(" ", 4); + int quantity = Integer.parseInt(ls[0]); + for (int i = 0; i < quantity; i++) { + pack.add(new DeckCardInfo(ls[3], ls[2], ls[1])); + } + } + } + JUMPSTART_PACKS = Collections.unmodifiableList(packs); + } catch (IOException e) { + throw new UncheckedIOException(e); } - } - JUMPSTART_PACKS = Collections.unmodifiableList(packs); - } catch (IOException e) { - throw new UncheckedIOException(e); } - } - /* Notes + private static Set doGeneratePool() { + try { + DeckCardLists list = new DeckCardLists(); + SecureRandom random = new SecureRandom(); + for (int i = 0; i < 2; i++) { + int index = random.nextInt(JUMPSTART_PACKS.size()); + list.getCards().addAll(JUMPSTART_PACKS.get(index).getCards()); + } + return Deck.load(list, false, false).getCards(); + } catch (GameException e) { + throw new RuntimeException(e); + } + } + + /* Notes * * 1) the pools generated by this method are for how the prerelease will be played (see https://mtg.gamepedia.com/Jumpstart#Events) * In order to support the 4 pack version, xmage would need to support editing multiple decks and some Duo format @@ -93,37 +109,33 @@ public class JumpstartPoolGenerator { * * 3) this does not attempt to add an additional rare 1/3 of the time as described here: * https://mtg.gamepedia.com/Jumpstart#Marketing - */ - public static Set generatePool() { - try { - DeckCardLists list = new DeckCardLists(); - SecureRandom random = new SecureRandom(); - for (int i = 0; i < 2; i++) { - int index = random.nextInt(JUMPSTART_PACKS.size()); - list.getCards().addAll(JUMPSTART_PACKS.get(index).getCards()); - } - return Deck.load(list, false, false).getCards(); - } catch (GameException e) { - throw new RuntimeException(e); - } - } - - public static class JumpstartPack { - - private final List cards = new ArrayList<>(); - - public void add(DeckCardInfo card) { - cards.add(card); + */ + public static Set generatePool() { + setupPacks("", true); + return doGeneratePool(); } - public boolean isEmpty() { - return cards.isEmpty(); + public static Set generatePool(String userJumpstartPacks) { + setupPacks(userJumpstartPacks, false); + return doGeneratePool(); } - public List getCards() { - return Collections.unmodifiableList(cards); - } + public static class JumpstartPack { - } + private final List cards = new ArrayList<>(); + + public void add(DeckCardInfo card) { + cards.add(card); + } + + public boolean isEmpty() { + return cards.isEmpty(); + } + + public List getCards() { + return Collections.unmodifiableList(cards); + } + + } } diff --git a/Mage/src/main/java/mage/game/tournament/LimitedOptions.java b/Mage/src/main/java/mage/game/tournament/LimitedOptions.java index 9628b5c33a..473dce849e 100644 --- a/Mage/src/main/java/mage/game/tournament/LimitedOptions.java +++ b/Mage/src/main/java/mage/game/tournament/LimitedOptions.java @@ -1,11 +1,10 @@ package mage.game.tournament; -import mage.cards.decks.Deck; -import mage.game.draft.DraftCube; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import mage.cards.decks.Deck; +import mage.game.draft.DraftCube; /** * @author BetaSteward_at_googlemail.com @@ -20,6 +19,20 @@ public class LimitedOptions implements Serializable { protected boolean isRandom; protected boolean isRichMan; protected Deck cubeFromDeck; + + protected String jumpstartPacks; + // Eg of jumpstartPacks - uploaded by user + /* + # Minions + 1 JMP 236 Ghoulcaller Gisa + 1 JMP 226 Dutiful Attendant + 1 M21 126 Village Rites + + # Phyrexian + 1 JMP 278 Sheoldred, Whispering One + 1 JMP 227 Entomber Exarch + 1 JMP 265 Phyrexian Gargantua + */ protected boolean isJumpstart; public List getSetCodes() { @@ -50,6 +63,14 @@ public class LimitedOptions implements Serializable { return cubeFromDeck; } + public void setJumpstartPacks(String jumpstartPacks) { + this.jumpstartPacks = jumpstartPacks; + } + + public String getJumpstartPacks() { + return jumpstartPacks; + } + public DraftCube getDraftCube() { return draftCube; } diff --git a/Mage/src/main/java/mage/game/tournament/TournamentImpl.java b/Mage/src/main/java/mage/game/tournament/TournamentImpl.java index 001cf9dc6e..47f1214b6d 100644 --- a/Mage/src/main/java/mage/game/tournament/TournamentImpl.java +++ b/Mage/src/main/java/mage/game/tournament/TournamentImpl.java @@ -1,4 +1,3 @@ - package mage.game.tournament; import java.util.ArrayList; @@ -12,9 +11,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; - import mage.cards.ExpansionSet; import mage.cards.decks.Deck; import mage.constants.TournamentPlayerState; @@ -37,6 +33,7 @@ import mage.game.result.ResultProtos.TourneyRoundProto; import mage.players.Player; import mage.players.PlayerType; import mage.util.RandomUtil; +import org.apache.log4j.Logger; /** * @@ -411,7 +408,11 @@ public abstract class TournamentImpl implements Tournament { player.getDeck().getSideboard().addAll(cube.createBooster()); } } else if (options.getLimitedOptions().getIsJumpstart()) { - player.getDeck().getCards().addAll(JumpstartPoolGenerator.generatePool()); + if (options.getLimitedOptions().jumpstartPacks == null) { + player.getDeck().getCards().addAll(JumpstartPoolGenerator.generatePool()); + } else { + player.getDeck().getCards().addAll(JumpstartPoolGenerator.generatePool(options.getLimitedOptions().jumpstartPacks)); + } } else { for (ExpansionSet set : sets) { player.getDeck().getSideboard().addAll(set.createBooster()); From b64806606c3ff9c44de56448a810bf5910e54dc0 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sat, 6 Feb 2021 00:19:36 +1100 Subject: [PATCH 2/2] Adding in Jumpstart Custom (requested fixes) --- .../client/dialog/NewTournamentDialog.java | 20 +++++++++----- .../jumpstart/JumpstartPoolGenerator.java | 27 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index 8e34f93df0..bc884ff57d 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -785,19 +785,21 @@ public class NewTournamentDialog extends MageDialog { return ""; } + private JFileChooser fcJumpstartSelectDeck = null; + protected String playerLoadJumpstartPacks() { - if (fcSelectDeck == null) { - fcSelectDeck = new JFileChooser(); - fcSelectDeck.setAcceptAllFileFilterUsed(false); - fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("txt", "Jumpstart Packs (*.txt)")); + if (fcJumpstartSelectDeck == null) { + fcJumpstartSelectDeck = new JFileChooser(); + fcJumpstartSelectDeck.setAcceptAllFileFilterUsed(false); + fcJumpstartSelectDeck.addChoosableFileFilter(new DeckFileFilter("txt", "Jumpstart Packs (*.txt)")); } String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", ""); if (!lastFolder.isEmpty()) { - fcSelectDeck.setCurrentDirectory(new File(lastFolder)); + fcJumpstartSelectDeck.setCurrentDirectory(new File(lastFolder)); } - int ret = fcSelectDeck.showDialog(this, "Select Jumpstart Packs file"); + int ret = fcJumpstartSelectDeck.showDialog(this, "Select Jumpstart Packs file"); if (ret == JFileChooser.APPROVE_OPTION) { - File file = fcSelectDeck.getSelectedFile(); + File file = fcJumpstartSelectDeck.getSelectedFile(); return (file.getPath()); } return ""; @@ -1234,6 +1236,10 @@ public class NewTournamentDialog extends MageDialog { String jumpstartPacksData = ""; try { jumpstartPacksData = new String(Files.readAllBytes(Paths.get(jumpstartPacksFilename))); + if (jumpstartPacksData.length() > 300000) { + JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Chosen file too big", "Jumpstart Packs data is too long. Please trim or choose another file.", JOptionPane.ERROR_MESSAGE); + jumpstartPacksData = ""; + } } catch (IOException e2) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), e2.getMessage(), "Error loading Jumpstart Packs data", JOptionPane.ERROR_MESSAGE); } diff --git a/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java b/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java index 147ce1e6d7..1108f29954 100644 --- a/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java +++ b/Mage/src/main/java/mage/game/jumpstart/JumpstartPoolGenerator.java @@ -48,9 +48,14 @@ public class JumpstartPoolGenerator { * Deck Lists: https://magic.wizards.com/en/articles/archive/feature/jumpstart-decklists-2020-06-18 */ private static final String RESOURCE_NAME = "jumpstart/jumpstart.txt"; - private static List JUMPSTART_PACKS; + private static final List JUMPSTART_PACKS; - private static void setupPacks(String jumpstartPacks, boolean useDefault) { + static { + List packs = getPacks ("", true); + JUMPSTART_PACKS = Collections.unmodifiableList(packs); + } + + private static List getPacks(String jumpstartPacks, boolean useDefault) { try { CharSource source; if (useDefault) { @@ -77,19 +82,19 @@ public class JumpstartPoolGenerator { } } } - JUMPSTART_PACKS = Collections.unmodifiableList(packs); + return packs; } catch (IOException e) { throw new UncheckedIOException(e); } } - private static Set doGeneratePool() { + private static Set doGeneratePool(List packs) { try { DeckCardLists list = new DeckCardLists(); SecureRandom random = new SecureRandom(); for (int i = 0; i < 2; i++) { - int index = random.nextInt(JUMPSTART_PACKS.size()); - list.getCards().addAll(JUMPSTART_PACKS.get(index).getCards()); + int index = random.nextInt(packs.size()); + list.getCards().addAll(packs.get(index).getCards()); } return Deck.load(list, false, false).getCards(); } catch (GameException e) { @@ -111,13 +116,15 @@ public class JumpstartPoolGenerator { * https://mtg.gamepedia.com/Jumpstart#Marketing */ public static Set generatePool() { - setupPacks("", true); - return doGeneratePool(); + return doGeneratePool(JUMPSTART_PACKS); } public static Set generatePool(String userJumpstartPacks) { - setupPacks(userJumpstartPacks, false); - return doGeneratePool(); + if (userJumpstartPacks == null || userJumpstartPacks.length() > 300000) { + return generatePool(); + } + List packs = getPacks(userJumpstartPacks, false); + return doGeneratePool(packs); } public static class JumpstartPack {