summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-30 20:16:48 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-30 20:16:48 +0200
commit1660736239d9f437f0ffa336d3f3bb8ed7ae407f (patch)
tree96185492c79b33ec3354b61550edff3f81c90aa1
parentc398c081ed4d83660ec867cabfb0ee9bc56b90ad (diff)
downloadJRummikub-1660736239d9f437f0ffa336d3f3bb8ed7ae407f.tar
JRummikub-1660736239d9f437f0ffa336d3f3bb8ed7ae407f.zip
Man kann jetzt die Anzahl der Steinsätze einstellen
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@328 72836036-5685-4462-b002-a69064685172
-rw-r--r--mock/jrummikub/view/MockSettingsPanel.java22
-rw-r--r--src/jrummikub/control/SettingsControl.java16
-rw-r--r--src/jrummikub/view/ISettingsPanel.java33
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java32
-rw-r--r--test/jrummikub/control/SettingsControlTest.java3
5 files changed, 36 insertions, 70 deletions
diff --git a/mock/jrummikub/view/MockSettingsPanel.java b/mock/jrummikub/view/MockSettingsPanel.java
index a159524..f296286 100644
--- a/mock/jrummikub/view/MockSettingsPanel.java
+++ b/mock/jrummikub/view/MockSettingsPanel.java
@@ -35,8 +35,6 @@ public class MockSettingsPanel implements ISettingsPanel {
public boolean addPlayerButtonEnabled = true;
/** */
public boolean removePlayerButtonsEnabled = false;
- /** */
- public GameSettings gameSettings = new GameSettings();
/** */
public MockEvent1<Integer> changeInitialMeldThresholdEvent = new MockEvent1<Integer>();
@@ -107,13 +105,9 @@ public class MockSettingsPanel implements ISettingsPanel {
@Override
public void setGameSettings(GameSettings gameSettings) {
- this.gameSettings = gameSettings;
-
- }
-
- @Override
- public void setInitialMeldThreshold(int value) {
- initialMeldThreshold = value;
+ initialMeldThreshold = gameSettings.getInitialMeldThreshold();
+ jokerNumber = gameSettings.getJokerNumber();
+ stoneSetNumber = gameSettings.getStoneSetNumber();
}
@Override
@@ -122,11 +116,6 @@ public class MockSettingsPanel implements ISettingsPanel {
}
@Override
- public void setJokerNumber(int jokerNumber) {
- this.jokerNumber = jokerNumber;
- }
-
- @Override
public IEvent2<Integer, Type> getChangePlayerTypeEvent() {
return changePlayerTypeEvent;
}
@@ -136,9 +125,4 @@ public class MockSettingsPanel implements ISettingsPanel {
return changeStoneSetNumberEvent;
}
- @Override
- public void setStoneSetNumber(int number) {
- stoneSetNumber = number;
- }
-
}
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 9cb216d..f12f1ad 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -56,10 +56,6 @@ public class SettingsControl {
* Start the operation of the settings control
*/
public void startSettings() {
- view.getSettingsPanel().setInitialMeldThreshold(
- settings.getInitialMeldThreshold());
- view.getSettingsPanel().setJokerNumber(settings.getJokerNumber());
-
connections.add(view.getSettingsPanel()
.getChangeInitialMeldThresholdEvent()
.add(new IListener1<Integer>() {
@@ -79,6 +75,15 @@ public class SettingsControl {
}
}));
+ connections.add(view.getSettingsPanel().getChangeStoneSetNumberEvent()
+ .add(new IListener1<Integer>() {
+ @Override
+ public void handle(Integer value) {
+ settings.setStoneSetNumber(value);
+ update();
+ }
+ }));
+
addPlayerSettingsListeners();
view.showSettingsPanel(true);
@@ -237,7 +242,8 @@ public class SettingsControl {
int totalStonesDealt = settings.getNumberOfStonesDealt()
* settings.getPlayerList().size();
- int totalStones = settings.getHighestCard() * settings.getStoneSetNumber()
+ int totalStones = settings.getHighestCard()
+ * settings.getStoneSetNumber()
* settings.getStoneColors().size() + settings.getJokerNumber();
if (totalStones <= totalStonesDealt) {
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index 3caa8cb..5c83f47 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -132,6 +132,13 @@ public interface ISettingsPanel {
public void setGameSettings(GameSettings gameSettings);
/**
+ * Emitted when the joker number is changed
+ *
+ * @return the event
+ */
+ public IEvent1<Integer> getChangeJokerNumberEvent();
+
+ /**
* Specifies the different kinds of settings errors that can be displayed
*/
public enum SettingsError {
@@ -150,30 +157,4 @@ public interface ISettingsPanel {
/** Only computer players added */
COMPUTER_PLAYERS_ONLY_WARNING
}
-
- /**
- * Sets the initial meld threshold in the option pane
- *
- * @param value
- * initial meld threshold
- */
- public void setInitialMeldThreshold(int value);
-
- public void setStoneSetNumber(int number);
-
- /**
- * Emitted when the joker number is changed
- *
- * @return the event
- */
- public IEvent1<Integer> getChangeJokerNumberEvent();
-
-
- /**
- * Sets the joker number in the option pane
- *
- * @param jokerNumber
- * the joker number
- */
- public void setJokerNumber(int jokerNumber);
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index 1eb8e45..5eb82fb 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -65,6 +65,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private List<PlayerSettingsPanel> playerSettingsPanels = new ArrayList<PlayerSettingsPanel>();
private JSpinner initialMeldThresholdSpinner;
+ private JSpinner stoneSetNumberSpinner;
private JSpinner jokerNumberSpinner;
private Event startGameEvent = new Event();
@@ -174,6 +175,11 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
updatePlayerSettingsPanel(i, gameSettings.getPlayerList().get(i));
}
+ initialMeldThresholdSpinner.setValue(gameSettings
+ .getInitialMeldThreshold());
+ stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber());
+ jokerNumberSpinner.setValue(gameSettings.getJokerNumber());
+
playerSettingsViewport.revalidate();
}
@@ -241,13 +247,17 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
initialMeldThresholdSpinner = makeOptionSpinner(0, 1, 999, 1,
changeInitialMeldThresholdEvent);
- makeOptionLabel(1, "Jokeranzahl:");
- jokerNumberSpinner = makeOptionSpinner(1, 1, 999, 1,
+ makeOptionLabel(1, "Anzahl Steins\u00e4tze:");
+ stoneSetNumberSpinner = makeOptionSpinner(1, 1, 999, 1,
+ changeStoneSetNumberEvent);
+
+ makeOptionLabel(2, "Jokeranzahl:");
+ jokerNumberSpinner = makeOptionSpinner(2, 1, 999, 1,
changeJokerNumberEvent);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 1;
- c.gridy = 2;
+ c.gridy = 3;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
@@ -503,28 +513,12 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
@Override
- public void setInitialMeldThreshold(int value) {
- initialMeldThresholdSpinner.setValue(value);
- }
-
- @Override
public IEvent1<Integer> getChangeJokerNumberEvent() {
return changeJokerNumberEvent;
}
@Override
- public void setJokerNumber(int jokerNumber) {
- jokerNumberSpinner.setValue(jokerNumber);
- }
-
- @Override
public IEvent2<Integer, Type> getChangePlayerTypeEvent() {
return changePlayerTypeEvent;
}
-
- @Override
- public void setStoneSetNumber(int number) {
- // TODO Auto-generated method stub
-
- }
}
diff --git a/test/jrummikub/control/SettingsControlTest.java b/test/jrummikub/control/SettingsControlTest.java
index ff870d0..969b554 100644
--- a/test/jrummikub/control/SettingsControlTest.java
+++ b/test/jrummikub/control/SettingsControlTest.java
@@ -61,6 +61,7 @@ public class SettingsControlTest {
for (int i = 0; i < 14; i++) {
view.settingsPanel.addPlayerEvent.emit();
}
+ view.settingsPanel.changeStoneSetNumberEvent.emit(8);
view.settingsPanel.startGameEvent.emit();
assertNotNull(gameSettings);
assertEquals(16, gameSettings.getPlayerList().size());
@@ -75,6 +76,7 @@ public class SettingsControlTest {
view.settingsPanel.addPlayerEvent.emit();
}
view.settingsPanel.removePlayerEvent.emit(0);
+ view.settingsPanel.changeStoneSetNumberEvent.emit(8);
view.settingsPanel.startGameEvent.emit();
assertNotNull(gameSettings);
assertEquals(15, gameSettings.getPlayerList().size());
@@ -209,7 +211,6 @@ public class SettingsControlTest {
view.settingsPanel.changeStoneSetNumberEvent.emit(3);
view.settingsPanel.startGameEvent.emit();
assertEquals(3, gameSettings.getStoneSetNumber());
-
}
/** */