Inheritance: Player
Ejemplo n.º 1
0
        public void winLossTest()
        {
            Node[] nodes     = constructBasicBoard();
            Player mrX       = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);
            Dictionary <int, Player> players = new Dictionary <int, Player>();

            players.Add(mrX.getId(), mrX);
            players.Add(detective.getId(), detective);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            int dummyWinningPlayerId;

            Assert.False(GameLogic.checkWin(players, out dummyWinningPlayerId));

            detective.move(nodes[0], TransportType.taxi);

            int  firstWinningPlayerId;
            bool gameWon = GameLogic.checkWin(players, out firstWinningPlayerId);

            Assert.True(gameWon);
            Assert.AreEqual(1, firstWinningPlayerId);

            for (int i = 1; i < 10; i++)
            {
                detective.move(nodes[4], TransportType.taxi);
            }

            int secondWinningPlayerId;

            gameWon = GameLogic.checkWin(players, out secondWinningPlayerId);

            Assert.True(gameWon);
            Assert.AreEqual(0, secondWinningPlayerId);

            for (int i = 0; i < 8; i++)
            {
                detective.move(nodes[3], TransportType.bus);
            }
            for (int i = 0; i < 4; i++)
            {
                detective.move(nodes[3], TransportType.underground);
            }

            int thirdWinningPlayerId;

            gameWon = GameLogic.checkWin(players, out thirdWinningPlayerId);
            Assert.True(gameWon);
            Assert.AreEqual(0, thirdWinningPlayerId);
        }
Ejemplo n.º 2
0
        public void basicGameLogicTest()
        {
            Node[] nodes = constructBasicBoard();
            Player mrX = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            Assert.True(GameLogic.canMove(mrX));
            Assert.True(GameLogic.canMove(detective));

            mrX.move(nodes[3], TransportType.taxi);
            mrX.move(nodes[0], TransportType.taxi);
            mrX.move(nodes[3], TransportType.taxi);
            mrX.move(nodes[0], TransportType.taxi);
            mrX.move(nodes[2], TransportType.underground);
            mrX.move(nodes[0], TransportType.underground);
            mrX.move(nodes[2], TransportType.underground);
            mrX.move(nodes[0], TransportType.blackCard);
            mrX.move(nodes[1], TransportType.blackCard);
            mrX.move(nodes[0], TransportType.bus);
            mrX.move(nodes[1], TransportType.bus);
            mrX.move(nodes[0], TransportType.bus);

            Assert.False(GameLogic.canMove(mrX));

            Player blockade1 = new Detective("Blockade 1", 2);
            Player blockade2 = new Detective("Blockade 2", 3);
            Player blockade3 = new Detective("Blockade 3", 4);

            blockade1.setLocation(nodes[1]);
            blockade2.setLocation(nodes[2]);
            blockade3.setLocation(nodes[3]);

            Assert.True(GameLogic.canMove(detective));
        }
Ejemplo n.º 3
0
        public void basicGameLogicTest()
        {
            Node[] nodes     = constructBasicBoard();
            Player mrX       = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            Assert.True(GameLogic.canMove(mrX));
            Assert.True(GameLogic.canMove(detective));

            mrX.move(nodes[3], TransportType.taxi);
            mrX.move(nodes[0], TransportType.taxi);
            mrX.move(nodes[3], TransportType.taxi);
            mrX.move(nodes[0], TransportType.taxi);
            mrX.move(nodes[2], TransportType.underground);
            mrX.move(nodes[0], TransportType.underground);
            mrX.move(nodes[2], TransportType.underground);
            mrX.move(nodes[0], TransportType.blackCard);
            mrX.move(nodes[1], TransportType.blackCard);
            mrX.move(nodes[0], TransportType.bus);
            mrX.move(nodes[1], TransportType.bus);
            mrX.move(nodes[0], TransportType.bus);

            Assert.False(GameLogic.canMove(mrX));

            Player blockade1 = new Detective("Blockade 1", 2);
            Player blockade2 = new Detective("Blockade 2", 3);
            Player blockade3 = new Detective("Blockade 3", 4);

            blockade1.setLocation(nodes[1]);
            blockade2.setLocation(nodes[2]);
            blockade3.setLocation(nodes[3]);

            Assert.True(GameLogic.canMove(detective));
        }
