Fix bug that caused diversions with the same message to launch people back in their timeline

This commit is contained in:
Ruben van de Ven 2019-06-16 19:42:59 +02:00
parent be26add0c1
commit dbcff93237

View file

@ -549,6 +549,7 @@ class Direction(object):
self.conditions = [] self.conditions = []
self.conditionMet = None self.conditionMet = None
self.isDiversionReturn = False self.isDiversionReturn = False
self.diversionHasReturned = False # for isDiversionReturn.
def __getstate__(self): def __getstate__(self):
@ -1438,6 +1439,12 @@ class Story(object):
chosenDirection = None chosenDirection = None
metCondition = None metCondition = None
for direction in directions: for direction in directions:
if direction.isDiversionReturn and direction.diversionHasReturned:
# Prevent that returns created from the same message send you
# back to a previous point in time.
# self.logger.warn("Skipping double direction for diversion")
continue
condition = self._processDirection(direction) condition = self._processDirection(direction)
if not condition: if not condition:
continue continue
@ -1461,6 +1468,7 @@ class Story(object):
if not isDiverging and chosenDirection: if not isDiverging and chosenDirection:
if chosenDirection.isDiversionReturn and self.currentDiversion: if chosenDirection.isDiversionReturn and self.currentDiversion:
chosenDirection.diversionHasReturned = True
await self.currentDiversion.finalise(self) await self.currentDiversion.finalise(self)
await self.setCurrentMessage(chosenDirection.msgTo, allowReplyInterrupt=allowReplyInterrupt) await self.setCurrentMessage(chosenDirection.msgTo, allowReplyInterrupt=allowReplyInterrupt)