From 182fb2db03e5c4bfd1ca42e9d32aa162abad6e68 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sat, 29 Jun 2013 13:20:49 -0400 Subject: do stuff --- www/js/imachine.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 www/js/imachine.js (limited to 'www/js/imachine.js') diff --git a/www/js/imachine.js b/www/js/imachine.js new file mode 100644 index 0000000..fd657ef --- /dev/null +++ b/www/js/imachine.js @@ -0,0 +1,66 @@ +html5ks.imachine = (function () { + "use strict"; + return { + start: function () { + return this.run("imachine"); + }, + run: function (label) { + var deferred = when.defer(), + ilabel = html5ks.data.imachine[label], + i = 0, + runInst = function () { + var inst = ilabel[i++]; + console.log(inst); + switch (typeof inst) { + case "undefined": + break; + case "string": // jump_out + this.run(inst); + break; + case "object": + switch (inst[0]) { + case "iscene": + case "act_op": + switch (inst[1]) { + case "op_vid1": + html5ks.api.movie_cutscene("op_1").then(runInst); + break; + default: + html5ks.api[inst[0]](inst[1]).then(runInst); + } + break; + case "seen_scene": + if (this.seen_scene(inst[1])) { + runInst(inst[2]); + } else { + runInst(inst[3]); + } + break; + case "attraction_sc": + case "attraction_hanako": + case "attraction_kenji": + if (typeof inst[1] === "number") { + if (html5ks.persistent.store[inst[0]] > inst[1]) { + runInst(inst[3]); + } else { + runInst(inst[4]); + } + } else { + html5ks.persistent.store[inst[0]]++; + } + break; + case "path_end": + // TODO: disp vid + deferred.resolve(); + break; + default: + console.error("unknown imachine inst"); + console.error(inst); + } + } + }.bind(this); + runInst(); + return deferred.promise; + } + }; +}()); -- cgit v1.2.3-54-g00ecf