(scene)
| 68 | const sequence = [] |
| 69 | |
| 70 | function addSceneToSequence (scene) { |
| 71 | if (type.isArray(scene)) { |
| 72 | scene.forEach(function (s) { addSceneToSequence(s) }) |
| 73 | } |
| 74 | |
| 75 | if (type.isString(scene)) { |
| 76 | let partials = scene.split(':') |
| 77 | |
| 78 | let actorName |
| 79 | if (partials.length > 1 && partials[0].charAt(partials[0].length - 1) !== '\\') { |
| 80 | actorName = partials.shift() |
| 81 | |
| 82 | addSceneToSequence({ name: 'erase', actor: actorName }) |
| 83 | } |
| 84 | |
| 85 | let speech = partials.join(':').replace(/\\:/g, ':') |
| 86 | let sceneObj = { name: 'type', args: [speech] } |
| 87 | |
| 88 | if (actorName != null) { |
| 89 | sceneObj.actor = actorName |
| 90 | } |
| 91 | |
| 92 | addSceneToSequence(sceneObj) |
| 93 | } |
| 94 | |
| 95 | if (type.isFunction(scene)) { |
| 96 | addSceneToSequence({ name: 'callback', args: [scene] }) |
| 97 | } |
| 98 | |
| 99 | if (type.isNumber(scene)) { |
| 100 | if (scene > 0) { |
| 101 | addSceneToSequence({ name: 'wait', args: [scene] }) |
| 102 | } else { |
| 103 | addSceneToSequence({ name: 'erase', args: [scene] }) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if (type.isObject(scene)) { |
| 108 | if (!type.isArray(scene.args)) { |
| 109 | scene.args = [] |
| 110 | } |
| 111 | |
| 112 | scene.args.unshift(function () { |
| 113 | publish(`${scene.name}:end`, scene) |
| 114 | playNextScene() |
| 115 | }) |
| 116 | |
| 117 | sequence.push(scene) |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | addSceneToSequence([{ name: 'publisher', args: ['sequence:start'] }].concat(scenes).concat({ name: 'publisher', args: ['sequence:end'] })) |
| 122 | Array.prototype.push.apply(props.scenario, sequence) |
no test coverage detected