Relax quest pref constraints and cleanup related code

This commit is contained in:
elcnesh
2015-04-30 09:58:54 +00:00
parent 324a3aac5c
commit 0ab47360b2
3 changed files with 239 additions and 298 deletions

View File

@@ -1,13 +1,15 @@
package forge.screens.home.quest; package forge.screens.home.quest;
import javax.swing.SwingUtilities;
import com.google.common.primitives.Ints;
import forge.UiCommand; import forge.UiCommand;
import forge.gui.framework.ICDoc; import forge.gui.framework.ICDoc;
import forge.model.FModel; import forge.model.FModel;
import forge.quest.data.QuestPreferences; import forge.quest.data.QuestPreferences;
import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput; import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput;
import javax.swing.*;
/** /**
* Controls the quest preferences submenu in the home UI. * Controls the quest preferences submenu in the home UI.
* *
@@ -15,7 +17,6 @@ import javax.swing.*;
* *
*/ */
public enum CSubmenuQuestPrefs implements ICDoc { public enum CSubmenuQuestPrefs implements ICDoc {
/** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
@Override @Override
@@ -40,17 +41,20 @@ public enum CSubmenuQuestPrefs implements ICDoc {
} }
/** /**
* Checks validity of values entered into prefInputs. * Checks validity of values entered into quest preference input text
* @param i0   a PrefInput object * 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; } if (i0.getText().equals(i0.getPreviousText())) { return; }
final QuestPreferences prefs = FModel.getQuestPreferences(); final QuestPreferences prefs = FModel.getQuestPreferences();
int val = Integer.parseInt(i0.getText()); final Integer val = Ints.tryParse(i0.getText());
resetErrors(); 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) { if (validationError != null) {
showError(i0, validationError); showError(i0, validationError);
return; return;
@@ -61,9 +65,9 @@ public enum CSubmenuQuestPrefs implements ICDoc {
i0.setPreviousText(i0.getText()); 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; final VSubmenuQuestPrefs view = VSubmenuQuestPrefs.SINGLETON_INSTANCE;
String s = "Save failed: " + s0; final String s = "Save failed: " + s0;
switch(i0.getErrType()) { switch(i0.getErrType()) {
case BOOSTER: case BOOSTER:
view.getLblErrBooster().setVisible(true); view.getLblErrBooster().setVisible(true);
@@ -82,6 +86,7 @@ public enum CSubmenuQuestPrefs implements ICDoc {
view.getLblErrShop().setText(s); view.getLblErrShop().setText(s);
break; break;
default: default:
break;
} }
i0.setText(i0.getPreviousText()); i0.setText(i0.getPreviousText());

View File

@@ -1,5 +1,18 @@
package forge.screens.home.quest; 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.assets.FSkinProp;
import forge.gui.framework.DragCell; import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab; import forge.gui.framework.DragTab;
@@ -16,16 +29,6 @@ import forge.toolbox.FScrollPane;
import forge.toolbox.FSkin; import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinColor; import forge.toolbox.FSkin.SkinColor;
import forge.toolbox.FSkin.SkinnedTextField; 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. * Assembles Swing components of quest preferences submenu singleton.
@@ -195,45 +198,45 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
focusTarget.requestFocusInWindow(); focusTarget.requestFocusInWindow();
} }
private final String constraints1 = "w 60px!, h 26px!"; private final static String fieldConstraints = "w 60px!, h 26px!";
private final String constraints2 = "w 200px!, h 26px!, gap 0 10px 0 0"; private final static String labelConstraints = "w 200px!, h 26px!, gap 0 10px 0 0";
private void populateRewards() { private void populateRewards() {
pnlRewards.setOpaque(false); 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.removeAll();
pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1"); 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); 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 FLabel.Builder().text("No Losses").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_UNDEFEATED, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Poison Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_POISON, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Milling Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_MILLED, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Mulligan 0 Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_MULLIGAN0, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Alternative Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_ALTERNATIVE, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Win by Turn 15").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_TURN15, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Win by Turn 10").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_TURN10, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("Win by Turn 5").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_TURN5, QuestPreferencesErrType.REWARDS), constraints1); 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 FLabel.Builder().text("First Turn Win").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlRewards.add(new PrefInput(QPref.REWARDS_TURN1, QuestPreferencesErrType.REWARDS), constraints1); pnlRewards.add(new PrefInput(QPref.REWARDS_TURN1, QuestPreferencesErrType.REWARDS), fieldConstraints);
} }
private void populateDifficulty() { private void populateDifficulty() {
@@ -243,83 +246,83 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlDifficulty.removeAll(); pnlDifficulty.removeAll();
pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1"); pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1");
pnlDifficulty.add(new FLabel.Builder().text("").build(), constraints2); pnlDifficulty.add(new FLabel.Builder().text("").build(), labelConstraints);
pnlDifficulty.add(new FLabel.Builder().text("Easy").build(), constraints1); pnlDifficulty.add(new FLabel.Builder().text("Easy").build(), fieldConstraints);
pnlDifficulty.add(new FLabel.Builder().text("Medium").build(), constraints1); pnlDifficulty.add(new FLabel.Builder().text("Medium").build(), fieldConstraints);
pnlDifficulty.add(new FLabel.Builder().text("Hard").build(), constraints1); pnlDifficulty.add(new FLabel.Builder().text("Hard").build(), fieldConstraints);
pnlDifficulty.add(new FLabel.Builder().text("Expert").build(), constraints1); 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 FLabel.Builder().text("Wins for Booster").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Wins for Rank Increase").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Wins for Medium AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Wins for Hard AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Wins for Expert AI").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Starting Commons").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Starting Uncommons").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Starting Rares").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Starting Credits").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EASY, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EASY, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_MEDIUM, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_HARD, QuestPreferencesErrType.DIFFICULTY), constraints1); pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_HARD, QuestPreferencesErrType.DIFFICULTY), fieldConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EXPERT, QuestPreferencesErrType.DIFFICULTY), constraints1); 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 FLabel.Builder().text("Starting Basic Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_BASIC_LANDS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); 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 FLabel.Builder().text("Wins for New Draft").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_DRAFT, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); 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 FLabel.Builder().text("Wins per Draft Rotation").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_ROTATE_DRAFT, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); 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 FLabel.Builder().text("Starting Snow Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); 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 FLabel.Builder().text("Color Bias (1-10)").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_POOL_COLOR_BIAS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); 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(), constraints2); pnlDifficulty.add(new FLabel.Builder().text("Penalty for Loss").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), constraints1 + ", wrap"); pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
} }
@@ -330,14 +333,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlBooster.removeAll(); pnlBooster.removeAll();
pnlBooster.add(lblErrBooster, "w 100%!, h 30px!, span 2 1"); 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 FLabel.Builder().text("Common").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlBooster.add(new PrefInput(QPref.BOOSTER_COMMONS, QuestPreferencesErrType.BOOSTER), constraints1); 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 FLabel.Builder().text("Uncommon").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlBooster.add(new PrefInput(QPref.BOOSTER_UNCOMMONS, QuestPreferencesErrType.BOOSTER), constraints1); 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 FLabel.Builder().text("Rare").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlBooster.add(new PrefInput(QPref.BOOSTER_RARES, QuestPreferencesErrType.BOOSTER), constraints1); pnlBooster.add(new PrefInput(QPref.BOOSTER_RARES, QuestPreferencesErrType.BOOSTER), fieldConstraints);
} }
@@ -348,38 +351,38 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlShop.removeAll(); pnlShop.removeAll();
pnlShop.add(lblErrShop, "w 100%!, h 30px!, span 2 1"); 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 FLabel.Builder().text("Maximum Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_MAX_PACKS, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Minimum Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_MIN_PACKS, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Starting Packs").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_STARTING_PACKS, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Wins for Pack").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Wins per Set Unlock").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.WINS_UNLOCK_SET, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Common Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_COMMON, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Uncommon Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_UNCOMMON, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Rare Singles").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, QuestPreferencesErrType.SHOP), constraints1); 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 FLabel.Builder().text("Card Sale Price Cap").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.SHOP_MAX_SELLING_PRICE, QuestPreferencesErrType.SHOP), constraints1); 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 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), constraints1); 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(), constraints2); pnlShop.add(new FLabel.Builder().text("Item Level Restriction").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, QuestPreferencesErrType.SHOP), constraints1); pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, QuestPreferencesErrType.SHOP), fieldConstraints);
} }
@@ -398,7 +401,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
* @param e0 &emsp; {@link forge.view.home.ViewQuestPreference.QuestPreferencesErrType} * @param e0 &emsp; {@link forge.view.home.ViewQuestPreference.QuestPreferencesErrType}
* where error should display to * where error should display to
*/ */
public PrefInput(QPref qp0, QuestPreferencesErrType e0) { public PrefInput(final QPref qp0, final QuestPreferencesErrType e0) {
super(); super();
this.qpref = qp0; this.qpref = qp0;
@@ -419,14 +422,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(final MouseEvent e) {
if (isFocus) { return; } if (isFocus) { return; }
setOpaque(true); setOpaque(true);
repaint(); repaint();
} }
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(final MouseEvent e) {
if (isFocus) { return; } if (isFocus) { return; }
setOpaque(false); setOpaque(false);
repaint(); repaint();
@@ -435,14 +438,14 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
this.addFocusListener(new FocusAdapter() { this.addFocusListener(new FocusAdapter() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(final FocusEvent e) {
isFocus = true; isFocus = true;
setOpaque(true); setOpaque(true);
setBackground(clrActive); setBackground(clrActive);
} }
@Override @Override
public void focusLost(FocusEvent e) { public void focusLost(final FocusEvent e) {
isFocus = false; isFocus = false;
setOpaque(false); setOpaque(false);
setBackground(clrHover); setBackground(clrHover);
@@ -468,7 +471,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
} }
/** @param s0 &emsp; {@link java.lang.String} */ /** @param s0 &emsp; {@link java.lang.String} */
public void setPreviousText(String s0) { public void setPreviousText(final String s0) {
this.previousText = s0; this.previousText = s0;
} }
} }
@@ -503,7 +506,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
* @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell) * @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell)
*/ */
@Override @Override
public void setParentCell(DragCell cell0) { public void setParentCell(final DragCell cell0) {
this.parentCell = cell0; this.parentCell = cell0;
} }

View File

@@ -17,13 +17,14 @@
*/ */
package forge.quest.data; package forge.quest.data;
import java.io.Serializable;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.properties.PreferencesStore; import forge.properties.PreferencesStore;
import java.io.Serializable;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> implements Serializable { public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> implements Serializable {
/** /**
* Preference identifiers, and their default values. * Preference identifiers, and their default values.
*/ */
@@ -155,7 +156,6 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
ITEM_LEVEL_RESTRICTION("1"); ITEM_LEVEL_RESTRICTION("1");
private final String strDefaultVal; private final String strDefaultVal;
/** /**
@@ -164,7 +164,7 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
* @param s0 * @param s0
* &emsp; {@link java.lang.String} * &emsp; {@link java.lang.String}
*/ */
QPref(final String s0) { private QPref(final String s0) {
this.strDefaultVal = s0; this.strDefaultVal = s0;
} }
@@ -195,27 +195,30 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
super(ForgeConstants.QUEST_PREFS_FILE, QPref.class); super(ForgeConstants.QUEST_PREFS_FILE, QPref.class);
} }
@Override
protected QPref[] getEnumValues() { protected QPref[] getEnumValues() {
return QPref.values(); return QPref.values();
} }
protected QPref valueOf(String name) { @Override
protected QPref valueOf(final String name) {
try { try {
return QPref.valueOf(name); return QPref.valueOf(name);
} }
catch (Exception e) { catch (final Exception e) {
return null; return null;
} }
} }
protected String getPrefDefault(QPref key) { @Override
protected String getPrefDefault(final QPref key) {
return key.getDefault(); return key.getDefault();
} }
/** /**
* Returns a preference value according to a difficulty index. * 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(); String newQPref = pref.toString();
switch (difficultyIndex) { switch (difficultyIndex) {
@@ -232,12 +235,7 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
newQPref += "_EXPERT"; newQPref += "_EXPERT";
break; break;
default: default:
try { throw new IllegalArgumentException(String.format("Difficulty index %d out of bounds, preference %s", Integer.valueOf(difficultyIndex), newQPref));
throw new Exception();
} catch (final Exception e1) {
System.err.println("Difficulty index out of bounds: " + difficultyIndex);
e1.printStackTrace();
}
} }
return getPref(QPref.valueOf(newQPref)); return getPref(QPref.valueOf(newQPref));
@@ -246,96 +244,12 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
/** /**
* Returns a difficulty-indexed preference value, as an int. * 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)); return Integer.parseInt(this.getPref(pref, difficultyIndex));
} }
/** public String validatePreference(final QPref qpref, final int val) {
* 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;
switch (qpref) { 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);
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);
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);
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: case STARTING_POOL_COLOR_BIAS:
if (val < 1) { if (val < 1) {
return "Bias value too small (minimum 1)."; return "Bias value too small (minimum 1).";
@@ -343,26 +257,45 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
return "Bias value too large (maximum 10)."; return "Bias value too large (maximum 10).";
} }
break; break;
case ITEM_LEVEL_RESTRICTION: case ITEM_LEVEL_RESTRICTION:
if (val != 0 && val != 1) { if (val != 0 && val != 1) {
return "Only values 0 or 1 are acceptable. 1 for enabled, 0 for disabled."; 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; break;
case SHOP_MAX_PACKS:
case SHOP_MAX_SELLING_PRICE:
case SHOP_WINS_FOR_ADDITIONAL_PACK:
case WINS_NEW_DRAFT: case WINS_NEW_DRAFT:
case WINS_ROTATE_DRAFT: case WINS_ROTATE_DRAFT:
case SHOP_MAX_SELLING_PRICE: case WINS_UNLOCK_SET:
if (val < 1) { if (val < 1) {
return "Value too small (minimum 1)."; return "Value too small (minimum 1).";
} }
break; 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: default:
if (val > 100) { if (val < 0) {
return "Value too large (maximum 100)."; return "Value too small (minimum 0).";
} }
break; break;
} }