summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-13 17:19:26 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-13 17:19:26 +0200
commita4faa8db23589930a828250816ebaeddf787c689 (patch)
treec206089bd3329f37312043942f0c88d7a01346e3 /src/jrummikub
parent9f2d3aa5cd370683c94d73a76b2960ac3e46f33b (diff)
downloadJRummikub-a4faa8db23589930a828250816ebaeddf787c689.tar
JRummikub-a4faa8db23589930a828250816ebaeddf787c689.zip
Fix SettingsControl.checkSettings method length
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@419 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/control/SettingsControl.java48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 17d37a9..ad88b70 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -34,9 +34,9 @@ public class SettingsControl {
* Create a new settings control
*
* @param view
- * the view to use
+ * the view to use
* @param settings
- * initial game settings
+ * initial game settings
*/
public SettingsControl(IView view, GameSettings settings) {
this.view = view;
@@ -44,8 +44,8 @@ public class SettingsControl {
}
/**
- * the start game event is emitted when the user wants to start a game and
- * the settings made are valid
+ * the start game event is emitted when the user wants to start a game and the
+ * settings made are valid
*
* @return the event
*/
@@ -78,8 +78,7 @@ public class SettingsControl {
private void addOptionListeners1() {
connections.add(view.getSettingsPanel()
- .getChangeInitialMeldThresholdEvent()
- .add(new IListener1<Integer>() {
+ .getChangeInitialMeldThresholdEvent().add(new IListener1<Integer>() {
@Override
public void handle(Integer value) {
settings.setInitialMeldThreshold(value);
@@ -104,8 +103,7 @@ public class SettingsControl {
update();
}
}));
- connections.add(view.getSettingsPanel()
- .getChangeNumberOfStonesDealtEvent()
+ connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent()
.add(new IListener1<Integer>() {
@Override
public void handle(Integer value) {
@@ -248,8 +246,7 @@ public class SettingsControl {
break;
}
- settings.getPlayerList().add(
- new PlayerSettings("Spieler " + num, color));
+ settings.getPlayerList().add(new PlayerSettings("Spieler " + num, color));
update();
}
@@ -290,9 +287,8 @@ public class SettingsControl {
protected void update() {
view.getSettingsPanel().enableRemovePlayerButtons(
settings.getPlayerList().size() > 2);
- view.getSettingsPanel()
- .enableAddPlayerButton(
- settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length);
+ view.getSettingsPanel().enableAddPlayerButton(
+ settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length);
checkSettings();
@@ -300,6 +296,19 @@ public class SettingsControl {
}
private boolean checkSettings() {
+ if (!checkErrors()) {
+ return false;
+ }
+
+ view.getSettingsPanel().setError(ISettingsPanel.SettingsError.NO_ERROR);
+ view.getSettingsPanel().enableStartGameButton(true);
+
+ checkWarnings();
+
+ return true;
+ }
+
+ private boolean checkErrors() {
for (PlayerSettings player : settings.getPlayerList()) {
if (player.getName().isEmpty()) {
view.getSettingsPanel().setError(
@@ -313,9 +322,8 @@ 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_ERROR);
+ view.getSettingsPanel().setError(
+ ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
view.getSettingsPanel().enableStartGameButton(false);
return false;
}
@@ -324,8 +332,7 @@ public class SettingsControl {
int totalStonesDealt = settings.getNumberOfStonesDealt()
* settings.getPlayerList().size();
- int totalStones = settings.getHighestValue()
- * settings.getStoneSetNumber()
+ int totalStones = settings.getHighestValue() * settings.getStoneSetNumber()
* settings.getStoneColors().size() + settings.getJokerNumber();
if (totalStones <= totalStonesDealt) {
@@ -342,11 +349,6 @@ public class SettingsControl {
return false;
}
- view.getSettingsPanel().setError(ISettingsPanel.SettingsError.NO_ERROR);
- view.getSettingsPanel().enableStartGameButton(true);
-
- checkWarnings();
-
return true;
}