From e76977652d55463b98f847ce261926f0d9d7c0de Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 18 May 2011 17:01:11 +0200 Subject: RoundControl: Create players from player settings list from game settings git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@253 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/JRummikub.java | 11 ++++++++++- src/jrummikub/control/GameControl.java | 4 ++-- src/jrummikub/model/GameSettings.java | 17 ++++++++++++++++- src/jrummikub/model/RoundState.java | 10 +++++----- 4 files changed, 33 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java index a1fada3..9c22dc6 100644 --- a/src/jrummikub/JRummikub.java +++ b/src/jrummikub/JRummikub.java @@ -1,9 +1,12 @@ package jrummikub; +import java.awt.Color; + import javax.swing.UIManager; import jrummikub.control.GameControl; import jrummikub.model.GameSettings; +import jrummikub.model.PlayerSettings; import jrummikub.view.impl.View; /** @@ -15,7 +18,7 @@ public class JRummikub { * The main method * * @param args - * command line arguments + * command line arguments */ public static void main(String[] args) { String nativeLF = UIManager.getSystemLookAndFeelClassName(); @@ -26,6 +29,12 @@ public class JRummikub { } GameSettings gameSettings = new GameSettings(); + gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED)); + gameSettings.getPlayerList().add( + new PlayerSettings("Matthias", Color.YELLOW)); + gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN)); + gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK)); + View view = new View(); GameControl gameControl = new GameControl(gameSettings, view); diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java index 195eba3..b5d763a 100644 --- a/src/jrummikub/control/GameControl.java +++ b/src/jrummikub/control/GameControl.java @@ -51,9 +51,9 @@ public class GameControl { return; } - RoundState gameState = new RoundState(gameSettings); + RoundState roundState = new RoundState(gameSettings); - roundControl = new RoundControl(gameState, view); + roundControl = new RoundControl(roundState, view); roundControl.getEndRoundEvent().add(new IListener() { @Override diff --git a/src/jrummikub/model/GameSettings.java b/src/jrummikub/model/GameSettings.java index b7177ef..b5079d4 100644 --- a/src/jrummikub/model/GameSettings.java +++ b/src/jrummikub/model/GameSettings.java @@ -1,9 +1,14 @@ package jrummikub.model; +import java.util.ArrayList; +import java.util.List; + /** * The overall game settings */ public class GameSettings { + private List players = new ArrayList(); + private int initialMeldThreshold; /** @@ -13,10 +18,20 @@ public class GameSettings { initialMeldThreshold = 30; } + /** + * Returns the list containing the settings of all players + * + * @return the player settings list + */ + public List getPlayerList() { + return players; + } + /** * Sets the initial meld threshold * - * @param value the value to set + * @param value + * the value to set */ public void setInitialMeldThreshold(int value) { initialMeldThreshold = value; diff --git a/src/jrummikub/model/RoundState.java b/src/jrummikub/model/RoundState.java index b566fdf..56f7904 100644 --- a/src/jrummikub/model/RoundState.java +++ b/src/jrummikub/model/RoundState.java @@ -1,6 +1,5 @@ package jrummikub.model; -import java.awt.Color; import java.util.ArrayList; import java.util.List; @@ -24,10 +23,11 @@ public class RoundState implements IRoundState { table = new Table(); players = new ArrayList(); - players.add(new Player(new PlayerSettings("Ida", Color.RED))); - players.add(new Player(new PlayerSettings("Matthias", Color.YELLOW))); - players.add(new Player(new PlayerSettings("Jannis", Color.GREEN))); - players.add(new Player(new PlayerSettings("Bennet", Color.BLACK))); + + for (PlayerSettings playerSettings : gameSettings.getPlayerList()) { + players.add(new Player(playerSettings)); + } + activePlayer = 0; gameHeap = new StoneHeap(); } -- cgit v1.2.3