--- @alias Class "dev_warrior"|"dev_mage"

--- @class StatsBehavior : Behavior
--- @field hp integer
--- @field mana integer
--- @field initiative integer
--- @field class Class
--- @field isInTurnOrder boolean
--- @field amIAlive boolean
local behavior = {}
behavior.__index = behavior
behavior.id = "stats"

--- план прост, если что-то не так, то мы просто убиваем бехавиор (по крайней мере так должно было быть, но пиаш мне запретил :sob:)
function behavior:checkStats()
    -- if self.hp <= 0 then behavior:die() end
    if self.hp <= 0 then
        self.amIAlive = false
    end
end

--- @param damage integer
function behavior:dealDamage(damage)
    self.hp = self.hp - damage
    self:checkStats()
end

--- @param hp? integer
--- @param mana? integer
--- @param initiative? integer
--- @param class? Class
--- @param isInTurnOrder? boolean
function behavior.new(hp, mana, initiative, class, isInTurnOrder)
    return setmetatable({
        hp = hp or 20,
        mana = mana or 10,
        initiative = initiative or 10,
        class = class or "dev_warrior",
        isInTurnOrder = isInTurnOrder or true,
    }, behavior)
end

return behavior
