コード例 #1
0
ファイル: Test_Player.cs プロジェクト: GuidoBekkers/STVRogue
        public void Test_PlayerUse()
        {
            // Instance the player object
            Player p = new Player("pId", "Player", 2, 1);

            // Instance a rage potion
            RagePotion ragePotion = new RagePotion("rPotionId");

            // Instance a healing potion
            HealingPotion healingPotion = new HealingPotion("hPotionId", 1);

            // Add the items to the player's bag
            p.Bag.Add(ragePotion);
            p.Bag.Add(healingPotion);

            // Test the rage potion use
            p.Use(ragePotion);

            // Check if the player became enraged
            Assert.IsTrue(p.Enraged);

            // Set the player's health to 1
            p.Hp = 1;

            // Test the healing potion use
            p.Use(healingPotion);

            // Check if the player was healed and that the max health was not exceeded
            Assert.IsTrue(p.Hp == 2 && p.Hp <= p.HpMax);
        }
コード例 #2
0
ファイル: Test_Item.cs プロジェクト: GuidoBekkers/STVRogue
        public void Test_RagePotion_Use()
        {
            // Create an exception variable, for debugging
            Exception exc = null;

            // Create the rage potion
            RagePotion rPotion = new RagePotion("potionId");

            // Create the player
            Player player = new Player("playerId", "playerName", 1, 1);

            // Add the potion to the players' bag
            player.Bag.Add(rPotion);

            // Try using the potion
            try
            {
                rPotion.Use(player);
            }
            catch (Exception e)
            {
                exc = e;
            }

            // Post-Conditions
            // Check if the player became enraged
            Assert.IsTrue(player.Enraged);
        }
コード例 #3
0
        public void Test_Game_UseItem_RagePotion_EliteFlee()
        {
            // Initialize the valid GameConfiguration
            GameConfiguration gameConfiguration = new GameConfiguration
            {
                numberOfRooms              = 3,
                maxRoomCapacity            = 5,
                dungeonShape               = DungeonShapeType.LINEARshape,
                initialNumberOfMonsters    = 1,
                initialNumberOfHealingPots = 1,
                initialNumberOfRagePots    = 1,
                difficultyMode             = DifficultyMode.ELITEmode
            };

            // Initialize the game
            Game g = new Game(gameConfiguration);

            // Move the player to a room adjacent to the exit room
            g.Player.Location = g.Dungeon.ExitRoom.Neighbors.First();

            // Initialize the potion
            RagePotion potion = new RagePotion("rId");

            // Add the potion to the player's bag
            g.Player.Bag.Add(potion);

            // Store the current healUsed
            int rageUsedOld = g.RageUsed;

            // Up the turn number
            g.TurnNumber = 5;

            // Use the rage potion
            g.UseItem(potion);

            // Check if the rageUsed is updated
            Assert.IsTrue(g.RageUsed != rageUsedOld && g.RageUsed == g.TurnNumber);

            // Check if the rage potion was used
            Assert.IsTrue(g.Player.Enraged);

            // Check if the EliteFlee bool was updated
            Assert.IsFalse(g.Player.EliteFlee);
        }
コード例 #4
0
ファイル: Test_Player.cs プロジェクト: GuidoBekkers/STVRogue
        public void Test_PlayerUse_NotInBag()
        {
            // Instance the player object
            Player p = new Player("pId", "Player", 2, 1);

            p.Hp = 1;

            // Instance a rage potion
            RagePotion ragePotion = new RagePotion("rPotionId");

            // Instance a healing potion
            HealingPotion healingPotion = new HealingPotion("hPotionId", 1);

            // Check that the correct exception is thrown because the item is not in the player's bag
            Assert.Throws <ArgumentException>(() => p.Use(ragePotion));
            Assert.Throws <ArgumentException>(() => p.Use(healingPotion));

            // Check that the player's stats have remained the same
            Assert.IsTrue(!p.Enraged);
            Assert.IsTrue(p.Hp == 1);
        }
コード例 #5
0
ファイル: Test_Item.cs プロジェクト: GuidoBekkers/STVRogue
        public void Test_RagePotion_Constructor()
        {
            // Define the rage potion variables
            RagePotion rPotion = null;

            // Create an exception variable, for debugging
            Exception exc = null;

            // Try creating the healing potion
            try
            {
                rPotion = new RagePotion("id");
            }
            catch (Exception e)
            {
                exc = e;
            }

            // Post-Condition
            // Check if the potion was actually made
            Assert.IsTrue(rPotion != null);
        }
コード例 #6
0
        public void Test_Game_UseItem_RagePotion()
        {
            // Initialize the valid GameConfiguration
            GameConfiguration gameConfiguration = new GameConfiguration
            {
                numberOfRooms              = 3,
                maxRoomCapacity            = 5,
                dungeonShape               = DungeonShapeType.LINEARshape,
                initialNumberOfMonsters    = 1,
                initialNumberOfHealingPots = 1,
                initialNumberOfRagePots    = 1,
                difficultyMode             = DifficultyMode.NORMALmode
            };

            // Initialize the game
            Game g = new Game(gameConfiguration);

            // Initialize the potion
            RagePotion potion = new RagePotion("rId");

            // Add the potion to the player's bag
            g.Player.Bag.Add(potion);

            // Store the current healUsed
            int rageUsedOld = g.RageUsed;

            // Up the turn number
            g.TurnNumber = 5;

            // Use the rage potion
            g.UseItem(potion);

            // Check if the rageUsed is updated
            Assert.IsTrue(g.RageUsed != rageUsedOld && g.RageUsed == g.TurnNumber);

            // Check if the rage potion was used
            Assert.IsTrue(g.Player.Enraged);
        }