public void MakeAMoveCauseTokenToCrossMultipleTiles() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); Tile t4 = test.makeTile(0, 1, 2, 7, 4, 5, 3, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 1, 3)); b.registerPlayer(p1); b.grid[1, 1] = t2; b.grid[1, 3] = t1; b.grid[1, 4] = t3; TurnResult tr = a.playATurn(b, t4); Posn playerPosn = tr.currentPlayers[0].getPlayerPosn(); Assert.IsTrue(playerPosn.returnRow() == 1); Assert.IsTrue(playerPosn.returnCol() == 4); Assert.IsTrue(playerPosn.returnLocationOnTile() == 3); }
public void DragonTileBeforeTurnStillNoNewTiles() { 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("p1", new List <Tile>()); p1.setPosn(new Posn(1, 0, 2)); SPlayer p2 = new SPlayer("p2", new List <Tile>()); p2.setPosn(new Posn(0, 1, 5)); SPlayer p3 = new SPlayer("p3", new List <Tile>()); p3.setPosn(new Posn(1, 2, 6)); b.registerPlayer(p1); b.registerPlayer(p2); b.registerPlayer(p3); b.grid[1, 2] = t2; TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(tr.b.isDragonTileHolder("p1")); Assert.IsTrue(tr.currentPlayers[0].returnHand().Count == 0); Assert.IsTrue(tr.currentPlayers[1].returnHand().Count == 0); Assert.IsTrue(tr.currentPlayers[2].returnHand().Count == 0); }
public void LeastSymPlayerChoosesLeastSymTileRotated() { //the least symmetric tile is not valid unless rotated //so the player will rotate the least symmetric tile and play that move TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, mostSymTile, leastSymTile); SPlayer p1 = new SPlayer("blue", playerTiles, new LeastSymmetricPlayer()); Board b = new Board(); p1.initialize("blue", new List <string> { "blue" }); test.setStartPos(b, p1, new Posn(0, 1, 7)); Tile actualTile = p1.playTurn(b, 0); //playturn should return the least symmetric tile rotated once Assert.IsTrue(actualTile.isEqualOrRotation(leastSymTile)); Tile leastSymRot3 = test.makeTile(0, 4, 1, 7, 2, 5, 3, 6); Assert.IsTrue(leastSymRot3.isEqual(actualTile)); }
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 boardToXMLWithEliminatedPlayers() { 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); board.placeTileAt(normalTile, 0, 0); board.placeTileAt(eliminationTile, 3, 0); // Player set up SPlayer activePlayer = new SPlayer("red", new List <Tile>(), new RandomPlayer()); //activePlayer.initialize(board); test.setStartPos(board, activePlayer, new Posn(0, 0, 3)); SPlayer eliminatedPlayer = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); //eliminatedPlayer.initialize(board); test.setStartPos(board, eliminatedPlayer, new Posn(3, 0, 7)); // Test XElement boardToXMLActual = XMLEncoder.boardToXML(board); 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>red</color><pawn-loc><v></v><n>1</n><n>1</n></pawn-loc></ent><ent><color>blue</color><pawn-loc><v></v><n>0</n><n>6</n></pawn-loc></ent></map></board>"); Assert.IsTrue(XNode.DeepEquals(boardToXMLActual, boardToXMLExpected)); }
public void PlayAValidTurnChangesOrderOfInGamePlayers() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); List <Tile> drawpile = test.makeDrawPile(t2, t3); Admin a = test.createAdminWithDrawPile(drawpile); Board b = new Board(); SPlayer p1 = new SPlayer("blue", new List <Tile>()); Posn p1Pos = new Posn(0, 0, 3); SPlayer p2 = new SPlayer("green", new List <Tile>()); Posn p2Pos = new Posn(4, 4, 0); a.addToActivePlayers(p1); a.addToActivePlayers(p2); b.addPlayerToBoard("blue", p1Pos); b.addPlayerToBoard("green", p2Pos); List <SPlayer> l1 = new List <SPlayer>() { p1, p2 }; List <SPlayer> l2 = new List <SPlayer>(); TurnResult tmpturn = a.playATurn(b, t1); Assert.IsTrue(tmpturn.currentPlayers[0].getColor() == "green"); Assert.IsTrue(tmpturn.currentPlayers[1].getColor() == "blue"); Assert.IsTrue(tmpturn.currentPlayers.Count == 2); }
public void DragonTileBeforeTurnStillNoNewTiles() { 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); Assert.IsTrue(a.isDragonHolder("blue")); Assert.IsTrue(tr.currentPlayers[0].getHand().Count == 0); Assert.IsTrue(tr.currentPlayers[1].getHand().Count == 0); Assert.IsTrue(tr.currentPlayers[2].getHand().Count == 0); }
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.grid[0, 0] = normalTile; board.addTileToDrawPile(drawPileTile); // Player set up SPlayer eliminatedPlayer = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); eliminatedPlayer.initialize(board); test.setStartPos(board, eliminatedPlayer, new Posn(3, -1, 3)); SPlayer activePlayer = new SPlayer("red", new List <Tile>(), new RandomPlayer()); activePlayer.initialize(board); test.setStartPos(board, activePlayer, new Posn(0, 0, 3)); 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>red</color><pawn-loc><v></v><n>1</n><n>1</n></pawn-loc></ent><ent><color>blue</color><pawn-loc><v></v><n>0</n><n>6</n></pawn-loc></ent></map></board>"); 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 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 LeastSymPlayerChoosesLeastSymTileRotated() { //the least symmetric tile is not valid unless rotated once //so the player will rotate the least symmetric tile and play that move TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, mostSymTile, leastSymTile); SPlayer p1 = new SPlayer("blue", playerTiles, new LeastSymmetricPlayer()); //p1.initialize("blue", new List<string> { "hotpink", "green" }); Board b = new Board(); p1.initialize(b); test.setStartPos00(b, p1); p1.setPosn(new Posn(1, 0, 0)); Tile checkTile = p1.playTurn(b, 0); //playturn should return the least symmetric tile rotated once Assert.IsTrue(checkTile.isEqual(leastSymTile)); Assert.IsTrue(checkTile.paths[0].isEqual(new Path(2, 7))); Assert.IsTrue(checkTile.paths[1].isEqual(new Path(3, 5))); Assert.IsTrue(checkTile.paths[2].isEqual(new Path(4, 0))); Assert.IsTrue(checkTile.paths[3].isEqual(new Path(6, 1))); }
public void MostSymPlayerChoosesMidSymTile() { TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, mostSymTile, leastSymTile); SPlayer p1 = new SPlayer("hotpink", playerTiles, new MostSymmetricPlayer()); Board b = new Board(); p1.initialize(b); test.setStartPos00(b, p1); // Assign start position to top left of board p1.setPosn(new Posn(-1, 0, 5)); Tile checkTile = p1.playTurn(b, 0); //playturn should return the mid symmetric tile (first valid move) Assert.IsTrue(checkTile.isEqual(medSymTile)); Assert.IsTrue(checkTile.paths[0].isEqual(new Path(2, 0))); Assert.IsTrue(checkTile.paths[1].isEqual(new Path(3, 7))); Assert.IsTrue(checkTile.paths[2].isEqual(new Path(4, 6))); Assert.IsTrue(checkTile.paths[3].isEqual(new Path(5, 1))); }
public void TileActuallyRotates() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t1_test_rotated = t1.rotate(); Tile t1_actual_rotated = test.makeTile(2, 3, 4, 6, 5, 0, 7, 1); int j = 0; foreach (Path p in t1_actual_rotated.paths) { Assert.IsTrue(p.isEqual(t1_test_rotated.paths[j])); j++; } //check tile rotates once Assert.IsTrue(t1_test_rotated.isEqualOrRotation(t1_actual_rotated)); //check that after tile is rotated 4 times, it is equivalent to the orig orientation for (int i = 0; i < 3; i++) { t1_test_rotated = t1_test_rotated.rotate(); } Assert.IsTrue(t1_test_rotated.isEqualOrRotation(t1)); }
public void MakeAMoveCauseTokenToCrossMultipleTiles() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); Tile t4 = test.makeTile(0, 1, 2, 7, 4, 5, 3, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("blue", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 1, 3)); a.addToActivePlayers(p1); b.placeTileAt(t2, 1, 1); b.placeTileAt(t1, 1, 3); b.placeTileAt(t3, 1, 4); TurnResult tr = a.playATurn(b, t4); Posn playerPosn = b.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(new Posn(1, 4, 3).isEqual(playerPosn)); }
public void ValidTurnCausePlayerToBeEliminated() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); List <Tile> drawpile = test.makeDrawPile(t2, t3); Admin a = test.createAdminWithDrawPile(drawpile); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); Posn p1Pos = new Posn(0, 1, 6); test.setStartPos(b, p1, p1Pos); SPlayer p2 = new SPlayer("p2", new List <Tile>()); Posn p2Pos = new Posn(4, 4, 0); test.setStartPos(b, p2, p2Pos); a.addToActivePlayers(p1); a.addToActivePlayers(p2); TurnResult tmpturn = a.playATurn(b, t1); Assert.AreEqual(1, a.numEliminated(), "count of eliminated players has not increased to 1"); Assert.IsTrue(tmpturn.eliminatedPlayers.Count == 1, "count of eliminated players has not increased to 1"); Assert.IsTrue(tmpturn.eliminatedPlayers.Exists(x => x.getColor() == "p1"), "p1 has not been moved to eliminated players"); Assert.IsFalse(tmpturn.currentPlayers.Exists(x => x.getColor() == "p1"), "p1 has not been removed from current players"); Assert.IsTrue(tmpturn.currentPlayers.Count == 1, "count of current players has not decreased to 1"); }
public void IsEqualDifferentOrderPaths() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); Tile t1SameDiffOrdering = test.makeTile(1, 3, 4, 7, 2, 6, 0, 5); Assert.IsTrue(t1.isEqualOrRotation(t1SameDiffOrdering)); }
public void TilesIsNotEqual() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Assert.IsFalse(t1.isEqualOrRotation(t2)); }
public void PlayerHasDragonTileCausesPlayerToBeEliminated() { 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.grid[1, 1] = t2; //players to be eliminated List <Tile> elim1Tiles = new List <Tile>() { t3, t4 }; SPlayer elim1 = new SPlayer("elim1", elim1Tiles); elim1.setPosn(new Posn(0, 0, 2)); elim1.playerState = SPlayer.State.Playing; //players left over SPlayer p2 = new SPlayer("p2", new List <Tile>()); p2.setPosn(new Posn(4, 4, 3)); p2.playerState = SPlayer.State.Playing; SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 1, 0)); p1.playerState = SPlayer.State.Playing; b.registerPlayer(p1); b.registerPlayer(elim1); b.registerPlayer(p2); b.setDragonTileHolder(p1); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(tr.b.isDragonTileHolder("p1")); Assert.AreEqual(1, tr.eliminatedPlayers.Count); Assert.AreEqual(2, tr.currentPlayers.Count); Assert.AreEqual(1, b.returnEliminated().Count); Assert.AreEqual(2, b.getNumActive()); Assert.AreEqual(1, p2.returnHand().Count); Assert.AreEqual(1, p1.returnHand().Count); Assert.IsTrue(p1.returnHand().Contains(t3)); Assert.IsTrue(p2.returnHand().Contains(t4)); Assert.AreEqual("p2", b.getFirstActivePlayer().returnColor()); }
public void PlayerHasDragonTileCausesPlayerToBeEliminated() { 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 = new SPlayer("blue", elim1Tiles); b.addPlayerToBoard(elim1.getColor(), new Posn(0, 0, 2)); elim1.playerState = SPlayer.State.Playing; //players left over SPlayer p2 = new SPlayer("green", new List <Tile>()); b.addPlayerToBoard(p2.getColor(), new Posn(4, 4, 3)); p2.playerState = SPlayer.State.Playing; SPlayer p1 = new SPlayer("hotpink", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 1, 0)); p1.playerState = SPlayer.State.Playing; a.addToActivePlayers(p1); a.addToActivePlayers(elim1); a.addToActivePlayers(p2); a.setDragonTileHolder(p1); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(a.isDragonHolder("hotpink")); 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(p1.getHand().Contains(t3)); Assert.IsTrue(p2.getHand().Contains(t4)); Assert.AreEqual("green", a.getFirstActivePlayer().getColor()); }
public void IsEqualRotatedDifferentOrderPaths() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); Tile t1RotatedDiffOrdering = test.makeTile(0, 4, 1, 6, 2, 7, 3, 5); Tile t1Rotated = t1.rotate(); Assert.IsTrue(t1Rotated.isEqualOrRotation(t1RotatedDiffOrdering)); }
public void PlayerEliminatedOtherPlayersDrawRefilledDeck() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t2 = test.makeTile(0, 7, 2, 3, 4, 5, 6, 1); Tile t3 = test.makeTile(0, 3, 2, 1, 4, 5, 6, 7); List <Tile> hand = test.makeHand(t2, t3); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = new SPlayer(null, hand, new RandomPlayer()); SPlayer p2 = new SPlayer(new RandomPlayer()); SPlayer p3 = new SPlayer(new RandomPlayer()); p1.initialize("blue", new List <string> { "blue", "green", "hotpink" }); p2.initialize("green", new List <string> { "blue", "green", "hotpink" }); p3.initialize("hotpink", new List <string> { "blue", "green", "hotpink" }); test.setStartPos00(board, p1); test.setStartPos(board, p2, new Posn(3, 3, 3)); test.setStartPos(board, p3, new Posn(4, 3, 3)); admin.addToActivePlayers(p1); admin.addToActivePlayers(p2); admin.addToActivePlayers(p3); admin.setDragonTileHolder(p2); Assert.AreEqual(0, admin.getDrawPileSize()); TurnResult tr = admin.playATurn(board, t1); // Green and hotpink both drew a tile // Green has t2 // Hot pink has t3 // No dragon tile holder Assert.AreEqual(2, admin.numActive()); SPlayer greenPlayer = admin.getFirstActivePlayer(); Assert.AreEqual("green", greenPlayer.getColor()); Assert.IsTrue(admin.isActivePlayer("hotpink")); Assert.AreEqual(1, greenPlayer.getHand().Count); Assert.AreEqual(1, p3.getHand().Count); Assert.IsTrue(greenPlayer.getHand().Exists(x => x.isEqualOrRotation(t2))); Assert.IsTrue(p3.getHand().Exists(x => x.isEqualOrRotation(t3))); Assert.IsTrue(admin.isDragonHolder("green")); }
public void GetSymmetricityFourSym() { TestScenerios test = new TestScenerios(); Tile fourSymTile = test.makeTile(0, 6, 1, 2, 3, 4, 5, 7); Tile fourSymTileUnmodified = test.makeTile(0, 6, 1, 2, 3, 4, 5, 7); Assert.AreEqual(4, fourSymTile.lazyGetSymmetricity()); // Check original tile was not rotated Assert.IsTrue(fourSymTileUnmodified.isEqual(fourSymTile)); }
public void PlaceTileInTheMiddleOfBoardLeadsPlayerToEdge() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 5, 3, 7, 4, 6); Tile t2 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); SPlayer p1 = new SPlayer("blue", new List <Tile>()); Board b = new Board(); p1.setPosn(new Posn(0, 1, 3)); b.grid[0, 1] = t1; Assert.IsFalse(b.isNotEliminationMove(p1, t2)); }
public void PlaceTileInTheMiddleOfBoardLeadsPlayerToEdge() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 5, 3, 7, 4, 6); Tile t2 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Board b = new Board(); b.placeTileAt(t1, 0, 1); b.addPlayerToBoard("blue", new Posn(0, 1, 3)); Assert.IsTrue(b.isEliminationMove("blue", t2)); }
public void XMLBoardToGrid() { XElement boardXML = XElement.Parse("<board>" + "<map>" + "<ent><xy><x>0</x><y>0</y></xy>" + "<tile>" + "<connect><n>0</n><n>4</n></connect>" + "<connect><n>1</n><n>5</n></connect>" + "<connect><n>2</n><n>7</n></connect>" + "<connect><n>3</n><n>6</n></connect>" + "</tile>" + "</ent>" + "<ent><xy><x>5</x><y>3</y></xy>" + "<tile>" + "<connect><n>0</n><n>1</n></connect>" + "<connect><n>2</n><n>6</n></connect>" + "<connect><n>3</n><n>7</n></connect>" + "<connect><n>4</n><n>5</n></connect>" + "</tile>" + "</ent>" + "</map>" + "<map>" + "<ent><color>red</color><pawn-loc><h></h><n>0</n><n>0</n></pawn-loc>" + "</ent></map></board>"); Tile[,] actualBoardGrid = XMLDecoder.xmlBoardToGrid(boardXML); Tile[,] expectedBoardGrid = new Tile[6, 6]; TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 4, 1, 5, 2, 7, 3, 6); Tile t2 = test.makeTile(0, 1, 2, 6, 3, 7, 4, 5); expectedBoardGrid[0, 0] = t1; expectedBoardGrid[3, 5] = t2; // Check boards are the same for (int i = 0; i < expectedBoardGrid.GetLength(0); i++) { for (int j = 0; j < expectedBoardGrid.GetLength(0); j++) { if (expectedBoardGrid[i, j] == null) { Assert.IsNull(actualBoardGrid[i, j]); } else { Assert.IsTrue(expectedBoardGrid[i, j].isEqual(actualBoardGrid[i, j])); } } } }
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 SPlayerPlayTurnChoosesValidMoveAndRemovesTileFromHand() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(4, 3, 5, 2, 6, 7, 0, 1); Tile t2 = test.makeTile(4, 3, 5, 7, 6, 1, 0, 2); Tile t3 = test.makeTile(4, 5, 6, 0, 7, 1, 2, 3); List <Tile> hand = test.makeHand(t1, t2, t3); Admin a = new Admin(); Board b = new Board(); SPlayer player1 = new SPlayer("blue", hand); player1.setPosn(new Posn(1, 0, 0)); }
public void TileInHandNotRotated() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); List <Tile> hand = test.makeHand(t1, t2, t3); Admin a = new Admin(); Board b = new Board(); SPlayer player1 = new SPlayer("blue", hand); Assert.IsTrue(player1.tileInHand(t1)); }
public void TestLocationEndMethod() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Assert.AreEqual(t1.getLocationEnd(0), 1); }
public void RotatedTileIsEqualToOriginalTile() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Assert.IsTrue(t1.isEqualOrRotation(t1.rotate())); }