From 0ab47360b2bf52a5f0b48e9e83d1b6d2e45bf78d Mon Sep 17 00:00:00 2001 From: elcnesh Date: Thu, 30 Apr 2015 09:58:54 +0000 Subject: [PATCH] Relax quest pref constraints and cleanup related code --- .../home/quest/CSubmenuQuestPrefs.java | 63 ++-- .../home/quest/VSubmenuQuestPrefs.java | 269 +++++++++--------- .../forge/quest/data/QuestPreferences.java | 205 +++++-------- 3 files changed, 239 insertions(+), 298 deletions(-) diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestPrefs.java b/forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestPrefs.java index c69c34106fb..2a80a13e8ff 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestPrefs.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestPrefs.java @@ -1,21 +1,22 @@ package forge.screens.home.quest; +import javax.swing.SwingUtilities; + +import com.google.common.primitives.Ints; + import forge.UiCommand; import forge.gui.framework.ICDoc; import forge.model.FModel; import forge.quest.data.QuestPreferences; import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput; -import javax.swing.*; - -/** +/** * Controls the quest preferences submenu in the home UI. - * + * *

(C at beginning of class name denotes a control class.) * */ public enum CSubmenuQuestPrefs implements ICDoc { - /** */ SINGLETON_INSTANCE; @Override @@ -40,17 +41,20 @@ public enum CSubmenuQuestPrefs implements ICDoc { } /** - * Checks validity of values entered into prefInputs. - * @param i0   a PrefInput object + * Checks validity of values entered into quest preference input text + * fields. + * + * @param i0 + * the input. */ - public static void validateAndSave(PrefInput i0) { + public static void validateAndSave(final PrefInput i0) { if (i0.getText().equals(i0.getPreviousText())) { return; } final QuestPreferences prefs = FModel.getQuestPreferences(); - int val = Integer.parseInt(i0.getText()); + final Integer val = Ints.tryParse(i0.getText()); resetErrors(); - String validationError = prefs.validatePreference(i0.getQPref(), val); + final String validationError = val == null ? "Enter a number" : prefs.validatePreference(i0.getQPref(), val.intValue()); if (validationError != null) { showError(i0, validationError); return; @@ -61,27 +65,28 @@ public enum CSubmenuQuestPrefs implements ICDoc { i0.setPreviousText(i0.getText()); } - private static void showError(PrefInput i0, String s0) { + private static void showError(final PrefInput i0, final String s0) { final VSubmenuQuestPrefs view = VSubmenuQuestPrefs.SINGLETON_INSTANCE; - String s = "Save failed: " + s0; + final String s = "Save failed: " + s0; switch(i0.getErrType()) { - case BOOSTER: - view.getLblErrBooster().setVisible(true); - view.getLblErrBooster().setText(s); - break; - case DIFFICULTY: - view.getLblErrDifficulty().setVisible(true); - view.getLblErrDifficulty().setText(s); - break; - case REWARDS: - view.getLblErrRewards().setVisible(true); - view.getLblErrRewards().setText(s); - break; - case SHOP: - view.getLblErrShop().setVisible(true); - view.getLblErrShop().setText(s); - break; - default: + case BOOSTER: + view.getLblErrBooster().setVisible(true); + view.getLblErrBooster().setText(s); + break; + case DIFFICULTY: + view.getLblErrDifficulty().setVisible(true); + view.getLblErrDifficulty().setText(s); + break; + case REWARDS: + view.getLblErrRewards().setVisible(true); + view.getLblErrRewards().setText(s); + break; + case SHOP: + view.getLblErrShop().setVisible(true); + view.getLblErrShop().setText(s); + break; + default: + break; } i0.setText(i0.getPreviousText()); diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java b/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java index f964a423646..87864cb730f 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java @@ -1,5 +1,18 @@ package forge.screens.home.quest; +import java.awt.Color; +import java.awt.Font; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.border.Border; + +import net.miginfocom.swing.MigLayout; import forge.assets.FSkinProp; import forge.gui.framework.DragCell; import forge.gui.framework.DragTab; @@ -16,18 +29,8 @@ import forge.toolbox.FScrollPane; import forge.toolbox.FSkin; import forge.toolbox.FSkin.SkinColor; import forge.toolbox.FSkin.SkinnedTextField; -import net.miginfocom.swing.MigLayout; -import javax.swing.*; -import javax.swing.border.Border; - -import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** +/** * Assembles Swing components of quest preferences submenu singleton. * *

(V at beginning of class name denotes a view class.) @@ -195,45 +198,45 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { focusTarget.requestFocusInWindow(); } - private final String constraints1 = "w 60px!, h 26px!"; - private final String constraints2 = "w 200px!, h 26px!, gap 0 10px 0 0"; + private final static String fieldConstraints = "w 60px!, h 26px!"; + private final static String labelConstraints = "w 200px!, h 26px!, gap 0 10px 0 0"; private void populateRewards() { pnlRewards.setOpaque(false); - pnlRewards.setLayout(new MigLayout("insets 0, gap 0, wrap 2, hidemode 3")); + pnlRewards.setLayout(new MigLayout("insets 0px, gap 0, wrap 2, hidemode 3")); pnlRewards.removeAll(); pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1"); - pnlRewards.add(new FLabel.Builder().text("Base Winnings").fontAlign(SwingConstants.RIGHT).build(), constraints2); + pnlRewards.add(new FLabel.Builder().text("Base Winnings").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); focusTarget = new PrefInput(QPref.REWARDS_BASE, QuestPreferencesErrType.REWARDS); - pnlRewards.add(focusTarget, constraints1); + pnlRewards.add(focusTarget, fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("No Losses").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_UNDEFEATED, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("No Losses").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_UNDEFEATED, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Poison Win").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_POISON, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Poison Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_POISON, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Milling Win").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_MILLED, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Milling Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_MILLED, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Mulligan 0 Win").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_MULLIGAN0, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Mulligan 0 Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_MULLIGAN0, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Alternative Win").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_ALTERNATIVE, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Alternative Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_ALTERNATIVE, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Win by Turn 15").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_TURN15, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Win by Turn 15").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_TURN15, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Win by Turn 10").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_TURN10, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Win by Turn 10").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_TURN10, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("Win by Turn 5").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_TURN5, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("Win by Turn 5").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_TURN5, QuestPreferencesErrType.REWARDS), fieldConstraints); - pnlRewards.add(new FLabel.Builder().text("First Turn Win").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlRewards.add(new PrefInput(QPref.REWARDS_TURN1, QuestPreferencesErrType.REWARDS), constraints1); + pnlRewards.add(new FLabel.Builder().text("First Turn Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlRewards.add(new PrefInput(QPref.REWARDS_TURN1, QuestPreferencesErrType.REWARDS), fieldConstraints); } private void populateDifficulty() { @@ -243,84 +246,84 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { pnlDifficulty.removeAll(); pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1"); - pnlDifficulty.add(new FLabel.Builder().text("").build(), constraints2); - pnlDifficulty.add(new FLabel.Builder().text("Easy").build(), constraints1); - pnlDifficulty.add(new FLabel.Builder().text("Medium").build(), constraints1); - pnlDifficulty.add(new FLabel.Builder().text("Hard").build(), constraints1); - pnlDifficulty.add(new FLabel.Builder().text("Expert").build(), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("").build(), labelConstraints); + pnlDifficulty.add(new FLabel.Builder().text("Easy").build(), fieldConstraints); + pnlDifficulty.add(new FLabel.Builder().text("Medium").build(), fieldConstraints); + pnlDifficulty.add(new FLabel.Builder().text("Hard").build(), fieldConstraints); + pnlDifficulty.add(new FLabel.Builder().text("Expert").build(), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Wins for Booster").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Wins for Booster").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Wins for Rank Increase").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Wins for Rank Increase").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Wins for Medium AI").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Wins for Medium AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Wins for Hard AI").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Wins for Hard AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Wins for Expert AI").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Wins for Expert AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Starting Commons").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Starting Commons").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Starting Uncommons").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Starting Uncommons").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Starting Rares").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Starting Rares").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Starting Credits").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); - pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); + pnlDifficulty.add(new FLabel.Builder().text("Starting Credits").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EXPERT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints); - pnlDifficulty.add(new FLabel.Builder().text("Starting Basic Lands").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_BASIC_LANDS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); + pnlDifficulty.add(new FLabel.Builder().text("Starting Basic Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_BASIC_LANDS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); - pnlDifficulty.add(new FLabel.Builder().text("Wins for New Draft").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_DRAFT, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); + pnlDifficulty.add(new FLabel.Builder().text("Wins for New Draft").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); - pnlDifficulty.add(new FLabel.Builder().text("Wins per Draft Rotation").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.WINS_ROTATE_DRAFT, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); + pnlDifficulty.add(new FLabel.Builder().text("Wins per Draft Rotation").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.WINS_ROTATE_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); - pnlDifficulty.add(new FLabel.Builder().text("Starting Snow Lands").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); + pnlDifficulty.add(new FLabel.Builder().text("Starting Snow Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); - pnlDifficulty.add(new FLabel.Builder().text("Color Bias (1-10)").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.STARTING_POOL_COLOR_BIAS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); + pnlDifficulty.add(new FLabel.Builder().text("Color Bias (1-10)").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.STARTING_POOL_COLOR_BIAS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); + + pnlDifficulty.add(new FLabel.Builder().text("Penalty for Loss").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); - pnlDifficulty.add(new FLabel.Builder().text("Penalty for Loss").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); - } private void populateBooster() { @@ -330,14 +333,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { pnlBooster.removeAll(); pnlBooster.add(lblErrBooster, "w 100%!, h 30px!, span 2 1"); - pnlBooster.add(new FLabel.Builder().text("Common").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlBooster.add(new PrefInput(QPref.BOOSTER_COMMONS, QuestPreferencesErrType.BOOSTER), constraints1); + pnlBooster.add(new FLabel.Builder().text("Common").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlBooster.add(new PrefInput(QPref.BOOSTER_COMMONS, QuestPreferencesErrType.BOOSTER), fieldConstraints); - pnlBooster.add(new FLabel.Builder().text("Uncommon").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlBooster.add(new PrefInput(QPref.BOOSTER_UNCOMMONS, QuestPreferencesErrType.BOOSTER), constraints1); + pnlBooster.add(new FLabel.Builder().text("Uncommon").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlBooster.add(new PrefInput(QPref.BOOSTER_UNCOMMONS, QuestPreferencesErrType.BOOSTER), fieldConstraints); - pnlBooster.add(new FLabel.Builder().text("Rare").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlBooster.add(new PrefInput(QPref.BOOSTER_RARES, QuestPreferencesErrType.BOOSTER), constraints1); + pnlBooster.add(new FLabel.Builder().text("Rare").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlBooster.add(new PrefInput(QPref.BOOSTER_RARES, QuestPreferencesErrType.BOOSTER), fieldConstraints); } @@ -348,39 +351,39 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { pnlShop.removeAll(); pnlShop.add(lblErrShop, "w 100%!, h 30px!, span 2 1"); - pnlShop.add(new FLabel.Builder().text("Maximum Packs").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_MAX_PACKS, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Maximum Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_MAX_PACKS, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Minimum Packs").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_MIN_PACKS, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Minimum Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_MIN_PACKS, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Starting Packs").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_STARTING_PACKS, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Starting Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_STARTING_PACKS, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Wins for Pack").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Wins for Pack").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Wins per Set Unlock").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.WINS_UNLOCK_SET, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Wins per Set Unlock").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.WINS_UNLOCK_SET, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Common Singles").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_COMMON, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Common Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_COMMON, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Uncommon Singles").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_UNCOMMON, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Uncommon Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_UNCOMMON, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Rare Singles").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Rare Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Card Sale Price Cap").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_MAX_SELLING_PRICE, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Card Sale Price Cap").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_MAX_SELLING_PRICE, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Wins to Uncap Sale Price").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_NO_SELL_LIMIT, QuestPreferencesErrType.SHOP), constraints1); + pnlShop.add(new FLabel.Builder().text("Wins to Uncap Sale Price").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_NO_SELL_LIMIT, QuestPreferencesErrType.SHOP), fieldConstraints); + + pnlShop.add(new FLabel.Builder().text("Item Level Restriction").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); + pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, QuestPreferencesErrType.SHOP), fieldConstraints); - pnlShop.add(new FLabel.Builder().text("Item Level Restriction").fontAlign(SwingConstants.RIGHT).build(), constraints2); - pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, QuestPreferencesErrType.SHOP), constraints1); - } /** */ @@ -398,7 +401,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { * @param e0   {@link forge.view.home.ViewQuestPreference.QuestPreferencesErrType} * where error should display to */ - public PrefInput(QPref qp0, QuestPreferencesErrType e0) { + public PrefInput(final QPref qp0, final QuestPreferencesErrType e0) { super(); this.qpref = qp0; @@ -419,14 +422,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { this.addMouseListener(new MouseAdapter() { @Override - public void mouseEntered(MouseEvent e) { + public void mouseEntered(final MouseEvent e) { if (isFocus) { return; } setOpaque(true); repaint(); } @Override - public void mouseExited(MouseEvent e) { + public void mouseExited(final MouseEvent e) { if (isFocus) { return; } setOpaque(false); repaint(); @@ -435,14 +438,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { this.addFocusListener(new FocusAdapter() { @Override - public void focusGained(FocusEvent e) { + public void focusGained(final FocusEvent e) { isFocus = true; setOpaque(true); setBackground(clrActive); } @Override - public void focusLost(FocusEvent e) { + public void focusLost(final FocusEvent e) { isFocus = false; setOpaque(false); setBackground(clrHover); @@ -468,7 +471,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { } /** @param s0   {@link java.lang.String} */ - public void setPreviousText(String s0) { + public void setPreviousText(final String s0) { this.previousText = s0; } } @@ -503,7 +506,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu { * @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell) */ @Override - public void setParentCell(DragCell cell0) { + public void setParentCell(final DragCell cell0) { this.parentCell = cell0; } diff --git a/forge-gui/src/main/java/forge/quest/data/QuestPreferences.java b/forge-gui/src/main/java/forge/quest/data/QuestPreferences.java index 9f598b23b74..dd5d9e74bc5 100644 --- a/forge-gui/src/main/java/forge/quest/data/QuestPreferences.java +++ b/forge-gui/src/main/java/forge/quest/data/QuestPreferences.java @@ -6,24 +6,25 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package forge.quest.data; +import java.io.Serializable; + import forge.properties.ForgeConstants; import forge.properties.PreferencesStore; -import java.io.Serializable; - @SuppressWarnings("serial") public class QuestPreferences extends PreferencesStore implements Serializable { + /** * Preference identifiers, and their default values. */ @@ -39,7 +40,7 @@ public class QuestPreferences extends PreferencesStore i // How many credits are lost for losing a match PENALTY_LOSS("15"), - // Currently chosen quest and deck + // Currently chosen quest and deck CURRENT_QUEST("DEFAULT"), CURRENT_DECK("DEFAULT"), @@ -131,7 +132,7 @@ public class QuestPreferences extends PreferencesStore i WINS_EXPERTAI_MEDIUM("36"), WINS_EXPERTAI_HARD("32"), WINS_EXPERTAI_EXPERT("28"), - + WINS_UNLOCK_SET("20"), // Maximum amount of "Packs" opened by the Shop and available as singles @@ -145,7 +146,7 @@ public class QuestPreferences extends PreferencesStore i // How many wins it takes to open an additional pack in the shop SHOP_WINS_FOR_ADDITIONAL_PACK("10"), - // How many packs the shop start with. + // How many packs the shop start with. SHOP_STARTING_PACKS("5"), // Maximum selling price in a spell shop @@ -154,23 +155,22 @@ public class QuestPreferences extends PreferencesStore i SHOP_WINS_FOR_NO_SELL_LIMIT("50"), ITEM_LEVEL_RESTRICTION("1"); - private final String strDefaultVal; /** * Instantiates a new q pref. - * + * * @param s0 *   {@link java.lang.String} */ - QPref(final String s0) { + private QPref(final String s0) { this.strDefaultVal = s0; } /** * Gets the default. - * + * * @return {@link java.lang.String} */ public String getDefault() { @@ -179,7 +179,7 @@ public class QuestPreferences extends PreferencesStore i } public static enum DifficultyPrefs { - STARTING_COMMONS, + STARTING_COMMONS, STARTING_UNCOMMONS, STARTING_RARES, STARTING_CREDITS, @@ -189,33 +189,36 @@ public class QuestPreferences extends PreferencesStore i WINS_HARDAI, WINS_EXPERTAI } - + /** Instantiates a QuestPreferences object. */ public QuestPreferences() { super(ForgeConstants.QUEST_PREFS_FILE, QPref.class); } + @Override protected QPref[] getEnumValues() { return QPref.values(); } - - protected QPref valueOf(String name) { + + @Override + protected QPref valueOf(final String name) { try { return QPref.valueOf(name); } - catch (Exception e) { + catch (final Exception e) { return null; } } - protected String getPrefDefault(QPref key) { + @Override + protected String getPrefDefault(final QPref key) { return key.getDefault(); } /** * Returns a preference value according to a difficulty index. */ - public String getPref(DifficultyPrefs pref, int difficultyIndex) { + public String getPref(final DifficultyPrefs pref, final int difficultyIndex) { String newQPref = pref.toString(); switch (difficultyIndex) { @@ -232,12 +235,7 @@ public class QuestPreferences extends PreferencesStore i newQPref += "_EXPERT"; break; default: - try { - throw new Exception(); - } catch (final Exception e1) { - System.err.println("Difficulty index out of bounds: " + difficultyIndex); - e1.printStackTrace(); - } + throw new IllegalArgumentException(String.format("Difficulty index %d out of bounds, preference %s", Integer.valueOf(difficultyIndex), newQPref)); } return getPref(QPref.valueOf(newQPref)); @@ -246,125 +244,60 @@ public class QuestPreferences extends PreferencesStore i /** * Returns a difficulty-indexed preference value, as an int. */ - public int getPrefInt(DifficultyPrefs pref, int difficultyIndex) { + public int getPrefInt(final DifficultyPrefs pref, final int difficultyIndex) { return Integer.parseInt(this.getPref(pref, difficultyIndex)); } - /** - * Gets the difficulty. - */ - public static String getDifficulty(int difficultyIndex) { - String s; - switch (difficultyIndex) { - case 1: - s = "EASY"; - break; - case 2: - s = "MEDIUM"; - break; - case 3: - s = "HARD"; - break; - case 4: - s = "EXPERT"; - break; - default: - s = "UNKNOWN"; - } - return s; - } - - public String validatePreference(QPref qpref, int val) { - int temp1, temp2; + public String validatePreference(final QPref qpref, final int val) { switch (qpref) { - case STARTING_CREDITS_EASY: case STARTING_CREDITS_MEDIUM: - case STARTING_CREDITS_HARD: case STARTING_CREDITS_EXPERT: - case REWARDS_MILLED: case REWARDS_MULLIGAN0: - case REWARDS_ALTERNATIVE: case REWARDS_TURN5: - if (val > 500) { - return "Value too large (maximum 500)."; - } - break; - case BOOSTER_COMMONS: - temp1 = getPrefInt(QPref.BOOSTER_UNCOMMONS); - temp2 = getPrefInt(QPref.BOOSTER_RARES); + case STARTING_POOL_COLOR_BIAS: + if (val < 1) { + return "Bias value too small (minimum 1)."; + } else if (val > 10) { + return "Bias value too large (maximum 10)."; + } + break; - if (temp1 + temp2 + val > 15) { - return "Booster packs must have maximum 15 cards."; - } - break; - case BOOSTER_UNCOMMONS: - temp1 = getPrefInt(QPref.BOOSTER_COMMONS); - temp2 = getPrefInt(QPref.BOOSTER_RARES); + case ITEM_LEVEL_RESTRICTION: + if (val != 0 && val != 1) { + return "Only values 0 or 1 are acceptable; 1 for enabled, 0 for disabled."; + } + break; - if (temp1 + temp2 + val > 15) { - return "Booster packs must have maximum 15 cards."; - } - break; - case BOOSTER_RARES: - temp1 = getPrefInt(QPref.BOOSTER_COMMONS); - temp2 = getPrefInt(QPref.BOOSTER_UNCOMMONS); + case SHOP_MAX_PACKS: + case SHOP_MAX_SELLING_PRICE: + case SHOP_WINS_FOR_ADDITIONAL_PACK: + case WINS_NEW_DRAFT: + case WINS_ROTATE_DRAFT: + case WINS_UNLOCK_SET: + if (val < 1) { + return "Value too small (minimum 1)."; + } + break; - if (temp1 + temp2 + val > 15) { - return "Booster packs must have maximum 15 cards."; - } - break; - case REWARDS_TURN1: - if (val > 2000) { - return "Value too large (maximum 2000)."; - } - break; - case SHOP_STARTING_PACKS: - case SHOP_SINGLES_COMMON: case SHOP_SINGLES_UNCOMMON: case SHOP_SINGLES_RARE: - if (val < 0) { - return "Value too small (minimum 0)."; - } else if (val > 15) { - return "Value too large (maximum 15)."; - } - break; - case SHOP_WINS_FOR_ADDITIONAL_PACK: case SHOP_MAX_PACKS: case SHOP_MIN_PACKS: - if (val < 1) { - return "Value too small (minimum 1)."; - } else if (val > 25) { - return "Value too large (maximum 25)."; - } - break; - case WINS_UNLOCK_SET: - if (val < 1) { - return "Value too small (minimum 1)."; - } else if (val > 100) { - return "Value too large (maximum 100)."; - } - break; - case STARTING_POOL_COLOR_BIAS: - if (val < 1) { - return "Bias value too small (minimum 1)."; - } else if (val > 10) { - return "Bias value too large (maximum 10)."; - } - break; - case ITEM_LEVEL_RESTRICTION: - if (val != 0 && val != 1) { - return "Only values 0 or 1 are acceptable. 1 for enabled, 0 for disabled."; - } - break; - case SHOP_WINS_FOR_NO_SELL_LIMIT: - if (val < 0) { - return "Value too small (minimum 0)."; - } - break; - case WINS_NEW_DRAFT: - case WINS_ROTATE_DRAFT: - case SHOP_MAX_SELLING_PRICE: - if (val < 1) { - return "Value too small (minimum 1)."; - } - break; - default: - if (val > 100) { - return "Value too large (maximum 100)."; - } - break; + case BOOSTER_COMMONS: + case BOOSTER_UNCOMMONS: + case BOOSTER_RARES: + case STARTING_CREDITS_EASY: + case STARTING_CREDITS_MEDIUM: + case STARTING_CREDITS_HARD: + case STARTING_CREDITS_EXPERT: + case REWARDS_MILLED: + case REWARDS_MULLIGAN0: + case REWARDS_ALTERNATIVE: + case REWARDS_TURN5: + case REWARDS_TURN1: + case SHOP_MIN_PACKS: + case SHOP_STARTING_PACKS: + case SHOP_SINGLES_COMMON: + case SHOP_SINGLES_UNCOMMON: + case SHOP_SINGLES_RARE: + case SHOP_WINS_FOR_NO_SELL_LIMIT: + default: + if (val < 0) { + return "Value too small (minimum 0)."; + } + break; } return null; }