Ejemplo n.º 1
0
        public void TestPlayerHasWon3()
        {
            Game game = new Game("world war 2", 2);
            Player p1 = new Player("jan", Player.playerColor.blue, null);
            Player p2 = new Player("nils", Player.playerColor.green, null);
            game.activePlayer = p1;

            for (int i = 0; i < 16; i++)
            {
                game.setTerritory(i, p1, 5);
            }
            game.setTerritory(10, p2, 5);

            Assert.IsFalse(game.checkIfActivePlayerIsHasWon());

            game.activePlayer = p2;
            Assert.IsFalse(game.checkIfActivePlayerIsHasWon());
        }
Ejemplo n.º 2
0
        public void TestPlayerControlContinent()
        {
            Game game = new Game("world war 2", 2);
            Player p1 = new Player("jan", Player.playerColor.blue, null);
            Player p2 = new Player("nils", Player.playerColor.green, null);

            // set all territories belonging to me
            for (int i = 0; i < 16; i++)
            {
                game.setTerritory(i, p1, 5);
            }

            Assert.IsTrue(game.checkIfPlayerControlContinent(p1, game.Continents[1]));
            Assert.IsTrue(game.checkIfPlayerControlContinent(p1, game.Continents[2]));

            Assert.IsFalse(game.checkIfPlayerControlContinent(p1, null));
            Assert.IsFalse(game.checkIfPlayerControlContinent(null, null));
            Assert.IsFalse(game.checkIfPlayerControlContinent(null, game.Continents[1]));
            Assert.IsFalse(game.checkIfPlayerControlContinent(p2, game.Continents[1]));
            Assert.IsFalse(game.checkIfPlayerControlContinent(p2, game.Continents[2]));
        }
Ejemplo n.º 3
0
        public void TestPlayerHasLost2()
        {
            Game game = new Game("world war 2", 4);
            Player p1 = new Player("jan", Player.playerColor.blue, null);
            Player p2 = new Player("nils", Player.playerColor.green, null);
            Player p3 = new Player("peter", Player.playerColor.green, null);
            Player p4 = new Player("arne", Player.playerColor.green, null);

            Assert.IsTrue(game.addPlayer(p1, true));
            Assert.IsTrue(game.addPlayer(p2, true));
            Assert.IsTrue(game.addPlayer(p3, true));
            Assert.IsTrue(game.addPlayer(p4, true));

            for (int i = 0; i < 16; i++)
            {
                game.setTerritory(i, p1, 5);
            }

            game.setTerritory(10, p3, 4);

            Assert.IsTrue(game.playerExist(p1.nickname).alive);
            Assert.IsTrue(game.playerExist(p2.nickname).alive);
            Assert.IsTrue(game.playerExist(p3.nickname).alive);
            Assert.IsTrue(game.playerExist(p4.nickname).alive);

            // p2 owns no territories and should be "dead"
            game.checkIfPlayerHasLost();

            Assert.IsTrue(game.playerExist(p1.nickname).alive);
            Assert.IsFalse(game.playerExist(p2.nickname).alive);
            Assert.IsTrue(game.playerExist(p3.nickname).alive);
            Assert.IsFalse(game.playerExist(p4.nickname).alive);
        }