Esempio n. 1
0
        /// <summary>
        ///     Computes the damage inflicted by an attacker and defender
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <returns></returns>
        public static CombatResult ComputeDamage(TemporaryCombatData attacker, TemporaryCombatData defender)
        {
            // for each effect or tag in the attack
            if (attacker.AttackTags != null)
            {
                attacker.AttackTags.ForEach(tag => tag.Apply(ref defender));
            }

            // consult the DefenseEffects and apply any defense modifiers
            if (defender.DefenseTags != null)
            {
                defender.DefenseTags.ForEach(t => t.Apply(ref attacker));
            }

            // Calculate damage
            // TODO: combat needs to be modified to send in current AttackInfo. For now we assume combat is all melee.
            var damage = attacker.SealieAttack.Damage;

            if (defender.DefenseInfo != null && defender.DefenseInfo.DamageType == attacker.SealieAttack.DamageType)
            {
                damage = (int)Math.Floor(damage * 0.01m * defender.DefenseInfo.DamageMitigation);
            }

            // return the calcuated damage
            damage -= defender.Armor;

            return(new CombatResult {
                DefenderDamage =
                {
                    HealthDamage = (short)(damage < 0 ? 0 : damage),
                    ManaDamage   = 0
                },
                AttackerDamage =
                {
                    HealthDamage = 0,
                    ManaDamage   = 0
                }
            });
        }
Esempio n. 2
0
 /// <summary>
 /// Applies the attack tag to a defender's combat data
 /// </summary>
 /// <param name="cd">The defender's combat data</param>
 public abstract void Apply(ref TemporaryCombatData cd);