summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/JRummikub.java4
-rw-r--r--src/jrummikub/control/GameControl.java9
-rw-r--r--src/jrummikub/model/GameSettings.java33
-rw-r--r--src/jrummikub/model/IRoundState.java11
-rw-r--r--src/jrummikub/model/RoundState.java20
5 files changed, 68 insertions, 9 deletions
diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java
index e9fd9dd..a1fada3 100644
--- a/src/jrummikub/JRummikub.java
+++ b/src/jrummikub/JRummikub.java
@@ -3,6 +3,7 @@ package jrummikub;
import javax.swing.UIManager;
import jrummikub.control.GameControl;
+import jrummikub.model.GameSettings;
import jrummikub.view.impl.View;
/**
@@ -24,9 +25,10 @@ public class JRummikub {
} catch (Exception e) {
}
+ GameSettings gameSettings = new GameSettings();
View view = new View();
- GameControl gameControl = new GameControl(view);
+ GameControl gameControl = new GameControl(gameSettings, view);
gameControl.startGame();
}
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java
index 14e5adc..195eba3 100644
--- a/src/jrummikub/control/GameControl.java
+++ b/src/jrummikub/control/GameControl.java
@@ -1,5 +1,6 @@
package jrummikub.control;
+import jrummikub.model.GameSettings;
import jrummikub.model.RoundState;
import jrummikub.util.IListener;
import jrummikub.view.IView;
@@ -8,16 +9,20 @@ import jrummikub.view.IView;
* Controls a Game, at some point including all Rounds, starts new Rounds
*/
public class GameControl {
+ private GameSettings gameSettings;
private IView view;
private RoundControl roundControl;
/**
* Constructor
*
+ * @param gameSettings
+ * the game settings
* @param view
* the view
*/
- public GameControl(IView view) {
+ public GameControl(GameSettings gameSettings, IView view) {
+ this.gameSettings = gameSettings;
this.view = view;
view.getNewGameEvent().add(new IListener() {
@@ -46,7 +51,7 @@ public class GameControl {
return;
}
- RoundState gameState = new RoundState();
+ RoundState gameState = new RoundState(gameSettings);
roundControl = new RoundControl(gameState, view);
roundControl.getEndRoundEvent().add(new IListener() {
diff --git a/src/jrummikub/model/GameSettings.java b/src/jrummikub/model/GameSettings.java
new file mode 100644
index 0000000..b7177ef
--- /dev/null
+++ b/src/jrummikub/model/GameSettings.java
@@ -0,0 +1,33 @@
+package jrummikub.model;
+
+/**
+ * The overall game settings
+ */
+public class GameSettings {
+ private int initialMeldThreshold;
+
+ /**
+ * Creates new GameSettings with default values
+ */
+ public GameSettings() {
+ initialMeldThreshold = 30;
+ }
+
+ /**
+ * Sets the initial meld threshold
+ *
+ * @param value the value to set
+ */
+ public void setInitialMeldThreshold(int value) {
+ initialMeldThreshold = value;
+ }
+
+ /**
+ * Returns the initial meld threshold
+ *
+ * @return the threshold
+ */
+ public int getInitialMeldThreshold() {
+ return initialMeldThreshold;
+ }
+}
diff --git a/src/jrummikub/model/IRoundState.java b/src/jrummikub/model/IRoundState.java
index cb6cd73..af7a478 100644
--- a/src/jrummikub/model/IRoundState.java
+++ b/src/jrummikub/model/IRoundState.java
@@ -6,6 +6,13 @@ package jrummikub.model;
public interface IRoundState {
/**
+ * Get the current {@link GameSettings}
+ *
+ * @return The game settings
+ */
+ public GameSettings getGameSettings();
+
+ /**
* Get the current {@link Table}
*
* @return The current Table
@@ -16,7 +23,7 @@ public interface IRoundState {
* Sets the current {@link Table}
*
* @param table
- * The new Table
+ * The new Table
*/
public void setTable(ITable table);
@@ -48,7 +55,7 @@ public interface IRoundState {
* Returns the player that would be the active player after i turns
*
* @param i
- * number of turns
+ * number of turns
* @return player active after i turns
*/
public IPlayer getNthNextPlayer(int i);
diff --git a/src/jrummikub/model/RoundState.java b/src/jrummikub/model/RoundState.java
index 82d93b0..4a27d2d 100644
--- a/src/jrummikub/model/RoundState.java
+++ b/src/jrummikub/model/RoundState.java
@@ -4,17 +4,24 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
-/** Class managing the overall and momentary GameState */
+/** Class managing the overall and momentary RoundState */
public class RoundState implements IRoundState {
+ private GameSettings gameSettings;
+
private ITable table;
private List<Player> players;
private int activePlayer;
private StoneHeap gameHeap;
- /**
- * Create a new GameState with an empty table and (currently) 4 new players.
+ /**
+ * Create a new RoundState with an empty table
+ *
+ * @param gameSettings
+ * the game settings
*/
- public RoundState() {
+ public RoundState(GameSettings gameSettings) {
+ this.gameSettings = gameSettings;
+
table = new Table();
players = new ArrayList<Player>();
players.add(new Player("Ida", Color.RED));
@@ -59,4 +66,9 @@ public class RoundState implements IRoundState {
public StoneHeap getGameHeap() {
return gameHeap;
}
+
+ @Override
+ public GameSettings getGameSettings() {
+ return gameSettings;
+ }
}