From bbe77195ac5251e6d400f6a5a3e834e5d7a939f5 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Oct 2020 02:48:26 -0400 Subject: [PATCH] Fixed Cooldowns Bug --- cooldowns.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) 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