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
This commit is contained in:
parent
9b7aac51f5
commit
45656861ab
17 changed files with 508 additions and 130 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue