Esempio n. 1
0
        public void TestExplosiveOnHero(FightItemKind fightItemKind)
        {
            var game = CreateGame();
            var en   = PlainEnemies.First();

            en.AddFightItem(fightItemKind);
            en.AddFightItem(fightItemKind);
            var hero        = game.GameManager.Hero;
            var beginHealth = hero.Stats.Health;

            var explosiveCocktail = en.GetFightItem(fightItemKind) as ProjectileFightItem;
            var dam = explosiveCocktail.Damage;

            PlaceCloseToHero(en);
            Assert.True(game.GameManager.ApplyAttackPolicy(en, hero, explosiveCocktail, null, (p) => { }));
            var lifeDiff = beginHealth - hero.Stats.Health;

            Assert.Greater(lifeDiff, 0);
            while (hero.LastingEffects.Any())
            {
                GotoNextHeroTurn();
            }

            beginHealth = hero.Stats.Health;
            Assert.True(en.SetLevel(5));
            explosiveCocktail = en.GetFightItem(fightItemKind) as ProjectileFightItem;
            //Assert.Greater(explosiveCocktail.Damage, dam);
            Assert.True(game.GameManager.ApplyAttackPolicy(en, hero, explosiveCocktail, null, (p) => { }));
            var lifeDiff1 = beginHealth - hero.Stats.Health;

            Assert.Greater(lifeDiff1, lifeDiff);
        }
Esempio n. 2
0
        public void TestChanceToRepeatMelleeAttack()
        {
            var game = CreateGame();

            game.Hero.Stats.SetNominal(EntityStatKind.ChanceToMeleeHit, 100);

            var en = PlainEnemies.First();

            en.Stats.SetNominal(EntityStatKind.Health, 300);
            var enHealthBase = en.Stats.Health;

            en.OnMelleeHitBy(game.Hero);
            var healthDiffBase = enHealthBase - en.Stats.Health;

            enHealthBase = en.Stats.Health;
            Assert.Greater(healthDiffBase, 0);
            Assert.AreEqual(game.Hero.Stats.GetCurrentValue(EntityStatKind.ChanceToRepeatMelleeAttack), 0);
            game.Hero.Stats.SetNominal(EntityStatKind.ChanceToRepeatMelleeAttack, 50);
            bool works = false;

            for (int i = 0; i < 20; i++)
            {
                game.GameManager.InteractHeroWith(en);
                GotoNextHeroTurn();
                var healthDiff = enHealthBase - en.Stats.Health;
                if (healthDiff > healthDiffBase)
                {
                    works = true;
                    break;
                }

                enHealthBase = en.Stats.Health;
            }
            Assert.True(works);
        }
Esempio n. 3
0
        public void MagicProjectileEnemyHitTest(AbilityKind ak)
        {
            var game             = CreateGame();
            var ab               = game.GameManager.Hero.GetPassiveAbility(ak);
            var enemy            = PlainEnemies.First();
            var enemyBeginHealth = enemy.Stats.Health;

            UseSpellSource(game.Hero, enemy, true, AbilityKind2SpellKind[ak]);
            Assert.Less(enemy.Stats.Health, enemyBeginHealth);
            var diff1 = enemyBeginHealth - enemy.Stats.Health;

            enemyBeginHealth = enemy.Stats.Health;

            for (int i = 0; i < ab.MaxLevel; i++)
            {
                ab.IncreaseLevel(game.Hero);
            }

            GotoNextHeroTurn();

            UseSpellSource(game.Hero, enemy, true, AbilityKind2SpellKind[ak]);
            Assert.Less(enemy.Stats.Health, enemyBeginHealth);
            var diff2 = enemyBeginHealth - enemy.Stats.Health;

            Assert.Greater(diff2, diff1);
        }
Esempio n. 4
0
        private void TestRestoreFactorChange(bool forMana)
        {
            var Hero = game.Hero;

            Hero.AbilityPoints = 5;
            var abVal = 0.0;
            var ab    = Hero.GetPassiveAbility(forMana ? AbilityKind.RestoreMana : AbilityKind.RestoreHealth);

            for (int i = 0; i < ab.MaxLevel + 1; i++)
            {
                var done = Hero.IncreaseAbility(forMana ? AbilityKind.RestoreMana : AbilityKind.RestoreHealth);
                ab = Hero.GetPassiveAbility(forMana ? AbilityKind.RestoreMana : AbilityKind.RestoreHealth);
                Assert.AreEqual(ab.PrimaryStat.Unit, EntityStatUnit.Percentage);
                AssertNextValue(i, ab, abVal, null);
                var factor = GetFactor(ab, true);
                Assert.Less(factor, 10);
                abVal = factor;
            }
            if (forMana)
            {
                var en             = PlainEnemies.First();
                var mana           = Hero.Stats.Mana;
                var fireBallScroll = new Scroll(Roguelike.Spells.SpellKind.FireBall);
                UseScroll(Hero, fireBallScroll);

                var mana1 = Hero.Stats.Mana;
                Assert.Less(mana1, mana);

                if (game.GameManager.Context.TurnOwner == Roguelike.TurnOwner.Hero)//TODO
                {
                    game.GameManager.Context.MoveToNextTurnOwner();
                }

                GotoNextHeroTurn();

                var mana2 = Hero.Stats.Mana;
                Assert.Greater(mana2, mana1);
            }
            else
            {
                var en     = PlainEnemies.First();
                var health = Hero.Stats.Health;
                while (Hero.OnMeleeHitBy(en) == 0)
                {
                    ;
                }
                var health1 = Hero.Stats.Health;
                Assert.Less(health1, health);

                if (game.GameManager.Context.TurnOwner == Roguelike.TurnOwner.Hero)//TODO
                {
                    game.GameManager.Context.MoveToNextTurnOwner();
                }

                GotoNextHeroTurn();

                var health2 = Hero.Stats.Health;
                Assert.Greater(health2, health1);
            }
        }
