コード例 #1
0
        /// <summary>
        /// Gets the total amount of damage a given damage amount will do to a character modified by
        /// the character's stats.
        /// </summary>
        /// <param name="damage">The unmodified amount of damage.</param>
        /// <param name="character">The character whose stats are being calculated against.</param>
        /// <returns>An integer representing the total damage that will be dealt to the character.</returns>
        public static int GetTotalDamage(DamageTypes damageType, Character character)
        {
            int totalDamage = 0;

            int[] damage = damageType.AsArray();
            for (int j = 0; j < damage.Count(); j++)
            {
                // If a specific type of armor is over 100% (meaning heals instead of damages) then target heals for any percentage of the damage
                // over 100%
                if (character.ArmorPercentage.AsArray()[j] > 100 && damage[j] > 0)
                {
                    totalDamage += damage[j] * (100 - character.ArmorPercentage.AsArray()[j]) / 100;
                }
                // If resist all percentage is over 100%, target heals for any percentage of damage over 100%
                else if (character.ResistAllPercentage > 100 && damage[j] > 0)
                {
                    totalDamage += damage[j] * (100 - character.ResistAllPercentage) / 100;
                }
                // If damage is greater than the target's armor, calculate total damage by deducting target's armor values from damage
                else if (damage[j] > character.Armor.AsArray()[j])
                {
                    totalDamage -= (damage[j] - character.Armor.AsArray()[j])
                                   * (100 - character.ArmorPercentage.AsArray()[j]) / 100
                                   * (100 - character.ResistAllPercentage) / 100;
                }
            }
            return(totalDamage);
        }