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