Example #1
0
        public virtual void Attack(int attackRoll, int damageRoll, string attackText)
        {
            if (IsDead)
            {
                return;
            }
            string attackResultText;

            if (attackRoll >= Defense)
            {
                stats.InflictDamage(damageRoll);
                if (IsDead)
                {
                    attackResultText = string.Format("You deal {0} damage, fatally wounding it.", damageRoll);
                }
                else
                {
                    attackResultText = string.Format("{0} damage dealt.", damageRoll);
                }
            }
            else
            {
                attackResultText = "You miss.";
            }
            Logger.LogFormat("{0} {1}", attackText, attackResultText);
            if (IsDead)
            {
                // It's important we do this after we've logged the attack, otherwise any logging conducted by
                // the Die method would come before the attack.
                Die();
            }
        }
Example #2
0
 public void Attack(AttackResult attack)
 {
     if (attack.IsSuccess)
     {
         stats.InflictDamage(attack.TotalDamage);
         Heal(attack.TotalHealing);
         if (IsDead)
         {
             Die();
         }
     }
 }