Esempio n. 1
0
        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("elim1", new List <Tile>());

            elim1.setPosn(new Posn(0, 0, 2));
            elim1.playerState = SPlayer.State.Playing;
            SPlayer elim2 = new SPlayer("elim2", new List <Tile>());

            elim2.setPosn(new Posn(0, 0, 3));
            elim2.playerState = SPlayer.State.Playing;
            //player left over
            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(elim2);

            TurnResult tr         = a.playATurn(b, t1);
            Posn       playerPosn = tr.currentPlayers[0].getPlayerPosn();

            Assert.AreEqual(playerPosn.returnLocationOnTile(), 3, "Remaining player not at location 3 on tile");
            Assert.IsTrue(playerPosn.returnCol() == 1);
            Assert.IsTrue(playerPosn.returnRow() == 1);
            Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.returnColor() == "elim1"), "eliminated player is in eliminated list");
            Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.returnColor() == "elim2"), "eliminated player is in eliminated list");

            Assert.IsNotNull(tr.playResult);
            Assert.IsTrue(tr.playResult.Exists(x => x.returnColor() == "p1"), "p1 not in the winning list of players");
            Assert.AreEqual(tr.playResult.Count, 1);
        }
Esempio n. 2
0
        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);
        }