From 70d6ae6d749d11ced007fa781ce65c6e27229007 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Mon, 13 Jun 2011 18:22:55 +0200 Subject: Player Type in player settings verschoben git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@420 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/RoundControl.java | 2 +- src/jrummikub/control/SettingsControl.java | 39 ++++++++++++---------- src/jrummikub/control/turn/TurnControlFactory.java | 14 ++------ 3 files changed, 26 insertions(+), 29 deletions(-) (limited to 'src/jrummikub/control') diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 281b367..a420b6d 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -1,6 +1,6 @@ package jrummikub.control; -import static jrummikub.control.turn.TurnControlFactory.Type.*; +import static jrummikub.model.PlayerSettings.Type.*; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java index ad88b70..0da2f19 100644 --- a/src/jrummikub/control/SettingsControl.java +++ b/src/jrummikub/control/SettingsControl.java @@ -6,10 +6,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import jrummikub.control.turn.TurnControlFactory; -import jrummikub.control.turn.TurnControlFactory.Type; import jrummikub.model.GameSettings; import jrummikub.model.PlayerSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.Connection; import jrummikub.util.Event1; @@ -34,9 +33,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 +43,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,7 +77,8 @@ public class SettingsControl { private void addOptionListeners1() { connections.add(view.getSettingsPanel() - .getChangeInitialMeldThresholdEvent().add(new IListener1() { + .getChangeInitialMeldThresholdEvent() + .add(new IListener1() { @Override public void handle(Integer value) { settings.setInitialMeldThreshold(value); @@ -103,7 +103,8 @@ public class SettingsControl { update(); } })); - connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent() + connections.add(view.getSettingsPanel() + .getChangeNumberOfStonesDealtEvent() .add(new IListener1() { @Override public void handle(Integer value) { @@ -206,9 +207,9 @@ public class SettingsControl { } })); connections.add(view.getSettingsPanel().getChangePlayerTypeEvent() - .add(new IListener2() { + .add(new IListener2() { @Override - public void handle(Integer i, TurnControlFactory.Type type) { + public void handle(Integer i, Type type) { setPlayerType(i, type); } })); @@ -246,7 +247,8 @@ public class SettingsControl { break; } - settings.getPlayerList().add(new PlayerSettings("Spieler " + num, color)); + settings.getPlayerList().add( + new PlayerSettings("Spieler " + num, color)); update(); } @@ -287,8 +289,9 @@ 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(); @@ -322,8 +325,9 @@ 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; } @@ -332,7 +336,8 @@ 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) { @@ -361,7 +366,7 @@ public class SettingsControl { boolean humanPlayerFound = false; for (PlayerSettings player : settings.getPlayerList()) { - if (player.getTurnControlType() == TurnControlFactory.Type.HUMAN) { + if (player.getTurnControlType() == Type.HUMAN) { humanPlayerFound = true; break; } diff --git a/src/jrummikub/control/turn/TurnControlFactory.java b/src/jrummikub/control/turn/TurnControlFactory.java index b42f7ff..4d143e7 100644 --- a/src/jrummikub/control/turn/TurnControlFactory.java +++ b/src/jrummikub/control/turn/TurnControlFactory.java @@ -1,21 +1,13 @@ package jrummikub.control.turn; +import jrummikub.model.PlayerSettings; + /** * Creates a turn control for the active player, regarding if layer is human or * computer * */ public abstract class TurnControlFactory { - /** - * Type of turn control. - */ - public enum Type { - /** */ - HUMAN, - /** */ - COMPUTER - }; - /** * Creates a new turn control instance * @@ -30,7 +22,7 @@ public abstract class TurnControlFactory { * Human or Computer * @return TurnControlFactory for the player kind */ - static public TurnControlFactory getFactory(Type type) { + static public TurnControlFactory getFactory(PlayerSettings.Type type) { switch (type) { case HUMAN: return HumanTurnControl.getFactory(); -- cgit v1.2.3