예제 #1
0
        /// <summary>
        /// Swap the Item the character has for one from the pool
        ///
        /// Drop the current item back into the Pool
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="setLocation"></param>
        /// <param name="PoolItem"></param>
        /// <returns></returns>
        private ItemModel SwapCharacterItem(EntityInfoModel character, ItemLocationEnum setLocation, ItemModel PoolItem)
        {
            // Put on the new ItemModel, which drops the one back to the pool
            var droppedItem = character.AddItem(setLocation, PoolItem.Id);

            // Add the PoolItem to the list of selected items
            BattleScore.ItemModelSelectList.Add(PoolItem);

            // Remove the ItemModel just put on from the pool
            ItemPool.Remove(PoolItem);

            if (droppedItem != null)
            {
                // Add the dropped ItemModel to the pool
                ItemPool.Add(droppedItem);
            }

            return(droppedItem);
        }
예제 #2
0
        public void HackathonScenario_Scenario_14_If_Confusion_Turn_Character_Should_Skip()
        {
            /*
             * Scenario Number:
             *  14
             *
             * Description:
             *      Confusion, have % chance to occuring each round.
             *      If happens, then confusion occurs for each monster and character for that round
             *      Each party member rolls a chance of being confused.
             *
             * Changes Required (Classes, Methods etc.)  List Files, Methods, and Describe Changes:
             *      Change to Turn Engine, Take Turn method, added switch check and dice roll
             *      Changed BaseEngine, added boolean switch for enabling confusion, and is confusion turn or not.
             *      Check for Experience gained is 0
             *
             * Test Algrorithm:
             *  Create Character named Bob
             *  Create Monster
             *  Call TakeTurn
             *
             * Test Conditions:
             *  Test with Character of Named ConfusionCharacter
             *
             * Validation:
             *      Verify Experience gained is 0
             *
             */

            //Arrange
            DiceHelper.EnableForcedRolls();
            DiceHelper.SetForcedRollValue(0);
            // Set Character Conditions

            BattleEngine.MaxNumberPartyCharacters = 1;
            var TestSword       = ItemViewModel.Dataset.Where(a => a.Location == ItemLocationEnum.PrimaryHand).FirstOrDefault();
            var CharacterPlayer = new EntityInfoModel(
                new CharacterModel
            {
                Level         = 10,
                CurrentHealth = 200,
                MaxHealth     = 200,
                //TestDamage = 123,
                Experience = 100,
                Name       = "Confused Character",
            });

            CharacterPlayer.Attack  = 25;
            CharacterPlayer.Speed   = 20;
            CharacterPlayer.Defense = 25;
            CharacterPlayer.AddItem(ItemLocationEnum.PrimaryHand, TestSword.Id);
            BattleEngine.CharacterList.Add(CharacterPlayer);

            // Set Monster Conditions

            // Add a monster to attack
            BattleEngine.MaxNumberPartyCharacters = 1;

            var MonsterPlayer = new EntityInfoModel(
                new MonsterModel
            {
                Speed         = 10,
                Level         = 10,
                CurrentHealth = 100,
                Experience    = 100,
                Name          = "Monster",
            });

            BattleEngine.CharacterList.Add(MonsterPlayer);

            // Have dice roll to 20
            DiceHelper.EnableForcedRolls();
            DiceHelper.SetForcedRollValue(20);

            // EnableConfusionRounds
            BattleEngine.EnableConfusionRound = true;
            BattleEngine.NewRound();

            //Act
            var result = BattleEngine.TakeTurn(CharacterPlayer);

            //Reset
            DiceHelper.DisableForcedRolls();
            BattleEngine.EnableConfusionRound = false;

            //Assert
            Assert.AreEqual(true, result);
            Assert.AreEqual(AutoBattleEngine.BattleScore.ExperienceGainedTotal, 0);
        }