summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-07 00:23:00 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-07 00:23:00 +0200
commitaf3661fea084df6e089c2597dc4b311c77f39e4f (patch)
tree85984ed5b225dfe2d24f602d9074ad2228b7c05e /src/jrummikub/control/RoundControl.java
parentc59332950be525408da7b2e66687603a68cb560b (diff)
downloadJRummikub-af3661fea084df6e089c2597dc4b311c77f39e4f.tar
JRummikub-af3661fea084df6e089c2597dc4b311c77f39e4f.zip
Always operate on cloned hands in the turn controls
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@380 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 4819aad..5e85167 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -36,6 +36,7 @@ public class RoundControl {
IRoundState roundState;
private IView view;
private ITable clonedTable;
+ IHand clonedHand;
private Event restartRoundEvent = new Event();
private Event1<Score> endOfRoundEvent = new Event1<Score>();
private List<Connection> connections = new ArrayList<Connection>();
@@ -84,6 +85,7 @@ public class RoundControl {
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
.getTurnControlType() == HUMAN;
clonedTable = (ITable) roundState.getTable().clone();
+ clonedHand = (IHand) roundState.getActivePlayer().getHand().clone();
view.setBottomPanel(isHuman ? BottomPanelType.START_TURN_PANEL
: BottomPanelType.COMPUTER_HAND_PANEL);
@@ -109,7 +111,7 @@ public class RoundControl {
if (roundState.getTurnNumber() < 1) {
turnMode = TurnMode.INSPECT_ONLY;
- if (roundState.getActivePlayer().getHand().getIdenticalStoneCount() >= 3) {
+ if (clonedHand.getIdenticalStoneCount() >= 3) {
turnMode = TurnMode.MAY_REDEAL;
}
}
@@ -120,8 +122,9 @@ public class RoundControl {
turnControl = TurnControlFactory.getFactory(
roundState.getActivePlayer().getPlayerSettings().getTurnControlType())
.create();
- turnControl.setup(roundState.getGameSettings(),
- roundState.getActivePlayer(), clonedTable, view, turnMode);
+ turnControl.setup(new ITurnControl.TurnInfo(clonedTable, clonedHand,
+ roundState.getActivePlayer().getLaidOut(), turnMode), roundState
+ .getGameSettings(), view);
turnControl.getEndOfTurnEvent().add(new IListener() {
@Override
public void handle() {
@@ -189,6 +192,8 @@ public class RoundControl {
}
private void checkTurn() {
+ roundState.getActivePlayer().setHand(clonedHand);
+
if (!clonedTable.isValid()) {
rejectMove();
return;