Esempio n. 1
0
        public void MonsterStunnedEffectExpiresWhenCurrentRoundGreaterThanMaxRoundUnitTest()
        {
            Monster        monster        = new Monster(5, MonsterType.Skeleton);
            EffectSettings effectSettings = new EffectSettings {
                EffectHolder = monster,
                Name         = "stunned test",
                MaxRound     = 3
            };
            IEffect stunnedEffect = new StunnedEffect(effectSettings);

            for (int i = 0; i < stunnedEffect.MaxRound; i++)
            {
                stunnedEffect.ProcessRound();
            }

            Assert.AreEqual(4, stunnedEffect.CurrentRound);
            Assert.AreEqual(true, stunnedEffect.IsEffectExpired);
        }
Esempio n. 2
0
        public void MonsterStunnedEffectDoesNotExpireWhenCurrentRoundEqualsMaxRoundUnitTest()
        {
            Monster        monster        = new Monster(5, MonsterType.Skeleton);
            EffectSettings effectSettings = new EffectSettings {
                EffectHolder = monster,
                Name         = "stunned test",
                MaxRound     = 3
            };
            IEffect stunnedEffect = new StunnedEffect(effectSettings);

            for (int i = 0; i < effectSettings.MaxRound - 1; i++)
            {
                stunnedEffect.ProcessRound();
            }

            Assert.AreEqual(3, stunnedEffect.CurrentRound);
            Assert.AreEqual(false, stunnedEffect.IsEffectExpired);
        }
Esempio n. 3
0
        public void ExpiredBleedingEffectDoesNotAffectMonsterUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Monster        monster        = new Monster(5, MonsterType.Skeleton);
            EffectSettings effectSettings = new EffectSettings {
                EffectHolder = monster,
                Name         = "stunned test",
                MaxRound     = 3
            };
            IEffect stunnedEffect = new StunnedEffect(effectSettings)
            {
                IsEffectExpired = true
            };

            stunnedEffect.ProcessRound();

            Assert.AreEqual(0, OutputHelper.Display.Output.Count);
            Assert.AreEqual(1, stunnedEffect.CurrentRound);
        }
Esempio n. 4
0
        public void ProcessStunnedEffectRoundMonsterUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Monster        monster        = new Monster(5, MonsterType.Skeleton);
            EffectSettings effectSettings = new EffectSettings {
                EffectHolder = monster,
                Name         = "stunned test",
                MaxRound     = 3
            };
            IEffect stunnedEffect = new StunnedEffect(effectSettings);

            monster.Effects.Add(stunnedEffect);
            string stunnedMessage = $"The {monster.Name} is stunned and cannot attack.";

            stunnedEffect.ProcessRound();

            Assert.AreEqual(stunnedMessage, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(2, stunnedEffect.CurrentRound);
            Assert.AreEqual(false, stunnedEffect.IsEffectExpired);
        }
