示例#1
0
        public void ManaScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            var enemy = AllEnemies.First();

            enemy.Symbol = EnemySymbols.SnakeSymbol;
            enemy.SetSpecialAttackStat();

            var scroll = PrepareScroll(hero, SpellKind.ManaShield, enemy);
            var spell  = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);

            Assert.NotNull(spell);

            var heroHealth = game.Hero.Stats.Health;

            game.Hero.OnMelleeHitBy(enemy);                      //PoisonBallSpell work on mana shields!
            Assert.AreEqual(game.Hero.Stats.Health, heroHealth); //mana shield

            GotoSpellEffectEnd(spell);

            heroHealth = game.Hero.Stats.Health;
            game.Hero.OnMelleeHitBy(enemy);
            Assert.Less(game.Hero.Stats.Health, heroHealth);//mana shield gone
        }
示例#2
0
        public void TestPoisonPotionConsume()
        {
            var game = CreateGame();
            var hero = game.Hero;

            hero.SetChanceToExperienceEffect(EffectType.Poisoned, 100);

            //make enemy poisonus
            var enemy        = AllEnemies.First();
            var poisonAttack = enemy.Stats.GetStat(EntityStatKind.PoisonAttack);

            poisonAttack.Value.Nominal = 10;

            game.Hero.OnMeleeHitBy(enemy);
            var le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);

            Assert.NotNull(le1);

            var pot = Helper.AddTile <Potion>();

            pot.SetKind(PotionKind.Antidote);
            AddItemToInv(pot);
            hero.Consume(pot);

            le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);
            Assert.Null(le1);
        }
示例#3
0
        public void TestBleeding()
        {
            var game = CreateGame(true, 1);

            Assert.AreEqual(AllEnemies.Count, 1);
            int actionCounter = 0;

            game.GameManager.EventsManager.ActionAppended += (object sender, Roguelike.Events.GameEvent e) =>
            {
                if (e is LivingEntityAction)
                {
                    var lea = e as LivingEntityAction;
                    if (lea.Kind == LivingEntityActionKind.ExperiencedEffect)
                    {
                        if (lea.Info.Contains(EffectType.Bleeding.ToDescription()))
                        {
                            actionCounter++;
                        }
                    }
                }
            };

            var enemy = AllEnemies.First();

            Assert.True(enemy.Revealed);
            var enemyHealthStat = enemy.Stats.GetStat(EntityStatKind.Health);

            enemyHealthStat.Value.Nominal = 150;
            enemy.SetIsWounded(true);//make sure will bleed
            var enemyHealth = enemy.Stats.Health;

            var wpn = game.GameManager.LootGenerator.GetLootByTileName <Weapon>("rusty_sword");

            SetHeroEquipment(wpn);

            enemy.OnMelleeHitBy(game.Hero);
            var le1 = enemy.LastingEffects.Where(i => i.Type == EffectType.Bleeding).FirstOrDefault();

            Assert.NotNull(le1);
            Assert.Greater(enemyHealth, enemy.Stats.Health);

            //var value = game.Hero.Stats.GetStat(EntityStatKind.Defense).Value;
            var turns = le1.PendingTurns;

            for (int i = 0; i < turns; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
            }
            Assert.AreEqual(actionCounter, 3);
        }
示例#4
0
        public void RageScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            hero.UseAttackVariation = false;
            var enemy = AllEnemies.First();

            Func <float> hitEnemy = () =>
            {
                var enemyHealth = enemy.Stats.Health;
                enemy.OnMelleeHitBy(game.Hero);
                var lastEnemyHealthDiff = enemyHealth - enemy.Stats.Health;
                return(lastEnemyHealthDiff);
            };
            var healthDiff = hitEnemy();

            var emp = CurrentNode.GetClosestEmpty(hero);

            CurrentNode.SetTile(enemy, emp.point);

            var scroll = new Scroll(SpellKind.Rage);

            hero.Inventory.Add(scroll);
            var attackPrev = hero.GetCurrentValue(EntityStatKind.MeleeAttack);
            var spell      = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);

            Assert.NotNull(spell);
            Assert.Greater(hero.GetCurrentValue(EntityStatKind.MeleeAttack), attackPrev);

            var healthDiffRage = hitEnemy();

            Assert.Greater(healthDiffRage, healthDiff);//rage in work

            GotoSpellEffectEnd(spell);
            Assert.AreEqual(hero.GetCurrentValue(EntityStatKind.MeleeAttack), attackPrev);
            var healthDiffAfterRage = hitEnemy();
            var delta = Math.Abs(healthDiffAfterRage - healthDiff);

            Assert.Less(delta, 0.001);//rage was over
        }