Ejemplo n.º 4
0
        public void playerTest()
        {
            Node[] nodes     = constructBasicBoard();
            Player mrX       = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            Assert.AreEqual(nodes[0], mrX.getLocation());
            Assert.AreEqual(nodes[4], detective.getLocation());

            Assert.AreEqual(4, mrX.getTickets(TransportType.taxi));
            Assert.AreEqual(3, mrX.getTickets(TransportType.bus));
            Assert.AreEqual(3, mrX.getTickets(TransportType.underground));
            Assert.AreEqual(2, mrX.getTickets(TransportType.blackCard));

            Assert.AreEqual(10, detective.getTickets(TransportType.taxi));
            Assert.AreEqual(8, detective.getTickets(TransportType.bus));
            Assert.AreEqual(4, detective.getTickets(TransportType.underground));

            detective.move(nodes[2], TransportType.taxi);
            Assert.AreEqual(nodes[2], detective.getLocation());
            Assert.AreEqual(9, detective.getTickets(TransportType.taxi));

            detective.move(nodes[3], TransportType.underground);
            Assert.AreEqual(nodes[3], detective.getLocation());
            Assert.AreEqual(3, detective.getTickets(TransportType.underground));

            detective.move(nodes[1], TransportType.bus);
            Assert.AreEqual(nodes[1], detective.getLocation());
            Assert.AreEqual(7, detective.getTickets(TransportType.bus));

            mrX.move(nodes[4], TransportType.blackCard);
            Assert.AreEqual(nodes[4], mrX.getLocation());
            Assert.AreEqual(1, mrX.getTickets(TransportType.blackCard));
        }
Ejemplo n.º 5
0
        public void winLossTest()
        {
            Node[] nodes = constructBasicBoard();
            Player mrX = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);
            Dictionary<int, Player> players = new Dictionary<int, Player>();
            players.Add(mrX.getId(), mrX);
            players.Add(detective.getId(), detective);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            int dummyWinningPlayerId;
            Assert.False(GameLogic.checkWin(players, out dummyWinningPlayerId));

            detective.move(nodes[0], TransportType.taxi);

            int firstWinningPlayerId;
            bool gameWon = GameLogic.checkWin (players, out  firstWinningPlayerId);

            Assert.True(gameWon);
            Assert.AreEqual(1, firstWinningPlayerId);

            for(int i = 1; i < 10; i++){
                detective.move(nodes[4], TransportType.taxi);
            }

            int secondWinningPlayerId;
            gameWon = GameLogic.checkWin (players, out secondWinningPlayerId);

            Assert.True(gameWon);
            Assert.AreEqual(0, secondWinningPlayerId);

            for(int i = 0; i < 8; i++){
                detective.move(nodes[3], TransportType.bus);
            }
            for(int i = 0; i < 4; i++){
                detective.move(nodes[3], TransportType.underground);
            }

            int thirdWinningPlayerId;
            gameWon = GameLogic.checkWin (players, out thirdWinningPlayerId);
            Assert.True(gameWon);
            Assert.AreEqual(0, thirdWinningPlayerId);
        }
Ejemplo n.º 6
0
        public void playerTest()
        {
            Node[] nodes = constructBasicBoard();
            Player mrX = new MrX("Mr. X", 0);
            Player detective = new Detective("Detective", 1);

            mrX.setLocation(nodes[0]);
            detective.setLocation(nodes[4]);

            Assert.AreEqual(nodes[0], mrX.getLocation());
            Assert.AreEqual(nodes[4], detective.getLocation());

            Assert.AreEqual(4, mrX.getTickets(TransportType.taxi));
            Assert.AreEqual(3, mrX.getTickets(TransportType.bus));
            Assert.AreEqual(3, mrX.getTickets(TransportType.underground));
            Assert.AreEqual(2, mrX.getTickets(TransportType.blackCard));

            Assert.AreEqual(10, detective.getTickets(TransportType.taxi));
            Assert.AreEqual(8, detective.getTickets(TransportType.bus));
            Assert.AreEqual(4, detective.getTickets(TransportType.underground));

            detective.move(nodes[2], TransportType.taxi);
            Assert.AreEqual(nodes[2], detective.getLocation());
            Assert.AreEqual(9, detective.getTickets(TransportType.taxi));

            detective.move(nodes[3], TransportType.underground);
            Assert.AreEqual(nodes[3], detective.getLocation());
            Assert.AreEqual(3, detective.getTickets(TransportType.underground));

            detective.move(nodes[1], TransportType.bus);
            Assert.AreEqual(nodes[1], detective.getLocation());
            Assert.AreEqual(7, detective.getTickets(TransportType.bus));

            mrX.move(nodes[4], TransportType.blackCard);
            Assert.AreEqual(nodes[4], mrX.getLocation());
            Assert.AreEqual(1, mrX.getTickets(TransportType.blackCard));
        }