Esempio n. 5
0
        public void FrostNovaSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };

            player.Spellbook.Add(new PlayerSpell(
                                     "frost nova", 40, 1, SpellType.FrostNova, 8));
            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, FrostResistance = 0
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            int spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.FrostNova);

            string[] infoInput = new[] { "spell", "frost", "nova" };
            PlayerHelper.SpellInfo(player, infoInput);
            Assert.AreEqual("Frost Nova", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Mana Cost: 40", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual($"Frost damage will freeze opponent for {player.Spellbook[spellIndex].Offensive.AmountMaxRounds} rounds.",
                            OutputHelper.Display.Output[4][2]);
            Assert.AreEqual("Frozen opponents take 1.5x physical, arcane and frost damage.",
                            OutputHelper.Display.Output[5][2]);
            Assert.AreEqual($"Opponent will be stunned for {player.Spellbook[spellIndex].Offensive.AmountMaxRounds} rounds.",
                            OutputHelper.Display.Output[6][2]);
            string[] input     = new[] { "cast", "frost", "nova" };
            string   spellName = InputHelper.ParseInput(input);

            Assert.AreEqual("frost nova", spellName);
            player.PlayerWeapon.Durability = 100;
            double baseDamage = player.PhysicalAttack(monster);

            player.CastSpell(monster, spellName);
            string attackSuccessString = $"You hit the {monster.Name} for {player.Spellbook[spellIndex].Offensive.Amount} frost damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[7][2]);
            string frozenString = $"The {monster.Name} is frozen. Physical, frost and arcane damage to it will be increased by 50%!";

            Assert.AreEqual(frozenString, OutputHelper.Display.Output[8][2]);
            OutputHelper.Display.ClearUserOutput();
            Assert.AreEqual(player.ManaPoints, player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost);
            int frostIndex = monster.Effects.FindIndex(f => f is FrozenEffect);
            int stunIndex  = monster.Effects.FindIndex(f => f is StunnedEffect);

            Assert.AreEqual(85, monster.HitPoints);
            Assert.AreEqual(1, monster.Effects[frostIndex].CurrentRound);
            Assert.AreEqual(1, monster.Effects[stunIndex].CurrentRound);
            Assert.AreEqual(2, monster.Effects[frostIndex].MaxRound);
            Assert.AreEqual(2, monster.Effects[stunIndex].MaxRound);
            FrozenEffect  frozenEffect           = monster.Effects[frostIndex] as FrozenEffect;
            StunnedEffect stunnedEffect          = monster.Effects[stunIndex] as StunnedEffect;
            int           monsterHitPointsBefore = monster.HitPoints;
            double        totalBaseDamage        = 0.0;
            double        totalFrozenDamage      = 0.0;
            double        multiplier             = frozenEffect.EffectMultiplier;

            for (int i = 2; i < 4; i++)
            {
                OutputHelper.Display.ClearUserOutput();
                stunnedEffect.ProcessRound();
                frozenEffect.ProcessRound();
                string stunnedRoundString = $"The {monster.Name} is stunned and cannot attack.";
                Assert.AreEqual(stunnedRoundString, OutputHelper.Display.Output[0][2]);
                Assert.AreEqual(true, monster.IsStunned);
                Assert.AreEqual(i, monster.Effects[stunIndex].CurrentRound);
                player.PlayerWeapon.Durability = 100;
                double frozenDamage = player.PhysicalAttack(monster);
                Assert.AreEqual(i, monster.Effects[frostIndex].CurrentRound);
                string frozenRoundString = $"The {monster.Name} is frozen. Physical, frost and arcane damage to it will be increased by 50%!";
                Assert.AreEqual(frozenRoundString, OutputHelper.Display.Output[1][2]);
                monster.HitPoints -= (int)frozenDamage;
                totalBaseDamage   += baseDamage;
                totalFrozenDamage += frozenDamage;
            }
            GameHelper.RemovedExpiredEffectsAsync(monster);
            Thread.Sleep(1000);
            Assert.AreEqual(false, monster.Effects.Any());
            Assert.AreEqual(false, monster.IsStunned);
            int finalBaseDamageWithMod = (int)(totalBaseDamage * multiplier);
            int finalTotalFrozenDamage = (int)totalFrozenDamage;

            Assert.AreEqual(finalTotalFrozenDamage, finalBaseDamageWithMod, 14);
            Assert.AreEqual(monster.HitPoints, monsterHitPointsBefore - (int)totalFrozenDamage);
        }
Esempio n. 6
0
        public void ChargeAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                InCombat      = true
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, InCombat = true
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Charge);

            string[] inputInfo = new[] { "ability", "charge" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Charge", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]);
            string abilityInfoString = $"Stuns opponent for {player.Abilities[abilityIndex].Stun.StunMaxRounds} rounds, preventing their attacks.";

            Assert.AreEqual(abilityInfoString, OutputHelper.Display.Output[4][2]);
            string[] input       = new[] { "use", "charge" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("charge", abilityName);
            player.UseAbility(monster, input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            int    abilityDamage       = player.Abilities[abilityIndex].Stun.DamageAmount;
            int    abilityCurRounds    = player.Abilities[abilityIndex].Stun.StunCurRounds;
            int    abilityMaxRounds    = player.Abilities[abilityIndex].Stun.StunMaxRounds;
            string attackSuccessString = $"You {player.Abilities[abilityIndex].Name} the {monster.Name} for {abilityDamage} physical damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[5][2]);
            string stunString = $"The {monster.Name} is stunned!";

            Assert.AreEqual(stunString, OutputHelper.Display.Output[6][2]);
            Assert.AreEqual(monster.MaxHitPoints - abilityDamage, monster.HitPoints);
            Assert.AreEqual(true, monster.Effects[0] is StunnedEffect);
            Assert.AreEqual(abilityCurRounds, monster.Effects[0].CurrentRound);
            Assert.AreEqual(abilityMaxRounds, monster.Effects[0].MaxRound);
            StunnedEffect stunnedEffect = monster.Effects[0] as StunnedEffect;

            OutputHelper.Display.ClearUserOutput();
            for (int i = 2; i < 4; i++)
            {
                stunnedEffect.ProcessRound();
                string stunnedString = $"The {monster.Name} is stunned and cannot attack.";
                Assert.AreEqual(stunnedString, OutputHelper.Display.Output[i - 2][2]);
                Assert.AreEqual(i, monster.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(monster);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, monster.Effects.Any());
        }