from core.tuning.skill import SkillTuning
from siege import game


class RapidShot(object):
    NAME = "RapidShot"
    ICON = SkillTuning.RAPID_SHOT.ICON

    def __init__(self, owner, level, duration):
        self.level = level
        owner.event["use_delay"].listen(self.handleUseDelay)

    def onRemove(self, owner):
        owner.event["use_delay"].remove(self.handleUseDelay)

    def handleUseDelay(self, item, delay):
        if item.weapon.category == "Bow":
            delay.final -= int(delay.start * ((15.0 + self.level * 5.0) / 100.0))

    def isPositive(self):
        return False

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