summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/SettingsControl.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index ffd1911..9cb216d 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -216,7 +216,7 @@ public class SettingsControl {
for (PlayerSettings player : settings.getPlayerList()) {
if (player.getName().isEmpty()) {
view.getSettingsPanel().setError(
- ISettingsPanel.SettingsError.NO_PLAYER_NAME);
+ ISettingsPanel.SettingsError.NO_PLAYER_NAME_ERROR);
view.getSettingsPanel().enableStartGameButton(false);
return false;
}
@@ -226,16 +226,50 @@ public class SettingsControl {
for (int j = i + 1; j < settings.getPlayerList().size(); ++j) {
if (settings.getPlayerList().get(j).getName().equals(name)) {
- view.getSettingsPanel().setError(
- ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME);
+ view.getSettingsPanel()
+ .setError(
+ ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
view.getSettingsPanel().enableStartGameButton(false);
return false;
}
}
}
+ int totalStonesDealt = settings.getNumberOfStonesDealt()
+ * settings.getPlayerList().size();
+ int totalStones = settings.getHighestCard() * settings.getStoneSetNumber()
+ * settings.getStoneColors().size() + settings.getJokerNumber();
+
+ if (totalStones <= totalStonesDealt) {
+ view.getSettingsPanel().setError(
+ ISettingsPanel.SettingsError.NOT_ENOUGH_STONES_ERROR);
+ view.getSettingsPanel().enableStartGameButton(false);
+ return false;
+ }
+
view.getSettingsPanel().setError(ISettingsPanel.SettingsError.NO_ERROR);
view.getSettingsPanel().enableStartGameButton(true);
+
+ if (settings.getInitialMeldThreshold() >= 100) {
+ view.getSettingsPanel().setError(
+ ISettingsPanel.SettingsError.TOO_HIGH_THRESHOLD_WARNING);
+ return true;
+ }
+
+ boolean humanPlayerFound = false;
+ for (PlayerSettings player : settings.getPlayerList()) {
+ if (player.getTurnControlType() == TurnControlFactory.Type.HUMAN) {
+ humanPlayerFound = true;
+ break;
+ }
+ }
+
+ if (!humanPlayerFound) {
+ view.getSettingsPanel().setError(
+ ISettingsPanel.SettingsError.COMPUTER_PLAYERS_ONLY_WARNING);
+ return true;
+ }
+
return true;
}