public void DragonTileHolderChangesFromPlayerToNullIfAfterDrawingAllPlayersHave3Tiles() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t3 = test.makeTile(0, 3, 2, 4, 1, 6, 5, 7); Tile t4 = test.makeTile(0, 2, 4, 5, 1, 7, 3, 6); Tile t5 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); Tile t6 = test.makeTile(1, 5, 2, 4, 3, 7, 0, 6); Admin admin = test.createAdminWithDrawPile(new List <Tile> { t1, t2 }); Board board = new Board(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p2 = test.createPlayerAtPos("red", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p3 = test.createPlayerAtPos("sienna", new List <Tile> { t3, t4, t1 }, new RandomPlayer(), new Posn(2, 2, 2), board); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); admin.addToActivePlayers(p3); admin.setDragonTileHolder(p1); admin.drawTilesWithDragonHolder(); Assert.IsNull(admin.getDragonTileHolder()); }
public void DragonHolderDoesntDrawEmptyDrawPile() { TestScenerios test = new TestScenerios(); Board b = new Board(); Admin a = new Admin(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(-1, 0, 5), b); SPlayer p2 = test.createPlayerAtPos("hotpink", new List <Tile>(), new RandomPlayer(), new Posn(0, -1, 3), b); SPlayer p3 = test.createPlayerAtPos("green", new List <Tile>(), new RandomPlayer(), new Posn(4, 2, 1), b); a.addToActivePlayers(p1); a.addToActivePlayers(p2); a.addToActivePlayers(p3); a.setDragonTileHolder(p2); Tile t1 = test.makeTile(0, 3, 6, 1, 2, 5, 4, 7); TurnResult tr = a.playATurn(b, t1); Assert.AreEqual(0, p2.getHand().Count); }
public void PlayerOrderUpdatesAfterEndOfTurnWithElimination() { TestScenerios test = new TestScenerios(); Board b = new Board(); Admin a = new Admin(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(-1, 0, 5), b); SPlayer p2 = test.createPlayerAtPos("hotpink", new List <Tile>(), new RandomPlayer(), new Posn(0, -1, 3), b); SPlayer p3 = test.createPlayerAtPos("green", new List <Tile>(), new RandomPlayer(), new Posn(4, 2, 1), b); a.addToActivePlayers(p1); a.addToActivePlayers(p2); a.addToActivePlayers(p3); Tile t1 = test.makeTile(0, 3, 6, 1, 2, 5, 4, 7); TurnResult tr = a.playATurn(b, t1); Assert.AreEqual(2, tr.currentPlayers.Count); Assert.AreEqual(1, tr.eliminatedPlayers.Count); Assert.AreEqual("hotpink", tr.eliminatedPlayers[0].getColor()); Assert.AreEqual("green", tr.currentPlayers[0].getColor()); Assert.AreEqual("blue", tr.currentPlayers[1].getColor()); }
public void DragonTileHolderDoesNotChangeAfterPlayATurn() { TestScenerios test = new TestScenerios(); Admin a = test.createAdminWithDrawPile(new List <Tile> { }); Board b = new Board(); Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); Tile t2 = test.makeTile(1, 3, 0, 5, 2, 7, 4, 6); Tile t3 = test.makeTile(2, 4, 3, 6, 5, 1, 7, 0); SPlayer p1 = test.createPlayerAtPos("red", new List <Tile> { t1, t2 }, new RandomPlayer(), new Posn(3, 4, 3), b); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile> { t1, t2, t3 }, new RandomPlayer(), new Posn(3, 4, 3), b); SPlayer p3 = test.createPlayerAtPos("blue", new List <Tile> { t1, t2 }, new RandomPlayer(), new Posn(2, 4, 6), b); a.addToActivePlayers(p1); a.addToActivePlayers(p2); a.addToActivePlayers(p3); a.setDragonTileHolder(p3); a.playATurn(b, t3); Assert.AreEqual("blue", a.getDragonTileHolder().getColor()); Console.WriteLine(XMLEncoder.splayerToXML(p3, a)); }
public void DragonTileHolderGetsEliminatedAndReturnsTilesToDrawPile() { TestScenerios test = new TestScenerios(); Tile toPlayTile = test.makeTile(0, 4, 1, 5, 2, 6, 3, 7); Tile redTile1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile redTile2 = test.makeTile(0, 3, 2, 4, 1, 6, 5, 7); Tile blueTile1 = test.makeTile(0, 2, 4, 5, 1, 7, 3, 6); Tile blueTile2 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); Tile randTile = test.makeTile(1, 5, 2, 4, 3, 7, 0, 6); Board board = test.createBoardWithDrawPile(new List <Tile> { }); SPlayer p1 = test.createPlayerAtPos("red", new List <Tile> { redTile1, redTile2 }, new RandomPlayer(), new Posn(1, 2, 1), board); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile> { randTile, randTile, randTile }, new RandomPlayer(), new Posn(3, 3, 3), board); SPlayer p3 = test.createPlayerAtPos("sienna", new List <Tile> { randTile, randTile, randTile }, new RandomPlayer(), new Posn(1, 5, 5), board); SPlayer p4 = test.createPlayerAtPos("blue", new List <Tile> { blueTile1, blueTile2 }, new RandomPlayer(), new Posn(1, 2, 0), board); board.setDragonTileHolder(p4); Admin admin = new Admin(); admin.playATurn(board, toPlayTile); Assert.AreEqual(4, board.drawPile.Count); Assert.IsFalse(board.existsDragonTileHolder()); }
public void EndOfGameFrom35TilesBeingPlaced() { TestScenerios test = new TestScenerios(); Board board = new Board(); Admin admin = new Admin(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t_play = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { board.placeTileAt(t1, i, j); } } // Clear two tiles board.placeTileAt(null, 2, 3); board.placeTileAt(null, 2, 4); SPlayer p1 = test.createPlayerAtPos("green", new List <Tile> { }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p2 = test.createPlayerAtPos("sienna", new List <Tile> { }, new RandomPlayer(), new Posn(2, 2, 3), board); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); TurnResult tr = admin.playATurn(board, t_play); Assert.IsTrue(tr.playResult != null); }
public void DragonTileHolderGetsEliminatedAndDragonTileHolderReturnsToNull() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t3 = test.makeTile(0, 3, 2, 4, 1, 6, 5, 7); Tile t4 = test.makeTile(0, 2, 4, 5, 1, 7, 3, 6); Tile t5 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); Tile t6 = test.makeTile(1, 5, 2, 4, 3, 7, 0, 6); Board board = test.createBoardWithDrawPile(new List <Tile> { }); SPlayer p1 = test.createPlayerAtPos("red", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile> { t3, t4, t2 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p3 = test.createPlayerAtPos("sienna", new List <Tile> { t3, t4, t1 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p4 = test.createPlayerAtPos("blue", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); board.setDragonTileHolder(p4); board.eliminatePlayer(p1); board.eliminatePlayer(p4); Assert.AreEqual(4, board.drawPile.Count); Assert.IsFalse(board.existsDragonTileHolder()); }
public void GetTurnResultOfEndOfGameFrom35TilesBeingPlaced() { TestScenerios test = new TestScenerios(); Board board = test.createBoardWithDrawPile(new List <Tile> { }); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { board.grid[i, j] = t1; } } board.grid[1, 1] = null; SPlayer p1 = test.createPlayerAtPos("green", new List <Tile> { }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p2 = test.createPlayerAtPos("sienna", new List <Tile> { }, new RandomPlayer(), new Posn(2, 2, 3), board); board.setDragonTileHolder(p1); TurnResult tr = board.GetTurnResult(); Assert.IsTrue(tr.playResult != null); }
public void PlayerWithoutDragonTileCausesDragonTileHolderToBeEliminated() { 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); Tile t3 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t4 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); b.placeTileAt(t2, 1, 1); //players to be eliminated List <Tile> elim1Tiles = new List <Tile>() { t3, t4 }; SPlayer elim1 = test.createPlayerAtPos("elim1", elim1Tiles, new RandomPlayer(), new Posn(0, 0, 2), b); //players left over SPlayer p2 = test.createPlayerAtPos("p2", new List <Tile>(), new RandomPlayer(), new Posn(4, 4, 3), b); SPlayer p1 = test.createPlayerAtPos("p1", new List <Tile>(), new RandomPlayer(), new Posn(1, 1, 0), b); a.addToActivePlayers(elim1); a.addToActivePlayers(p2); a.addToActivePlayers(p1); a.setDragonTileHolder(elim1); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(a.isDragonHolder("p2")); Assert.AreEqual(1, tr.eliminatedPlayers.Count); Assert.AreEqual(2, tr.currentPlayers.Count); Assert.AreEqual(1, a.numEliminated()); Assert.AreEqual(2, a.numActive()); Assert.AreEqual(1, p2.getHand().Count); Assert.AreEqual(1, p1.getHand().Count); Assert.IsTrue(p2.getHand().Contains(t3)); Assert.IsTrue(p1.getHand().Contains(t4)); }
public void boardToXMLPlayerEliminatedCurrentTurn() { Admin a = new Admin(); Board board = new Board(); TestScenerios test = new TestScenerios(); // Board set up Tile normalTile = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile eliminationTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile drawPileTile = test.makeTile(0, 3, 2, 1, 4, 7, 6, 5); board.placeTileAt(normalTile, 0, 0); a.addTileToDrawPile(drawPileTile); // Player set up SPlayer eliminatedPlayer = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(3, -1, 3), board); SPlayer activePlayer = test.createPlayerAtPos("red", new List <Tile>(), new RandomPlayer(), new Posn(0, 0, 3), board); a.addToActivePlayers(eliminatedPlayer); a.addToActivePlayers(activePlayer); TurnResult tmpturn = a.playATurn(board, eliminationTile); // Test XElement boardToXMLActual = XMLEncoder.boardToXML(tmpturn.b); XElement boardToXMLExpected = XElement.Parse("<board><map>" + "<ent><xy><x>0</x><y>0</y></xy>" + "<tile><connect><n>0</n><n>1</n></connect>" + "<connect><n>2</n><n>4</n></connect>" + "<connect><n>3</n><n>6</n></connect>" + "<connect><n>5</n><n>7</n></connect></tile></ent>" + "<ent><xy><x>0</x><y>3</y></xy>" + "<tile><connect><n>0</n><n>1</n></connect>" + "<connect><n>2</n><n>3</n></connect>" + "<connect><n>4</n><n>5</n></connect>" + "<connect><n>6</n><n>7</n></connect></tile></ent></map>" + "<map>" + "<ent><color>blue</color><pawn-loc><v></v><n>0</n><n>6</n></pawn-loc></ent>" + "<ent><color>red</color><pawn-loc><v></v><n>1</n><n>1</n></pawn-loc></ent>" + "</map></board>"); Console.WriteLine(boardToXMLActual); Console.WriteLine(boardToXMLExpected); Assert.IsTrue(XNode.DeepEquals(boardToXMLActual, boardToXMLExpected)); }
public void GetLegalMoves() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t2 = test.makeTile(0, 1, 2, 6, 3, 7, 4, 5); Tile t3 = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); List <Tile> hand = new List <Tile> { t1, t2, t3 }; Board b = new Board(); SPlayer p1 = test.createPlayerAtPos("blue", hand, new RandomPlayer(), new Posn(-1, 0, 4), b); // Call test function List <Tile> actualLegalMoves = b.getLegalMoves(hand, "blue"); // Construct expected result Tile t2Rot = test.makeTile(0, 4, 1, 5, 2, 3, 6, 7); Tile t3Rot2 = test.makeTile(0, 3, 1, 4, 2, 6, 5, 7); List <Tile> expected = new List <Tile> { t2Rot, t3, t3Rot2 }; Assert.AreEqual(3, actualLegalMoves.Count); for (int i = 0; i < actualLegalMoves.Count; i++) { Assert.IsTrue(actualLegalMoves[i].isEqualOrRotation(expected[i])); } }
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 PlayerTakesDragonTile() { TestScenerios test = new TestScenerios(); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = test.createPlayerAtPos("p1", new List <Tile>(), new RandomPlayer(), new Posn(3, 3, 1), b); SPlayer p2 = test.createPlayerAtPos("p2", new List <Tile>(), new RandomPlayer(), new Posn(4, 3, 1), b); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(tr.b.isDragonTileHolder("p1")); }
public void PlayerOrderUpdatesAfterEndOfTurn() { TestScenerios test = new TestScenerios(); Board b = new Board(); Admin a = new Admin(); SPlayer p1 = test.createPlayerAtPos("blue", new List <Tile>(), new RandomPlayer(), new Posn(3, 3, 1), b); SPlayer p2 = test.createPlayerAtPos("hotpink", new List <Tile>(), new RandomPlayer(), new Posn(4, 3, 1), b); SPlayer p3 = test.createPlayerAtPos("green", new List <Tile>(), new RandomPlayer(), new Posn(4, 2, 1), b); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); TurnResult tr = a.playATurn(b, t1); Assert.AreEqual(3, tr.currentPlayers.Count); Assert.AreEqual("hotpink", tr.currentPlayers[0].returnColor()); Assert.AreEqual("green", tr.currentPlayers[1].returnColor()); Assert.AreEqual("blue", tr.currentPlayers[2].returnColor()); }
public void DragonTileHolderGetsEliminatedAndReturnsTilesToDrawPile() { TestScenerios test = new TestScenerios(); Tile toPlayTile = test.makeTile(0, 4, 1, 5, 2, 6, 3, 7); Tile redTile1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile redTile2 = test.makeTile(0, 3, 2, 4, 1, 6, 5, 7); Tile blueTile1 = test.makeTile(0, 2, 4, 5, 1, 7, 3, 6); Tile blueTile2 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); Tile randTile = test.makeTile(1, 5, 2, 4, 3, 7, 0, 6); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = test.createPlayerAtPos("red", new List <Tile> { redTile1, redTile2 }, new RandomPlayer(), new Posn(1, 2, 1), board); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile> { randTile, randTile, randTile }, new RandomPlayer(), new Posn(3, 3, 3), board); SPlayer p3 = test.createPlayerAtPos("sienna", new List <Tile> { randTile, randTile, randTile }, new RandomPlayer(), new Posn(1, 5, 5), board); SPlayer p4 = test.createPlayerAtPos("blue", new List <Tile> { blueTile1, blueTile2 }, new RandomPlayer(), new Posn(1, 2, 0), board); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); admin.addToActivePlayers(p3); admin.addToActivePlayers(p4); admin.setDragonTileHolder(p4); admin.playATurn(board, toPlayTile); Assert.AreEqual(4, admin.getDrawPileSize()); Assert.IsNull(admin.getDragonTileHolder()); }
public void DragonTileHolderGetsEliminatedAndDragonTileHolderReturnsToNull() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t3 = test.makeTile(0, 3, 2, 4, 1, 6, 5, 7); Tile t4 = test.makeTile(0, 2, 4, 5, 1, 7, 3, 6); Tile t5 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); Tile t6 = test.makeTile(1, 5, 2, 4, 3, 7, 0, 6); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = test.createPlayerAtPos("red", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p2 = test.createPlayerAtPos("green", new List <Tile> { t3, t4, t2 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p3 = test.createPlayerAtPos("sienna", new List <Tile> { t3, t4, t1 }, new RandomPlayer(), new Posn(2, 2, 2), board); SPlayer p4 = test.createPlayerAtPos("blue", new List <Tile> { t3, t4 }, new RandomPlayer(), new Posn(2, 2, 2), board); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); admin.addToActivePlayers(p3); admin.addToActivePlayers(p4); admin.setDragonTileHolder(p4); admin.eliminatePlayer(p1.getColor()); admin.eliminatePlayer(p4.getColor()); Assert.AreEqual(4, admin.getDrawPileSize()); Assert.IsNull(admin.getDragonTileHolder()); }
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")); }
public void GetLegalMovesAllElimination() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); List <Tile> hand = new List <Tile> { t1 }; Board b = new Board(); SPlayer p1 = test.createPlayerAtPos("blue", hand, new RandomPlayer(), new Posn(-1, 0, 4), b); // Call test function List <Tile> actualLegalMoves = b.getLegalMoves(hand, "blue"); // Construct expected result List <Tile> expected = new List <Tile> { t1 }; Assert.AreEqual(1, actualLegalMoves.Count); Assert.IsTrue(actualLegalMoves[0].isEqualOrRotation(expected[0])); }