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:
|
if self.hugvey.recorder:
|
||||||
self.hugvey.recorder.updateTranscription(self.currentReply.getText())
|
self.hugvey.recorder.updateTranscription(self.currentReply.getText())
|
||||||
|
|
||||||
|
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))
|
||||||
|
direction.setMetCondition(condition)
|
||||||
|
return condition
|
||||||
|
return None
|
||||||
|
|
||||||
async def _processDirections(self, directions):
|
async def _processDirections(self, directions):
|
||||||
':type directions: list(Direction)'
|
':type directions: list(Direction)'
|
||||||
chosenDirection = None
|
chosenDirection = None
|
||||||
metCondition = None
|
metCondition = None
|
||||||
for direction in directions:
|
for direction in directions:
|
||||||
for condition in direction.conditions:
|
condition = self._processDirection(direction)
|
||||||
if condition.isMet(self):
|
if not condition:
|
||||||
self.logger.info("Condition is met: {0} ({2}), going to {1}".format(
|
continue
|
||||||
condition.id, direction.msgTo.id, condition.type))
|
self.addToLog(condition)
|
||||||
self.hugvey.eventLogger.info("condition: {0}".format(condition.id))
|
self.addToLog(direction)
|
||||||
self.hugvey.eventLogger.info("direction: {0}".format(direction.id))
|
self.currentMessage.setFinished(self.timer.getElapsed())
|
||||||
metCondition = condition
|
chosenDirection = direction
|
||||||
direction.setMetCondition(condition)
|
metCondition = condition
|
||||||
self.addToLog(condition)
|
break
|
||||||
self.addToLog(direction)
|
|
||||||
self.currentMessage.setFinished(self.timer.getElapsed())
|
|
||||||
chosenDirection = direction
|
|
||||||
|
|
||||||
isDiverging = await self._processDiversions(chosenDirection)
|
isDiverging = await self._processDiversions(chosenDirection)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue