from siege import game


class Poison(object):
    NAME = "Poison"
    ICON = "mods/core/effect/poison.png"

    def __init__(self, owner, level, duration):
        #tick is 3s if poison lasts for 24 seconds then that is 25% life
        hp = owner.stats.HP
        hpRegen = owner.stats.HPRegen
        self.adjustment = -hp.getMax() / (34 - level * 2)
        hpRegen.adjust(self.adjustment)

    def onRemove(self, owner):
        hpRegen = owner.stats.HPRegen
        hpRegen.adjust(-self.adjustment)

    def update(self, frameTime, owner):
        #Reset combat time so the player doesn't get out of combat health regen
        if owner.has("combat"):
            owner.combat.timeSinceCombat = 0
        return True

    def isPositive(self):
        return False

    @staticmethod
    def register():
        game.effects.register(Poison.NAME, Poison)
