Remove listener in turn control and have explicit turn start method
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@148 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
cce3c6bc6e
commit
8ad8432d85
2 changed files with 5 additions and 4 deletions
|
@ -13,13 +13,13 @@ public class TurnControl {
|
||||||
private ITurnTimer timer;
|
private ITurnTimer timer;
|
||||||
private IView view;
|
private IView view;
|
||||||
private Event endOfTurnEvent = new Event();
|
private Event endOfTurnEvent = new Event();
|
||||||
|
IListener endOfTurnListener;
|
||||||
|
|
||||||
public TurnControl(IHand hand, ITable table, IView view) {
|
public TurnControl(IHand hand, ITable table, IView view) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.timer = new TurnTimer(view);
|
this.timer = new TurnTimer(view);
|
||||||
setup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test only constructor **/
|
/** Test only constructor **/
|
||||||
|
@ -28,12 +28,11 @@ public class TurnControl {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.timer = testTimer;
|
this.timer = testTimer;
|
||||||
setup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
public void startTurn() {
|
||||||
|
|
||||||
IListener endOfTurnListener = new IListener() {
|
endOfTurnListener = new IListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
@ -60,6 +59,7 @@ public class TurnControl {
|
||||||
private void endOfTurn() {
|
private void endOfTurn() {
|
||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
endOfTurnEvent.emit();
|
endOfTurnEvent.emit();
|
||||||
|
view.getPlayerPanel().getEndTurnEvent().remove(endOfTurnListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEvent getEndOfTurnEvent() {
|
public IEvent getEndOfTurnEvent() {
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class TurnControlTest {
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
mockHand = new MockHand();
|
mockHand = new MockHand();
|
||||||
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
||||||
|
testControl.startTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Reference in a new issue