public void Player1MoveCausesPlayer2MovementBeforeFirstTurn() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 5, 3, 7, 4, 6); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); board.addPlayerToBoard(p1.getColor(), new Posn(5, 6, 7)); SPlayer p2 = new SPlayer("green", new List <Tile>(), new RandomPlayer()); board.addPlayerToBoard(p2.getColor(), new Posn(5, 6, 6)); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); TurnResult tr = admin.playATurn(board, t1); Posn p1EndPosExpected = new Posn(5, 5, 0); Posn p2EndPosExpected = new Posn(5, 5, 7); Posn p1EndPosActual = board.getPlayerPosn(tr.currentPlayers[1].getColor()); Posn p2EndPosActual = board.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(p1EndPosExpected.isEqual(p1EndPosActual)); Assert.IsTrue(p2EndPosExpected.isEqual(p2EndPosActual)); }
public void Player1MoveCausesPlayer2EliminationBeforeFirstTurn() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 5, 3, 4, 6, 7); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); p1.initialize(board); test.setStartPos(board, p1, new Posn(5, 6, 7)); SPlayer p2 = new SPlayer("green", new List <Tile>(), new RandomPlayer()); p2.initialize(board); test.setStartPos(board, p2, new Posn(5, 6, 6)); TurnResult tr = admin.playATurn(board, t1); Posn p1EndPosExpected = new Posn(5, 5, 0); Posn p1EndPosActual = tr.currentPlayers[0].getPlayerPosn(); Assert.IsTrue(p1EndPosExpected.isEqual(p1EndPosActual)); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.returnColor() == "green")); Assert.IsTrue(tr.playResult.Exists(x => x.returnColor() == "blue")); }
public void SettingPlayerPosition() { TestScenerios test = new TestScenerios(); Board b = new Board(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(1, 2, 3), b); Posn playerPosn = b.getPlayerPosn(p1.getColor()); Assert.IsTrue(playerPosn.isEqual(new Posn(1, 2, 3))); }
public void MakeMoveWhereMultiplePlayersEliminated() { Admin a = new Admin(); Board b = new Board(); TestScenerios test = new TestScenerios(); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); //tile the player is on Tile t2 = test.makeTile(1, 3, 0, 5, 2, 7, 4, 6); test.putTileOnBoard(t2, b, 1, 1); //players to be eliminated SPlayer elim1 = new SPlayer("blue", new List <Tile>()); b.addPlayerToBoard(elim1.getColor(), new Posn(0, 0, 2)); elim1.playerState = SPlayer.State.Playing; SPlayer elim2 = new SPlayer("green", new List <Tile>()); b.addPlayerToBoard(elim2.getColor(), new Posn(0, 0, 3)); elim2.playerState = SPlayer.State.Playing; //player left over SPlayer p1 = new SPlayer("hotpink", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 1, 0)); p1.playerState = SPlayer.State.Playing; a.addToActivePlayers(elim1); a.addToActivePlayers(elim2); a.addToActivePlayers(p1); TurnResult tr = a.playATurn(b, t1); Posn playerPosn = b.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(playerPosn.isEqual(new Posn(1, 1, 3))); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.getColor() == "blue"), "eliminated player is in eliminated list"); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.getColor() == "green"), "eliminated player is in eliminated list"); Assert.IsNotNull(tr.playResult); Assert.IsTrue(tr.playResult.Exists(x => x.getColor() == "hotpink"), "p1 not in the winning list of players"); Assert.AreEqual(tr.playResult.Count, 1); }
public void MakeAMoveCauseMultiplePlayersToMove() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 6, 3, 5, 4, 7); Tile t2 = test.makeTile(0, 1, 2, 7, 3, 4, 5, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("blue", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 0, 2)); SPlayer p2 = new SPlayer("green", new List <Tile>()); b.addPlayerToBoard(p2.getColor(), new Posn(0, 1, 5)); SPlayer p3 = new SPlayer("hotpink", new List <Tile>()); b.addPlayerToBoard(p3.getColor(), new Posn(1, 2, 6)); a.addToActivePlayers(p1); a.addToActivePlayers(p2); a.addToActivePlayers(p3); b.placeTileAt(t2, 1, 2); TurnResult tr = a.playATurn(b, t1); Posn playerPosn0 = b.getPlayerPosn(tr.currentPlayers[0].getColor()); Posn playerPosn1 = b.getPlayerPosn(tr.currentPlayers[1].getColor()); Posn playerPosn2 = b.getPlayerPosn(tr.currentPlayers[2].getColor()); Assert.IsTrue(playerPosn0.isEqual(new Posn(1, 2, 2))); Assert.IsTrue(playerPosn1.isEqual(new Posn(1, 1, 5))); Assert.IsTrue(playerPosn2.isEqual(new Posn(1, 1, 4))); Assert.IsNull(tr.playResult); }
public void MakeAMoveWhenTileIsRotated() { Admin a = new Admin(); Board b = new Board(); List <SPlayer> inGame = new List <SPlayer>(); SPlayer p1 = new SPlayer("blue", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 1, 3)); a.addToActivePlayers(p1); inGame.Add(p1); TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 3, 6, 4, 7, 2, 1, 5); Tile rotatedTile = t1.rotate(); TurnResult tr = a.playATurn(b, rotatedTile); Posn playerPosn = b.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(playerPosn.isEqual(new Posn(1, 2, 0))); Assert.IsTrue(tr.currentPlayers.Exists(x => x.getColor() == "blue"), "p1 not in winning players"); }
public void Player1MoveCausesPlayer2EliminationBeforeFirstTurn() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 5, 3, 4, 6, 7); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(5, 6, 7), board); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile>(), new RandomPlayer(), new Posn(5, 6, 6), board); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); TurnResult tr = admin.playATurn(board, t1); Posn p1EndPosExpected = new Posn(5, 5, 0); Posn p1EndPosActual = board.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(p1EndPosExpected.isEqual(p1EndPosActual)); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.getColor() == "green")); Assert.IsTrue(tr.playResult.Exists(x => x.getColor() == "blue")); }