using UnityEngine;


public class Status_Player : Status
{

    [SerializeField] private Data_Status_Player _data;

    public Data_Status_Player Data
    {
        get { return _data; }
        set
        {
            if (value != null)
            {
                _data = value;
            }
        }
    }
    
    // --- 부모의 abstract 프로퍼티들 ---
    public override int Level => _data.level;
    public override float Hp => _data.hp;
    public override float MaxHp => _data.maxHp;
    public override float Mp => _data.mp;
    public override float MaxMp => _data.maxMp;
    public override float Attack => _data.attack;
    public override float Defense => _data.defense;
    public override float MoveSpeed => _data.moveSpeed;
    public override float AtkSpeed => _data.atkSpeed;


    // --- Player 전용 프로퍼티들 ---
    public float Exp => _data.exp;
    public float MaxExp => _data.maxExp;
    public int Gold => _data.gold;
    
    
    
    public override float ApplyDamage(float damage)
    {
        Data.hp = _data.hp - damage;
        return Hp;
    }
    
    public float ApplyExp(float exp)
    {
        Data.exp += exp;
        if (Data.exp < 0) Data.exp = 0;
        
        while (Exp >= MaxExp) { LevelUp(); }
        return Exp;
    }

    private void LevelUp()
    {
        // 후에 레벨업하게 되면 증가할 다른 스텟들도 추가
        Data.exp -= MaxExp;
        Data.level += 1;
    }

    
    
}