From af3661fea084df6e089c2597dc4b311c77f39e4f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 7 Jun 2011 00:23:00 +0200 Subject: Always operate on cloned hands in the turn controls git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@380 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/RoundControlTest.java | 26 ++++++++++++---------- test/jrummikub/control/turn/BaseAIControlTest.java | 6 ++--- test/jrummikub/control/turn/TurnControlTest.java | 15 +++++-------- 3 files changed, 22 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index d709b6b..f726a38 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -147,7 +147,7 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueOne, new Position(0, 0)); hand.drop(blueTwo, new Position(0, 0)); hand.drop(blueThree, new Position(0, 0)); @@ -177,7 +177,7 @@ public class RoundControlTest { } view.startTurnEvent.emit(); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; assertFalse(roundState.getActivePlayer().getLaidOut()); @@ -202,7 +202,7 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueOne, new Position(0, 0)); hand.drop(blueTwo, new Position(0, 0)); hand.drop(blueThree, new Position(0, 0)); @@ -255,7 +255,7 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueOne, new Position(0, 0)); hand.drop(blueTwo, new Position(0, 0)); hand.drop(blueThree, new Position(0, 0)); @@ -286,7 +286,7 @@ public class RoundControlTest { Stone redNine = new Stone(9, RED); Stone redTen = new Stone(10, RED); - hand = roundState.getActivePlayer().getHand(); + hand = roundControl.clonedHand; hand.drop(redEight, new Position(0, 0)); hand.drop(redNine, new Position(0, 0)); hand.drop(redTen, new Position(0, 0)); @@ -326,7 +326,7 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueOne, new Position(0, 0)); hand.drop(blueTwo, new Position(0, 0)); hand.drop(blueThree, new Position(0, 0)); @@ -358,7 +358,7 @@ public class RoundControlTest { Stone redTen = new Stone(10, RED); Stone redEleven = new Stone(11, RED); - hand = roundState.getActivePlayer().getHand(); + hand = roundControl.clonedHand; hand.drop(redEight, new Position(0, 0)); hand.drop(redNine, new Position(0, 0)); hand.drop(redTen, new Position(0, 0)); @@ -400,7 +400,7 @@ public class RoundControlTest { Stone blueSix = new Stone(6, BLUE); Stone blueSeven = new Stone(7, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueFive, new Position(0, 0)); hand.drop(blueSix, new Position(0, 0)); hand.drop(blueSeven, new Position(0, 0)); @@ -427,7 +427,7 @@ public class RoundControlTest { assertEquals(2, roundState.getTable().getSize()); view.startTurnEvent.emit(); - hand = roundState.getActivePlayer().getHand(); + hand = roundControl.clonedHand; view.tablePanel.stoneClickEvent.emit(blueFour, false); view.tablePanel.stoneClickEvent.emit(blueFive, true); @@ -464,7 +464,7 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - IHand hand = roundState.getActivePlayer().getHand(); + IHand hand = roundControl.clonedHand; hand.drop(blueOne, new Position(0, 0)); hand.drop(blueTwo, new Position(0, 0)); hand.drop(blueThree, new Position(0, 0)); @@ -573,7 +573,7 @@ public class RoundControlTest { view.startTurnEvent.emit(); assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType); - IHand hand = testRoundState.players.get(0).hand; + IHand hand = testRound.clonedHand; Stone stone = hand.iterator().next().getFirst(); hand.pickUp(stone); testTable.drop(new StoneSet(stone), new Position(0, 0)); @@ -658,7 +658,7 @@ public class RoundControlTest { view.startTurnEvent.emit(); assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType); - IHand hand = testRoundState.players.get(0).hand; + IHand hand = testRound.clonedHand; Stone blueEight = new Stone(8, BLUE); Stone blackEight = new Stone(8, BLACK); @@ -680,6 +680,7 @@ public class RoundControlTest { for (int i = 0; i < 4; i++) { testRoundState.players.get(i).hand = new Hand(); } + testRound.clonedHand = (IHand) testRoundState.players.get(3).hand.clone(); resetTurnStart(); assertFalse(roundEnded); @@ -952,6 +953,7 @@ public class RoundControlTest { hand.drop(new Stone(i / 2, RED), new Position(0, 0)); } testRoundState.players.get(0).hand = hand; + testRound.clonedHand = (IHand) hand.clone(); view.startTurnEvent.emit(); assertEquals(view.playerPanel.turnMode, TurnMode.MAY_REDEAL); for (int i = 0; i < 4; i++) { diff --git a/test/jrummikub/control/turn/BaseAIControlTest.java b/test/jrummikub/control/turn/BaseAIControlTest.java index 2c7b1fe..fe06398 100644 --- a/test/jrummikub/control/turn/BaseAIControlTest.java +++ b/test/jrummikub/control/turn/BaseAIControlTest.java @@ -75,7 +75,7 @@ public class BaseAIControlTest { */ @Test(timeout = 10000) public void testTurnZeroRedealing() throws InterruptedException { - aiControl.setup(gameSettings, player, table, view, TurnMode.MAY_REDEAL); + aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.MAY_REDEAL), gameSettings, view); aiControl.startTurn(); while (!redealt) { Thread.sleep(100); @@ -89,7 +89,7 @@ public class BaseAIControlTest { */ @Test(timeout = 10000) public void testTurnZeroNotMelding() throws InterruptedException { - aiControl.setup(gameSettings, player, table, view, TurnMode.INSPECT_ONLY); + aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.INSPECT_ONLY), gameSettings, view); aiControl.startTurn(); while (!turnEnded) { Thread.sleep(100); @@ -103,7 +103,7 @@ public class BaseAIControlTest { */ @Test(timeout = 10000) public void testNormalTurnMelding() throws InterruptedException { - aiControl.setup(gameSettings, player, table, view, TurnMode.NORMAL_TURN); + aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.NORMAL_TURN), gameSettings, view); aiControl.startTurn(); while (!turnEnded) { Thread.sleep(100); diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java index ed0b758..bebfff5 100644 --- a/test/jrummikub/control/turn/TurnControlTest.java +++ b/test/jrummikub/control/turn/TurnControlTest.java @@ -110,8 +110,7 @@ public class TurnControlTest { mockPlayer = new MockPlayer(null, null); mockPlayer.hand = mockHand; testControl = new HumanTurnControl(mockTimer); - testControl.setup(new GameSettings(), mockPlayer, mockTable, mockView, - TurnMode.NORMAL_TURN); + testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); } /** */ @@ -135,8 +134,7 @@ public class TurnControlTest { mockHand.iterable = stones; testControl = new HumanTurnControl(mockTimer); - testControl.setup(new GameSettings(), mockPlayer, mockTable, mockView, - TurnMode.NORMAL_TURN); + testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); testControl.startTurn(); int i = 0; @@ -629,8 +627,7 @@ public class TurnControlTest { public void testAddLeft() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new GameSettings(), mockPlayer, table, mockView, - TurnMode.NORMAL_TURN); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); turnControl.startTurn(); Stone blueOne = new Stone(1, BLUE); Stone redOne = new Stone(1, RED); @@ -747,8 +744,7 @@ public class TurnControlTest { public void testAddRight() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new GameSettings(), mockPlayer, table, mockView, - TurnMode.NORMAL_TURN); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); turnControl.startTurn(); Stone blueOne = new Stone(1, BLUE); Stone redOne = new Stone(1, RED); @@ -865,8 +861,7 @@ public class TurnControlTest { public void testAddNewSet() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new GameSettings(), mockPlayer, table, mockView, - TurnMode.NORMAL_TURN); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); turnControl.startTurn(); Stone blueOne = new Stone(1, BLUE); Stone redOne = new Stone(1, RED); -- cgit v1.2.3