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 # ignore the direction argument, and only check if the current message has a valid default
return return
msgTo = direction.msgTo
if not direction:
return
waitTime = 1.8 if 'waitTime' not in self.params else float(self.params['waitTime']) waitTime = 1.8 if 'waitTime' not in self.params else float(self.params['waitTime'])
timeSince = story.currentReply.getTimeSinceLastUtterance() timeSince = story.currentReply.getTimeSinceLastUtterance()
if timeSince < waitTime: if timeSince < waitTime:
@ -801,11 +796,18 @@ class Diversion(object):
story.logger.critical(f"Not a valid message id for diversion: {self.params['msgId']}") story.logger.critical(f"Not a valid message id for diversion: {self.params['msgId']}")
return 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 self.returnMessage = msgTo
if self.params['returnAfterStrand']: if self.params['returnAfterStrand']:
self.createReturnDirectionsTo(story, msg, msgTo, direction) self.createReturnDirectionsTo(story, msg, msgTo, direction, inheritTiming=returnInheritTiming)
await story.setCurrentMessage(msg) await story.setCurrentMessage(msg)
story.currentDiversion = self story.currentDiversion = self

View File

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