diff --git a/cooldowns.py b/cooldowns.py index abbd5be..3b2647c 100644 --- a/cooldowns.py +++ b/cooldowns.py @@ -38,12 +38,12 @@ class Cooldowns_Module: if len(self.actionList) >= self.coolDownActionLimit: actionCount = len(self.actionList) - maxTmpIndex = actionCount - self.coolDownActionLimit - 1 + maxTmpIndex = actionCount - self.coolDownActionLimit maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex] timeDiff = timenow - maxRecentAction.time - maxTimeAllowed = timedelta(seconds = self.coolDownDuration) + if timeDiff < maxTimeAllowed: isCoolDownActivated = True @@ -56,22 +56,35 @@ class Cooldowns_Module: if __name__ == "__main__": testCD = Cooldowns_Module() - testCD.setupCooldown("test", 20, 5) + testCD.setupCooldown("test", 20, 2) print("CD Test 1: ") + for x in range(20): + testCD.actionTrigger() + sleep(0) + print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) + + print("CD Test 2: ") for x in range(10): testCD.actionTrigger() sleep(0) print(testCD.isCooldownActive()) - - print("CD Test 2: ") - for x in range(21): - testCD.actionTrigger() - sleep(0.05) - print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) print("CD Test 3: ") + for x in range(20): + testCD.actionTrigger() + sleep(0.05) + print(testCD.isCooldownActive()) + print("//Test Done//") + sleep(2) + + print("CD Test 4: ") for x in range(20): testCD.actionTrigger() sleep(0.6) - print(testCD.isCooldownActive()) \ No newline at end of file + print(testCD.isCooldownActive()) + print("//Test Done//") \ No newline at end of file