public void DragonHolderEliminatedPassestoNextClockwisePlayer() { Admin a = new Admin(); Board board = new Board(); SPlayer p1 = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); SPlayer p2 = new SPlayer("green", new List <Tile>(), new RandomPlayer()); SPlayer p3 = new SPlayer("hotpink", new List <Tile>(), new RandomPlayer()); // Initialize start positions to satisfy contract - can't be // eliminated before placing pawn TestScenerios test = new TestScenerios(); test.setStartPos00(board, p1); test.setStartPos(board, p2, new Posn(3, 3, 3)); test.setStartPos(board, p3, new Posn(4, 3, 3)); a.addToActivePlayers(p1); a.addToActivePlayers(p2); a.addToActivePlayers(p3); a.setDragonTileHolder(p2); a.eliminatePlayer(p2.getColor()); Assert.IsTrue(a.isDragonHolder("hotpink")); Assert.IsTrue(p3.getHand().Count < 3); }
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 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 PlayerHasRotatedVersionOfSameTileInHand() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(t1, t1.rotate()); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void LeastSymPlayerChoosesLeastSymTile() { 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); Board b = new Board(); SPlayer lsp1 = new SPlayer("blue", playerTiles, new LeastSymmetricPlayer()); lsp1.initialize(b); test.setStartPos00(b, lsp1); //playturn should return the least symmetric tile Assert.IsTrue(lsp1.playTurn(b, 0).isEqual(leastSymTile)); }
public void PlayerHasTooManyTilesInHand() { 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); Tile extraTile = test.makeTile(0, 4, 1, 7, 2, 6, 3, 5); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(mostSymTile, medSymTile, leastSymTile, extraTile); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void PlayerHandAlreadyOnBoard() { 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); Admin a = new Admin(); Board b = new Board(); b.grid[1, 1] = mostSymTile; SPlayer p1 = new SPlayer("blue", test.makeHand(mostSymTile, medSymTile), new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void PlayerHasTooManyTilesInHand() { 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); Tile extraTile = test.makeTile(0, 4, 1, 7, 2, 6, 3, 5); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(mostSymTile, medSymTile, leastSymTile, extraTile); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize("blue", new List <string> { "blue" }); test.setStartPos00(b, p1); Assert.IsTrue(a.isCheating(p1, b, mostSymTile)); }
public void RandomPlayerChoosesTileWhenAllMovesAreValidAndRemovesTileFromHand() { 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> playerHand = test.makeHand(t1, t2, t3); Board b = new Board(); SPlayer p1 = new SPlayer("blue", playerHand, new RandomPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.setPosn(new Posn(2, 2, 2)); Tile t = p1.playTurn(b, 0); Assert.AreEqual(2, p1.returnHand().Count); Assert.IsFalse(p1.returnHand().Exists(x => x.isEqual(t))); }
public void MostSymPlayerChoosesOneOfMostSymTile() { TestScenerios test = new TestScenerios(); Tile mostSymTile1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile mostSymTile2 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, mostSymTile1, mostSymTile2); SPlayer p1 = new SPlayer("blue", playerTiles, new MostSymmetricPlayer()); Board b = new Board(); p1.initialize(b); test.setStartPos00(b, p1); p1.setPosn(new Posn(2, 2, 2)); Tile checkTile = p1.playTurn(b, 0); //playturn should return the most symmetric tile Assert.IsTrue(checkTile.isEqual(mostSymTile1)); }
public void LeastSymPlayerChoosesFirstTileIfAllTilesAreSameSym() { TestScenerios test = new TestScenerios(); //the least symmetric tile is not valid unless rotated once //so the player will rotate the least symmetric tile and play that move Tile leastSymTile1 = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); Tile leastSymTile2 = test.makeTile(0, 3, 1, 4, 2, 7, 5, 6); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, leastSymTile1, leastSymTile2); Board b = new Board(); SPlayer lsp1 = new SPlayer("blue", playerTiles, new LeastSymmetricPlayer()); lsp1.initialize(b); test.setStartPos00(b, lsp1); //playturn should return the least symmetric tile Assert.IsTrue(lsp1.playTurn(b, 0).isEqual(leastSymTile1)); }
public void PlayerHasRotatedVersionOfSameTileInHand() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(t1, t1.rotate()); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize("blue", new List <string> { "blue" }); test.setStartPos00(b, p1); a.addToActivePlayers(p1); Tile t = p1.playTurn(b, a.getDrawPileSize()); Assert.IsTrue(a.isCheating(p1, b, t)); }
public void PlayerHandAlreadyOnBoard() { 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); Admin a = test.createAdminWithDrawPile(new List <Tile> { }); Board b = new Board(); b.placeTileAt(mostSymTile, 1, 1); SPlayer p1 = new SPlayer("blue", test.makeHand(mostSymTile, medSymTile), new MostSymmetricPlayer()); p1.initialize("blue", new List <string> { "blue" }); test.setStartPos00(b, p1); Tile t = p1.playTurn(b, a.getDrawPileSize()); Assert.IsTrue(a.isCheating(p1, b, t)); }