Esempio n. 1
0
        public int TakeDamage(DamageBlob damageBlob)
        {
            int damageTaken;

            ApplyResistanceToDamage(damageBlob);
            damageTaken = ApplyDamage(damageBlob);

            return(damageTaken);
        }
Esempio n. 2
0
        public int ApplyDamage(DamageBlob damageBlob)
        {
            int damageTaken = 0;

            foreach (Damage d in damageBlob.DamageList)
            {
                HitPoints   -= d.DamageAfterResistance;
                damageTaken += d.DamageAfterResistance;
            }

            return(damageTaken);
        }
Esempio n. 3
0
        public int ApplyResistanceToDamage(DamageBlob damageBlob)
        {
            int totalDamage = 0;

            foreach (Damage d in damageBlob.DamageList)
            {
                d.AmountResisted = GetResistaneValue(d);
                totalDamage     += d.DamageAfterResistance;
            }

            return(totalDamage);
        }
 public override void ModifyPostBlockDamageTaken(DamageBlob damageBlob)
 {
     if (damageBlob.Damage >= Stacks)
     {
         damageBlob.Damage -= this.Stacks;
         this.Stacks        = 0;
     }
     else
     {
         this.Stacks      -= damageBlob.Damage;
         damageBlob.Damage = 0;
     }
 }
    /// <summary>
    /// Source is allowed to be null in cases where isAttack is false.
    /// </summary>
    public static void ProcessDamageWithCalculatedModifiers(AbstractBattleUnit damageSource,
                                                            AbstractBattleUnit target,
                                                            AbstractCard nullableCardPlayed,
                                                            int baseDamage,
                                                            bool isAttack = true)
    {
        int totalDamageAfterModifiers = baseDamage;

        // todo: first, process card modifiers (stickers, really)

        if (isAttack)
        {
            totalDamageAfterModifiers = GetAnticipatedDamageToUnit(damageSource, target, baseDamage, isAttack, nullableCardPlayed);
        }

        if (nullableCardPlayed != null)
        {
            foreach (var damageMod in nullableCardPlayed.DamageModifiers)
            {
                damageMod.OnStrike(nullableCardPlayed, target, totalDamageAfterModifiers);
            }
        }

        var damageDealtAfterBlocking = totalDamageAfterModifiers;

        if (target.CurrentBlock >= totalDamageAfterModifiers)
        {
            damageDealtAfterBlocking = 0;
            target.CurrentBlock     -= totalDamageAfterModifiers;
        }
        else
        {
            damageDealtAfterBlocking -= target.CurrentBlock;

            target.CurrentBlock = 0;
        }
        if (damageDealtAfterBlocking != 0)
        {
            var damageBlob = new DamageBlob
            {
                Damage         = damageDealtAfterBlocking,
                IsAttackDamage = isAttack
            };

            if (target.CurrentHp > 0)
            {
                foreach (var effect in target.StatusEffects)
                {
                    effect.ModifyPostBlockDamageTaken(damageBlob);
                }
            }

            target.CurrentHp -= damageBlob.Damage;

            if (target.CurrentHp > 0 && isAttack)
            {
                ProcessAttackDamageReceivedHooks(damageSource, target, nullableCardPlayed, damageBlob.Damage);
            }

            if (damageBlob.Damage > 0)
            {
                ProcessHpLossHooks(damageSource, target, damageBlob.Damage);
            }

            CheckAndRegisterDeath(target, damageSource, nullableCardPlayed);
        }
    }
 /// <summary>
 /// Note that this BOTH modifies the damage AND does anything relating to the damage modification (such as decreasing stacks of the mitigating attribute.)
 /// This is expected to mitigate damage AFTER block is consumed.  PRE-BLOCK damage is not impacted by this method.
 /// </summary>
 /// <param name="damageBlob"></param>
 public virtual void ModifyPostBlockDamageTaken(DamageBlob damageBlob)
 {
 }