summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBennet Gerlach <bennet_gerlach@web.de>2011-05-05 00:19:02 +0200
committerBennet Gerlach <bennet_gerlach@web.de>2011-05-05 00:19:02 +0200
commitbc827302d0753a67774fd625d0c90eba7d83094f (patch)
treebcdbec60daa269507fb286e55b2aad4742cb759b
parent0318d8cee285d98e69851c450a029a434cd4dce7 (diff)
downloadJRummikub-bc827302d0753a67774fd625d0c90eba7d83094f.tar
JRummikub-bc827302d0753a67774fd625d0c90eba7d83094f.zip
Show initial hand succeeds
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@136 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/control/TurnControl.java20
-rw-r--r--test/jrummikub/control/TurnControlTest.java28
-rw-r--r--test/jrummikub/model/MockHand.java8
3 files changed, 31 insertions, 25 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index 26084e3..f73a6a4 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -1,6 +1,5 @@
package jrummikub.control;
-
import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.util.Event;
@@ -14,7 +13,6 @@ public class TurnControl {
private ITurnTimer timer;
private IView view;
private Event endOfTurnEvent = new Event();
-
public TurnControl(IHand hand, ITable table, IView view) {
this.hand = hand;
@@ -23,21 +21,20 @@ public class TurnControl {
this.timer = new TurnTimer(view);
setup();
}
-
+
/** Test only constructor **/
TurnControl(IHand hand, ITable table, IView view, ITurnTimer testTimer) {
- // TODO: change timer to interface
this.hand = hand;
this.table = table;
this.view = view;
this.timer = testTimer;
setup();
}
-
+
private void setup() {
-
+
IListener endOfTurnListener = new IListener() {
-
+
@Override
public void handle() {
endOfTurn();
@@ -45,6 +42,11 @@ public class TurnControl {
};
timer.getTimeRunOutEvent().add(endOfTurnListener);
view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener);
+
+ view.getPlayerPanel().getHandPanel().setStones(hand.clone());
+ view.enableStartTurnPanel(false);
+
+ timer.startTimer();
}
private void sortByValue() {
@@ -54,12 +56,12 @@ public class TurnControl {
private void sortByColor() {
}
-
+
private void endOfTurn() {
timer.stopTimer();
endOfTurnEvent.emit();
}
-
+
public IEvent getEndOfTurnEvent() {
return endOfTurnEvent;
}
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java
index 2efab67..2cca3e8 100644
--- a/test/jrummikub/control/TurnControlTest.java
+++ b/test/jrummikub/control/TurnControlTest.java
@@ -59,14 +59,14 @@ public class TurnControlTest {
mockTimer = new MockTimer();
mockTable = new MockTable();
mockHand = new MockHand();
- testControl = new TurnControl(null, mockTable, mockView, mockTimer);
+ testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
}
@Test
public void startTimer() {
assertTrue(mockTimer.timerRunning);
}
-
+
@SuppressWarnings("unchecked")
@Test
public void showInitialHand() {
@@ -74,25 +74,25 @@ public class TurnControlTest {
mockTimer = new MockTimer();
mockTable = new MockTable();
mockHand = new MockHand();
-
-
- mockView.displayStartTurnPanel = false;
-
- 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)));
-
+
+ mockView.displayStartTurnPanel = true;
+
+ 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)));
+
mockHand.iterable = stones;
-
- testControl = new TurnControl(null, mockTable, mockView, mockTimer);
-
+
+ testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
+
int i = 0;
for (Pair<Stone, Position> pair : mockView.playerPanel.handPanel.stones) {
assertSame(stones.get(i), pair);
i++;
}
assertEquals(stones.size(), i);
-
- assertTrue(mockView.displayStartTurnPanel);
+
+ assertFalse(mockView.displayStartTurnPanel);
}
@Test
diff --git a/test/jrummikub/model/MockHand.java b/test/jrummikub/model/MockHand.java
index 0d0c523..2132ff4 100644
--- a/test/jrummikub/model/MockHand.java
+++ b/test/jrummikub/model/MockHand.java
@@ -9,7 +9,7 @@ import jrummikub.util.Pair;
public class MockHand implements IHand {
public List<Stone> stones = new ArrayList<Stone>();
-
+
public Iterable<Pair<Stone, Position>> iterable;
@Override
@@ -45,6 +45,10 @@ public class MockHand implements IHand {
}
public MockHand clone() {
- return null;
+ try {
+ return (MockHand) super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
}
}