Esempio n. 5
0
        public void TestStaffMastering()
        {
            var   game = CreateGame();
            float originalStatValue = 0;
            var   destExtraStat     = SetWeapon(AbilityKind.SceptersMastering, game.Hero, out originalStatValue);
            var   weapon            = game.Hero.GetActiveWeapon();

            var en = PlainEnemies.First();

            en.Stats.SetNominal(EntityStatKind.Health, 300);
            var enHealthBase = en.Stats.Health;

            var spell = weapon.SpellSource.CreateSpell(game.Hero);

            PlaceCloseToHero(en);
            Assert.True(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, en, weapon.SpellSource));
            GotoNextHeroTurn();

            var healthDiffBase = enHealthBase - en.Stats.Health;

            enHealthBase = en.Stats.Health;
            Assert.Greater(healthDiffBase, 0);
            Assert.AreEqual(game.Hero.Stats.GetCurrentValue(EntityStatKind.ChanceToRepeatElementalProjectileAttack), 0);
            game.Hero.Stats.SetNominal(EntityStatKind.ChanceToRepeatElementalProjectileAttack, 50);
            bool works = false;

            for (int i = 0; i < 10; i++)
            {
                spell = weapon.SpellSource.CreateSpell(game.Hero);
                Assert.True(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, en, weapon.SpellSource));
                GotoNextHeroTurn();
                var healthDiff = enHealthBase - en.Stats.Health;
                if (healthDiff > healthDiffBase)
                {
                    works = true;
                    break;
                }

                enHealthBase = en.Stats.Health;
            }
            Assert.True(works);
        }
Esempio n. 6
0
        public void TestStrikeBack()
        {
            var game = CreateGame();
            var en   = PlainEnemies.First();

            PlaceCloseToHero(en);
            float en1Health = en.Stats.Health;

            var ab = game.GameManager.Hero.GetPassiveAbility(AbilityKind.StrikeBack);

            MaximizeAbility(ab, game.Hero);

            game.Hero.RecalculateStatFactors(false);
            var sb = game.Hero.GetTotalValue(EntityStatKind.ChanceToStrikeBack);

            for (int i = 0; i < 50; i++)
            {
                game.GameManager.ApplyPhysicalAttackPolicy(en, game.Hero, (p) => { });
                //GotoNextHeroTurn();
            }

            Assert.Greater(en1Health, en.Stats.Health);
        }
Esempio n. 7
0
        private float TestWeaponKindMastering(AbilityKind kind)
        {
            var abVal    = 0.0f;
            var abValAux = 0.0f;
            var hero     = game.Hero;

            hero.UseAttackVariation = false;
            float auxStatValue;
            var   destStat = SetWeapon(kind, hero, out auxStatValue);
            var   en       = PlainEnemies.First();

            en.Stats.SetNominal(EntityStatKind.Health, 100);
            en.AddImmunity(Roguelike.Effects.EffectType.Bleeding);//not to mix test results
            var wpn = hero.GetActiveWeapon();

            wpn.StableDamage = true;
            Assert.Greater(wpn.LevelIndex, 0);

            Func <float> hitEnemy = () =>
            {
                var health = en.Stats.Health;
                if (!wpn.IsBowLike)
                {
                    en.OnMelleeHitBy(hero);
                }
                else
                {
                    en.OnHitBy(hero.ActiveFightItem as ProjectileFightItem);
                }
                var health1 = en.Stats.Health;
                return(health - health1);
            };

            if (wpn.IsBowLike)
            {
                ProjectileFightItem pfi = null;
                if (wpn.Kind == Weapon.WeaponKind.Bow)
                {
                    pfi = new ProjectileFightItem(FightItemKind.PlainArrow)
                    {
                        Count = 2
                    };
                }
                else if (wpn.Kind == Weapon.WeaponKind.Crossbow)
                {
                    pfi = new ProjectileFightItem(FightItemKind.PlainBolt)
                    {
                        Count = 2
                    };
                }
                pfi.Caller = hero;
                hero.Inventory.Add(pfi);
                hero.ActiveFightItem = pfi;
            }
            var damage = hitEnemy();

            Assert.Greater(damage, 0);

            var heroAttack = hero.GetAttackValue(AttackKind.Unset).CurrentTotal;

            for (int i = 0; i < MaxAbilityInc + 1; i++)
            {
                hero.IncreaseAbility(kind);
                var ab = hero.GetPassiveAbility(kind);
                Assert.AreNotEqual(ab.PrimaryStat.Kind, EntityStatKind.Unset);
                AssertNextValue(i, ab, abVal, abValAux);

                abVal    = GetFactor(ab, true);
                abValAux = GetFactor(ab, false);
                Assert.Less(abVal, 21);
                Assert.Less(abValAux, 26);

                abVal = ab.PrimaryStat.Factor;
                //Debug.WriteLine(kind + " Level: " + ab.Level + ", value :" + ab.PrimaryStat.Factor);
            }
            var statValueWithAbility = hero.Stats.GetCurrentValue(destStat);

            Assert.Greater(statValueWithAbility, auxStatValue);

            var heroAttackWithAbility = hero.GetAttackValue(AttackKind.Unset).CurrentTotal;

            Assert.Greater(heroAttackWithAbility, heroAttack);
            var damageWithAbility = hitEnemy();

            if (damageWithAbility < damage)
            {
                int k = 0;
                k++;
            }
            Assert.Greater(damageWithAbility, damage);
            return(abVal);
        }
