Fixed Cooldowns Bug

This commit is contained in:
Alex Orid 2020-10-15 02:48:26 -04:00
parent e7d9ecb273
commit bbe77195ac

View File

@ -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())
print("//Test Done//")