Reply_contains diversion now can move to next chapter on finish

This commit is contained in:
Ruben van de Ven 2019-06-09 11:34:41 +02:00
parent 0bd9e80429
commit 87c7db2489
2 changed files with 23 additions and 8 deletions

View file

@ -773,11 +773,6 @@ class Diversion(object):
# ignore the direction argument, and only check if the current message has a valid default
return
msgTo = direction.msgTo
if not direction:
return
waitTime = 1.8 if 'waitTime' not in self.params else float(self.params['waitTime'])
timeSince = story.currentReply.getTimeSinceLastUtterance()
if timeSince < waitTime:
@ -801,11 +796,18 @@ class Diversion(object):
story.logger.critical(f"Not a valid message id for diversion: {self.params['msgId']}")
return
# TODO: pick the direction with timeout as next Message.
if 'nextChapterOnReturn' in self.params and self.params['nextChapterOnReturn']:
msgTo = story.getNextChapterForMsg(story.currentMessage, False) or direction.msgTo
returnInheritTiming = False
else:
msgTo = direction.msgTo
returnInheritTiming = True
self.returnMessage = msgTo
if self.params['returnAfterStrand']:
self.createReturnDirectionsTo(story, msg, msgTo, direction)
self.createReturnDirectionsTo(story, msg, msgTo, direction, inheritTiming=returnInheritTiming)
await story.setCurrentMessage(msg)
story.currentDiversion = self

View file

@ -393,6 +393,7 @@ class Graph {
else if(type == 'reply_contains') {
div['params']['regex'] = "";
div['params']['returnAfterStrand'] = true;
div['params']['nextChapterOnReturn'] = false;
div['params']['msgId'] = "";
div['params']['notForColor'] = "";
div['params']['waitTime'] = 1.8;
@ -540,6 +541,15 @@ class Graph {
if(div['params']['returnAfterStrand']) {
returnAttrs['checked'] = 'checked';
}
let returnChapterAttrs = {
'type': 'checkbox',
'on': {
'change': (e) => div['params']['nextChapterOnReturn'] = e.target.checked
}
}
if(div['params']['nextChapterOnReturn']) {
returnChapterAttrs['checked'] = 'checked';
}
let msgOptions = [crel('option',"")];
let starts = this.messages.filter( m => m.hasOwnProperty('start') && m['start'] == true);
for(let startMsg of starts) {
@ -599,6 +609,9 @@ class Graph {
crel('label', 'Return to point of departure afterwards',
crel('input', returnAttrs)
),
crel('label', 'On return, skip to next chapter',
crel('input', returnChapterAttrs)
),
crel('label', 'Go to (start message)',
crel('select', {'on': {
'change': (e) => div['params']['msgId'] = e.target.value