diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-19 19:46:06 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-19 19:46:06 +0200 |
commit | 45656861ab2e618938764f0c46f830184099a71d (patch) | |
tree | 8e5cd9ab28d47f242408d6dcfc29317902048605 /src/jrummikub/control/turn | |
parent | 9b7aac51f58eb628978ed0e4d1a922a959917a3b (diff) | |
download | JRummikub-45656861ab2e618938764f0c46f830184099a71d.tar JRummikub-45656861ab2e618938764f0c46f830184099a71d.zip |
Added NetworkRoundControlTest and started NetworkRoundControl and NetworkTurnControl implementation
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@491 72836036-5685-4462-b002-a69064685172
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 |