Show in start turn panel if a player has redealed or drawn the last stone
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@570 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
62a55c0a91
commit
d6c4da6224
20 changed files with 358 additions and 252 deletions
|
@ -92,7 +92,7 @@ public class GameControlTest {
|
|||
view.playerPanel.endTurnEvent.emit();
|
||||
view.startTurnEvent.emit();
|
||||
view.playerPanel.redealEvent.emit();
|
||||
assertSame(BottomPanelType.START_TURN_PANEL, view.bottomPanelType);
|
||||
assertSame(BottomPanelType.START_REDEAL_TURN_PANEL, view.bottomPanelType);
|
||||
view.startTurnEvent.emit();
|
||||
assertSame(firstPlayer, gameControl.roundControl.roundState
|
||||
.getActivePlayer().getPlayerSettings());
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
|
||||
import jrummikub.control.turn.TurnMode;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.GameState;
|
||||
import jrummikub.model.Hand;
|
||||
import jrummikub.model.IHand;
|
||||
import jrummikub.model.IPlayer;
|
||||
|
@ -22,7 +23,6 @@ import jrummikub.model.RoundState;
|
|||
import jrummikub.model.Score;
|
||||
import jrummikub.model.Stone;
|
||||
import jrummikub.model.StoneSet;
|
||||
import jrummikub.util.IListener;
|
||||
import jrummikub.util.IListener1;
|
||||
import jrummikub.util.Pair;
|
||||
import jrummikub.view.IView.BottomPanelType;
|
||||
|
@ -86,8 +86,9 @@ public class RoundControlTest {
|
|||
public void setup() {
|
||||
view = new MockView();
|
||||
testRoundState = new MockRoundState();
|
||||
testRoundState.gameState = new GameState();
|
||||
testRound = new RoundControl(testRoundState, view);
|
||||
Stone stone = testRoundState.getGameHeap().drawStone();
|
||||
Stone stone = testRoundState.getStoneHeap().drawStone();
|
||||
testRoundState.table.drop(new StoneSet(stone), new Position(5, 0));
|
||||
testTable = new MockTable();
|
||||
testTable.sets.add(testRoundState.table.sets.get(0));
|
||||
|
@ -99,24 +100,21 @@ 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));
|
||||
roundState = new RoundState(gameSettings, null);
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
|
||||
roundState = new RoundState(gameSettings, new GameState());
|
||||
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.getStoneHeap()
|
||||
.getSize());
|
||||
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
|
||||
assertEquals(settings.getNumberOfStonesDealt(), testRoundState
|
||||
.getNthNextPlayer(i).getHand().getSize());
|
||||
|
@ -187,8 +185,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());
|
||||
}
|
||||
|
@ -210,8 +208,7 @@ 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 */
|
||||
|
@ -248,8 +245,7 @@ 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());
|
||||
}
|
||||
|
||||
private void dropStonesOnHand(IHand hand, List<Stone> stones) {
|
||||
|
@ -308,8 +304,7 @@ 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 */
|
||||
|
@ -361,8 +356,7 @@ 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());
|
||||
}
|
||||
|
||||
/** */
|
||||
|
@ -415,8 +409,7 @@ 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 */
|
||||
|
@ -499,8 +492,9 @@ public class RoundControlTest {
|
|||
testTable.valid = true;
|
||||
testTable.sets.clear();
|
||||
testTable.drop(
|
||||
new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
|
||||
orangeEight)), new Position(0, 0));
|
||||
new StoneSet(Arrays
|
||||
.asList(blueEight, blackEight, redEight, orangeEight)),
|
||||
new Position(0, 0));
|
||||
oldTable.clonedTable = testTable;
|
||||
|
||||
view.startTurnEvent.emit();
|
||||
|
@ -529,9 +523,10 @@ public class RoundControlTest {
|
|||
|
||||
testTable.valid = false;
|
||||
testTable.sets.clear();
|
||||
testTable.drop(
|
||||
new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
|
||||
blackFour)), new Position(0, 0));
|
||||
testTable
|
||||
.drop(
|
||||
new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
|
||||
blackFour)), new Position(0, 0));
|
||||
oldTable.clonedTable = testTable;
|
||||
|
||||
view.startTurnEvent.emit();
|
||||
|
@ -587,8 +582,9 @@ public class RoundControlTest {
|
|||
MockTable oldTable = testRoundState.table;
|
||||
oldTable.sets.clear();
|
||||
oldTable.drop(
|
||||
new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
|
||||
orangeEight)), new Position(0, 0));
|
||||
new StoneSet(Arrays
|
||||
.asList(blueEight, blackEight, redEight, orangeEight)),
|
||||
new Position(0, 0));
|
||||
|
||||
testTable.valid = false;
|
||||
testTable.sets.clear();
|
||||
|
@ -672,7 +668,7 @@ public class RoundControlTest {
|
|||
}
|
||||
});
|
||||
|
||||
roundState.getGameHeap().drawStones(106 - 14 * 4 - 1);
|
||||
roundState.getStoneHeap().drawStones(106 - 14 * 4 - 1);
|
||||
|
||||
roundControl.startRound();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
@ -713,20 +709,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(1).laidOut = true;
|
||||
testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(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, 0));
|
||||
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();
|
||||
|
@ -760,19 +755,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);
|
||||
|
@ -810,9 +805,9 @@ public class RoundControlTest {
|
|||
/** */
|
||||
@Test
|
||||
public void testRedeal() {
|
||||
testRound.getRestartRoundEvent().add(new IListener() {
|
||||
testRound.getRestartRoundEvent().add(new IListener1<PlayerSettings>() {
|
||||
@Override
|
||||
public void handle() {
|
||||
public void handle(PlayerSettings player) {
|
||||
roundRestarted = true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -33,13 +33,12 @@ public class GameJoinControlTest {
|
|||
@Before
|
||||
public void setup() {
|
||||
mockConnection = new MockConnectionControl();
|
||||
mockConnection.nickname = "Karl";
|
||||
view = new MockView();
|
||||
loginData = new LoginData("Karl", "server", "password", "channel");
|
||||
networkControl = new NetworkControl(loginData, mockConnection, null, view);
|
||||
networkControl.startNetwork();
|
||||
|
||||
mockConnection.connectedEvent.emit();
|
||||
mockConnection.connectedEvent.emit();
|
||||
}
|
||||
|
||||
/** */
|
||||
|
@ -52,7 +51,8 @@ public class GameJoinControlTest {
|
|||
assertEquals(SettingsMode.NETWORK_JOIN, view.settingsPanel.settingsMode);
|
||||
offerJoinedGame(id1, "Anne", "Karl");
|
||||
view.settingsPanel.changePlayerColorEvent.emit(1, Color.GRAY);
|
||||
assertEquals(Type.HUMAN, mockConnection.getCurrentGame().getGameSettings().getPlayerList().get(1).getType());
|
||||
assertEquals(Type.HUMAN, mockConnection.getCurrentGame().getGameSettings()
|
||||
.getPlayerList().get(1).getType());
|
||||
assertEquals(Color.GRAY, mockConnection.playerColor);
|
||||
|
||||
view.settingsPanel.backEvent.emit();
|
||||
|
@ -71,14 +71,14 @@ public class GameJoinControlTest {
|
|||
mockConnection.gameOfferEvent.emit(gameData);
|
||||
return gameData;
|
||||
}
|
||||
|
||||
|
||||
private GameData offerJoinedGame(UUID id, String host, String player) {
|
||||
GameSettings gsettings = new GameSettings();
|
||||
PlayerSettings psettings = new PlayerSettings(host, Color.BLACK);
|
||||
psettings.setType(Type.HUMAN);
|
||||
psettings.setType(Type.NETWORK);
|
||||
gsettings.getPlayerList().add(psettings);
|
||||
PlayerSettings psettings2 = new PlayerSettings(player, Color.RED);
|
||||
psettings2.setType(Type.NETWORK);
|
||||
psettings2.setType(Type.HUMAN);
|
||||
gsettings.getPlayerList().add(psettings2);
|
||||
GameData gameData = new GameData(id, gsettings, host);
|
||||
mockConnection.gameOfferEvent.emit(gameData);
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Collections;
|
|||
import jrummikub.control.RoundControl.InvalidTurnInfo;
|
||||
import jrummikub.control.turn.AIControl;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.GameState;
|
||||
import jrummikub.model.IPlayer;
|
||||
import jrummikub.model.PlayerSettings;
|
||||
import jrummikub.model.PlayerSettings.Type;
|
||||
|
@ -21,9 +22,6 @@ import jrummikub.view.MockView;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for network round control
|
||||
*/
|
||||
public class NetworkRoundControlTest {
|
||||
private MockConnectionControl connectionControl;
|
||||
private MockView view;
|
||||
|
@ -32,7 +30,6 @@ public class NetworkRoundControlTest {
|
|||
|
||||
private GameSettings gameSettings;
|
||||
|
||||
/** */
|
||||
@Before
|
||||
public void setup() {
|
||||
AIControl.useBackgroundThread = false;
|
||||
|
@ -42,26 +39,20 @@ 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().get(1).setType(Type.COMPUTER);
|
||||
gameSettings.getPlayerList().get(2).setType(Type.NETWORK);
|
||||
gameSettings.getPlayerList().get(3).setType(Type.COMPUTER);
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
|
||||
|
||||
view = new MockView();
|
||||
connectionControl = new MockConnectionControl();
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testHostRound() {
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(0)
|
||||
.getName();
|
||||
gameSettings.getPlayerList().get(1).setType(Type.COMPUTER);
|
||||
gameSettings.getPlayerList().get(2).setType(Type.NETWORK);
|
||||
gameSettings.getPlayerList().get(3).setType(Type.COMPUTER);
|
||||
|
||||
testRoundState = new RoundState(gameSettings, null);
|
||||
testRoundState = new RoundState(gameSettings, new GameState());
|
||||
testRound = new NetworkRoundControl(testRoundState, view,
|
||||
connectionControl, true);
|
||||
|
||||
|
@ -75,8 +66,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) {
|
||||
|
@ -88,8 +79,7 @@ public class NetworkRoundControlTest {
|
|||
}
|
||||
}
|
||||
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -104,8 +94,7 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(1),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -117,59 +106,52 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(2),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(3),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testClientRound() {
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(2)
|
||||
.getName();
|
||||
gameSettings.getPlayerList().get(0).setType(Type.NETWORK);
|
||||
gameSettings.getPlayerList().get(1).setType(Type.COMPUTER);
|
||||
gameSettings.getPlayerList().get(3).setType(Type.COMPUTER);
|
||||
|
||||
testRoundState = new RoundState(gameSettings, null);
|
||||
testRoundState = new RoundState(gameSettings, new GameState());
|
||||
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;
|
||||
|
@ -178,39 +160,35 @@ public class NetworkRoundControlTest {
|
|||
|
||||
connectionControl.roundStateUpdateEvent.emit(testRoundState);
|
||||
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(1),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(2),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
|
||||
|
@ -223,8 +201,7 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(3),
|
||||
testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -236,10 +213,8 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
|
Reference in a new issue