Exemple #1
0
        public void BattleEngine_AutoBattle_With_Characters_Level_2_Should_Level_Up_Pass()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Turn off random numbers
            // For a hit on everything...
            GameGlobals.SetForcedRandomNumbers(1, 20);  // Needs to be 20 so monsters always score a hit...

            MasterDataStore.ForceDataRestoreAll();

            // Add new Characters in automaticaly
            // Characters are Level 2
            // Monsters are Level 1
            // Characters have weapons...
            // Use 6 existing Characters.  This will go for a few rounds.
            var myLevel     = 3;
            var myCharacter = myBattleEngine.GetRandomCharacter(myLevel, myLevel);

            myCharacter.Attribute.MaxHealth     = 100;
            myCharacter.Attribute.CurrentHealth = 100;

            // Set them just below the next level, so they level up...
            myCharacter.ExperienceTotal = LevelTable.Instance.LevelDetailsList[myLevel + 1].Experience - 1;

            for (var count = 1; count < 7; count++)
            {
                var myNewCharacter = new Character(myCharacter);
                myNewCharacter.Name = "Fighter " + count;
                myBattleEngine.CharacterList.Add(myNewCharacter);
            }

            var TempDamageBonusValue = GameGlobals.ForceCharacterDamangeBonusValue;

            // Make myCharacter s hit really really hard...
            GameGlobals.ForceCharacterDamangeBonusValue = 100;

            myBattleEngine.AutoBattle();

            // Reset
            GameGlobals.ToggleRandomState();
            GameGlobals.ForceCharacterDamangeBonusValue = TempDamageBonusValue;

            var Actual = myBattleEngine.BattleScore;

            Assert.AreNotEqual(1, Actual.RoundCount, "Round Count " + TestContext.CurrentContext.Test.Name);

            Assert.AreNotEqual(null, Actual, "Score Object " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ExperienceGainedTotal, "Experience " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.TurnCount, "Turn Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ScoreTotal, "Score Total " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.ItemsDroppedList, "Items Dropped " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.MonstersKilledList, "Monsters Killed " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.CharacterAtDeathList, "Character List " + TestContext.CurrentContext.Test.Name);
        }