diff options
Diffstat (limited to 'src/jrummikub/control/turn')
-rw-r--r-- | src/jrummikub/control/turn/AIControl.java | 6 | ||||
-rw-r--r-- | src/jrummikub/control/turn/AbstractTurnControl.java | 19 | ||||
-rw-r--r-- | src/jrummikub/control/turn/HumanTurnControl.java | 4 | ||||
-rw-r--r-- | src/jrummikub/control/turn/ITurnControl.java | 2 |
4 files changed, 22 insertions, 9 deletions
diff --git a/src/jrummikub/control/turn/AIControl.java b/src/jrummikub/control/turn/AIControl.java index b69d72b..ba222ea 100644 --- a/src/jrummikub/control/turn/AIControl.java +++ b/src/jrummikub/control/turn/AIControl.java @@ -21,7 +21,7 @@ import jrummikub.util.Pair; */ public class AIControl extends AbstractTurnControl { private TurnLogic logic; - boolean useBackgroundThread = true; + public static boolean useBackgroundThread = true; long startTime; private boolean isPaused = false; @@ -30,7 +30,7 @@ public class AIControl extends AbstractTurnControl { private boolean aborted = false; @Override - public void startTurn() { + protected void doStartTurn() { timer.startTimer(); startTime = System.currentTimeMillis(); compute(); @@ -221,7 +221,7 @@ public class AIControl extends AbstractTurnControl { return; } cleanUp(); - endOfTurnEvent.emit(); + endOfTurnEvent.emit(turnInfo.getTable()); } /** diff --git a/src/jrummikub/control/turn/AbstractTurnControl.java b/src/jrummikub/control/turn/AbstractTurnControl.java index fd88370..f129f24 100644 --- a/src/jrummikub/control/turn/AbstractTurnControl.java +++ b/src/jrummikub/control/turn/AbstractTurnControl.java @@ -19,7 +19,7 @@ import jrummikub.view.IView; * Abstract base class for TurnControls */ public abstract class AbstractTurnControl implements ITurnControl { - protected Event endOfTurnEvent = new Event(); + protected Event1<ITable> endOfTurnEvent = new Event1<ITable>(); protected Event redealEvent = new Event(); protected Event1<ITable> tableUpdateEvent = new Event1<ITable>(); protected TurnInfo turnInfo; @@ -27,9 +27,10 @@ public abstract class AbstractTurnControl implements ITurnControl { protected IView view; protected ITurnTimer timer; protected List<Connection> connections = new ArrayList<Connection>(); + private boolean started = false; @Override - public IEvent getEndOfTurnEvent() { + public IEvent1<ITable> getEndOfTurnEvent() { return endOfTurnEvent; } @@ -37,7 +38,7 @@ public abstract class AbstractTurnControl implements ITurnControl { public IEvent getRedealEvent() { return redealEvent; } - + @Override public IEvent1<ITable> getTableUpdateEvent() { return tableUpdateEvent; @@ -53,6 +54,18 @@ public abstract class AbstractTurnControl implements ITurnControl { view.enablePauseMode(false); } + @Override + public void startTurn() { + if (started) { + return; + } + + started = true; + doStartTurn(); + } + + protected abstract void doStartTurn(); + protected abstract void timeOut(); @Override diff --git a/src/jrummikub/control/turn/HumanTurnControl.java b/src/jrummikub/control/turn/HumanTurnControl.java index 3efad2f..51f77e4 100644 --- a/src/jrummikub/control/turn/HumanTurnControl.java +++ b/src/jrummikub/control/turn/HumanTurnControl.java @@ -54,7 +54,7 @@ public class HumanTurnControl extends AbstractTurnControl { } @Override - public void startTurn() { + public void doStartTurn() { addButtonHandlers(); addHandPanelHandlers(); @@ -449,7 +449,7 @@ public class HumanTurnControl extends AbstractTurnControl { if (redeal) { redealEvent.emit(); } else { - endOfTurnEvent.emit(); + endOfTurnEvent.emit(turnInfo.getTable()); } } diff --git a/src/jrummikub/control/turn/ITurnControl.java b/src/jrummikub/control/turn/ITurnControl.java index 0039a42..1860d69 100644 --- a/src/jrummikub/control/turn/ITurnControl.java +++ b/src/jrummikub/control/turn/ITurnControl.java @@ -30,7 +30,7 @@ public interface ITurnControl { * * @return end of turn event */ - public IEvent getEndOfTurnEvent(); + public IEvent1<ITable> getEndOfTurnEvent(); /** * Emitted when the round is aborted and needs to be restarted |