summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/RoundControlTest.java126
-rw-r--r--test/jrummikub/control/network/NetworkRoundControlTest.java70
-rw-r--r--test/jrummikub/control/turn/TurnControlTest.java139
3 files changed, 201 insertions, 134 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index 8785fba..80a91be 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -4,6 +4,7 @@ import static jrummikub.model.StoneColor.*;
import static org.junit.Assert.*;
import java.awt.Color;
+import java.util.Arrays;
import java.util.Iterator;
import jrummikub.control.turn.TurnMode;
@@ -97,21 +98,24 @@ public class RoundControlTest {
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
gameSettings.getPlayerList().add(
new PlayerSettings("Matthias", Color.YELLOW));
- gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
- gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Jannis", Color.GREEN));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Bennet", Color.BLACK));
roundState = new RoundState(gameSettings, null);
roundControl = new RoundControl(roundState, view);
}
private void checkCorrectlyDealt() {
GameSettings settings = testRoundState.getGameSettings();
- int totalStones = settings.getHighestValue() * settings.getStoneSetNumber()
+ int totalStones = settings.getHighestValue()
+ * settings.getStoneSetNumber()
* settings.getStoneColors().size() + settings.getJokerNumber();
assertEquals(
totalStones - testRoundState.getPlayerCount()
* settings.getNumberOfStonesDealt()
- - testRoundState.table.getSize(), testRoundState.getGameHeap()
- .getSize());
+ - testRoundState.table.getSize(), testRoundState
+ .getGameHeap().getSize());
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
assertEquals(settings.getNumberOfStonesDealt(), testRoundState
.getNthNextPlayer(i).getHand().getSize());
@@ -182,8 +186,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
assertEquals(14 + 6, roundState.getActivePlayer().getHand().getSize());
}
@@ -205,7 +209,8 @@ public class RoundControlTest {
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
- assertEquals(14 + 1, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 1, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -246,7 +251,8 @@ public class RoundControlTest {
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
- assertEquals(14 + 9, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 9, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -304,7 +310,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 6, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 6, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -364,7 +371,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 7, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 7, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** */
@@ -417,7 +425,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 3, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 3, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -487,8 +496,7 @@ public class RoundControlTest {
/** */
@Test
- public void testTableValidHandChanged() {
- fail();
+ public void testTableValidTableChanged() {
testRoundState.players.get(0).setLaidOut(true);
testRound.startRound();
for (int i = 0; i < 4; i++) {
@@ -496,18 +504,23 @@ public class RoundControlTest {
view.playerPanel.endTurnEvent.emit();
}
MockTable oldTable = testRoundState.table;
+ oldTable.sets.clear();
+
testTable.valid = true;
+ testTable.sets.clear();
+ testTable.drop(
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ orangeEight)), new Position(0, 0));
oldTable.clonedTable = testTable;
view.startTurnEvent.emit();
assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType);
- IHand hand = testRoundState.players.get(0).hand;
- hand.pickUp(hand.iterator().next().getFirst());
resetTurnStart();
view.getPlayerPanel().endTurnEvent.emit();
assertSame(testTable, testRoundState.setTable);
+ assertEquals(14, testRoundState.players.get(0).getHand().getSize());
assertEquals(1, testRoundState.activePlayer);
checkTurnStartSetUp();
@@ -515,37 +528,38 @@ public class RoundControlTest {
/** */
@Test
- public void testTableInvalidHandChanged() {
- fail();
+ public void testTableInvalidTableChanged() {
testRound.startRound();
for (int i = 0; i < 4; i++) {
view.startTurnEvent.emit();
view.playerPanel.endTurnEvent.emit();
}
MockTable oldTable = testRoundState.table;
+ oldTable.sets.clear();
+
testTable.valid = false;
+ testTable.sets.clear();
+ testTable.drop(
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ blackFour)), new Position(0, 0));
oldTable.clonedTable = testTable;
- IHand hand = testRoundState.getActivePlayer().getHand();
view.startTurnEvent.emit();
assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType);
- Stone stone = hand.iterator().next().getFirst();
- hand.pickUp(stone);
- testTable.drop(new StoneSet(stone), new Position(0, 0));
+
resetTurnStart();
view.getPlayerPanel().endTurnEvent.emit();
view.acknowledgeInvalidEvent.emit();
assertNull(testRoundState.setTable);
assertEquals(1, testRoundState.activePlayer);
- assertEquals(14 + 3, testRoundState.players.get(0).hand.getSize());
+ assertEquals(14 + 4 + 3, testRoundState.players.get(0).hand.getSize());
checkTurnStartSetUp();
}
/** */
@Test
- public void testTableValidHandUnchanged() {
- fail();
+ public void testTableValidTabelUnchanged() {
testRoundState.players.get(0).setLaidOut(true);
testRound.startRound();
for (int i = 0; i < 4; i++) {
@@ -553,7 +567,10 @@ public class RoundControlTest {
view.playerPanel.endTurnEvent.emit();
}
MockTable oldTable = testRoundState.table;
+ oldTable.sets.clear();
+
testTable.valid = true;
+ testTable.sets.clear();
oldTable.clonedTable = testTable;
view.startTurnEvent.emit();
@@ -570,8 +587,7 @@ public class RoundControlTest {
/** */
@Test
- public void testTableInvalidHandUnchanged() {
- fail();
+ public void testTableInvalidTabelReordered() {
testRoundState.players.get(1).setLaidOut(true);
testRound.startRound();
for (int i = 0; i < 4; i++) {
@@ -579,11 +595,22 @@ public class RoundControlTest {
view.playerPanel.endTurnEvent.emit();
}
MockTable oldTable = testRoundState.table;
+ oldTable.sets.clear();
+ oldTable.drop(
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ orangeEight)), new Position(0, 0));
+
testTable.valid = false;
- oldTable.clonedTable = testTable;
+ testTable.sets.clear();
+ oldTable.clonedTable = testTable;
+ testTable.drop(new StoneSet(Arrays.asList(blueEight, blackEight)),
+ new Position(0, 0));
+ testTable.drop(new StoneSet(Arrays.asList(redEight, orangeEight)),
+ new Position(0, 0));
view.startTurnEvent.emit();
assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType);
+
resetTurnStart();
view.getPlayerPanel().endTurnEvent.emit();
view.acknowledgeInvalidEvent.emit();
@@ -696,19 +723,20 @@ public class RoundControlTest {
}
testRoundState.players.get(0).laidOut = true;
- testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
- 0));
- testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
- 0));
+ testRoundState.players.get(0).hand.drop(new Stone(1, RED),
+ new Position(0, 0));
+ testRoundState.players.get(0).hand.drop(new Stone(2, RED),
+ new Position(0, 0));
testRoundState.players.get(1).laidOut = true;
- testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0));
- testRoundState.players.get(2).laidOut = false;
- testRoundState.players.get(2).hand.drop(new Stone(9, RED), new Position(0,
- 0));
- testRoundState.players.get(2).hand.drop(new Stone(10, RED), new Position(0,
- 0));
- testRoundState.players.get(2).hand.drop(new Stone(11, RED), new Position(0,
+ testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0,
0));
+ testRoundState.players.get(2).laidOut = false;
+ testRoundState.players.get(2).hand.drop(new Stone(9, RED),
+ new Position(0, 0));
+ testRoundState.players.get(2).hand.drop(new Stone(10, RED),
+ new Position(0, 0));
+ testRoundState.players.get(2).hand.drop(new Stone(11, RED),
+ new Position(0, 0));
testRoundState.players.get(3).laidOut = true;
testRound.endOfRound();
@@ -742,19 +770,19 @@ public class RoundControlTest {
}
testRoundState.players.get(0).laidOut = true;
- testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
- 0));
- testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
- 0));
+ testRoundState.players.get(0).hand.drop(new Stone(1, RED),
+ new Position(0, 0));
+ testRoundState.players.get(0).hand.drop(new Stone(2, RED),
+ new Position(0, 0));
testRoundState.players.get(1).laidOut = true;
- testRoundState.players.get(1).hand.drop(new Stone(3, RED), new Position(0,
- 0));
+ testRoundState.players.get(1).hand.drop(new Stone(3, RED),
+ new Position(0, 0));
testRoundState.players.get(2).laidOut = true;
- testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), new Position(0,
- 0));
+ testRoundState.players.get(2).hand.drop(new Stone(3, BLUE),
+ new Position(0, 0));
testRoundState.players.get(3).laidOut = false;
- testRoundState.players.get(3).hand.drop(new Stone(13, RED), new Position(0,
- 0));
+ testRoundState.players.get(3).hand.drop(new Stone(13, RED),
+ new Position(0, 0));
testRound.endOfRound();
assertTrue(roundEnded);
diff --git a/test/jrummikub/control/network/NetworkRoundControlTest.java b/test/jrummikub/control/network/NetworkRoundControlTest.java
index 24360c6..f444581 100644
--- a/test/jrummikub/control/network/NetworkRoundControlTest.java
+++ b/test/jrummikub/control/network/NetworkRoundControlTest.java
@@ -35,8 +35,10 @@ public class NetworkRoundControlTest {
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
gameSettings.getPlayerList().add(
new PlayerSettings("Matthias", Color.YELLOW));
- gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
- gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Jannis", Color.GREEN));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Bennet", Color.BLACK));
gameSettings.getPlayerList().get(1).setType(Type.COMPUTER);
gameSettings.getPlayerList().get(2).setType(Type.NETWORK);
@@ -48,7 +50,8 @@ public class NetworkRoundControlTest {
@Test
public void testHostRound() {
- connectionControl.nickname = gameSettings.getPlayerList().get(0).getName();
+ connectionControl.nickname = gameSettings.getPlayerList().get(0)
+ .getName();
testRoundState = new RoundState(gameSettings, null);
testRound = new NetworkRoundControl(testRoundState, view,
@@ -64,8 +67,8 @@ public class NetworkRoundControlTest {
IPlayer player = testRoundState.getNthPlayer(i);
assertSame(gameSettings.getPlayerList().get(i),
player.getPlayerSettings());
- assertEquals(gameSettings.getNumberOfStonesDealt(), player.getHand()
- .getSize());
+ assertEquals(gameSettings.getNumberOfStonesDealt(), player
+ .getHand().getSize());
}
for (int i = 0; i < 4; ++i) {
@@ -77,45 +80,50 @@ public class NetworkRoundControlTest {
}
}
- assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(0),
+ testRoundState.getActivePlayer());
assertTrue(connectionControl.turnStarted);
connectionControl.turnStarted = false;
- connectionControl.turnStartEvent.emit(testRoundState);
+ connectionControl.turnStartEvent.emit();
assertFalse(connectionControl.turnEnded);
view.playerPanel.endTurnEvent.emit();
assertTrue(connectionControl.turnEnded);
connectionControl.turnEnded = false;
- assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(1),
+ testRoundState.getActivePlayer());
assertTrue(connectionControl.turnStarted);
connectionControl.turnStarted = false;
- connectionControl.turnStartEvent.emit(testRoundState);
+ connectionControl.turnStartEvent.emit();
assertTrue(connectionControl.turnEnded);
connectionControl.turnEnded = false;
- assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(2),
+ testRoundState.getActivePlayer());
assertTrue(connectionControl.turnStarted);
connectionControl.turnStarted = false;
- connectionControl.turnStartEvent.emit(testRoundState);
+ connectionControl.turnStartEvent.emit();
assertFalse(connectionControl.turnEnded);
- connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
- .getHand(), testRoundState.getTable(), testRoundState.getTable());
+ connectionControl.turnEndEvent.emit(testRoundState);
- assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(3),
+ testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
- .getHand(), testRoundState.getTable(), testRoundState.getTable());
+ .getHand(), testRoundState.getTable(), testRoundState
+ .getTable());
- assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(0),
+ testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
connectionControl.turnStartEvent.emit(testRoundState);
@@ -124,41 +132,49 @@ public class NetworkRoundControlTest {
@Test
public void testClientRound() {
- connectionControl.nickname = gameSettings.getPlayerList().get(2).getName();
+ connectionControl.nickname = gameSettings.getPlayerList().get(2)
+ .getName();
testRoundState = new RoundState(gameSettings, null);
for (int i = 0; i < 4; ++i) {
IPlayer player = testRoundState.getNthPlayer(i);
- player.getHand().drop(new Stone(StoneColor.RED), new Position(0, 0));
+ player.getHand()
+ .drop(new Stone(StoneColor.RED), new Position(0, 0));
}
- testRound = new NetworkRoundControl(null, view, connectionControl, false);
+ testRound = new NetworkRoundControl(null, view, connectionControl,
+ false);
connectionControl.turnStarted = false;
connectionControl.turnEnded = false;
testRound.startRound();
- assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(0),
+ testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
- .getHand(), testRoundState.getTable(), testRoundState.getTable());
+ .getHand(), testRoundState.getTable(), testRoundState
+ .getTable());
- assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(1),
+ testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
- .getHand(), testRoundState.getTable(), testRoundState.getTable());
+ .getHand(), testRoundState.getTable(), testRoundState
+ .getTable());
- assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(2),
+ testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
connectionControl.turnStartEvent.emit(testRoundState);
@@ -168,7 +184,8 @@ public class NetworkRoundControlTest {
assertTrue(connectionControl.turnEnded);
connectionControl.turnEnded = false;
- assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(3),
+ testRoundState.getActivePlayer());
assertTrue(connectionControl.turnStarted);
connectionControl.turnStarted = false;
@@ -176,7 +193,8 @@ public class NetworkRoundControlTest {
assertTrue(connectionControl.turnEnded);
connectionControl.turnEnded = false;
- assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
+ assertSame(testRoundState.getNthPlayer(0),
+ testRoundState.getActivePlayer());
assertTrue(connectionControl.turnStarted);
connectionControl.turnStarted = false;
diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java
index 9e89a57..76c2159 100644
--- a/test/jrummikub/control/turn/TurnControlTest.java
+++ b/test/jrummikub/control/turn/TurnControlTest.java
@@ -1,7 +1,13 @@
package jrummikub.control.turn;
-import static jrummikub.model.StoneColor.*;
-import static org.junit.Assert.*;
+import static jrummikub.model.StoneColor.BLACK;
+import static jrummikub.model.StoneColor.BLUE;
+import static jrummikub.model.StoneColor.ORANGE;
+import static jrummikub.model.StoneColor.RED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
@@ -12,11 +18,16 @@ import java.util.List;
import java.util.Set;
import jrummikub.control.ITurnTimer;
+import jrummikub.control.RoundControl;
+import jrummikub.control.RoundControl.InvalidTurnInfo;
+import jrummikub.control.turn.ITurnControl.TurnInfo;
import jrummikub.model.GameSettings;
import jrummikub.model.IHand;
+import jrummikub.model.IRoundState;
import jrummikub.model.ITable;
import jrummikub.model.MockHand;
import jrummikub.model.MockPlayer;
+import jrummikub.model.MockRoundState;
import jrummikub.model.MockTable;
import jrummikub.model.Position;
import jrummikub.model.Stone;
@@ -25,6 +36,7 @@ import jrummikub.model.StoneSet;
import jrummikub.model.Table;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
+import jrummikub.util.IListener2;
import jrummikub.util.IListener3;
import jrummikub.util.Pair;
import jrummikub.view.IView.BottomPanelType;
@@ -75,6 +87,7 @@ public class TurnControlTest {
MockTimer mockTimer;
MockTable mockTable;
MockHand mockHand;
+ private MockRoundState mockRoundState;
boolean eventFired;
Stone blueOne = new Stone(1, BLUE);
Stone redOne = new Stone(1, RED);
@@ -127,15 +140,15 @@ public class TurnControlTest {
@Before
public void setUp() {
mockView = new MockView();
+ mockRoundState = new MockRoundState();
mockTimer = new MockTimer();
mockTable = new MockTable();
mockHand = new MockHand();
mockPlayer = new MockPlayer(null, null);
mockPlayer.hand = mockHand;
testControl = new HumanTurnControl(mockTimer);
- testControl.setup(new ITurnControl.TurnInfo(mockTable,
- mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
- new GameSettings(), mockView);
+ testControl.setup(new ITurnControl.TurnInfo(mockRoundState,
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
}
/** */
@@ -159,9 +172,8 @@ public class TurnControlTest {
mockHand.iterable = stones;
testControl = new HumanTurnControl(mockTimer);
- testControl.setup(new ITurnControl.TurnInfo(mockTable,
- mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
- new GameSettings(), mockView);
+ testControl.setup(new ITurnControl.TurnInfo(mockRoundState,
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
testControl.startTurn();
int i = 0;
@@ -183,9 +195,10 @@ public class TurnControlTest {
mockTimer.timerRunning = true;
testControl.getEndOfTurnEvent().add(
- new IListener3<IHand, ITable, ITable>() {
+ new IListener2<IRoundState, RoundControl.InvalidTurnInfo>() {
@Override
- public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
+ public void handle(IRoundState roundState,
+ RoundControl.InvalidTurnInfo invalidTurnInfo) {
eventFired = true;
}
});
@@ -206,9 +219,10 @@ public class TurnControlTest {
mockTimer.timerRunning = true;
testControl.getEndOfTurnEvent().add(
- new IListener3<IHand, ITable, ITable>() {
+ new IListener2<IRoundState, RoundControl.InvalidTurnInfo>() {
@Override
- public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
+ public void handle(IRoundState value1,
+ InvalidTurnInfo value2) {
eventFired = true;
}
});
@@ -292,8 +306,8 @@ public class TurnControlTest {
mockView.handPanel.stoneClickEvent.emit(redJoker, true);
mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(blackJoker,
- true);
+ mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(
+ blackJoker, true);
assertCollection(Arrays.asList(redJoker, blackJoker));
}
@@ -309,7 +323,8 @@ public class TurnControlTest {
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker,
true);
- mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, true);
+ mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker,
+ true);
assertCollection(new ArrayList<Stone>());
}
@@ -407,8 +422,8 @@ public class TurnControlTest {
testControl.startTurn();
Stone stone4 = new Stone(4, StoneColor.RED);
- StoneSet set1 = new StoneSet(
- Arrays.asList(redOne, redTwo, redThree, stone4));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree,
+ stone4));
mockTable.findStoneSet.put(redOne, set1);
mockTable.findStoneSet.put(redThree, set1);
@@ -575,15 +590,14 @@ public class TurnControlTest {
public void testAddLeft() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new ITurnControl.TurnInfo(mockRoundState,
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
turnControl.startTurn();
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
mockHand.drop(blueThree, new Position(0, 0));
@@ -682,14 +696,13 @@ public class TurnControlTest {
public void testAddRight() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
+ new GameSettings(), mockView);
turnControl.startTurn();
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
mockHand.drop(blueThree, new Position(0, 0));
@@ -788,14 +801,13 @@ public class TurnControlTest {
public void testAddNewSet() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
+ new GameSettings(), mockView);
turnControl.startTurn();
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
mockHand.drop(blueThree, new Position(0, 0));
@@ -886,8 +898,8 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
@@ -935,8 +947,8 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
@@ -976,8 +988,8 @@ public class TurnControlTest {
assertCollection(new ArrayList<Stone>());
- Set<Stone> expected = new HashSet<Stone>(
- Arrays.asList(redJoker, blackJoker));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ blackJoker));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();
@@ -1004,7 +1016,8 @@ public class TurnControlTest {
assertCollection(Arrays.asList(blackJoker));
- Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker, black13));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ black13));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();
@@ -1020,12 +1033,15 @@ public class TurnControlTest {
public void testTableDifference() {
MockTable oldTable = new MockTable();
MockTable newTable = new MockTable();
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne));
+ StoneSet oldSet1 = new StoneSet(
+ Arrays.asList(blueOne, redOne, blackOne));
StoneSet oldSet2 = new StoneSet(blueTwo);
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
- StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour));
- StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree));
+ StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo,
+ blueFour));
+ StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne,
+ blueThree));
newTable.drop(newSet1, new Position(0, 0));
newTable.drop(newSet2, new Position(0, 0));
@@ -1033,7 +1049,8 @@ public class TurnControlTest {
expectedStones.add(blueThree);
expectedStones.add(blueFour);
- Set<Stone> stones = AbstractTurnControl.tableDifference(oldTable, newTable);
+ Set<Stone> stones = AbstractTurnControl.tableDifference(oldTable,
+ newTable);
assertTrue(expectedStones.containsAll(stones));
assertTrue(stones.containsAll(expectedStones));
@@ -1050,14 +1067,15 @@ public class TurnControlTest {
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
Stone blueFour = new Stone(4, BLUE);
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- orangeOne));
- StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, orangeOne));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree,
+ blueFour));
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
ITable newTable = (Table) oldTable.clone();
- List<StoneSet> newSets = AbstractTurnControl.tableSetDifference(oldTable,
- newTable);
+ List<StoneSet> newSets = AbstractTurnControl.tableSetDifference(
+ oldTable, newTable);
List<StoneSet> vanishedSets = AbstractTurnControl.tableSetDifference(
newTable, oldTable);
@@ -1065,10 +1083,11 @@ public class TurnControlTest {
assertTrue(vanishedSets.isEmpty());
newTable.pickUp(oldSet2);
- newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position(
- 0, 0));
+ newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))),
+ new Position(0, 0));
newSets = AbstractTurnControl.tableSetDifference(oldTable, newTable);
- vanishedSets = AbstractTurnControl.tableSetDifference(newTable, oldTable);
+ vanishedSets = AbstractTurnControl.tableSetDifference(newTable,
+ oldTable);
assertFalse(newSets.isEmpty());
assertFalse(vanishedSets.isEmpty());
@@ -1078,11 +1097,13 @@ public class TurnControlTest {
Stone redTwo = new Stone(2, RED);
Stone redThree = new Stone(3, RED);
Stone redFour = new Stone(4, RED);
- StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour));
+ StoneSet oldSet3 = new StoneSet(
+ Arrays.asList(redTwo, redThree, redFour));
ITable newTable2 = (Table) oldTable.clone();
newTable2.drop(oldSet3, new Position(0, 0));
newSets = AbstractTurnControl.tableSetDifference(oldTable, newTable2);
- vanishedSets = AbstractTurnControl.tableSetDifference(newTable2, oldTable);
+ vanishedSets = AbstractTurnControl.tableSetDifference(newTable2,
+ oldTable);
assertFalse(newSets.isEmpty());
assertTrue(vanishedSets.isEmpty());