summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mock/jrummikub/model/MockPlayer.java26
-rw-r--r--mock/jrummikub/model/MockRoundState.java8
-rw-r--r--src/jrummikub/control/RoundControl.java8
-rw-r--r--src/jrummikub/model/IPlayer.java17
-rw-r--r--src/jrummikub/model/Player.java30
-rw-r--r--src/jrummikub/model/PlayerSettings.java42
-rw-r--r--src/jrummikub/model/RoundState.java8
-rw-r--r--test/jrummikub/model/RoundStateTest.java6
8 files changed, 80 insertions, 65 deletions
diff --git a/mock/jrummikub/model/MockPlayer.java b/mock/jrummikub/model/MockPlayer.java
index a6dfe01..a580a48 100644
--- a/mock/jrummikub/model/MockPlayer.java
+++ b/mock/jrummikub/model/MockPlayer.java
@@ -1,7 +1,5 @@
package jrummikub.model;
-import java.awt.Color;
-
/**
* Mock class for {@link Player}
*/
@@ -9,22 +7,17 @@ public class MockPlayer implements IPlayer {
/** */
public Hand hand;
/** */
- public String name;
- /** */
- public Color color;
+ public PlayerSettings playerSettings;
/** */
public boolean laidOut;
/**
- * @param name
- * the player name
- * @param color
- * the player color
+ * @param playerSettings
+ * the player settings
*/
- public MockPlayer(String name, Color color) {
+ public MockPlayer(PlayerSettings playerSettings) {
hand = new Hand();
- this.name = name;
- this.color = color;
+ this.playerSettings = playerSettings;
laidOut = false;
}
@@ -39,12 +32,7 @@ public class MockPlayer implements IPlayer {
}
@Override
- public Color getColor() {
- return color;
- }
-
- @Override
- public String getName() {
- return name;
+ public PlayerSettings getPlayerSettings() {
+ return playerSettings;
}
}
diff --git a/mock/jrummikub/model/MockRoundState.java b/mock/jrummikub/model/MockRoundState.java
index b7ec1eb..7b58fab 100644
--- a/mock/jrummikub/model/MockRoundState.java
+++ b/mock/jrummikub/model/MockRoundState.java
@@ -25,10 +25,10 @@ public class MockRoundState implements IRoundState {
public MockRoundState() {
table = new MockTable();
players = new ArrayList<MockPlayer>();
- players.add(new MockPlayer("Player 1", Color.RED));
- players.add(new MockPlayer("Player 2", Color.YELLOW));
- players.add(new MockPlayer("Player 3", Color.GREEN));
- players.add(new MockPlayer("Player 4", Color.BLACK));
+ players.add(new MockPlayer(new PlayerSettings("Player 1", Color.RED)));
+ players.add(new MockPlayer(new PlayerSettings("Player 2", Color.YELLOW)));
+ players.add(new MockPlayer(new PlayerSettings("Player 3", Color.GREEN)));
+ players.add(new MockPlayer(new PlayerSettings("Player 4", Color.BLACK)));
activePlayer = 0;
gameHeap = new StoneHeap();
gameSettings = new GameSettings();
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 07adb99..9b746d1 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -72,13 +72,13 @@ public class RoundControl {
clonedTable = (ITable) gameState.getTable().clone();
view.enableStartTurnPanel(true);
view.getTablePanel().setStoneSets(clonedTable);
- view.setCurrentPlayerName(gameState.getActivePlayer().getName());
+ view.setCurrentPlayerName(gameState.getActivePlayer().getPlayerSettings().getName());
view.getTablePanel().setLeftPlayerName(
- gameState.getNthNextPlayer(1).getName());
+ gameState.getNthNextPlayer(1).getPlayerSettings().getName());
view.getTablePanel().setTopPlayerName(
- gameState.getNthNextPlayer(2).getName());
+ gameState.getNthNextPlayer(2).getPlayerSettings().getName());
view.getTablePanel().setRightPlayerName(
- gameState.getNthNextPlayer(3).getName());
+ gameState.getNthNextPlayer(3).getPlayerSettings().getName());
}
private void startTurn() {
diff --git a/src/jrummikub/model/IPlayer.java b/src/jrummikub/model/IPlayer.java
index ebe77fa..1ae6f12 100644
--- a/src/jrummikub/model/IPlayer.java
+++ b/src/jrummikub/model/IPlayer.java
@@ -1,7 +1,5 @@
package jrummikub.model;
-import java.awt.Color;
-
/**
* Interface for {@link Player} model
*/
@@ -15,19 +13,16 @@ public interface IPlayer {
public IHand getHand();
/**
- * Return the player's color
+ * Has the player laid out yet?
*
- * @return the player's color
+ * @return if the player has laid out
*/
- public Color getColor();
+ public boolean getLaidOut();
/**
- * Return the name of the player
+ * Returns the player settings
*
- * @return the player's name
+ * @return the player settings
*/
- public String getName();
-
- boolean getLaidOut();
-
+ public PlayerSettings getPlayerSettings();
} \ No newline at end of file
diff --git a/src/jrummikub/model/Player.java b/src/jrummikub/model/Player.java
index 9444b5a..f482f28 100644
--- a/src/jrummikub/model/Player.java
+++ b/src/jrummikub/model/Player.java
@@ -1,46 +1,36 @@
package jrummikub.model;
-import java.awt.Color;
-
/** Class managing player data. No methods in release 1 */
public class Player implements IPlayer {
-
+ private PlayerSettings settings;
private IHand hand;
- private String name;
- private Color color;
private boolean laidOut;
/**
* Create a new player with a given name and color
*
- * @param name
- * player name
- * @param color
- * player's color
+ * @param settings
+ * the player settings
*/
- public Player(String name, Color color) {
+ public Player(PlayerSettings settings) {
+ this.settings = settings;
+
hand = new Hand();
- this.name = name;
- this.color = color;
+ laidOut = false;
}
@Override
public IHand getHand() {
return hand;
}
-
+
@Override
public boolean getLaidOut() {
return laidOut;
}
@Override
- public Color getColor() {
- return color;
- }
-
- @Override
- public String getName() {
- return name;
+ public PlayerSettings getPlayerSettings() {
+ return settings;
}
}
diff --git a/src/jrummikub/model/PlayerSettings.java b/src/jrummikub/model/PlayerSettings.java
new file mode 100644
index 0000000..87c2a27
--- /dev/null
+++ b/src/jrummikub/model/PlayerSettings.java
@@ -0,0 +1,42 @@
+package jrummikub.model;
+
+import java.awt.Color;
+
+/**
+ * The settings of a player
+ */
+public class PlayerSettings {
+ private String name;
+ private Color color;
+
+ /**
+ * Create a new human player
+ *
+ * @param name
+ * the player's name
+ * @param color
+ * the player's color
+ */
+ public PlayerSettings(String name, Color color) {
+ this.name = name;
+ this.color = color;
+ }
+
+ /**
+ * Returns the player's color
+ *
+ * @return the color
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * Returns the player's name
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+}
diff --git a/src/jrummikub/model/RoundState.java b/src/jrummikub/model/RoundState.java
index 4a27d2d..b566fdf 100644
--- a/src/jrummikub/model/RoundState.java
+++ b/src/jrummikub/model/RoundState.java
@@ -24,10 +24,10 @@ public class RoundState implements IRoundState {
table = new Table();
players = new ArrayList<Player>();
- players.add(new Player("Ida", Color.RED));
- players.add(new Player("Matthias", Color.YELLOW));
- players.add(new Player("Jannis", Color.GREEN));
- players.add(new Player("Bennet", Color.BLACK));
+ 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)));
activePlayer = 0;
gameHeap = new StoneHeap();
}
diff --git a/test/jrummikub/model/RoundStateTest.java b/test/jrummikub/model/RoundStateTest.java
index 18afb53..de98090 100644
--- a/test/jrummikub/model/RoundStateTest.java
+++ b/test/jrummikub/model/RoundStateTest.java
@@ -23,13 +23,13 @@ public class RoundStateTest {
public void nextActiveTest() {
// All there?
assertEquals(4, testGame.getPlayerCount());
- assertSame(Color.red, testGame.getActivePlayer().getColor());
+ assertSame(Color.red, testGame.getActivePlayer().getPlayerSettings().getColor());
testGame.nextPlayer();
- assertSame(Color.yellow, testGame.getActivePlayer().getColor());
+ assertSame(Color.yellow, testGame.getActivePlayer().getPlayerSettings().getColor());
testGame.nextPlayer();
testGame.nextPlayer();
testGame.nextPlayer();
- assertSame(Color.red, testGame.getActivePlayer().getColor());
+ assertSame(Color.red, testGame.getActivePlayer().getPlayerSettings().getColor());
}
}