Show initial hand succeeds
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@136 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
0318d8cee2
commit
bc827302d0
3 changed files with 31 additions and 25 deletions
|
@ -1,6 +1,5 @@
|
||||||
package jrummikub.control;
|
package jrummikub.control;
|
||||||
|
|
||||||
|
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
|
@ -15,7 +14,6 @@ public class TurnControl {
|
||||||
private IView view;
|
private IView view;
|
||||||
private Event endOfTurnEvent = new Event();
|
private Event endOfTurnEvent = new Event();
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -26,7 +24,6 @@ public class TurnControl {
|
||||||
|
|
||||||
/** Test only constructor **/
|
/** Test only constructor **/
|
||||||
TurnControl(IHand hand, ITable table, IView view, ITurnTimer testTimer) {
|
TurnControl(IHand hand, ITable table, IView view, ITurnTimer testTimer) {
|
||||||
// TODO: change timer to interface
|
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
@ -45,6 +42,11 @@ public class TurnControl {
|
||||||
};
|
};
|
||||||
timer.getTimeRunOutEvent().add(endOfTurnListener);
|
timer.getTimeRunOutEvent().add(endOfTurnListener);
|
||||||
view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener);
|
view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener);
|
||||||
|
|
||||||
|
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
|
||||||
|
view.enableStartTurnPanel(false);
|
||||||
|
|
||||||
|
timer.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortByValue() {
|
private void sortByValue() {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class TurnControlTest {
|
||||||
mockTimer = new MockTimer();
|
mockTimer = new MockTimer();
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
mockHand = new MockHand();
|
mockHand = new MockHand();
|
||||||
testControl = new TurnControl(null, mockTable, mockView, mockTimer);
|
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -75,15 +75,15 @@ public class TurnControlTest {
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
mockHand = new MockHand();
|
mockHand = new MockHand();
|
||||||
|
|
||||||
|
mockView.displayStartTurnPanel = true;
|
||||||
|
|
||||||
mockView.displayStartTurnPanel = false;
|
List<Pair<Stone, Position>> stones = Arrays.asList(
|
||||||
|
new Pair<Stone, Position>(new Stone(RED), new Position(0, 0)),
|
||||||
List<Pair<Stone, Position>> stones = Arrays.asList(new Pair<Stone, Position>(new Stone(RED), new Position(0,0)),
|
new Pair<Stone, Position>(new Stone(BLACK), new Position(1, 0)));
|
||||||
new Pair<Stone, Position>(new Stone(BLACK), new Position(1,0)));
|
|
||||||
|
|
||||||
mockHand.iterable = stones;
|
mockHand.iterable = stones;
|
||||||
|
|
||||||
testControl = new TurnControl(null, mockTable, mockView, mockTimer);
|
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Pair<Stone, Position> pair : mockView.playerPanel.handPanel.stones) {
|
for (Pair<Stone, Position> pair : mockView.playerPanel.handPanel.stones) {
|
||||||
|
@ -92,7 +92,7 @@ public class TurnControlTest {
|
||||||
}
|
}
|
||||||
assertEquals(stones.size(), i);
|
assertEquals(stones.size(), i);
|
||||||
|
|
||||||
assertTrue(mockView.displayStartTurnPanel);
|
assertFalse(mockView.displayStartTurnPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -45,6 +45,10 @@ public class MockHand implements IHand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockHand clone() {
|
public MockHand clone() {
|
||||||
|
try {
|
||||||
|
return (MockHand) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue