From 7fdfc74e98a386adcb97c4934ce0fd15002b1dde Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 2 Jun 2016 22:45:28 -0700 Subject: [PATCH] Fix Bug #134 - Issue with Limiting Fire in Hunger Baubles --- SBA_Serv/World/Messaging.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SBA_Serv/World/Messaging.py b/SBA_Serv/World/Messaging.py index 690628c..9fd07ff 100644 --- a/SBA_Serv/World/Messaging.py +++ b/SBA_Serv/World/Messaging.py @@ -92,22 +92,26 @@ def __repr__(self): class OneTimeCommand(Command): def __init__(self, obj, msg, executefirst=False, ttl=4, required=0): super(OneTimeCommand, self).__init__(obj, msg, ttl, block=True, required=required) + self.__pre_execute = executefirst self.__executed = False self.__done = False - if executefirst: - self.__executed = True - self.onetime() def isComplete(self): return self.__done and self.__executed def isExpired(self): self.__done = super(OneTimeCommand, self).isExpired() - if not self.__executed: + # execute when expiring if tail end + if self.__done and not self.__executed: self.__executed = True self.onetime() def execute(self, t): + # check if execute now if front end + if not self.__executed and self.__pre_execute: + self.__executed = True + self.onetime() + self.isExpired() def onetime(self):