using ActionGame.GameArtifacts.Models.Characters;
using ActionGame.GameArtifacts.Models.Game;
using ActionGame.GameArtifacts.Models.WeaponSprites;
using ActionGame.GameArtifacts.Operators.Characters;
using ActionGame.RawResources.Manager;
using Microsoft.Xna.Framework.Audio;
using System;


namespace ActionGame.GameArtifacts.Operators.Items
{
    public class Healer
    {
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private Boolean isFixedAttackPower;
        private Int32 attackPower;


        public Healer(IRawContentManager rawContentManager, GameData gameData, Boolean isFixedAttackPower, Int32 attackPower)
        {
            this.rawContentManager = rawContentManager;
            this.gameData = gameData;
            this.isFixedAttackPower = isFixedAttackPower;
            this.attackPower = attackPower;
        }


        public void Do(IBattleObject target)
        {
            Int32 amount = attackPower;
            if (isFixedAttackPower == false) amount += target.CharacterStats.Attack;


            Damager damager = new Damager();
            Int32 damageDone = damager.Do(-amount, target);

            if (damageDone != 0)
            {
                DamageSprite damageSprite = new DamageSprite(rawContentManager, target, damageDone, target.WorldPosition);
                gameData.GameState.ActiveDisplaySprites.Add(damageSprite);
            }

            //sound effect
            SoundEffect sound = rawContentManager.SoundEffectRepository.GetContent(@"soundeffects\heal");
            sound.Play();
        }

    }
}
