Beispiel #1
0
        public void PoisonBiteAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Spider)
            {
                HitPoints = 50, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = monster.Abilities.FindIndex(
                f => f.AbilityCategory == Ability.PoisonBite);

            foreach (IItem item in player.Inventory.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            monster.Abilities[abilityIndex].UseOffenseDamageAbility(monster, player, abilityIndex);
            int abilityCost = monster.Abilities[abilityIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - abilityCost, monster.EnergyPoints);
            int    abilityDamage         = monster.Abilities[abilityIndex].Offensive.Amount;
            int    abilityDamageOverTime = monster.Abilities[abilityIndex].Offensive.AmountOverTime;
            int    abilityCurRounds      = monster.Abilities[abilityIndex].Offensive.AmountCurRounds;
            int    abilityMaxRounds      = monster.Abilities[abilityIndex].Offensive.AmountMaxRounds;
            string attackString          = $"The {monster.Name} tries to bite you!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} bites you for {abilityDamage} physical damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
            string bleedString = $"You are bleeding from {monster.Name}'s attack!";

            Assert.AreEqual(bleedString, OutputHelper.Display.Output[2][2]);
            Assert.AreEqual(true, player.Effects[0] is BleedingEffect);
            Assert.AreEqual(player.MaxHitPoints - abilityDamage, player.HitPoints);
            Assert.AreEqual(abilityCurRounds, player.Effects[0].CurrentRound);
            Assert.AreEqual(abilityMaxRounds, player.Effects[0].MaxRound);
            OutputHelper.Display.ClearUserOutput();
            BleedingEffect bleedEffect = player.Effects[0] as BleedingEffect;

            for (int i = 2; i < 5; i++)
            {
                bleedEffect.ProcessRound();
                int    bleedAmount      = bleedEffect.BleedDamageOverTime;
                string bleedRoundString = $"You bleed for {bleedAmount} physical damage.";
                Assert.AreEqual(bleedRoundString, OutputHelper.Display.Output[i - 2][2]);
                Assert.AreEqual(i, player.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(player);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, player.Effects.Any());
            Assert.AreEqual(player.MaxHitPoints - abilityDamage - (abilityDamageOverTime * abilityMaxRounds),
                            player.HitPoints);
        }
Beispiel #2
0
 void Start()
 {
     if (CommonObjectsStore.player == this.gameObject)
     {
         playerHealth = this;
     }
     be = this.GetComponent <BleedingEffect> ();
 }
Beispiel #3
0
        public void PlayerHasBleedingEffectUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage);
            EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                AmountOverTime = 20,
                EffectHolder   = player,
                MaxRound       = 3,
                Name           = "bleed test"
            };
            BleedingEffect bleedEffect = new BleedingEffect(effectOverTimeSettings);

            player.Effects.Add(bleedEffect);

            Assert.AreEqual(1, player.Effects.Count);
            Assert.AreEqual(effectOverTimeSettings.Name, bleedEffect.Name);
            Assert.AreEqual(true, player.Effects[0] is BleedingEffect);
        }
Beispiel #4
0
        public void PlayerBleedingEffectDoesNotExpireWhenCurrentRoundEqualsMaxRoundUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage);
            EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                AmountOverTime = 20,
                EffectHolder   = player,
                MaxRound       = 3,
                Name           = "bleed test"
            };
            BleedingEffect bleedEffect = new BleedingEffect(effectOverTimeSettings);

            player.Effects.Add(bleedEffect);

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

            Assert.AreEqual(3, bleedEffect.CurrentRound);
            Assert.AreEqual(false, bleedEffect.IsEffectExpired);
        }
Beispiel #5
0
        public void MonsterBleedingEffectExpiresWhenCurrentRoundGreaterThanMaxRoundUnitTest()
        {
            Monster monster = new Monster(5, MonsterType.Skeleton);
            EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                AmountOverTime = 20,
                EffectHolder   = monster,
                MaxRound       = 3,
                Name           = "bleed test"
            };
            BleedingEffect bleedEffect = new BleedingEffect(effectOverTimeSettings);

            monster.Effects.Add(bleedEffect);

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

            Assert.AreEqual(4, bleedEffect.CurrentRound);
            Assert.AreEqual(true, bleedEffect.IsEffectExpired);
        }
Beispiel #6
0
        public void ProcessBleedingEffectRoundMonsterUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(5, MonsterType.Skeleton);
            EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                AmountOverTime = 20,
                EffectHolder   = monster,
                MaxRound       = 3,
                Name           = "bleed test"
            };
            BleedingEffect bleedEffect = new BleedingEffect(effectOverTimeSettings);

            monster.Effects.Add(bleedEffect);
            string bleedMessage = $"The {monster.Name} bleeds for {effectOverTimeSettings.AmountOverTime} physical damage.";

            bleedEffect.ProcessRound();

            Assert.AreEqual(monster.MaxHitPoints - effectOverTimeSettings.AmountOverTime, monster.HitPoints);
            Assert.AreEqual(bleedMessage, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(2, bleedEffect.CurrentRound);
            Assert.AreEqual(false, bleedEffect.IsEffectExpired);
        }
