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 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 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 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 PlayAValidTurnRemovesTileFromDrawPile() { 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); b.addPlayerToBoard(p1.getColor(), p1Pos); SPlayer p2 = new SPlayer("hotpink", new List <Tile>()); Posn p2Pos = new Posn(4, 4, 0); b.addPlayerToBoard(p2.getColor(), p2Pos); a.addToActivePlayers(p1); a.addToActivePlayers(p2); List <SPlayer> l1 = new List <SPlayer>() { p1, p2 }; List <SPlayer> l2 = new List <SPlayer>(); TurnResult tmpturn = a.playATurn(b, t1); Assert.AreEqual(1, tmpturn.drawPile.Count); Assert.IsFalse(tmpturn.drawPile.Exists(x => x.isEqualOrRotation(t2))); List <Tile> hand = tmpturn.currentPlayers[1].getHand(); Assert.IsTrue(hand.Exists(x => x.isEqualOrRotation(t2))); }
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)); }
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 = test.createAdminWithDrawPile(new List <Tile> { }); Board b = new Board(); SPlayer player1 = new SPlayer("blue", hand, new RandomPlayer()); player1.initialize("blue", new List <string> { "blue" }); test.setStartPos(b, player1, new Posn(1, 0, 0)); a.addToActivePlayers(player1); Tile t = player1.playTurn(b, a.getDrawPileSize()); Assert.IsTrue(!b.isEliminationMove("blue", t)); Assert.IsFalse(player1.getHand().Contains(t)); }