Running only one condition until it matches. And go for that one
This commit is contained in:
parent
9fded4fd22
commit
b25d7dd6d5
1 changed files with 23 additions and 12 deletions
|
@ -1394,24 +1394,35 @@ class Story(object):
|
|||
if self.hugvey.recorder:
|
||||
self.hugvey.recorder.updateTranscription(self.currentReply.getText())
|
||||
|
||||
|
||||
async def _processDirections(self, directions):
|
||||
':type directions: list(Direction)'
|
||||
chosenDirection = None
|
||||
metCondition = None
|
||||
for direction in directions:
|
||||
def _processDirection(self, direction):
|
||||
"""
|
||||
return matching condition
|
||||
"""
|
||||
for condition in direction.conditions:
|
||||
if condition.isMet(self):
|
||||
self.logger.info("Condition is met: {0} ({2}), going to {1}".format(
|
||||
condition.id, direction.msgTo.id, condition.type))
|
||||
self.hugvey.eventLogger.info("condition: {0}".format(condition.id))
|
||||
self.hugvey.eventLogger.info("direction: {0}".format(direction.id))
|
||||
metCondition = condition
|
||||
direction.setMetCondition(condition)
|
||||
return condition
|
||||
return None
|
||||
|
||||
async def _processDirections(self, directions):
|
||||
':type directions: list(Direction)'
|
||||
chosenDirection = None
|
||||
metCondition = None
|
||||
for direction in directions:
|
||||
condition = self._processDirection(direction)
|
||||
if not condition:
|
||||
continue
|
||||
self.addToLog(condition)
|
||||
self.addToLog(direction)
|
||||
self.currentMessage.setFinished(self.timer.getElapsed())
|
||||
chosenDirection = direction
|
||||
metCondition = condition
|
||||
break
|
||||
|
||||
|
||||
isDiverging = await self._processDiversions(chosenDirection)
|
||||
|
||||
|
|
Loading…
Reference in a new issue