-- Health potion: restore health local BaseSkill = require("skills.base") local Skill = {} Skill.__index = Skill setmetatable(Skill, { __index = BaseSkill }) function Skill:new(asset, combatant) self = setmetatable(BaseSkill:new(asset, combatant), Skill) self.duration = 0.4 self.used = false return self end function Skill:update(dt) self.timer = self.timer + dt if not self.used then self.used = true local actualHeal = math.min(self.power or 1, self.combatant.maxHealth - self.combatant.health) self.combatant:heal(actualHeal) Sound.play("potion") end if self.timer >= self.duration then return true end return false end function Skill:draw() local alpha = 1 - (self.timer / self.duration) local ex = self.combatant.x + self.combatant.width / 2 local ey = self.combatant.y + self.combatant.height / 2 love.graphics.setColor(0.2, 0.8, 0.2, alpha * 0.6) love.graphics.circle("fill", ex, ey, 16 + self.timer * 20) love.graphics.setColor(1, 1, 1, 1) end return Skill