diff options
author | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-31 03:45:32 +0200 |
---|---|---|
committer | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-31 03:45:32 +0200 |
commit | d276b03c395e7c0e44740174168c0d98a8eaa06c (patch) | |
tree | 95642c255b484354769b7cb2ed4f9a65beb5a14e /test | |
parent | 278edc37a9861078d5ea1527695ef12766c0fb87 (diff) | |
download | JRummikub-d276b03c395e7c0e44740174168c0d98a8eaa06c.tar JRummikub-d276b03c395e7c0e44740174168c0d98a8eaa06c.zip |
AIUtil now needs game settings, both hand and player do not anymore
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@342 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 10 | ||||
-rw-r--r-- | test/jrummikub/model/HandTest.java | 114 |
2 files changed, 64 insertions, 60 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 1e960ff..887df30 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -675,7 +675,7 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); for (int i = 0; i < 4; i++) { - testRoundState.players.get(i).hand = new Hand(gameSettings); + testRoundState.players.get(i).hand = new Hand(); } resetTurnStart(); @@ -816,7 +816,7 @@ public class RoundControlTest { testRound.startRound(); for (int i = 0; i < 4; i++) { - testRoundState.players.get(i).hand = new Hand(gameSettings); + testRoundState.players.get(i).hand = new Hand(); } testRoundState.players.get(0).laidOut = true; @@ -863,7 +863,7 @@ public class RoundControlTest { testRound.startRound(); for (int i = 0; i < 4; i++) { - testRoundState.players.get(i).hand = new Hand(gameSettings); + testRoundState.players.get(i).hand = new Hand(); } testRoundState.players.get(0).laidOut = true; @@ -932,7 +932,7 @@ public class RoundControlTest { @Test public void testRedealDisallowed() { testRound.startRound(); - Hand hand = new Hand(gameSettings); + Hand hand = new Hand(); hand.drop(new Stone(1, RED), new Position(0, 0)); hand.drop(new Stone(1, BLACK), new Position(0, 0)); hand.drop(new Stone(1, BLUE), new Position(0, 0)); @@ -951,7 +951,7 @@ public class RoundControlTest { @Test public void testRedealAllowed() { testRound.startRound(); - Hand hand = new Hand(gameSettings); + Hand hand = new Hand(); for (int i = 0; i < 6; i++) { hand.drop(new Stone(i / 2, RED), new Position(0, 0)); } diff --git a/test/jrummikub/model/HandTest.java b/test/jrummikub/model/HandTest.java index abfa9ee..fa780a5 100644 --- a/test/jrummikub/model/HandTest.java +++ b/test/jrummikub/model/HandTest.java @@ -24,7 +24,7 @@ public class HandTest { /** */
@Before
public void setUp() {
- hand = new Hand(new GameSettings());
+ hand = new Hand();
}
/** */
@@ -129,32 +129,31 @@ public class HandTest { hand.drop(stone2, new Position(0, 0));
hand.drop(stone3, new Position(0, 0));
- assertEquals(56, hand.getStonePoints());
+ assertEquals(56, hand.getStonePoints(new GameSettings()));
}
private void dropStoneList(List<Stone> handStones) {
- hand = new Hand(new GameSettings());
+ hand = new Hand();
for (Stone stone : handStones) {
hand.drop(stone, new Position(0, 0));
}
}
-
+
private void testInitialMeld(boolean possible, List<Stone> handStones) {
dropStoneList(handStones);
- assertTrue(possible == hand.isInitialMeldPossible());
+ assertTrue(possible == hand.isInitialMeldPossible(new GameSettings()));
}
/** */
@Test
public void testInvalid() {
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
- RED), new Stone(10, RED), new Stone(12, RED),
- new Stone(13, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9, RED),
+ new Stone(10, RED), new Stone(12, RED), new Stone(13, RED)));
testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(10,
BLACK), new Stone(11, RED), new Stone(11, BLACK)));
- testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(10,
- RED), new Stone(10, BLACK), new Stone(11, RED), new Stone(11,
- BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(10, RED),
+ new Stone(10, RED), new Stone(10, BLACK), new Stone(11, RED),
+ new Stone(11, BLACK)));
testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(11,
BLACK), new Stone(12, RED)));
@@ -163,62 +162,62 @@ public class HandTest { /** */
@Test
public void testNotEnoughPoints() {
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
- RED), new Stone(10, RED)));
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
- RED), new Stone(3, RED), new Stone(4, RED)));
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
- RED), new Stone(3, RED), new Stone(1, BLACK), new Stone(2,
- BLACK), new Stone(3, BLACK)));
+ testInitialMeld(false,
+ Arrays.asList(new Stone(8, RED), new Stone(9, RED), new Stone(10, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
+ new Stone(3, RED), new Stone(4, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
+ new Stone(3, RED), new Stone(1, BLACK), new Stone(2, BLACK), new Stone(
+ 3, BLACK)));
}
/** */
@Test
public void testNotEnoughPointsWithJoker() {
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
- RED), new Stone(RED), new Stone(3, BLACK)));
- testInitialMeld(false, Arrays.asList(new Stone(4, RED), new Stone(5,
- RED), new Stone(4, BLACK), new Stone(5, BLACK), new Stone(RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9, RED),
+ new Stone(RED), new Stone(3, BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
+ new Stone(4, BLACK), new Stone(5, BLACK), new Stone(RED)));
}
/** */
@Test
public void testNotEnoughPointsWithTwoJokers() {
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
- BLUE), new Stone(3, BLACK), new Stone(RED), new Stone(BLACK)));
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(RED),
- new Stone(BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, BLUE),
+ new Stone(3, BLACK), new Stone(RED), new Stone(BLACK)));
+ testInitialMeld(false,
+ Arrays.asList(new Stone(8, RED), new Stone(RED), new Stone(BLACK)));
}
/** */
@Test
public void testValid() {
- testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(12,
- RED), new Stone(13, RED)));
- testInitialMeld(true, Arrays.asList(new Stone(4, RED),
- new Stone(5, RED), new Stone(6, RED), new Stone(5, ORANGE),
- new Stone(5, BLACK), new Stone(5, BLUE)));
- testInitialMeld(true, Arrays.asList(new Stone(10, RED), new Stone(10,
- BLACK), new Stone(10, ORANGE)));
+ testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(12, RED),
+ new Stone(13, RED)));
+ testInitialMeld(true, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
+ new Stone(6, RED), new Stone(5, ORANGE), new Stone(5, BLACK),
+ new Stone(5, BLUE)));
+ testInitialMeld(true, Arrays.asList(new Stone(10, RED),
+ new Stone(10, BLACK), new Stone(10, ORANGE)));
}
/** */
@Test
public void testValidWithJoker() {
- testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(RED),
- new Stone(13, RED)));
- testInitialMeld(true, Arrays.asList(new Stone(10, RED),
- new Stone(BLACK), new Stone(10, ORANGE)));
- testInitialMeld(true, Arrays.asList(new Stone(4, RED),
- new Stone(5, RED), new Stone(6, RED), new Stone(5, BLACK),
- new Stone(5, BLUE), new Stone(RED)));
+ testInitialMeld(true,
+ Arrays.asList(new Stone(11, RED), new Stone(RED), new Stone(13, RED)));
+ testInitialMeld(true, Arrays.asList(new Stone(10, RED), new Stone(BLACK),
+ new Stone(10, ORANGE)));
+ testInitialMeld(true, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
+ new Stone(6, RED), new Stone(5, BLACK), new Stone(5, BLUE), new Stone(
+ RED)));
}
/** */
@Test
public void testValidWithTwoJokers() {
- testInitialMeld(true, Arrays.asList(new Stone(9, RED), new Stone(RED),
- new Stone(BLACK)));
+ testInitialMeld(true,
+ Arrays.asList(new Stone(9, RED), new Stone(RED), new Stone(BLACK)));
}
/** */
@@ -235,30 +234,35 @@ public class HandTest { /** */
@Test
public void testInvalidHuge() {
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
- RED), new Stone(4, RED), new Stone(6, RED), new Stone(8, RED),
- new Stone(10, RED), new Stone(13, RED), new Stone(1, BLACK),
- new Stone(2, BLACK), new Stone(4, BLACK), new Stone(5, BLACK),
- new Stone(8, BLACK), new Stone(9, BLACK), new Stone(12, BLACK),
- new Stone(3, BLUE), new Stone(5, BLUE), new Stone(7, BLUE),
- new Stone(11, BLUE), new Stone(RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
+ new Stone(4, RED), new Stone(6, RED), new Stone(8, RED), new Stone(10,
+ RED), new Stone(13, RED), new Stone(1, BLACK), new Stone(2, BLACK),
+ new Stone(4, BLACK), new Stone(5, BLACK), new Stone(8, BLACK),
+ new Stone(9, BLACK), new Stone(12, BLACK), new Stone(3, BLUE),
+ new Stone(5, BLUE), new Stone(7, BLUE), new Stone(11, BLUE), new Stone(
+ RED)));
}
/** */
@Test
public void testCountIdenticalStones() {
- dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(2, RED), new Stone(1, BLUE)));
+ dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(2, RED),
+ new Stone(1, BLUE)));
assertEquals(0, hand.getIdenticalStoneCount());
- dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, BLUE)));
+ dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED),
+ new Stone(1, BLUE)));
assertEquals(1, hand.getIdenticalStoneCount());
- dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, BLUE), new Stone(1, BLUE)));
+ dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED),
+ new Stone(1, BLUE), new Stone(1, BLUE)));
assertEquals(2, hand.getIdenticalStoneCount());
- dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, RED)));
+ dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED),
+ new Stone(1, RED)));
assertEquals(1, hand.getIdenticalStoneCount());
- dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, RED), new Stone(1, RED)));
+ dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED),
+ new Stone(1, RED), new Stone(1, RED)));
assertEquals(2, hand.getIdenticalStoneCount());
dropStoneList(Arrays.asList(new Stone(RED), new Stone(RED)));
assertEquals(0, hand.getIdenticalStoneCount());
-
+
}
}
|