Ejemplo n.º 1
0
        public void TestWarningMessages()
        {
            GameLocations gameLocations = new GameLocations(1, new Random(1));

            //Move to every hazard in the cave and the wumpus, move one room off, and make sure the warning message contains what it should
            for (int i = 1; i < 6; i++)
            {
                gameLocations.Teleport(gameLocations.GetLocationInfo()[i]);
                gameLocations.ChangePlayerLocation(gameLocations.GetPlayerRoomInfo().TunnelLocations()[0]);
                if (i == 1)
                {
                    Assert.IsTrue(gameLocations.GetWarningMessages().Contains("I smell a wumpus"));
                    Debug.WriteLine(1);
                }
                else
                {
                    if (i <= 3 && i >= 2)
                    {
                        Assert.IsTrue(gameLocations.GetWarningMessages().Contains("Bats Nearby"));
                    }
                    else
                    {
                        Assert.IsTrue(gameLocations.GetWarningMessages().Contains("I feel a draft"));
                        Debug.WriteLine(1);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TestShootArrow()
        {
            GameLocations gameLocations = new GameLocations(1, new Random());

            //Move to a room adjacent to the wumpus and machine-gun a non-wumpus room until it moves
            gameLocations.Teleport(gameLocations.GetLocationInfo()[1]);
            int oldWumpusRoom = gameLocations.GetLocationInfo()[1];

            gameLocations.ChangePlayerLocation(gameLocations.GetPlayerRoomInfo().TunnelLocations()[0]);
            for (int k = 0; k < gameLocations.GetPlayerRoomInfo().ToRoomLocations().Length; k++)
            {
                if (gameLocations.GetPlayerRoomInfo().ToRoomLocations()[k] - 1 != gameLocations.GetLocationInfo()[1])
                {
                    while (oldWumpusRoom == gameLocations.GetLocationInfo()[1])
                    {
                        gameLocations.ShootArrow(gameLocations.GetPlayerRoomInfo().TunnelLocations()[k]);
                    }
                    k = gameLocations.GetPlayerRoomInfo().ToRoomLocations().Length;
                    Assert.AreNotEqual(oldWumpusRoom, gameLocations.GetLocationInfo()[1]);
                }
            }
            //Machine-gun the wumpus and make sure it dosen't move
            gameLocations.Teleport(gameLocations.GetLocationInfo()[1]);
            oldWumpusRoom = gameLocations.GetLocationInfo()[1];
            gameLocations.ChangePlayerLocation(gameLocations.GetPlayerRoomInfo().GetTunnelInfo(gameLocations.GetPlayerRoomInfo().TunnelLocations()[0]).GetDirection());
            for (int k = 0; k < gameLocations.GetPlayerRoomInfo().ToRoomLocations().Length; k++)
            {
                if (gameLocations.GetPlayerRoomInfo().ToRoomLocations()[k] - 1 == gameLocations.GetLocationInfo()[1])
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        gameLocations.ShootArrow(gameLocations.GetPlayerRoomInfo().TunnelLocations()[k]);
                    }
                    k = gameLocations.GetPlayerRoomInfo().ToRoomLocations().Length;
                    Assert.AreEqual(oldWumpusRoom, gameLocations.GetLocationInfo()[1]);
                }
            }
        }
Ejemplo n.º 3
0
        public void TestMovement()
        {
            GameLocations gameLocations = new GameLocations(1, new Random());

            //In every room, try to walk through every direction, and make sure it leads to the right place
            for (int i = 0; i < 30; i++)
            {
                gameLocations.Teleport(i);
                for (int j = 0; j < 5; j++)
                {
                    int expected = expected = gameLocations.GetLocationInfo()[0];
                    for (int k = 0; k < gameLocations.GetPlayerRoomInfo().TunnelLocations().Length; k++)
                    {
                        if (gameLocations.GetPlayerRoomInfo().TunnelLocations()[k] == j)
                        {
                            expected = gameLocations.GetPlayerRoomInfo().GetTunnelInfo(j).GetToRoom() - 1;
                        }
                    }
                    gameLocations.ChangePlayerLocation(j);
                    Assert.AreEqual(expected, gameLocations.GetLocationInfo()[0]);
                    gameLocations.Teleport(i);
                }
            }
        }