Beispiel #7
0
        public void ProcessBleedingEffectRoundPlayerUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Player player = new Player("test", PlayerClassType.Mage);
            EffectOverTimeSettings effectOverTimeSettings = new EffectOverTimeSettings {
                AmountOverTime = 20,
                EffectHolder   = player,
                MaxRound       = 3,
                Name           = "bleed test"
            };
            BleedingEffect bleedEffect = new BleedingEffect(effectOverTimeSettings);

            player.Effects.Add(bleedEffect);
            string bleedMessage = $"You bleed for {effectOverTimeSettings.AmountOverTime} physical damage.";

            bleedEffect.ProcessRound();

            Assert.AreEqual(player.MaxHitPoints - effectOverTimeSettings.AmountOverTime, player.HitPoints);
            Assert.AreEqual(bleedMessage, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(2, bleedEffect.CurrentRound);
            Assert.AreEqual(false, bleedEffect.IsEffectExpired);
        }
Beispiel #8
0
        public void RendAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100, RagePoints = 100
            };

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

            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.Rend);

            string[] inputInfo = new[] { "ability", "rend" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Rend", 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]);
            Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]);
            string bleedOverTimeString = $"Bleeding damage over time for {player.Abilities[abilityIndex].Offensive.AmountMaxRounds} rounds.";

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

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

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            int    abilityDamage         = player.Abilities[abilityIndex].Offensive.Amount;
            int    abilityDamageOverTime = player.Abilities[abilityIndex].Offensive.AmountOverTime;
            int    abilityCurRounds      = player.Abilities[abilityIndex].Offensive.AmountCurRounds;
            int    abilityMaxRounds      = player.Abilities[abilityIndex].Offensive.AmountMaxRounds;
            string abilitySuccessString  = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage.";

            Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[6][2]);
            string bleedString = $"The {monster.Name} is bleeding!";

            Assert.AreEqual(bleedString, OutputHelper.Display.Output[7][2]);
            Assert.AreEqual(true, monster.Effects[0] is BleedingEffect);
            Assert.AreEqual(monster.MaxHitPoints - abilityDamage, monster.HitPoints);
            Assert.AreEqual(abilityCurRounds, monster.Effects[0].CurrentRound);
            Assert.AreEqual(abilityMaxRounds, monster.Effects[0].MaxRound);
            BleedingEffect bleedEffect = monster.Effects[0] as BleedingEffect;

            OutputHelper.Display.ClearUserOutput();
            for (int i = 2; i < 5; i++)
            {
                bleedEffect.ProcessRound();
                int    bleedAmount      = bleedEffect.BleedDamageOverTime;
                string bleedRoundString = $"The {monster.Name} bleeds for {bleedAmount} physical damage.";
                Assert.AreEqual(bleedRoundString, 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());
            Assert.AreEqual(monster.MaxHitPoints - abilityDamage - (abilityDamageOverTime * abilityMaxRounds),
                            monster.HitPoints);
        }
Beispiel #9
0
    void Update()
    {
        if (playerBleed == null)
        {
            playerBleed = PersonHealth.playerHealth.gameObject.GetComponent <BleedingEffect> ();
        }
        else
        {
            if (playerBleed.bleeding == true)
            {
                bleeding.enabled = true;
            }
            else
            {
                bleeding.enabled = false;
            }
        }



        if (PersonHealth.playerHealth.armourValue > 0)
        {
            armour.enabled = true;
            armour.color   = new Color(1, 1, 1, PersonHealth.playerHealth.armourValue / 100);
        }
        else
        {
            armour.enabled = false;
        }
        disableIcons();
        foreach (EffectBase eb in EffectsManager.me.effectsOnPlayer)
        {
            if (eb.effectName == "Heroin High")
            {
                heroin.enabled     = true;
                heroinWith.enabled = false;
            }
            else if (eb.effectName == "Heroin Withdrawral")
            {
                heroin.enabled     = false;
                heroinWith.enabled = true;
            }
            else if (eb.effectName == "Cannabis High")
            {
                weed.enabled = true;
            }
            else if (eb.effectName == "Cocaine High")
            {
                coke.enabled = true;
            }
            else if (eb.effectName == "Morphine High")
            {
                morphine.enabled     = true;
                morphineWith.enabled = false;
            }
            else if (eb.effectName == "Morphine Withdrawral")
            {
                morphine.enabled     = true;
                morphineWith.enabled = false;
            }
            else if (eb.effectName == "Adrenaline")
            {
                adrenaline.enabled = true;
            }
        }

        ////Debug.Log (PersonHealth.playerHealth.healthValue);
        health.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, (240.0f / 5200.0f) * PersonHealth.playerHealth.healthValue);
        //bloodDisplay.text = "Blood: " + PersonHealth.playerHealth.healthValue + " ml";
        //health.SetSizeWithCurrentAnchors (RectTransform.Axis.Horizontal, PersonHealth.playerHealth.healthValue * 5f);
        //armour.SetSizeWithCurrentAnchors (RectTransform.Axis.Horizontal, PersonHealth.playerHealth.armourValue * 5f);
    }