diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-13 23:31:47 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-13 23:31:47 +0200 |
commit | f5a05f2c8d42b9f5978d8118c065fa8a871ec2fd (patch) | |
tree | 041fb50e7384618ed2202628f12df602e8c40394 /src/jrummikub/control | |
parent | 570187c95000afd1ac9f6d6e8bb5cab30b984e87 (diff) | |
download | JRummikub-f5a05f2c8d42b9f5978d8118c065fa8a871ec2fd.tar JRummikub-f5a05f2c8d42b9f5978d8118c065fa8a871ec2fd.zip |
Kommentare und kleinere Umbauten
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@426 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
4 files changed, 34 insertions, 23 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java index 398ce5d..32e80fe 100644 --- a/src/jrummikub/control/SettingsControl.java +++ b/src/jrummikub/control/SettingsControl.java @@ -35,9 +35,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; @@ -71,8 +71,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 */ @@ -89,7 +89,8 @@ 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); @@ -114,7 +115,8 @@ public class SettingsControl { update(); } })); - connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent() + connections.add(view.getSettingsPanel() + .getChangeNumberOfStonesDealtEvent() .add(new IListener1<Integer>() { @Override public void handle(Integer value) { @@ -303,8 +305,9 @@ public class SettingsControl { view.getSettingsPanel().enableRemovePlayerButtons( Collections.nCopies(settings.getPlayerList().size(), enableRemoveButtons)); - view.getSettingsPanel().enableAddPlayerButton( - settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); + view.getSettingsPanel() + .enableAddPlayerButton( + settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); checkSettings(); @@ -317,6 +320,9 @@ public class SettingsControl { } protected boolean checkSettings() { + if (!checkName()) { + return false; + } if (!checkErrors()) { return false; } @@ -329,7 +335,7 @@ public class SettingsControl { return true; } - private boolean checkErrors() { + private boolean checkName() { for (PlayerSettings player : settings.getPlayerList()) { if (player.getName().isEmpty()) { view.getSettingsPanel().setError( @@ -350,17 +356,22 @@ public class SettingsControl { for (int j = i + 1; j < settings.getPlayerList().size(); ++j) { PlayerSettings player2 = settings.getPlayerList().get(j); if (player2.getName().equals(name) && player2.getType() == type) { - view.getSettingsPanel().setError( - ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR); + view.getSettingsPanel() + .setError( + ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR); view.getSettingsPanel().enableStartGameButton(false); return false; } } } + return true; + } + private boolean checkErrors() { 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) { diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java index fd8087a..7980c2d 100644 --- a/src/jrummikub/control/network/ConnectionControl.java +++ b/src/jrummikub/control/network/ConnectionControl.java @@ -7,10 +7,10 @@ import javax.swing.SwingUtilities; import jrummikub.model.GameSettings; import jrummikub.util.Event; import jrummikub.util.Event1; +import jrummikub.util.GameData; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; import jrummikub.util.LoginData; -import jrummikub.view.IGameListPanel.GameData; import org.jivesoftware.smack.Connection; import org.jivesoftware.smack.PacketListener; diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java index 929ce03..4f4dad6 100644 --- a/src/jrummikub/control/network/NetworkControl.java +++ b/src/jrummikub/control/network/NetworkControl.java @@ -9,12 +9,11 @@ import java.util.UUID; import jrummikub.model.GameSettings; import jrummikub.util.Connection; import jrummikub.util.Event; +import jrummikub.util.GameData; import jrummikub.util.IEvent; import jrummikub.util.IListener; import jrummikub.util.IListener1; import jrummikub.util.LoginData; -import jrummikub.view.IGameListPanel; -import jrummikub.view.IGameListPanel.GameData; import jrummikub.view.IView; /** @@ -45,7 +44,7 @@ public class NetworkControl { addConnectionControlListeners(loginData, view); connections.add(view.getGameListPanel().getJoinEvent() - .add(new IListener1<IGameListPanel.GameData>() { + .add(new IListener1<GameData>() { @Override public void handle(GameData value) { // TODO Auto-generated method stub @@ -107,7 +106,7 @@ public class NetworkControl { })); connections.add(connectionControl.getGameOfferEvent().add( - new IListener1<IGameListPanel.GameData>() { + new IListener1<GameData>() { @Override public void handle(GameData value) { GameData game = gameMap.get(value.getGameID()); diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java index 61fcfa3..3c8dc42 100644 --- a/src/jrummikub/control/network/NetworkSettingsControl.java +++ b/src/jrummikub/control/network/NetworkSettingsControl.java @@ -21,12 +21,12 @@ public class NetworkSettingsControl extends SettingsControl { /** * Creates a new network settings control * - * @param connectionControl - * for gameOffers + * @param nickname + * to be set as player name * @param view - * for events and handlers + * for events and handlers * @param settings - * for playerNumber, color... + * for playerNumber, color... */ public NetworkSettingsControl(String nickname, IView view, GameSettings settings) { @@ -45,8 +45,9 @@ public class NetworkSettingsControl extends SettingsControl { @Override protected void update() { - view.getSettingsPanel().enableAddPlayerButton( - settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); + view.getSettingsPanel() + .enableAddPlayerButton( + settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); checkSettings(); |