using ActionGame.GameArtifacts.Models.Characters;
using System;


namespace ActionGame.GameArtifacts.Operators.Characters
{
    public class Damager
    {

        public Damager()
        {

        }


        public Int32 Do(Int32 attack, IBattleObject target)
        {
            Int32 damageDone = 0;

            if(attack > 0)
            {
                damageDone = attack - target.CharacterStats.Defence;
                target.CharacterStats.Health -= damageDone;

                if (target.CharacterStats.Health < 0) target.CharacterStats.Health = 0;
            }
            else
            {
                damageDone = attack;
                target.CharacterStats.Health -= damageDone;

                if (target.CharacterStats.Health > target.CharacterStats.MaximumHealth) target.CharacterStats.Health = target.CharacterStats.MaximumHealth;
            }

            return damageDone;
        }


    }
}
