Fixed Cooldowns Bug
This commit is contained in:
parent
e7d9ecb273
commit
bbe77195ac
31
cooldowns.py
31
cooldowns.py
@ -38,12 +38,12 @@ class Cooldowns_Module:
|
|||||||
if len(self.actionList) >= self.coolDownActionLimit:
|
if len(self.actionList) >= self.coolDownActionLimit:
|
||||||
actionCount = len(self.actionList)
|
actionCount = len(self.actionList)
|
||||||
|
|
||||||
maxTmpIndex = actionCount - self.coolDownActionLimit - 1
|
maxTmpIndex = actionCount - self.coolDownActionLimit
|
||||||
maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex]
|
maxRecentAction:Cooldown_Action = self.actionList[maxTmpIndex]
|
||||||
|
|
||||||
timeDiff = timenow - maxRecentAction.time
|
timeDiff = timenow - maxRecentAction.time
|
||||||
|
|
||||||
maxTimeAllowed = timedelta(seconds = self.coolDownDuration)
|
maxTimeAllowed = timedelta(seconds = self.coolDownDuration)
|
||||||
|
|
||||||
if timeDiff < maxTimeAllowed:
|
if timeDiff < maxTimeAllowed:
|
||||||
isCoolDownActivated = True
|
isCoolDownActivated = True
|
||||||
|
|
||||||
@ -56,22 +56,35 @@ class Cooldowns_Module:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
testCD = Cooldowns_Module()
|
testCD = Cooldowns_Module()
|
||||||
testCD.setupCooldown("test", 20, 5)
|
testCD.setupCooldown("test", 20, 2)
|
||||||
|
|
||||||
print("CD Test 1: ")
|
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):
|
for x in range(10):
|
||||||
testCD.actionTrigger()
|
testCD.actionTrigger()
|
||||||
sleep(0)
|
sleep(0)
|
||||||
print(testCD.isCooldownActive())
|
print(testCD.isCooldownActive())
|
||||||
|
print("//Test Done//")
|
||||||
print("CD Test 2: ")
|
sleep(2)
|
||||||
for x in range(21):
|
|
||||||
testCD.actionTrigger()
|
|
||||||
sleep(0.05)
|
|
||||||
print(testCD.isCooldownActive())
|
|
||||||
|
|
||||||
print("CD Test 3: ")
|
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):
|
for x in range(20):
|
||||||
testCD.actionTrigger()
|
testCD.actionTrigger()
|
||||||
sleep(0.6)
|
sleep(0.6)
|
||||||
print(testCD.isCooldownActive())
|
print(testCD.isCooldownActive())
|
||||||
|
print("//Test Done//")
|
||||||
Loading…
Reference in New Issue
Block a user