summaryrefslogtreecommitdiff
path: root/www/js/imachine.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/imachine.js')
-rw-r--r--www/js/imachine.js66
1 files changed, 66 insertions, 0 deletions
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;
+ }
+ };
+}());