Esempio n. 8
0
        public void TestMagicProjectileMasteringStats(EntityStatKind esk, AbilityKind ak)
        {
            var   game = CreateGame();
            float originalStatValue = 0;

            SetWeapon(ak, game.Hero, out originalStatValue);
            var weapon = game.Hero.GetActiveWeapon();

            var   en              = PlainEnemies.First();
            float enHealthBase    = PrepareEnemyToBeBeaten(en);
            var   damageComparer1 = new OuaDDamageComparer(en, this);

            var spell = weapon.SpellSource.CreateSpell(game.Hero);

            Assert.AreEqual(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, en, weapon.SpellSource), Roguelike.Managers.ApplyAttackPolicyResult.OK);
            GotoNextHeroTurn();

            damageComparer1.RegisterHealth(en);
            Assert.Greater(damageComparer1.HealthDifference, 0);

            var stat1Value = game.Hero.Stats.GetStat(EntityStatKind.ChanceToRepeatElementalProjectileAttack).Value;

            Assert.AreEqual(stat1Value.Factor, 0);
            Assert.AreEqual(game.Hero.Stats.GetStat(EntityStatKind.StaffExtraElementalProjectileDamage).Value.Factor, 0);
            var ab = game.Hero.GetPassiveAbility(ak);

            //do not call  MaximizeAbility as it's not possible to distinguish what cause greater damage ChanceToRepeat or StaffExtraDamage
            //MaximizeAbility(ab, game.Hero);
            var factor = 50;//%

            game.Hero.Stats.SetFactor(esk, factor);
            Assert.Greater(game.Hero.Stats.GetStat(esk).Value.Factor, 0);
            bool works = false;

            for (int i = 0; i < 20; i++)
            {
                var damageComparer2 = new OuaDDamageComparer(en, this);
                spell = weapon.SpellSource.CreateSpell(game.Hero);
                Assert.AreEqual(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, en, weapon.SpellSource), Roguelike.Managers.ApplyAttackPolicyResult.OK);
                GotoNextHeroTurn();
                damageComparer2.RegisterHealth(en);
                if (damageComparer2.HealthDifference > damageComparer1.HealthDifference)
                {
                    if (esk == EntityStatKind.StaffExtraElementalProjectileDamage)
                    {
                        AssertHealthDiffPercentageInRange(damageComparer1, damageComparer2, 140, 175);//+factor%
                    }
                    works = true;
                    break;
                }
            }
            Assert.True(works);
            ////SumPercentageFactorAndValue of EnityStat depends on Factor, so check it
            //var scroll = PrepareScroll(game.Hero, SpellKind.Skeleton);
            //scroll.Count = 10;
            //var gm = game.GameManager;
            //var spellSk = gm.SpellManager.ApplySpell(game.Hero, scroll) as SkeletonSpell;
            //Assert.NotNull(spellSk.Ally);

            //Assert.AreEqual(spellSk.Ally.Stats.GetStat(EntityStatKind.StaffExtraElementalProjectileDamage).Value.Factor, 0);
            //Assert.AreEqual(spellSk.Ally.Stats.GetStat(EntityStatKind.ChanceToRepeatElementalProjectileAttack).Value.Factor, 0);
            //MaximizeAbility(ab, spellSk.Ally);
            //Assert.Greater(spellSk.Ally.Stats.GetStat(EntityStatKind.StaffExtraElementalProjectileDamage).Value.Factor, 0);
            //Assert.Greater(spellSk.Ally.Stats.GetStat(EntityStatKind.ChanceToRepeatElementalProjectileAttack).Value.Factor, 0);
        }