示例#5
0
        public void TestPoisoned()
        {
            var game       = CreateGame();
            var healthStat = game.Hero.Stats.GetStat(EntityStatKind.Health);
            var health     = healthStat.Value.CurrentValue;

            Assert.Greater(game.Hero.GetChanceToExperienceEffect(EffectType.Poisoned), 0);
            game.Hero.SetChanceToExperienceEffect(EffectType.Poisoned, 100);

            //make enemy poisonus
            var enemy        = AllEnemies.First();
            var poisonAttack = enemy.Stats.GetStat(EntityStatKind.PoisonAttack);

            poisonAttack.Value.Nominal = 10;

            game.Hero.OnMelleeHitBy(enemy);
            var le1 = game.Hero.GetFirstLastingEffect(EffectType.Poisoned);

            Assert.NotNull(le1);

            Assert.Less(healthStat.Value.CurrentValue, health);
            var turns = le1.PendingTurns;

            for (int i = 0; i < turns; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
                Assert.Less(healthStat.Value.CurrentValue, health);
                health = healthStat.Value.CurrentValue;
            }

            health = healthStat.Value.CurrentValue;

            for (int i = 0; i < 5; i++)
            {
                game.GameManager.SkipHeroTurn();
                GotoNextHeroTurn();
                Assert.AreEqual(healthStat.Value.CurrentValue, health);
            }
        }
示例#6
0
        public void DziewannaScrollTest()
        {
            var game = CreateGame(numEnemies: 1);
            var hero = game.Hero;

            Enemy enemy  = AllEnemies.First();
            var   scroll = PrepareScroll(hero, SpellKind.Dziewanna, enemy);

            var enHealth = enemy.Stats.Health;
            var apples   = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple && i.EffectType == Roguelike.Effects.EffectType.Poisoned);

            Assert.AreEqual(apples.Count(), 0);
            game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);
            Assert.True(!game.GameManager.HeroTurn);
            apples = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple);
            var applesCount = apples.Count();

            Assert.Greater(applesCount, 0);

            for (int i = 0; i < 10; i++)
            {
                GotoNextHeroTurn();
                if (enemy.HasLastingEffect(Roguelike.Effects.EffectType.Poisoned)
                    //|| enemy.HasLastingEffect(Roguelike.Effects.EffectType.ConsumedRawFood)
                    )
                {
                    break;
                }
            }
            Assert.True(
                enemy.HasLastingEffect(Roguelike.Effects.EffectType.Poisoned)
                //|| enemy.HasLastingEffect(Roguelike.Effects.EffectType.ConsumedRawFood)
                );
            var applesAfter = game.GameManager.CurrentNode.GetTiles <Food>().Where(i => i.Kind == FoodKind.Apple && i.EffectType == Roguelike.Effects.EffectType.Poisoned).ToList();

            Assert.Greater(applesCount, applesAfter.Count);
            Assert.Greater(enHealth, enemy.Stats.Health);
        }
示例#7
0
        public void NonPlainEnemyUsesEffects()
        {
            var game = CreateGame(numEnemies: 1, numberOfRooms: 1);
            var hero = game.Hero;

            var spellAttackDone = false;

            game.GameManager.EventsManager.ActionAppended += (object sender, Roguelike.Events.GameEvent e) =>
            {
                if (e is LivingEntityAction lea)
                {
                    if (lea.Info.Contains("Ball"))
                    {
                        spellAttackDone = true;
                    }
                }
            };

            hero.Stats.SetNominal(Roguelike.Attributes.EntityStatKind.Health, 255);
            var enemy = AllEnemies.First();

            enemy.SetNonPlain(true);
            Assert.NotNull(enemy.ActiveManaPoweredSpellSource);
            var closeHero = game.Level.GetClosestEmpty(hero);

            game.Level.SetTile(enemy, closeHero.point);
            var enemyMana = enemy.Stats.Mana;

            for (int i = 0; i < 10; i++)
            {
                game.GameManager.EnemiesManager.AttackIfPossible(enemy, hero);//TODO
                if (enemy.Stats.Mana < enemyMana)
                {
                    break;
                }
            }
            Assert.True(spellAttackDone);
        }
示例#8
0
        public void TransformScrollTest()
        {
            var game = CreateGame();
            var hero = game.Hero;

            Enemy        enemy = AllEnemies.First();
            PassiveSpell spell;
            var          scroll = PrepareScroll(hero, SpellKind.Transform, enemy);

            Assert.True(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));
            spell = game.GameManager.SpellManager.ApplyPassiveSpell(hero, scroll);
            Assert.NotNull(spell);

            Assert.True(!game.GameManager.HeroTurn);
            var le = game.Hero.LastingEffectsSet.GetByType(Roguelike.Effects.EffectType.Transform);

            Assert.NotNull(le);
            Assert.False(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));

            GotoSpellEffectEnd(spell);

            Assert.True(game.GameManager.EnemiesManager.ShallChaseTarget(enemy, game.Hero));
        }