summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 5f46fd5..e1d2e97 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -7,6 +7,7 @@ import java.util.Set;
import jrummikub.control.turn.ITurnControl;
import jrummikub.control.turn.TurnControlFactory;
+import static jrummikub.control.turn.TurnControlFactory.Type.*;
import jrummikub.model.Hand;
import jrummikub.model.IHand;
import jrummikub.model.IPlayer;
@@ -35,6 +36,7 @@ public class RoundControl {
private Event restartRoundEvent = new Event();
private Event1<Score> endOfRoundEvent = new Event1<Score>();
private List<Connection> connections = new ArrayList<Connection>();
+ private ITurnControl turnControl;
private boolean roundFinished;
/**
@@ -76,26 +78,39 @@ public class RoundControl {
}
private void prepareTurn() {
+ boolean isHuman = roundState.getActivePlayer().getPlayerSettings().getTurnControlType() == HUMAN;
clonedTable = (ITable) roundState.getTable().clone();
- view.enableStartTurnPanel(true);
+
+ if (isHuman) {
+ view.enableStartTurnPanel(true);
+ } else {
+ view.enableThinkPanel(true);
+ }
+
view.getTablePanel().setStoneSets(clonedTable);
view.setCurrentPlayerName(roundState.getActivePlayer()
.getPlayerSettings().getName());
view.setCurrentPlayerColor(roundState.getActivePlayer()
.getPlayerSettings().getColor());
view.setHasLaidOut(roundState.getActivePlayer().getLaidOut());
-
+
+ if (!isHuman)
+ startTurn();
}
private void startTurn() {
+ if (turnControl != null)
+ return;
+ boolean isHuman = roundState.getActivePlayer().getPlayerSettings().getTurnControlType() == HUMAN;
boolean inspectOnly = roundState.getTurnNumber() < 1;
boolean mayRedeal = inspectOnly
&& roundState.getActivePlayer().getHand()
.getIdenticalStoneCount() >= 3;
- view.getPlayerPanel().setEndTurnMode(inspectOnly, mayRedeal);
-
- ITurnControl turnControl = TurnControlFactory.getFactory(roundState.getActivePlayer()
+ if (isHuman) {
+ view.getPlayerPanel().setEndTurnMode(inspectOnly, mayRedeal);
+ }
+ turnControl = TurnControlFactory.getFactory(roundState.getActivePlayer()
.getPlayerSettings().getTurnControlType()).create();
turnControl.setup(roundState.getActivePlayer(), clonedTable,
view, inspectOnly, mayRedeal);
@@ -142,6 +157,8 @@ public class RoundControl {
}
private void endOfTurn() {
+ view.enableThinkPanel(false);
+ turnControl = null;
if (roundState.getTurnNumber() >= 1) {
checkTurn();
}
@@ -335,6 +352,7 @@ public class RoundControl {
}
private void redeal() {
+ turnControl = null;
for (Connection c : new ArrayList<Connection>(connections)) {
c.remove();
}