diff --git a/src/main/java/forge/deck/DeckFormat.java b/src/main/java/forge/deck/DeckFormat.java index 6dce1586be2..440e5ac4957 100644 --- a/src/main/java/forge/deck/DeckFormat.java +++ b/src/main/java/forge/deck/DeckFormat.java @@ -35,6 +35,7 @@ public enum DeckFormat { // Main board: allowed size SB: restriction Max distinct non basic cards Constructed ( new IntRange(60, Integer.MAX_VALUE), new IntRange(15), 4), + QuestDeck ( new IntRange(40, Integer.MAX_VALUE), new IntRange(15), 4), Limited ( new IntRange(40, Integer.MAX_VALUE), null, Integer.MAX_VALUE), Commander ( new IntRange(99), new IntRange(10), 1), Vanguard ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4), diff --git a/src/main/java/forge/game/GameType.java b/src/main/java/forge/game/GameType.java index 1026c748523..c6cbf5230e1 100644 --- a/src/main/java/forge/game/GameType.java +++ b/src/main/java/forge/game/GameType.java @@ -12,7 +12,7 @@ public enum GameType { Sealed ( DeckFormat.Limited, true, true ), Draft ( DeckFormat.Limited, true, true ), Gauntlet ( DeckFormat.Limited, true, true ), - Quest ( DeckFormat.Constructed, true, true ), + Quest ( DeckFormat.QuestDeck, true, true ), Constructed ( DeckFormat.Constructed, false, true ), Archenemy ( DeckFormat.Archenemy, false, false ), Planechase ( DeckFormat.Planechase, false, false ), diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java index 0767fa952b5..94599bf9578 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java @@ -11,7 +11,6 @@ import forge.Command; import forge.Singletons; import forge.control.Lobby; import forge.deck.Deck; -import forge.deck.DeckFormat; import forge.game.GameType; import forge.game.MatchController; import forge.game.MatchStartHelper; @@ -54,7 +53,7 @@ public enum CSubmenuConstructed implements ICDoc { view.getBtnStart().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { - startGame(); + startGame(GameType.Constructed); } }); @@ -94,12 +93,13 @@ public enum CSubmenuConstructed implements ICDoc { - /** @param lists0   {@link java.util.List}<{@link javax.swing.JList}> */ - private void startGame() { + /** @param gameType + * @param lists0   {@link java.util.List}<{@link javax.swing.JList}> */ + private void startGame(final GameType gameType) { Deck humanDeck = VSubmenuConstructed.SINGLETON_INSTANCE.getDcHuman().getDeck(); if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) { - String errorMessage = DeckFormat.Constructed.getDeckConformanceProblem(humanDeck); + String errorMessage = gameType.getDecksFormat().getDeckConformanceProblem(humanDeck); if (null != errorMessage) { JOptionPane.showMessageDialog(null, "Your deck " + errorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE); return; @@ -126,7 +126,7 @@ public enum CSubmenuConstructed implements ICDoc { starter.addPlayer(lobby.findLocalPlayer(PlayerType.COMPUTER), aiDeck); MatchController mc = Singletons.getModel().getMatch(); - mc.initMatch(GameType.Constructed, starter.getPlayerMap()); + mc.initMatch(gameType, starter.getPlayerMap()); mc.startRound(); return null; diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java index cd29a2ed82e..c3caecc7cdd 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java @@ -14,7 +14,6 @@ import forge.Singletons; import forge.control.FControl; import forge.control.Lobby; import forge.deck.Deck; -import forge.deck.DeckFormat; import forge.deck.DeckGroup; import forge.game.GameType; import forge.game.MatchController; @@ -67,7 +66,7 @@ public enum CSubmenuDraft implements ICDoc { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - startGame(); + startGame(GameType.Draft); } }); } @@ -91,7 +90,7 @@ public enum CSubmenuDraft implements ICDoc { } } - private void startGame() { + private void startGame(final GameType gameType) { final boolean gauntlet = VSubmenuDraft.SINGLETON_INSTANCE.getRadSingle().isSelected() ? false : true; final Deck humanDeck = VSubmenuDraft.SINGLETON_INSTANCE.getLstDecks().getSelectedDeck(); final int aiIndex = (int) Math.floor(Math.random() * 8); @@ -101,11 +100,10 @@ public enum CSubmenuDraft implements ICDoc { "No deck selected for human!\r\n(You may need to build a new deck.)", "No deck", JOptionPane.ERROR_MESSAGE); return; - } else if (null != DeckFormat.Limited.getDeckConformanceProblem(humanDeck)) { - JOptionPane.showMessageDialog(null, - "The selected deck doesn't have enough cards to play (minimum 40)." - + "\r\nUse the deck editor to choose the cards you want before starting.", - "Invalid deck", JOptionPane.ERROR_MESSAGE); + } + String errorMessage = gameType.getDecksFormat().getDeckConformanceProblem(humanDeck); + if (null != errorMessage) { + JOptionPane.showMessageDialog(null, "Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid deck", JOptionPane.ERROR_MESSAGE); return; } @@ -113,7 +111,7 @@ public enum CSubmenuDraft implements ICDoc { if (gauntlet) { int rounds = Singletons.getModel().getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size(); - Singletons.getModel().getGauntletMini().launch(rounds, humanDeck, GameType.Draft); + Singletons.getModel().getGauntletMini().launch(rounds, humanDeck, gameType); return; } diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java index 57c0cb114f3..5b08618b437 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java @@ -19,7 +19,6 @@ import forge.Singletons; import forge.control.FControl; import forge.deck.Deck; import forge.deck.DeckBase; -import forge.deck.DeckFormat; import forge.deck.DeckGroup; import forge.game.limited.ReadDraftRankings; import forge.game.GameType; @@ -73,7 +72,7 @@ public enum CSubmenuSealed implements ICDoc { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - startGame(); + startGame(GameType.Sealed); } }); } @@ -105,7 +104,7 @@ public enum CSubmenuSealed implements ICDoc { VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setDecks(humanDecks); } - private void startGame() { + private void startGame(final GameType gameType) { final Deck human = VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().getSelectedDeck(); if (human == null) { @@ -113,17 +112,16 @@ public enum CSubmenuSealed implements ICDoc { "Please build and/or select a deck for yourself.", "No deck", JOptionPane.ERROR_MESSAGE); return; - } else if (null != DeckFormat.Limited.getDeckConformanceProblem(human)) { - JOptionPane.showMessageDialog(null, - "The selected deck doesn't have enough cards to play (minimum 40)." - + "\r\nUse the deck editor to choose the cards you want before starting.", - "Invalid deck", JOptionPane.ERROR_MESSAGE); + } + + String errorMessage = gameType.getDecksFormat().getDeckConformanceProblem(human); + if (null != errorMessage) { + JOptionPane.showMessageDialog(null, "Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid deck", JOptionPane.ERROR_MESSAGE); return; } int matches = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().size(); - - Singletons.getModel().getGauntletMini().launch(matches, human, GameType.Sealed); + Singletons.getModel().getGauntletMini().launch(matches, human, gameType); } @SuppressWarnings("unchecked")