/* Generated by Opal 0.8.0 */ Opal.modules["gamefic/core_ext/array"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; Opal.add_stubs(['$kind_of?', '$delete_if', '$==', '$clone', '$send', '$include?', '$new', '$[]', '$rand', '$length', '$delete_at', '$sort', '$<=>', '$sort!', '$join', '$last', '$strip', '$join_and']); return (function($base, $super) { function $Array(){}; var self = $Array = $klass($base, $super, 'Array', $Array); var def = self.$$proto, $scope = self.$$scope; def.$that_are = function(cls) { var $a, $b, TMP_1, $c, TMP_2, self = this; if ((($a = (((($b = cls['$kind_of?']($scope.get('Class'))) !== false && $b !== nil) ? $b : cls['$kind_of?']($scope.get('Module'))))) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = ($b = self.$clone()).$delete_if, $a.$$p = (TMP_1 = function(i){var self = TMP_1.$$s || this; if (i == null) i = nil; return i['$kind_of?'](cls)['$=='](false)}, TMP_1.$$s = self, TMP_1), $a).call($b) } else if ((($a = cls['$kind_of?']($scope.get('Symbol'))) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = ($c = self.$clone()).$delete_if, $a.$$p = (TMP_2 = function(i){var self = TMP_2.$$s || this; if (i == null) i = nil; return i.$send(cls)['$=='](false)}, TMP_2.$$s = self, TMP_2), $a).call($c) } else { if ((($a = self['$include?'](cls)) !== nil && (!$a.$$is_boolean || $a == true))) { return [cls]}; return $scope.get('Array').$new(); }; }; def.$that_are_not = function(cls) { var $a, $b, TMP_3, $c, TMP_4, self = this; if ((($a = (((($b = cls['$kind_of?']($scope.get('Class'))) !== false && $b !== nil) ? $b : cls['$kind_of?']($scope.get('Module'))))) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = ($b = self.$clone()).$delete_if, $a.$$p = (TMP_3 = function(i){var self = TMP_3.$$s || this; if (i == null) i = nil; return i['$kind_of?'](cls)['$=='](true)}, TMP_3.$$s = self, TMP_3), $a).call($b) } else if ((($a = cls['$kind_of?']($scope.get('Symbol'))) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = ($c = self.$clone()).$delete_if, $a.$$p = (TMP_4 = function(i){var self = TMP_4.$$s || this; if (i == null) i = nil; return i.$send(cls)['$=='](true)}, TMP_4.$$s = self, TMP_4), $a).call($c) } else { return $rb_minus(self.$clone(), [cls]) }; }; def.$random = function() { var self = this; return self['$[]'](self.$rand(self.$length())); }; def.$pop_random = function() { var self = this; return self.$delete_at(self.$rand(self.$length())); }; def.$shuffle = function() { var $a, $b, TMP_5, self = this; return ($a = ($b = self).$sort, $a.$$p = (TMP_5 = function(a, b){var self = TMP_5.$$s || this; if (a == null) a = nil;if (b == null) b = nil; return self.$rand(3)['$<=>'](self.$rand(3))}, TMP_5.$$s = self, TMP_5), $a).call($b); }; def['$shuffle!'] = function() { var $a, $b, TMP_6, self = this; return ($a = ($b = self)['$sort!'], $a.$$p = (TMP_6 = function(a, b){var self = TMP_6.$$s || this; if (a == null) a = nil;if (b == null) b = nil; return self.$rand(3)['$<=>'](self.$rand(3))}, TMP_6.$$s = self, TMP_6), $a).call($b); }; def.$join_and = function(sep, andSep, serial) { var self = this, start = nil; if (sep == null) { sep = ", " } if (andSep == null) { andSep = " and " } if (serial == null) { serial = true } if ($rb_lt(self.$length(), 3)) { return self.$join(andSep) } else { start = $rb_minus(self, [self.$last()]); return $rb_plus(start.$join(sep), "" + ((function() {if (serial !== false && serial !== nil) { return sep.$strip() } else { return "" }; return nil; })()) + (andSep) + (self.$last())); }; }; return (def.$join_or = function(sep, orSep, serial) { var self = this; if (sep == null) { sep = ", " } if (orSep == null) { orSep = " or " } if (serial == null) { serial = true } return self.$join_and(sep, orSep, serial); }, nil) && 'join_or'; })(self, null) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/core_ext/string"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; Opal.add_stubs(['$upcase', '$[]', '$length', '$capitalize_first', '$split', '$strip', '$gsub']); return (function($base, $super) { function $String(){}; var self = $String = $klass($base, $super, 'String', $String); var def = self.$$proto, $scope = self.$$scope; def.$capitalize_first = function() { var self = this; return "" + (self['$[]'](0, 1).$upcase()) + (self['$[]'](1, self.$length())); }; def.$cap_first = function() { var self = this; return self.$capitalize_first(); }; return (def.$split_words = function() { var self = this; return self.$gsub(/ +/, " ").$strip().$split(); }, nil) && 'split_words'; })(self, null) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/keywords"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$kind_of?', '$concat', '$join', '$split', '$downcase', '$strip', '$gsub', '$to_s', '$uniq!', '$each', '$include?', '$length', '$==', '$[]', '$to_f']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Keywords(){}; var self = $Keywords = $klass($base, $super, 'Keywords', $Keywords); var def = self.$$proto, $scope = self.$$scope; def.$initialize = function(statement) { var $a, self = this; if (statement == null) { statement = "" } if ((($a = statement['$kind_of?']($scope.get('Keywords'))) !== nil && (!$a.$$is_boolean || $a == true))) { self.$concat(statement) } else { if ((($a = statement['$kind_of?']($scope.get('Array'))) !== nil && (!$a.$$is_boolean || $a == true))) { statement = statement.$join(" ")}; self.$concat(statement.$to_s().$gsub(/[^a-z0-9]/i, " ").$strip().$downcase().$split(" ")); }; return self['$uniq!'](); }; def.$found_in = function(other) { var $a, $b, TMP_1, self = this, matches = nil; matches = 0.0; ($a = ($b = self).$each, $a.$$p = (TMP_1 = function(my_word){var self = TMP_1.$$s || this, $a, $b, TMP_2; if (my_word == null) my_word = nil; if ((($a = (other['$include?'](my_word))) !== nil && (!$a.$$is_boolean || $a == true))) { return matches = $rb_plus(matches, 1.0) } else { return ($a = ($b = other).$each, $a.$$p = (TMP_2 = function(other_word){var self = TMP_2.$$s || this; if (other_word == null) other_word = nil; if ($rb_lt(my_word.$length(), other_word.$length())) { if (other_word['$[]'](0, my_word.$length())['$=='](my_word)) { return matches = $rb_plus(matches, ($rb_divide(my_word.$length().$to_f(), other_word.$length().$to_f()))) } else { return nil } } else { return nil }}, TMP_2.$$s = self, TMP_2), $a).call($b) }}, TMP_1.$$s = self, TMP_1), $a).call($b); return matches; }; return (def.$to_s = function() { var self = this; return self.$join(" "); }, nil) && 'to_s'; })(self, $scope.get('Array')) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/serialized"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $hash2 = Opal.hash2; Opal.add_stubs(['$keys', '$serializer', '$class', '$each', '$[]=', '$dup', '$from_superclass', '$private', '$respond_to?', '$superclass', '$send', '$extend']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Serialized'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$serialized_attributes', function() { var self = this; return self.$class().$serializer().$keys(); }); (function($base) { var self = $module($base, 'ClassMethods'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$serialize', function(args) { var $a, $b, TMP_1, self = this; args = $slice.call(arguments, 0); return ($a = ($b = args).$each, $a.$$p = (TMP_1 = function(a){var self = TMP_1.$$s || this; if (a == null) a = nil; return self.$serializer()['$[]='](a, nil)}, TMP_1.$$s = self, TMP_1), $a).call($b); }); Opal.defn(self, '$serializer', function() { var $a, $b, self = this; return ((($a = (($b = Opal.cvars['@@serialized_attributes']) == null ? nil : $b)) !== false && $a !== nil) ? $a : (Opal.cvars['@@serialized_attributes'] = self.$from_superclass("serializer", $hash2([], {})).$dup())); }); self.$private(); Opal.defn(self, '$from_superclass', function(m, default$) { var $a, self = this; if (default$ == null) { default$ = nil } if ((($a = self.$superclass()['$respond_to?'](m)) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$superclass().$send(m) } else { return default$ }; }); })(self); Opal.defs(self, '$included', function(base) { var self = this; return base.$extend($scope.get('ClassMethods')); }); })(self) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/node"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module; Opal.add_stubs(['$==', '$new', '$clone', '$each', '$recurse_flatten', '$children', '$raise', '$!', '$parent', '$parent=', '$include?', '$flatten', '$send', '$protected', '$push', '$delete', '$concat', '$private']); (function($base, $super) { function $CircularNodeReferenceError(){}; var self = $CircularNodeReferenceError = $klass($base, $super, 'CircularNodeReferenceError', $CircularNodeReferenceError); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Exception')); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Node'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$children', function() { var self = this; if (self.children == null) self.children = nil; if (self.children['$=='](nil)) { self.children = $scope.get('Array').$new()}; return self.children.$clone(); }); Opal.defn(self, '$flatten', function() { var $a, $b, TMP_1, self = this, array = nil; array = $scope.get('Array').$new(); ($a = ($b = self.$children()).$each, $a.$$p = (TMP_1 = function(child){var self = TMP_1.$$s || this; if (child == null) child = nil; return array = $rb_plus(array, self.$recurse_flatten(child))}, TMP_1.$$s = self, TMP_1), $a).call($b); return array; }); Opal.defn(self, '$parent', function() { var self = this; if (self.parent == null) self.parent = nil; return self.parent; }); Opal.defn(self, '$parent=', function(node) { var $a, $b, self = this; if (self.parent == null) self.parent = nil; if (node['$=='](self.parent)) { return nil}; if (node['$=='](self)) { self.$raise($scope.get('CircularNodeReferenceError').$new("Node cannot be its own parent"))}; if ((($a = ($b = node['$=='](nil)['$!'](), $b !== false && $b !== nil ?node.$parent()['$=='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { (($a = [nil]), $b = node, $b['$parent='].apply($b, $a), $a[$a.length-1])}; if ((($a = ($b = node['$=='](nil)['$!'](), $b !== false && $b !== nil ?self.$flatten()['$include?'](node) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise($scope.get('CircularNodeReferenceError').$new("Node cannot be a child of a descendant"))}; if ((($a = self.parent['$=='](node)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = self.parent['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.parent.$send("rem_child", self)}; self.parent = node; if ((($a = self.parent['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.parent.$send("add_child", self) } else { return nil }; } else { return nil }; }); self.$protected(); Opal.defn(self, '$add_child', function(node) { var self = this; if (self.children == null) self.children = nil; self.$children(); return self.children.$push(node); }); Opal.defn(self, '$rem_child', function(node) { var self = this; if (self.children == null) self.children = nil; self.$children(); return self.children.$delete(node); }); Opal.defn(self, '$concat_children', function(children) { var self = this; return children.$concat(children); }); self.$private(); Opal.defn(self, '$recurse_flatten', function(node) { var $a, $b, TMP_2, self = this, array = nil; array = $scope.get('Array').$new(); array.$push(node); ($a = ($b = node.$children()).$each, $a.$$p = (TMP_2 = function(child){var self = TMP_2.$$s || this; if (child == null) child = nil; return array = $rb_plus(array, self.$recurse_flatten(child))}, TMP_2.$$s = self, TMP_2), $a).call($b); return array; }); })(self) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/describable"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $range = Opal.range, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$attr_reader', '$attr_accessor', '$attr_writer', '$new', '$name', '$synonyms', '$proper_named?', '$==', '$indefinite_article', '$definite_article', '$!', '$split_words', '$include?', '$downcase', '$[]', '$strip', '$length', '$to_s', '$%', '$default_description', '$definitely', '$capitalize_first', '$indefinitely']); self.$require("gamefic/keywords"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Describable'); var def = self.$$proto, $scope = self.$$scope; self.$attr_reader("name"); self.$attr_accessor("synonyms", "indefinite_article"); self.$attr_writer("definite_article"); Opal.defn(self, '$keywords', function() { var self = this; return $scope.get('Keywords').$new("" + (self.$name()) + " " + (self.$synonyms())); }); Opal.defn(self, '$indefinitely', function() { var $a, $b, self = this; return $rb_plus(((function() {if ((($a = (((($b = self['$proper_named?']()) !== false && $b !== nil) ? $b : self.$indefinite_article()['$==']("")))) !== nil && (!$a.$$is_boolean || $a == true))) { return "" } else { return "" + (self.$indefinite_article()) + " " }; return nil; })()), self.$name()); }); Opal.defn(self, '$definitely', function() { var $a, $b, self = this; return $rb_plus(((function() {if ((($a = (((($b = self['$proper_named?']()) !== false && $b !== nil) ? $b : self.$definite_article()['$==']("")))) !== nil && (!$a.$$is_boolean || $a == true))) { return "" } else { return "" + (self.$definite_article()) + " " }; return nil; })()), self.$name()); }); Opal.defn(self, '$definite_article', function() { var $a, self = this; if (self.definite_article == null) self.definite_article = nil; return ((($a = self.definite_article) !== false && $a !== nil) ? $a : "the"); }); Opal.defn(self, '$proper_named?', function() { var self = this; if (self.proper_named == null) self.proper_named = nil; return (self.proper_named['$=='](true)); }); Opal.defn(self, '$proper_named=', function(value) { var $a, self = this; if (self.definite_article == null) self.definite_article = nil; if (self.name == null) self.name = nil; if (value['$=='](true)) { if ((($a = self.definite_article['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.name = "" + (self.definite_article) + " " + (self.name); self.definite_article = nil;}}; return self.proper_named = value; }); Opal.defn(self, '$name=', function(value) { var $a, self = this, words = nil; words = value.$split_words(); if ((($a = ["a", "an"]['$include?'](words['$[]'](0).$downcase())) !== nil && (!$a.$$is_boolean || $a == true))) { self.indefinite_article = words['$[]'](0).$downcase(); self.definite_article = "the"; value = value['$[]']($range($rb_plus(words['$[]'](0).$length(), 1), -1, false)).$strip(); } else { if (words['$[]'](0).$downcase()['$==']("the")) { if ((($a = self['$proper_named?']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.definite_article = nil } else { self.definite_article = "the"; value = value['$[]']($range(4, -1, false)).$strip(); }}; if ((($a = ["a", "e", "i", "o", "u"]['$include?'](value['$[]'](0, 1).$downcase())) !== nil && (!$a.$$is_boolean || $a == true))) { self.indefinite_article = "an" } else { self.indefinite_article = "a" }; }; return self.name = value; }); Opal.defn(self, '$has_description?', function() { var self = this; if (self.description == null) self.description = nil; return (self.description.$to_s()['$==']("")['$!']()); }); Opal.defn(self, '$description', function() { var $a, self = this; if (self.description == null) self.description = nil; return ((($a = self.description) !== false && $a !== nil) ? $a : ($scope.get('Describable').$default_description()['$%']($hash2(["name", "Name"], {"name": self.$definitely(), "Name": self.$definitely().$capitalize_first()})))); }); Opal.defn(self, '$description=', function(text) { var $a, self = this; if ((($a = text['$=='](($scope.get('Describable').$default_description()['$%']($hash2(["name", "Name"], {"name": self.$definitely(), "Name": self.$definitely().$capitalize_first()}))))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.description = text } else { return self.description = nil }; }); Opal.defs(self, '$default_description=', function(text) { var self = this; return self.default_description = text; }); Opal.defs(self, '$default_description', function() { var $a, self = this; if (self.default_description == null) self.default_description = nil; return ((($a = self.default_description) !== false && $a !== nil) ? $a : "There's nothing special about %{name}."); }); Opal.defn(self, '$to_s', function() { var self = this; return self.$indefinitely(); }); })(self) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/stage"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $hash2 = Opal.hash2; Opal.add_stubs(['$generate_stage', '$nil?', '$module_eval', '$module_exec', '$to_proc', '$private', '$!', '$keys', '$exposed_methods', '$class', '$mounted_modules', '$new', '$define_singleton_method', '$==', '$length', '$caller', '$include?', '$[]', '$raise', '$each', '$public_send', '$__instance__', '$public_instance_methods', '$include', '$[]=', '$dup', '$from_superclass', '$respond_to?', '$superclass', '$send', '$extend']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Stage'); var def = self.$$proto, $scope = self.$$scope, TMP_1; Opal.defn(self, '$stage', TMP_1 = function(args) { var $a, $b, $c, self = this, $iter = TMP_1.$$p, block = $iter || nil, s = nil; args = $slice.call(arguments, 0); TMP_1.$$p = null; s = self.$generate_stage(); if ((($a = block['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = s).$module_eval.apply($a, [].concat(args)) } else { return ($b = ($c = s).$module_exec, $b.$$p = block.$to_proc(), $b).apply($c, [].concat(args)) }; }); self.$private(); Opal.defn(self, '$generate_stage', function() { var $a, $b, TMP_2, self = this, exposed = nil, mounted = nil, instance = nil, stage_module = nil; if (self.stage == null) self.stage = nil; if ((($a = self.stage['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.stage}; exposed = self.$class().$exposed_methods().$keys(); mounted = self.$class().$mounted_modules().$keys(); instance = self; self.stage = stage_module = ($a = ($b = $scope.get('Module')).$new, $a.$$p = (TMP_2 = function(){var self = TMP_2.$$s || this, $a, $b, TMP_3, $c, TMP_4, $d, TMP_6; ($a = ($b = self).$define_singleton_method, $a.$$p = (TMP_3 = function(){var self = TMP_3.$$s || this, $a, $b; if ((($a = ((($b = self.$caller().$length()['$=='](0)) !== false && $b !== nil) ? $b : self.$caller()['$[]'](0)['$include?']("gamefic/stage"))) !== nil && (!$a.$$is_boolean || $a == true))) { } else { self.$raise($scope.get('NoMethodError').$new("Method __instance__ is not available from the stage.")) }; return instance;}, TMP_3.$$s = self, TMP_3), $a).call($b, "__instance__"); ($a = ($c = exposed).$each, $a.$$p = (TMP_4 = function(exposed_method){var self = TMP_4.$$s || this, $a, $b, TMP_5; if (exposed_method == null) exposed_method = nil; return ($a = ($b = self).$define_singleton_method, $a.$$p = (TMP_5 = function(args){var self = TMP_5.$$s || this, block, $a, $b; args = $slice.call(arguments, 0); block = TMP_5.$$p || nil, TMP_5.$$p = null; return ($a = ($b = self.$__instance__()).$public_send, $a.$$p = block.$to_proc(), $a).apply($b, [exposed_method].concat(args))}, TMP_5.$$s = self, TMP_5), $a).call($b, exposed_method)}, TMP_4.$$s = self, TMP_4), $a).call($c); return ($a = ($d = mounted).$each, $a.$$p = (TMP_6 = function(dsl){var self = TMP_6.$$s || this, $a, $b, TMP_7; if (dsl == null) dsl = nil; return ($a = ($b = dsl.$public_instance_methods()).$each, $a.$$p = (TMP_7 = function(method){var self = TMP_7.$$s || this, $a, $b, TMP_8; if (method == null) method = nil; return ($a = ($b = self).$define_singleton_method, $a.$$p = (TMP_8 = function(args){var self = TMP_8.$$s || this, block, $a, $b, result = nil; args = $slice.call(arguments, 0); block = TMP_8.$$p || nil, TMP_8.$$p = null; result = ($a = ($b = self.$__instance__()).$public_send, $a.$$p = block.$to_proc(), $a).apply($b, [method].concat(args)); return result;}, TMP_8.$$s = self, TMP_8), $a).call($b, method)}, TMP_7.$$s = self, TMP_7), $a).call($b)}, TMP_6.$$s = self, TMP_6), $a).call($d);}, TMP_2.$$s = self, TMP_2), $a).call($b); return self.stage; }); (function($base) { var self = $module($base, 'ClassMethods'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$mount', function(args) { var $a, $b, TMP_9, self = this; args = $slice.call(arguments, 0); return ($a = ($b = args).$each, $a.$$p = (TMP_9 = function(a){var self = TMP_9.$$s || this; if (a == null) a = nil; self.$include(a); return self.$mounted_modules()['$[]='](a, nil);}, TMP_9.$$s = self, TMP_9), $a).call($b); }); Opal.defn(self, '$expose', function(args) { var $a, $b, TMP_10, self = this; args = $slice.call(arguments, 0); return ($a = ($b = args).$each, $a.$$p = (TMP_10 = function(a){var self = TMP_10.$$s || this; if (a == null) a = nil; return self.$exposed_methods()['$[]='](a, nil)}, TMP_10.$$s = self, TMP_10), $a).call($b); }); Opal.defn(self, '$exposed_methods', function() { var $a, $b, self = this; return ((($a = (($b = Opal.cvars['@@exposed_methods']) == null ? nil : $b)) !== false && $a !== nil) ? $a : (Opal.cvars['@@exposed_methods'] = self.$from_superclass("exposed_methods", $hash2([], {})).$dup())); }); Opal.defn(self, '$mounted_modules', function() { var $a, $b, self = this; return ((($a = (($b = Opal.cvars['@@mounted_modules']) == null ? nil : $b)) !== false && $a !== nil) ? $a : (Opal.cvars['@@mounted_modules'] = self.$from_superclass("mounted_modules", $hash2([], {})).$dup())); }); self.$private(); Opal.defn(self, '$from_superclass', function(m, default$) { var $a, self = this; if (default$ == null) { default$ = nil } if ((($a = self.$superclass()['$respond_to?'](m)) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$superclass().$send(m) } else { return default$ }; }); })(self); Opal.defs(self, '$included', function(base) { var self = this; return base.$extend($scope.get('ClassMethods')); }); })(self) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/tester"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$new', '$[]=', '$test_procs', '$stage', '$to_proc', '$[]', '$plot', '$length', '$scene']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Tester'); var def = self.$$proto, $scope = self.$$scope, TMP_1; Opal.defn(self, '$test_procs', function() { var $a, self = this; if (self.test_procs == null) self.test_procs = nil; return ((($a = self.test_procs) !== false && $a !== nil) ? $a : self.test_procs = $scope.get('Hash').$new()); }); Opal.defn(self, '$on_test', TMP_1 = function(name) { var self = this, $iter = TMP_1.$$p, block = $iter || nil; if (name == null) { name = "me" } TMP_1.$$p = null; return self.$test_procs()['$[]='](name, block); }); Opal.defn(self, '$run_test', function(name, actor) { var $a, $b, self = this, queue = nil; queue = []; ($a = ($b = actor.$plot()).$stage, $a.$$p = self.$test_procs()['$[]'](name).$to_proc(), $a).call($b, actor, queue); actor['$[]=']("test_queue", queue); actor['$[]=']("test_queue_length", queue.$length()); actor['$[]=']("test_queue_scene", actor.$scene()); return actor['$[]=']("testing", true); }); })(self) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/describable_articles"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$require', '$indefinitely', '$definitely', '$cap_first']); self.$require("gamefic/describable"); return (function($base) { var self = $module($base, 'DescribableArticles'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$a', function(entity) { var self = this; return entity.$indefinitely(); }); Opal.defn(self, '$an', function(entity) { var self = this; return entity.$indefinitely(); }); Opal.defn(self, '$the', function(entity) { var self = this; return entity.$definitely(); }); Opal.defn(self, '$A', function(entity) { var self = this; return entity.$indefinitely().$cap_first(); }); Opal.defn(self, '$An', function(entity) { var self = this; return entity.$indefinitely().$cap_first(); }); Opal.defn(self, '$The', function(entity) { var self = this; return entity.$definitely().$cap_first(); }); })($scope.get('Gamefic')); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/source"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $range = Opal.range; Opal.add_stubs(['$attr_reader', '$each', '$file?', '$new', '$raise', '$directory?', '$dirname', '$[]', '$length', '$basename', '$extname', '$push']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Source(){}; var self = $Source = $klass($base, $super, 'Source', $Source); var def = self.$$proto, $scope = self.$$scope; def.directories = nil; (Opal.cvars['@@extensions'] = ["", ".plot", ".rb"]); self.$attr_reader("directories"); def.$initialize = function(args) { var self = this; args = $slice.call(arguments, 0); return self.directories = args; }; def.$export = function(name) {try { var $a, $b, TMP_1, self = this; ($a = ($b = self.directories).$each, $a.$$p = (TMP_1 = function(directory){var self = TMP_1.$$s || this, $a, $b, TMP_2, $c; if (directory == null) directory = nil; return ($a = ($b = (($c = Opal.cvars['@@extensions']) == null ? nil : $c)).$each, $a.$$p = (TMP_2 = function(ext){var self = TMP_2.$$s || this, $a, absolute = nil; if (ext == null) ext = nil; absolute = $rb_plus($rb_plus($rb_plus(directory, "/"), name), ext); if ((($a = $scope.get('File')['$file?'](absolute)) !== nil && (!$a.$$is_boolean || $a == true))) { Opal.ret($scope.get('Script').$new(absolute, directory)) } else { return nil };}, TMP_2.$$s = self, TMP_2), $a).call($b)}, TMP_1.$$s = self, TMP_1), $a).call($b); return self.$raise("Script " + (name) + " not found"); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }; return (def.$search = function(path) { var $a, $b, TMP_3, self = this, found = nil; found = []; ($a = ($b = self.directories).$each, $a.$$p = (TMP_3 = function(base){var self = TMP_3.$$s || this, $a, $b, TMP_4; if (base == null) base = nil; if ((($a = $scope.get('File')['$directory?']($rb_plus($rb_plus(base, "/"), path))) !== nil && (!$a.$$is_boolean || $a == true))) { return ($a = ($b = $scope.get('Dir')['$[]']($rb_plus($rb_plus($rb_plus($rb_plus(base, "/"), path), "/"), "*"))).$each, $a.$$p = (TMP_4 = function(file){var self = TMP_4.$$s || this, name = nil; if (file == null) file = nil; name = $rb_plus($rb_plus($scope.get('File').$dirname(file['$[]']($range((base.$length()), -1, false))), "/"), $scope.get('File').$basename(file, $scope.get('File').$extname(file))); return found.$push(name);}, TMP_4.$$s = self, TMP_4), $a).call($b) } else { return nil }}, TMP_3.$$s = self, TMP_3), $a).call($b); return found; }, nil) && 'search'; })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/script"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $range = Opal.range; Opal.add_stubs(['$attr_reader', '$gsub', '$[]', '$length', '$dirname', '$basename', '$extname', '$read', '$==', '$base']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Script(){}; var self = $Script = $klass($base, $super, 'Script', $Script); var def = self.$$proto, $scope = self.$$scope; def.relative = def.absolute = nil; self.$attr_reader("absolute", "relative", "base", "read"); def.$initialize = function(filename, directory) { var self = this; self.absolute = filename.$gsub(/\/+/, "/"); self.relative = filename['$[]']($range(directory.$length(), -1, false)).$gsub(/\/+/, "/"); return self.base = ($rb_plus($rb_plus($scope.get('File').$dirname(self.relative), "/"), $scope.get('File').$basename(self.relative, $scope.get('File').$extname(self.relative)))).$gsub(/\/+/, "/"); }; def.$read = function() { var self = this; return $scope.get('File').$read(self.absolute); }; return (def['$=='] = function(other) { var self = this; return self.$base()['$=='](other.$base()); }, nil) && '=='; })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/base"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$include', '$attr_accessor', '$test_arguments', '$include?', '$delete', '$new', '$[]', '$context_from', '$each', '$that_are', '$match', '$objects', '$matching_text', '$remainder', '$==', '$length', '$respond_to?', '$!', '$nil?', '$last_order', '$arguments', '$validate', '$[]=', '$base_specificity', '$kind_of?', '$class', '$superclass', '$join', '$raise', '$instance_methods']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Base(){}; var self = $Base = $klass($base, $super, 'Base', $Base); var def = self.$$proto, $scope = self.$$scope; def.match_hash = def.optional = def["arguments"] = def.specificity = nil; self.$include($scope.get('Gamefic')); (Opal.cvars['@@last_new'] = nil); self.$attr_accessor("arguments"); Opal.defs(self, '$last_new', function() { var $a, self = this; return (($a = Opal.cvars['@@last_new']) == null ? nil : $a); }); def.$initialize = function(arguments$) { var $a, self = this; arguments$ = $slice.call(arguments, 0); self.$test_arguments(arguments$); self.optional = false; if ((($a = arguments$['$include?']("optional")) !== nil && (!$a.$$is_boolean || $a == true))) { self.optional = true; arguments$.$delete("optional");}; self["arguments"] = arguments$; (Opal.cvars['@@last_new'] = self); return self.match_hash = $scope.get('Hash').$new(); }; def.$last_match_for = function(subject) { var self = this; return self.match_hash['$[]'](subject); }; def['$optional?'] = function() { var self = this; return self.optional; }; def.$context_from = function(subject) { var self = this; return subject; }; def.$validate = function(subject, object) { var $a, $b, TMP_1, self = this, array = nil; array = self.$context_from(subject); ($a = ($b = self["arguments"]).$each, $a.$$p = (TMP_1 = function(arg){var self = TMP_1.$$s || this; if (arg == null) arg = nil; return array = array.$that_are(arg)}, TMP_1.$$s = self, TMP_1), $a).call($b); return array['$include?'](object); }; def.$execute = function(subject, description) { var $a, $b, TMP_2, $c, $d, self = this, array = nil, matches = nil, objects = nil, obj = nil; array = self.$context_from(subject); matches = $scope.get('Query').$match(description, array); objects = matches.$objects(); ($a = ($b = self["arguments"]).$each, $a.$$p = (TMP_2 = function(arg){var self = TMP_2.$$s || this; if (arg == null) arg = nil; return objects = objects.$that_are(arg)}, TMP_2.$$s = self, TMP_2), $a).call($b); matches = $scope.get('Matches').$new(objects, matches.$matching_text(), matches.$remainder()); if ((($a = ($c = (($d = objects.$length()['$=='](0)) ? matches.$remainder()['$==']("it") : $d), $c !== false && $c !== nil ?subject['$respond_to?']("last_order") : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = ($c = subject.$last_order()['$nil?']()['$!'](), $c !== false && $c !== nil ?subject.$last_order().$arguments()['$[]'](0)['$nil?']()['$!']() : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { obj = subject.$last_order().$arguments()['$[]'](0); if ((($a = self.$validate(subject, obj)) !== nil && (!$a.$$is_boolean || $a == true))) { matches = $scope.get('Matches').$new([obj], "it", "")};}}; self.match_hash['$[]='](subject, matches); return matches; }; def.$base_specificity = function() { var self = this; return 0; }; def.$specificity = function() { var $a, $b, TMP_3, self = this, magnitude = nil; if (self.specificity['$=='](nil)) { self.specificity = self.$base_specificity(); magnitude = 1; ($a = ($b = self["arguments"]).$each, $a.$$p = (TMP_3 = function(item){var self = TMP_3.$$s || this, $a, $b, s = nil; if (self.specificity == null) self.specificity = nil; if (item == null) item = nil; if ((($a = item['$kind_of?']($scope.get('Entity'))) !== nil && (!$a.$$is_boolean || $a == true))) { self.specificity = $rb_plus(self.specificity, ($rb_times(magnitude, 10))); item = item.$class();}; if ((($a = item['$kind_of?']($scope.get('Class'))) !== nil && (!$a.$$is_boolean || $a == true))) { s = item; while ((($b = s['$=='](nil)['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) { self.specificity = $rb_plus(self.specificity, magnitude); s = s.$superclass();}; } else { return self.specificity = $rb_plus(self.specificity, magnitude) };}, TMP_3.$$s = self, TMP_3), $a).call($b);}; return self.specificity; }; def.$signature = function() { var self = this; return "" + (self.$class()) + "(" + (self["arguments"].$join(",")) + ")"; }; return (def.$test_arguments = function(arguments$) { var $a, $b, TMP_4, self = this, cur_class = nil, cur_object = nil; cur_class = (($scope.get('Gamefic')).$$scope.get('Entity')); cur_object = nil; return ($a = ($b = arguments$).$each, $a.$$p = (TMP_4 = function(a){var self = TMP_4.$$s || this, $a, $b; if (a == null) a = nil; if ((($a = ((($b = a['$kind_of?']($scope.get('Class'))) !== false && $b !== nil) ? $b : a['$kind_of?']($scope.get('Module')))) !== nil && (!$a.$$is_boolean || $a == true))) { return cur_class = a } else if ((($a = a['$kind_of?'](cur_class)) !== nil && (!$a.$$is_boolean || $a == true))) { return cur_object = a } else if ((($a = a['$kind_of?']($scope.get('Symbol'))) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = cur_object['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = cur_object['$respond_to?'](a)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$raise($scope.get('ArgumentError').$new("Query signature target does not respond to " + (a))) } else { return nil } } else if ((($a = cur_class.$instance_methods()['$include?'](a)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$raise($scope.get('ArgumentError').$new("Query signature target methods do not include " + (a))) } else { return nil } } else { return self.$raise($scope.get('ArgumentError').$new("What the heck is this?")) }}, TMP_4.$$s = self, TMP_4), $a).call($b); }, nil) && 'test_arguments'; })(self, null) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/text"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$kind_of?', '$split_words', '$each', '$include?', '$==', '$length', '$new', '$push', '$join']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Text(){}; var self = $Text = $klass($base, $super, 'Text', $Text); var def = self.$$proto, $scope = self.$$scope; def["arguments"] = nil; def.$base_specificity = function() { var self = this; return 10; }; def.$validate = function(subject, description) { var $a, $b, TMP_1, self = this, valid = nil, words = nil; if ((($a = description['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) { } else { return false }; valid = false; words = description.$split_words(); ($a = ($b = words).$each, $a.$$p = (TMP_1 = function(word){var self = TMP_1.$$s || this, $a; if (word == null) word = nil; if ((($a = description['$include?'](word)) !== nil && (!$a.$$is_boolean || $a == true))) { valid = true; return ($breaker.$v = nil, $breaker); } else { return nil }}, TMP_1.$$s = self, TMP_1), $a).call($b); return valid; }; def.$execute = function(subject, description) { var $a, $b, TMP_2, self = this, keywords = nil, args = nil, found = nil, remainder = nil; if (self["arguments"].$length()['$=='](0)) { return $scope.get('Matches').$new([description], description, "")}; keywords = $scope.get('Keywords').$new(description); args = $scope.get('Keywords').$new(self["arguments"]); found = $scope.get('Array').$new(); remainder = $scope.get('Array').$new(); ($a = ($b = keywords).$each, $a.$$p = (TMP_2 = function(key){var self = TMP_2.$$s || this, $a; if (key == null) key = nil; if ((($a = args['$include?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) { return found.$push(key) } else { return remainder.$push(key) }}, TMP_2.$$s = self, TMP_2), $a).call($b); if ($rb_gt(found.$length(), 0)) { return $scope.get('Matches').$new([description], found.$join(" "), remainder.$join(" ")) } else { return $scope.get('Matches').$new([], "", description) }; }; return (def.$test_arguments = function(arguments$) { var self = this; return nil; }, nil) && 'test_arguments'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/self"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Self(){}; var self = $Self = $klass($base, $super, 'Self', $Self); var def = self.$$proto, $scope = self.$$scope; def.$base_specificity = function() { var self = this; return 30; }; return (def.$context_from = function(subject) { var self = this; return [subject]; }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/parent"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$parent']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Parent(){}; var self = $Parent = $klass($base, $super, 'Parent', $Parent); var def = self.$$proto, $scope = self.$$scope; def.$base_specificity = function() { var self = this; return 30; }; return (def.$context_from = function(subject) { var self = this; return [subject.$parent()]; }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/children"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$children']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Children(){}; var self = $Children = $klass($base, $super, 'Children', $Children); var def = self.$$proto, $scope = self.$$scope; def.$base_specificity = function() { var self = this; return 50; }; return (def.$context_from = function(subject) { var self = this; return subject.$children(); }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/siblings"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$children', '$parent']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Siblings(){}; var self = $Siblings = $klass($base, $super, 'Siblings', $Siblings); var def = self.$$proto, $scope = self.$$scope; def.$base_specificity = function() { var self = this; return 40; }; return (def.$context_from = function(subject) { var self = this; return ($rb_minus(subject.$parent().$children(), [subject])); }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/family"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$children', '$parent']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Family(){}; var self = $Family = $klass($base, $super, 'Family', $Family); var def = self.$$proto, $scope = self.$$scope; def.$base_specificity = function() { var self = this; return 40; }; return (def.$context_from = function(subject) { var self = this; return $rb_plus(subject.$children(), subject.$parent().$children()); }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/subquery"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$kind_of?', '$[]', '$shift', '$last_new', '$last_match_for', '$nil?', '$!', '$==', '$length', '$objects', '$children']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Subquery(){}; var self = $Subquery = $klass($base, $super, 'Subquery', $Subquery); var def = self.$$proto, $scope = self.$$scope, TMP_1; def.parent = nil; def.$base_specificity = function() { var self = this; return 40; }; def.$initialize = TMP_1 = function(arguments$) {var $zuper = $slice.call(arguments, 0); var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil; arguments$ = $slice.call(arguments, 0); TMP_1.$$p = null; if ((($a = arguments$['$[]'](0)['$kind_of?']((($scope.get('Query')).$$scope.get('Base')))) !== nil && (!$a.$$is_boolean || $a == true))) { self.parent = arguments$.$shift() } else { self.parent = $scope.get('Query').$last_new() }; return Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper); }; return (def.$context_from = function(subject) { var $a, $b, self = this, last = nil; last = self.parent.$last_match_for(subject); if ((($a = ((($b = last['$nil?']()) !== false && $b !== nil) ? $b : last.$objects().$length()['$=='](1)['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) { return []}; return last.$objects()['$[]'](0).$children(); }, nil) && 'context_from'; })(self, $scope.get('Base')) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query/matches"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_reader']); return (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Matches(){}; var self = $Matches = $klass($base, $super, 'Matches', $Matches); var def = self.$$proto, $scope = self.$$scope; self.$attr_reader("objects", "matching_text", "remainder"); return (def.$initialize = function(objects, matching_text, remainder) { var self = this; self.objects = objects; self.matching_text = matching_text; self.remainder = remainder; return (Opal.cvars['@@last_match'] = self); }, nil) && 'initialize'; })(self, null) })($scope.get('Gamefic')) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/query"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$require', '$autoload', '$last_new', '$split_words', '$each', '$==', '$uid', '$[]', '$new', '$shift', '$join', '$length', '$include?', '$match', '$objects', '$&', '$children', '$push', '$last', '$found_in', '$keywords', '$pop', '$clear']); self.$require("gamefic/keywords"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; self.$autoload("Base", "gamefic/query/base"); self.$autoload("Text", "gamefic/query/text"); self.$autoload("Self", "gamefic/query/self"); self.$autoload("Parent", "gamefic/query/parent"); self.$autoload("Children", "gamefic/query/children"); self.$autoload("Siblings", "gamefic/query/siblings"); self.$autoload("Family", "gamefic/query/family"); self.$autoload("Subquery", "gamefic/query/subquery"); self.$autoload("Matches", "gamefic/query/matches"); (Opal.cvars['@@ignored_words'] = ["a", "an", "the"]); (Opal.cvars['@@subquery_prepositions'] = ["in", "on", "of", "inside", "from"]); Opal.defs(self, '$last_new', function() { var self = this; return $scope.get('Base').$last_new(); }); Opal.defs(self, '$match', function(description, array) {try { var $a, $b, TMP_1, $c, $d, TMP_2, self = this, keywords = nil, used = nil, skipped = nil, possibilities = nil, at_least_one_match = nil, next_word = nil, so_far = nil, in_matched = nil, subset = nil, new_results = nil, most_matches = nil, intersection = nil; keywords = description.$split_words(); ($a = ($b = array).$each, $a.$$p = (TMP_1 = function(e){var self = TMP_1.$$s || this; if (e == null) e = nil; if (e.$uid()['$=='](keywords['$[]'](0))) { Opal.ret($scope.get('Matches').$new([e], keywords.$shift(), keywords.$join(" "))) } else { return nil }}, TMP_1.$$s = self, TMP_1), $a).call($b); used = []; skipped = []; possibilities = array; at_least_one_match = false; while ($rb_gt(keywords.$length(), 0)) { next_word = keywords.$shift(); if ((($c = (($d = Opal.cvars['@@subquery_prepositions']) == null ? nil : $d)['$include?'](next_word)) !== nil && (!$c.$$is_boolean || $c == true))) { so_far = keywords.$join(" "); in_matched = self.$match(so_far, array); if (in_matched.$objects().$length()['$=='](1)) { subset = self.$match(used.$join(" "), (array['$&'](in_matched.$objects()['$[]'](0).$children()))); if (subset.$objects().$length()['$=='](1)) { return subset};};}; used.$push(next_word); if ((($c = (($d = Opal.cvars['@@ignored_words']) == null ? nil : $d)['$include?'](next_word)) !== nil && (!$c.$$is_boolean || $c == true))) { continue;}; new_results = []; most_matches = 0.0; ($c = ($d = possibilities).$each, $c.$$p = (TMP_2 = function(p){var self = TMP_2.$$s || this, words = nil, matches = nil; if (p == null) p = nil; words = $scope.get('Keywords').$new(used.$last()); if ($rb_gt(words.$length(), 0)) { matches = words.$found_in(p.$keywords()); if ($rb_gt(matches, 0)) { new_results.$push(p); return most_matches = matches; } else { return nil }; } else { return nil };}, TMP_2.$$s = self, TMP_2), $c).call($d); if ($rb_gt(new_results.$length(), 0)) { at_least_one_match = true; intersection = possibilities['$&'](new_results); if (intersection.$length()['$=='](0)) { skipped.$push(used.$pop()) } else { skipped.$clear(); possibilities = intersection; }; } else { skipped.$push(used.$pop()) };}; if ((($a = (($c = at_least_one_match !== false && at_least_one_match !== nil) ? $rb_gt(($rb_minus(used, ["a", "an", "the", "to"])).$length(), 0) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { return $scope.get('Matches').$new(possibilities, used.$join(" "), skipped.$join(" ")) } else { return $scope.get('Matches').$new([], "", description) }; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }); })(self); (function($base) { var self = $module($base, 'Use'); var def = self.$$proto, $scope = self.$$scope; nil })(self); })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/plot/scene_mount"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module, $hash2 = Opal.hash2; Opal.add_stubs(['$nil?', '$[]=', '$new', '$scene_managers', '$start', '$options=', '$finish', '$to_proc', '$prompt=', '$answer', '$tell', '$call', '$==', '$key', '$scene', '$cue', '$next_cue', '$next_cue=', '$state=', '$[]', '$!', '$state', '$raise', '$scene=', '$prepare', '$NotConclusionError']); (function($base, $super) { function $NotConclusionError(){}; var self = $NotConclusionError = $klass($base, $super, 'NotConclusionError', $NotConclusionError); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Exception')); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'SceneMount'); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_4, TMP_7, TMP_10, TMP_14, TMP_16; Opal.defn(self, '$scene_managers', function() { var $a, self = this; if (self.scene_managers == null) self.scene_managers = nil; if ((($a = self.scene_managers['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { ((($a = self.scene_managers) !== false && $a !== nil) ? $a : self.scene_managers = $hash2([], {})); self.scene_managers['$[]=']("active", $scope.get('ActiveSceneManager').$new()); self.scene_managers['$[]=']("concluded", $scope.get('ConcludedSceneManager').$new());}; return self.scene_managers; }); Opal.defn(self, '$multiple_choice', TMP_1 = function(key, args) { var $a, $b, TMP_2, self = this, $iter = TMP_1.$$p, block = $iter || nil; args = $slice.call(arguments, 1); TMP_1.$$p = null; return self.$scene_managers()['$[]='](key, ($a = ($b = $scope.get('MultipleChoiceSceneManager')).$new, $a.$$p = (TMP_2 = function(config){var self = TMP_2.$$s || this, $a, $b, TMP_3, $c; if (config == null) config = nil; ($a = ($b = config).$start, $a.$$p = (TMP_3 = function(actor, data){var self = TMP_3.$$s || this, $a, $b; if (actor == null) actor = nil;if (data == null) data = nil; return (($a = [args]), $b = data, $b['$options='].apply($b, $a), $a[$a.length-1])}, TMP_3.$$s = self, TMP_3), $a).call($b); return ($a = ($c = config).$finish, $a.$$p = block.$to_proc(), $a).call($c);}, TMP_2.$$s = self, TMP_2), $a).call($b)); }); Opal.defn(self, '$yes_or_no', TMP_4 = function(key, prompt) { var $a, $b, TMP_5, self = this, $iter = TMP_4.$$p, block = $iter || nil, manager = nil; if (prompt == null) { prompt = nil } TMP_4.$$p = null; manager = ($a = ($b = $scope.get('YesOrNoSceneManager')).$new, $a.$$p = (TMP_5 = function(config){var self = TMP_5.$$s || this, $a, $b, TMP_6; if (config == null) config = nil; (($a = [prompt]), $b = config, $b['$prompt='].apply($b, $a), $a[$a.length-1]); return ($a = ($b = config).$finish, $a.$$p = (TMP_6 = function(actor, data){var self = TMP_6.$$s || this, $a; if (actor == null) actor = nil;if (data == null) data = nil; if ((($a = data.$answer()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return actor.$tell("Please answer Yes or No.") } else { block.$call(actor, data); if (actor.$scene().$key()['$=='](key)) { return self.$cue(actor, "active") } else { return nil }; }}, TMP_6.$$s = self, TMP_6), $a).call($b);}, TMP_5.$$s = self, TMP_5), $a).call($b); return self.$scene_managers()['$[]='](key, manager); }); Opal.defn(self, '$prompt', TMP_7 = function(key, prompt) { var $a, $b, TMP_8, $c, self = this, $iter = TMP_7.$$p, block = $iter || nil; TMP_7.$$p = null; self.$scene_managers()['$[]='](key, ($a = ($b = $scope.get('SceneManager')).$new, $a.$$p = (TMP_8 = function(config){var self = TMP_8.$$s || this, $a, $b, TMP_9; if (config == null) config = nil; (($a = [prompt]), $b = config, $b['$prompt='].apply($b, $a), $a[$a.length-1]); return ($a = ($b = config).$finish, $a.$$p = (TMP_9 = function(actor, data){var self = TMP_9.$$s || this, $a, $b; if (actor == null) actor = nil;if (data == null) data = nil; ($a = data, ((($b = $a.$next_cue()) !== false && $b !== nil) ? $b : $a['$next_cue=']("active"))); block.$call(actor, data); return self.$cue(actor, data.$next_cue());}, TMP_9.$$s = self, TMP_9), $a).call($b);}, TMP_8.$$s = self, TMP_8), $a).call($b)); return (($a = ["Prompted"]), $c = self.$scene_managers()['$[]'](key), $c['$state='].apply($c, $a), $a[$a.length-1]); }); Opal.defn(self, '$pause', TMP_10 = function(key) { var $a, $b, TMP_11, self = this, $iter = TMP_10.$$p, block = $iter || nil, manager = nil; TMP_10.$$p = null; manager = ($a = ($b = $scope.get('PausedSceneManager')).$new, $a.$$p = (TMP_11 = function(config){var self = TMP_11.$$s || this, $a, $b, TMP_12, $c, TMP_13; if (config == null) config = nil; ($a = ($b = config).$start, $a.$$p = (TMP_12 = function(actor, data){var self = TMP_12.$$s || this, $a, $b; if (actor == null) actor = nil;if (data == null) data = nil; (($a = ["active"]), $b = data, $b['$next_cue='].apply($b, $a), $a[$a.length-1]); return block.$call(actor, data);}, TMP_12.$$s = self, TMP_12), $a).call($b); return ($a = ($c = config).$finish, $a.$$p = (TMP_13 = function(actor, data){var self = TMP_13.$$s || this, $a; if (actor == null) actor = nil;if (data == null) data = nil; if (actor.$scene().$key()['$=='](key)) { return self.$cue(actor, (((($a = data.$next_cue()) !== false && $a !== nil) ? $a : "active"))) } else { return nil }}, TMP_13.$$s = self, TMP_13), $a).call($c);}, TMP_11.$$s = self, TMP_11), $a).call($b); return self.$scene_managers()['$[]='](key, manager); }); Opal.defn(self, '$conclusion', TMP_14 = function(key) { var $a, $b, TMP_15, self = this, $iter = TMP_14.$$p, block = $iter || nil, manager = nil; TMP_14.$$p = null; manager = ($a = ($b = $scope.get('ConcludedSceneManager')).$new, $a.$$p = (TMP_15 = function(config){var self = TMP_15.$$s || this, $a, $b; if (config == null) config = nil; return ($a = ($b = config).$start, $a.$$p = block.$to_proc(), $a).call($b)}, TMP_15.$$s = self, TMP_15), $a).call($b); return self.$scene_managers()['$[]='](key, manager); }); Opal.defn(self, '$scene', TMP_16 = function(key) { var $a, $b, TMP_17, self = this, $iter = TMP_16.$$p, block = $iter || nil, scene = nil; TMP_16.$$p = null; scene = ($a = ($b = $scope.get('SceneManager')).$new, $a.$$p = (TMP_17 = function(manager){var self = TMP_17.$$s || this, $a, $b, TMP_18, $c, TMP_19; if (manager == null) manager = nil; ($a = ($b = manager).$start, $a.$$p = (TMP_18 = function(actor, data){var self = TMP_18.$$s || this, $a, $b; if (actor == null) actor = nil;if (data == null) data = nil; block.$call(actor, data); return (($a = ["active"]), $b = data, $b['$next_cue='].apply($b, $a), $a[$a.length-1]);}, TMP_18.$$s = self, TMP_18), $a).call($b); return ($a = ($c = manager).$finish, $a.$$p = (TMP_19 = function(actor, data){var self = TMP_19.$$s || this; if (actor == null) actor = nil;if (data == null) data = nil; return self.$cue(actor, data.$next_cue())}, TMP_19.$$s = self, TMP_19), $a).call($c);}, TMP_17.$$s = self, TMP_17), $a).call($b); return self.$scene_managers()['$[]='](key, scene); }); Opal.defn(self, '$cue', function(actor, key) { var $a, $b, self = this, manager = nil; if (self.scene == null) self.scene = nil; if ((($a = ($b = actor.$scene()['$nil?']()['$!'](), $b !== false && $b !== nil ?actor.$scene().$state()['$==']("Concluded") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; if ((($a = key['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Cueing scene with nil key")}; manager = self.$scene_managers()['$[]'](key); if ((($a = manager['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("No '" + (key) + "' scene found") } else { (($a = [manager.$prepare(key)]), $b = actor, $b['$scene='].apply($b, $a), $a[$a.length-1]); if (actor.$scene().$state()['$==']("Passive")) { actor.$scene().$start(actor); actor.$scene().$finish(actor, nil);}; }; return self.scene; }); Opal.defn(self, '$conclude', function(actor, key) { var $a, self = this, manager = nil; if ((($a = key['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { key = "concluded"}; manager = self.$scene_managers()['$[]'](key); if ((($a = manager.$state()['$==']("Concluded")['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise(self.$NotConclusionError("Cued scene '" + (key) + "' is not a conclusion"))}; return self.$cue(actor, key); }); })($scope.get('Plot')) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/plot/command_mount"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$new', '$to_proc', '$action', '$xlate', '$each', '$first_word', '$!', '$nil?', '$push', '$syntaxes', '$uniq']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'CommandMount'); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3; Opal.defn(self, '$meta', TMP_1 = function(command, queries) { var $a, $b, self = this, $iter = TMP_1.$$p, proc = $iter || nil, act = nil; queries = $slice.call(arguments, 1); TMP_1.$$p = null; return act = ($a = ($b = $scope.get('Meta')).$new, $a.$$p = proc.$to_proc(), $a).apply($b, [self, command].concat(queries)); }); Opal.defn(self, '$action', TMP_2 = function(command, queries) { var $a, $b, self = this, $iter = TMP_2.$$p, proc = $iter || nil, act = nil; queries = $slice.call(arguments, 1); TMP_2.$$p = null; return act = ($a = ($b = $scope.get('Action')).$new, $a.$$p = proc.$to_proc(), $a).apply($b, [self, command].concat(queries)); }); Opal.defn(self, '$respond', TMP_3 = function(command, queries) { var $a, $b, self = this, $iter = TMP_3.$$p, proc = $iter || nil; queries = $slice.call(arguments, 1); TMP_3.$$p = null; return ($a = ($b = self).$action, $a.$$p = proc.$to_proc(), $a).apply($b, [command].concat(queries)); }); Opal.defn(self, '$interpret', function(args) { var $a, self = this; args = $slice.call(arguments, 0); return ($a = self).$xlate.apply($a, [].concat(args)); }); Opal.defn(self, '$syntax', function(args) { var $a, self = this; args = $slice.call(arguments, 0); return ($a = self).$xlate.apply($a, [].concat(args)); }); Opal.defn(self, '$xlate', function(args) { var $a, self = this, syn = nil; args = $slice.call(arguments, 0); syn = ($a = $scope.get('Syntax')).$new.apply($a, [self].concat(args)); return syn; }); Opal.defn(self, '$commandwords', function() { var $a, $b, TMP_4, self = this, words = nil; words = $scope.get('Array').$new(); ($a = ($b = self.$syntaxes()).$each, $a.$$p = (TMP_4 = function(s){var self = TMP_4.$$s || this, $a, word = nil; if (s == null) s = nil; word = s.$first_word(); if ((($a = word['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return words.$push(word) } else { return nil };}, TMP_4.$$s = self, TMP_4), $a).call($b); return words.$uniq(); }); })($scope.get('Plot')) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/plot/entity_mount"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $hash2 = Opal.hash2; Opal.add_stubs(['$new', '$to_proc', '$==', '$kind_of?', '$raise', '$match', '$entities', '$length', '$objects', '$[]']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'EntityMount'); var def = self.$$proto, $scope = self.$$scope, TMP_1; Opal.defn(self, '$make', TMP_1 = function(cls, args) { var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil, ent = nil; if (args == null) { args = $hash2([], {}) } TMP_1.$$p = null; ent = ($a = ($b = cls).$new, $a.$$p = block.$to_proc(), $a).call($b, self, args); if (ent['$kind_of?']($scope.get('Entity'))['$=='](false)) { self.$raise("Invalid entity class")}; return ent; }); Opal.defn(self, '$pick', function(description) { var self = this, result = nil; result = $scope.get('Query').$match(description, self.$entities()); if (result.$objects().$length()['$=='](0)) { self.$raise($scope.get('IndexError').$new("Unable to find entity from '" + (description) + "'")) } else if ($rb_gt(result.$objects().$length(), 1)) { self.$raise($scope.get('IndexError').$new("Ambiguous entities found from '" + (description) + "'"))}; return result.$objects()['$[]'](0); }); })($scope.get('Plot')) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/plot/query_mount"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$new']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base) { var self = $module($base, 'QueryMount'); var def = self.$$proto, $scope = self.$$scope; nil })($scope.get('Plot')); (function($base) { var self = $module($base, 'Query'); var def = self.$$proto, $scope = self.$$scope; Opal.defs(self, '$siblings', function(arguments$) { var $a, self = this; arguments$ = $slice.call(arguments, 0); return ($a = $scope.get('Siblings')).$new.apply($a, [].concat(arguments$)); }) })(self); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/plot"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $range = Opal.range; Opal.add_stubs(['$require', '$autoload', '$attr_reader', '$attr_accessor', '$include', '$mount', '$expose', '$new', '$post_initialize', '$clone', '$[]', '$[]=', '$to_proc', '$push', '$!', '$==', '$call', '$nil?', '$parent', '$scene', '$cue', '$default_scene', '$update', '$each', '$start', '$process_input', '$update_player', '$tell', '$exist?', '$stage', '$read', '$raise', '$import', '$search', '$source', '$export', '$include?', '$imported_scripts', '$absolute', '$pop', '$private', '$shift', '$queue', '$finish', '$delete', '$recursive_update', '$children', '$verb', '$delete_if', '$unshift', '$sort!', '$token_count', '$<=>', '$first_word', '$command', '$specificity', '$order_key', '$gsub', '$to_s', '$queries', '$strip', '$join']); self.$require("gamefic/stage"); self.$require("gamefic/tester"); self.$require("gamefic/describable_articles"); self.$require("gamefic/source"); self.$require("gamefic/script"); self.$require("gamefic/query"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Plot(){}; var self = $Plot = $klass($base, $super, 'Plot', $Plot); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_13; def.commands = def.imported_scripts = def.asserts = def.finishes = def.entities = def.syntaxes = def.update_procs = def.players = def.introduction = def.working_scripts = def.player_procs = nil; self.$autoload("SceneMount", "gamefic/plot/scene_mount"); self.$autoload("CommandMount", "gamefic/plot/command_mount"); self.$autoload("EntityMount", "gamefic/plot/entity_mount"); self.$autoload("QueryMount", "gamefic/plot/query_mount"); self.$attr_reader("commands", "imported_scripts", "rules", "asserts", "finishes", "source", "delegate_stack"); self.$attr_accessor("default_scene"); self.$include($scope.get('Stage')); self.$include($scope.get('Gamefic')); self.$mount($scope.get('DescribableArticles'), $scope.get('Tester'), $scope.get('SceneMount'), $scope.get('CommandMount'), $scope.get('EntityMount'), $scope.get('QueryMount')); self.$expose("import", "introduction", "assert_action", "on_update", "on_player_update", "entities"); def.$initialize = function(source) { var $a, self = this; if (source == null) { source = nil } self.source = ((($a = source) !== false && $a !== nil) ? $a : $scope.get('Source').$new()); self.commands = $scope.get('Hash').$new(); self.syntaxes = $scope.get('Array').$new(); self.update_procs = $scope.get('Array').$new(); self.player_procs = $scope.get('Array').$new(); self.working_scripts = $scope.get('Array').$new(); self.imported_scripts = $scope.get('Array').$new(); self.imported_identifiers = $scope.get('Array').$new(); self.entities = $scope.get('Array').$new(); self.players = $scope.get('Array').$new(); self.asserts = $scope.get('Hash').$new(); self.finishes = $scope.get('Hash').$new(); self.default_scene = "active"; self.delegate_stack = []; return self.$post_initialize(); }; def.$actions_with_verb = function(verb) { var $a, self = this; return ((($a = self.commands['$[]'](verb).$clone()) !== false && $a !== nil) ? $a : []); }; def.$imported_scripts = function() { var $a, self = this; return ((($a = self.imported_scripts) !== false && $a !== nil) ? $a : self.imported_scripts = []); }; def.$assert_action = TMP_1 = function(name) { var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil; TMP_1.$$p = null; return self.asserts['$[]='](name, ($a = ($b = $scope.get('Assert')).$new, $a.$$p = block.$to_proc(), $a).call($b, name)); }; def.$finish_action = TMP_2 = function(name) { var self = this, $iter = TMP_2.$$p, block = $iter || nil; TMP_2.$$p = null; return self.finishes['$[]='](name, block); }; def.$post_initialize = function() { var self = this; return nil; }; def.$entities = function() { var self = this; return self.entities.$clone(); }; def.$syntaxes = function() { var self = this; return self.syntaxes.$clone(); }; def.$on_update = TMP_3 = function() { var self = this, $iter = TMP_3.$$p, block = $iter || nil; TMP_3.$$p = null; return self.update_procs.$push(block); }; def.$introduction = TMP_4 = function() { var self = this, $iter = TMP_4.$$p, proc = $iter || nil; TMP_4.$$p = null; return self.introduction = proc; }; def.$introduce = function(player) { var $a, self = this; self.players.$push(player); if ((($a = self.introduction['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.introduction.$call(player)}; if ((($a = player.$parent()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {}; if ((($a = player.$scene()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$cue(player, self.$default_scene())}; return self.$update(); }; def.$ready = function() { var $a, $b, TMP_5, self = this; return ($a = ($b = self.players).$each, $a.$$p = (TMP_5 = function(p){var self = TMP_5.$$s || this; if (p == null) p = nil; return p.$scene().$start(p)}, TMP_5.$$s = self, TMP_5), $a).call($b); }; def.$update = function() { var $a, $b, TMP_6, $c, TMP_7, $d, TMP_8, $e, TMP_9, self = this; ($a = ($b = self.players).$each, $a.$$p = (TMP_6 = function(player){var self = TMP_6.$$s || this; if (player == null) player = nil; return self.$process_input(player)}, TMP_6.$$s = self, TMP_6), $a).call($b); ($a = ($c = self.entities).$each, $a.$$p = (TMP_7 = function(e){var self = TMP_7.$$s || this; if (e == null) e = nil; return e.$update()}, TMP_7.$$s = self, TMP_7), $a).call($c); ($a = ($d = self.players).$each, $a.$$p = (TMP_8 = function(player){var self = TMP_8.$$s || this; if (player == null) player = nil; return self.$update_player(player)}, TMP_8.$$s = self, TMP_8), $a).call($d); return ($a = ($e = self.update_procs).$each, $a.$$p = (TMP_9 = function(p){var self = TMP_9.$$s || this; if (p == null) p = nil; return p.$call()}, TMP_9.$$s = self, TMP_9), $a).call($e); }; def.$tell = function(entities, message, refresh) { var $a, $b, TMP_10, self = this; if (refresh == null) { refresh = false } return ($a = ($b = entities).$each, $a.$$p = (TMP_10 = function(entity){var self = TMP_10.$$s || this; if (entity == null) entity = nil; return entity.$tell(message, refresh)}, TMP_10.$$s = self, TMP_10), $a).call($b); }; def.$load = function(script) {try { var $a, $b, TMP_11, self = this; ($a = ($b = ["", ".plot", ".rb"]).$each, $a.$$p = (TMP_11 = function(ext){var self = TMP_11.$$s || this, $a; if (ext == null) ext = nil; if ((($a = $scope.get('File')['$exist?']($rb_plus(script, ext))) !== nil && (!$a.$$is_boolean || $a == true))) { self.$stage($scope.get('File').$read($rb_plus(script, ext)), $rb_plus(script, ext)); Opal.ret(nil); } else { return nil }}, TMP_11.$$s = self, TMP_11), $a).call($b); return self.$raise("File not found: " + (script)); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }; def.$import = function(script) { var $a, $b, TMP_12, $c, self = this, imported_script = nil; if (script['$[]'](-1)['$==']("*")) { return ($a = ($b = self.$source().$search(script['$[]']($range(0, -2, false)))).$each, $a.$$p = (TMP_12 = function(file){var self = TMP_12.$$s || this; if (file == null) file = nil; return self.$import(file)}, TMP_12.$$s = self, TMP_12), $a).call($b) } else { imported_script = self.$source().$export(script); if ((($a = imported_script['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Import not found: " + (script))}; if ((($a = ($c = self.working_scripts['$include?'](imported_script)['$!'](), $c !== false && $c !== nil ?self.$imported_scripts()['$include?'](imported_script)['$!']() : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { self.working_scripts.$push(imported_script); self.$stage(imported_script.$read(), imported_script.$absolute()); self.working_scripts.$pop(); return self.$imported_scripts().$push(imported_script); } else { return nil }; }; }; def.$on_player_update = TMP_13 = function() { var self = this, $iter = TMP_13.$$p, block = $iter || nil; TMP_13.$$p = null; return self.player_procs.$push(block); }; self.$private(); def.$process_input = function(player) { var $a, self = this, line = nil; line = player.$queue().$shift(); if ((($a = line['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return player.$scene().$finish(player, line) } else { return nil }; }; def.$update_player = function(player) { var $a, $b, TMP_14, self = this; ($a = ($b = self.player_procs).$each, $a.$$p = (TMP_14 = function(proc){var self = TMP_14.$$s || this; if (proc == null) proc = nil; return proc.$call(player)}, TMP_14.$$s = self, TMP_14), $a).call($b); if (player['$[]']("testing")['$=='](true)) { return self.$cue(player, "test") } else { return nil }; }; def.$rem_entity = function(entity) { var self = this; return self.entities.$delete(entity); }; def.$recursive_update = function(entity) { var $a, $b, TMP_15, self = this; entity.$update(); return ($a = ($b = entity.$children()).$each, $a.$$p = (TMP_15 = function(e){var self = TMP_15.$$s || this; if (e == null) e = nil; return self.$recursive_update(e)}, TMP_15.$$s = self, TMP_15), $a).call($b); }; def.$add_syntax = function(syntax) { var $a, $b, TMP_16, $c, TMP_17, self = this; if (self.commands['$[]'](syntax.$verb())['$=='](nil)) { self.$raise("Action \"" + (syntax.$verb()) + "\" does not exist")}; self.syntaxes = ($a = ($b = self.syntaxes).$delete_if, $a.$$p = (TMP_16 = function(existing){var self = TMP_16.$$s || this; if (existing == null) existing = nil; return existing['$=='](syntax)}, TMP_16.$$s = self, TMP_16), $a).call($b); self.syntaxes.$unshift(syntax); return ($a = ($c = self.syntaxes)['$sort!'], $a.$$p = (TMP_17 = function(a, b){var self = TMP_17.$$s || this; if (a == null) a = nil;if (b == null) b = nil; if (a.$token_count()['$=='](b.$token_count())) { return b.$first_word()['$<=>'](a.$first_word()) } else { return b.$token_count()['$<=>'](a.$token_count()) }}, TMP_17.$$s = self, TMP_17), $a).call($c); }; def.$add_action = function(action) { var $a, $b, TMP_18, $c, TMP_19, self = this, user_friendly = nil, args = nil, used_names = nil; if ((($a = (self.commands['$[]'](action.$command())['$=='](nil))) !== nil && (!$a.$$is_boolean || $a == true))) { self.commands['$[]='](action.$command(), $scope.get('Array').$new())}; self.commands['$[]'](action.$command()).$unshift(action); ($a = ($b = self.commands['$[]'](action.$command()))['$sort!'], $a.$$p = (TMP_18 = function(a, b){var self = TMP_18.$$s || this; if (a == null) a = nil;if (b == null) b = nil; if (a.$specificity()['$=='](b.$specificity())) { return b.$order_key()['$<=>'](a.$order_key()) } else { return b.$specificity()['$<=>'](a.$specificity()) }}, TMP_18.$$s = self, TMP_18), $a).call($b); user_friendly = action.$command().$to_s().$gsub(/_/, " "); args = $scope.get('Array').$new(); used_names = $scope.get('Array').$new(); ($a = ($c = action.$queries()).$each, $a.$$p = (TMP_19 = function(c){var self = TMP_19.$$s || this, $a, $b, num = nil, new_name = nil; if (c == null) c = nil; num = 1; new_name = ":var"; while ((($b = used_names['$include?'](new_name)) !== nil && (!$b.$$is_boolean || $b == true))) { num = $rb_plus(num, 1); new_name = ":var" + (num);}; used_names.$push(new_name); user_friendly = $rb_plus(user_friendly, " " + (new_name)); return args.$push(new_name);}, TMP_19.$$s = self, TMP_19), $a).call($c); return $scope.get('Syntax').$new(self, user_friendly.$strip(), "" + (action.$command()) + " " + (args.$join(" "))); }; def.$rem_action = function(action) { var self = this; return self.commands['$[]'](action.$command()).$delete(action); }; def.$rem_syntax = function(syntax) { var self = this; return self.syntaxes.$delete(syntax); }; return (def.$add_entity = function(entity) { var self = this; return self.entities.$push(entity); }, nil) && 'add_entity'; })(self, null) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/entity"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$include', '$attr_reader', '$serialize', '$==', '$kind_of?', '$raise', '$pre_initialize', '$send', '$each', '$new', '$post_initialize', '$to_s', '$object_id', '$call', '$push', '$!', '$parent=', '$[]', '$session', '$[]=', '$execute', '$length', '$objects', '$definitely']); self.$require("gamefic/node"); self.$require("gamefic/describable"); self.$require("gamefic/plot"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Entity(){}; var self = $Entity = $klass($base, $super, 'Entity', $Entity); var def = self.$$proto, $scope = self.$$scope, TMP_2, TMP_4, TMP_5; def.plot = def.uid = def.update_procs = nil; self.$include($scope.get('Node')); self.$include($scope.get('Describable')); self.$include($scope.get('Serialized')); self.$attr_reader("session", "plot"); self.$serialize("name", "parent", "description"); def.$initialize = TMP_2 = function(plot, args) { var $a, $b, TMP_1, self = this, $iter = TMP_2.$$p, $yield = $iter || nil; if (args == null) { args = $hash2([], {}) } TMP_2.$$p = null; if ((($a = (plot['$kind_of?']($scope.get('Plot'))['$=='](false))) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("First argument must be a Plot")}; self.$pre_initialize(); self.plot = plot; self.plot.$send("add_entity", self); ($a = ($b = args).$each, $a.$$p = (TMP_1 = function(key, value){var self = TMP_1.$$s || this; if (key == null) key = nil;if (value == null) value = nil; return self.$send("" + (key) + "=", value)}, TMP_1.$$s = self, TMP_1), $a).call($b); self.update_procs = $scope.get('Array').$new(); self.session = $scope.get('Hash').$new(); if (($yield !== nil)) { if (Opal.yield1($yield, self) === $breaker) return $breaker.$v}; return self.$post_initialize(); }; def.$uid = function() { var self = this; if (self.uid['$=='](nil)) { self.uid = self.$object_id().$to_s()}; return self.uid; }; def.$pre_initialize = function() { var self = this; return nil; }; def.$post_initialize = function() { var self = this; return nil; }; def.$tell = function(message) { var self = this; return nil; }; def.$stream = function(message) { var self = this; return nil; }; def.$update = function() { var $a, $b, TMP_3, self = this; return ($a = ($b = self.update_procs).$each, $a.$$p = (TMP_3 = function(p){var self = TMP_3.$$s || this; if (p == null) p = nil; return p.$call(self)}, TMP_3.$$s = self, TMP_3), $a).call($b); }; def.$on_update = TMP_4 = function() { var self = this, $iter = TMP_4.$$p, block = $iter || nil; TMP_4.$$p = null; return self.update_procs.$push(block); }; def['$parent='] = TMP_5 = function(node) {var $zuper = $slice.call(arguments, 0); var $a, $b, self = this, $iter = TMP_5.$$p, $yield = $iter || nil; TMP_5.$$p = null; if ((($a = ($b = node['$=='](nil)['$!'](), $b !== false && $b !== nil ?node['$kind_of?']($scope.get('Entity'))['$=='](false) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Entity's parent must be an Entity")}; return Opal.find_super_dispatcher(self, 'parent=', TMP_5, $iter).apply(self, $zuper); }; def.$destroy = function() { var $a, $b, self = this; (($a = [nil]), $b = self, $b['$parent='].apply($b, $a), $a[$a.length-1]); return self.plot.$send("rem_entity", self); }; def['$[]'] = function(key) { var self = this; return self.$session()['$[]'](key); }; def['$[]='] = function(key, value) { var self = this; return self.$session()['$[]='](key, value); }; return (def.$find = function(description) { var $a, self = this, query = nil, results = nil; query = (($scope.get('Query')).$$scope.get('Children')).$new(); results = query.$execute(self, description); if ((($a = results.$objects().$length()['$=='](1)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Find failed for " + (description) + " on " + (self.$definitely()))}; return results.$objects()['$[]'](0); }, nil) && 'find'; })(self, null) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/character"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2; Opal.add_stubs(['$attr_reader', '$attr_accessor', '$new', '$dispatch', '$!', '$==', '$user', '$to_s', '$gsub', '$send', '$stream', '$quit', '$nil?', '$last', '$delegate_stack', '$proceed', '$private']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Character(){}; var self = $Character = $klass($base, $super, 'Character', $Character); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2; def.user = def.delegate_stack = nil; self.$attr_reader("queue", "user", "last_order"); self.$attr_accessor("object_of_pronoun", "scene"); def.$initialize = TMP_1 = function(plot, args) {var $zuper = $slice.call(arguments, 0); var self = this, $iter = TMP_1.$$p, $yield = $iter || nil; if (args == null) { args = $hash2([], {}) } TMP_1.$$p = null; self.queue = $scope.get('Array').$new(); return Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper); }; def.$connect = function(user) { var self = this; return self.user = user; }; def.$disconnect = function() { var self = this; return self.user = nil; }; def.$perform = function(command) { var $a, self = this; command = $slice.call(arguments, 0); return ($a = $scope.get('Director')).$dispatch.apply($a, [self].concat(command)); }; def.$tell = function(message) { var $a, $b, self = this; if ((($a = ($b = self.$user()['$=='](nil)['$!'](), $b !== false && $b !== nil ?message.$to_s()['$==']("")['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { message = "

" + (message) + "

"; message = message.$gsub(/\n\n/, "

"); message = message.$gsub(/\n/, "
"); return self.$user().$stream().$send(message); } else { return nil }; }; def.$stream = function(message) { var $a, $b, self = this; if ((($a = ($b = self.$user()['$=='](nil)['$!'](), $b !== false && $b !== nil ?message.$to_s()['$==']("")['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$user().$stream().$send(message) } else { return nil }; }; def.$destroy = TMP_2 = function() {var $zuper = $slice.call(arguments, 0); var $a, self = this, $iter = TMP_2.$$p, $yield = $iter || nil; TMP_2.$$p = null; if ((($a = self.user['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.user.$quit()}; return Opal.find_super_dispatcher(self, 'destroy', TMP_2, $iter).apply(self, $zuper); }; def.$proceed = function() { var $a, self = this; if ((($a = self.$delegate_stack().$last()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; return self.$delegate_stack().$last().$proceed(); }; def.$on_turn = function() { var self = this; return nil; }; self.$private(); return (def.$delegate_stack = function() { var $a, self = this; return ((($a = self.delegate_stack) !== false && $a !== nil) ? $a : self.delegate_stack = []); }, nil) && 'delegate_stack'; })(self, $scope.get('Entity')) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_accessor', '$attr_writer', '$new', '$scene_class', '$attr_reader', '$instance_variable_get', '$state', '$data_class', '$prompt=', '$prompt', '$nil?', '$input=', '$call', '$next_cue', '$next_cue=']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $SceneManager(){}; var self = $SceneManager = $klass($base, $super, 'SceneManager', $SceneManager); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3; def.state = def.prompt = nil; self.$attr_accessor("state"); self.$attr_writer("prompt"); def.$initialize = TMP_1 = function() { var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil; TMP_1.$$p = null; if ((block !== nil)) { return $a = Opal.yield1(block, self), $a === $breaker ? $a : $a } else { return nil }; }; def.$data_class = function() { var self = this; return $scope.get('SceneData'); }; def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "Passive"); }; def.$scene_class = function() { var self = this; return $scope.get('Scene'); }; def.$start = TMP_2 = function() { var self = this, $iter = TMP_2.$$p, block = $iter || nil; TMP_2.$$p = null; return self.start = block; }; def.$finish = TMP_3 = function() { var self = this, $iter = TMP_3.$$p, block = $iter || nil; TMP_3.$$p = null; return self.finish = block; }; def.$prepare = function(key) { var self = this; return self.$scene_class().$new(self, key); }; return (def.$prompt = function() { var $a, self = this; return ((($a = self.prompt) !== false && $a !== nil) ? $a : self.prompt = ">"); }, nil) && 'prompt'; })(self, null); (function($base, $super) { function $SceneData(){}; var self = $SceneData = $klass($base, $super, 'SceneData', $SceneData); var def = self.$$proto, $scope = self.$$scope; return self.$attr_accessor("input", "prompt", "next_cue") })(self, null); (function($base, $super) { function $Scene(){}; var self = $Scene = $klass($base, $super, 'Scene', $Scene); var def = self.$$proto, $scope = self.$$scope; def.data = def.start = def.finish = nil; self.$attr_reader("data", "state", "key"); def.$initialize = function(manager, key) { var $a, $b, self = this; self.manager = manager; self.start = manager.$instance_variable_get("@start"); self.finish = manager.$instance_variable_get("@finish"); self.state = manager.$state(); self.data = manager.$data_class().$new(); (($a = [manager.$prompt()]), $b = self.data, $b['$prompt='].apply($b, $a), $a[$a.length-1]); return self.key = key; }; def.$start = function(actor) { var $a, $b, self = this; if ((($a = self.start['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; (($a = [nil]), $b = self.data, $b['$input='].apply($b, $a), $a[$a.length-1]); return self.start.$call(actor, self.data); }; return (def.$finish = function(actor, input) { var $a, $b, self = this; ($a = self.data, ((($b = $a.$next_cue()) !== false && $b !== nil) ? $b : $a['$next_cue=']("active"))); if ((($a = self.finish['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; (($a = [input]), $b = self.data, $b['$input='].apply($b, $a), $a[$a.length-1]); return self.finish.$call(actor, self.data); }, nil) && 'finish'; })(self, null); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene/active"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$input=', '$nil?', '$perform', '$input', '$data', '$instance_variable_set', '$call']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $ActiveSceneManager(){}; var self = $ActiveSceneManager = $klass($base, $super, 'ActiveSceneManager', $ActiveSceneManager); var def = self.$$proto, $scope = self.$$scope; def.state = nil; def.$scene_class = function() { var self = this; return $scope.get('ActiveScene'); }; return (def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "Active"); }, nil) && 'state'; })(self, $scope.get('SceneManager')); (function($base, $super) { function $ActiveScene(){}; var self = $ActiveScene = $klass($base, $super, 'ActiveScene', $ActiveScene); var def = self.$$proto, $scope = self.$$scope; def.data = def.finish = nil; return (def.$finish = function(actor, input) { var $a, $b, self = this, last_order = nil; (($a = [input]), $b = self.data, $b['$input='].apply($b, $a), $a[$a.length-1]); if ((($a = self.finish['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { last_order = actor.$perform(self.$data().$input()); return actor.$instance_variable_set("@last_order", last_order); } else { return self.finish.$call(actor, self.$data()) }; }, nil) && 'finish' })(self, $scope.get('Scene')); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene/concluded"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $ConcludedSceneManager(){}; var self = $ConcludedSceneManager = $klass($base, $super, 'ConcludedSceneManager', $ConcludedSceneManager); var def = self.$$proto, $scope = self.$$scope; def.state = def.prompt = nil; def.$scene_class = function() { var self = this; return $scope.get('ConcludedScene'); }; def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "Concluded"); }; return (def.$prompt = function() { var $a, self = this; return ((($a = self.prompt) !== false && $a !== nil) ? $a : self.prompt = "GAME OVER"); }, nil) && 'prompt'; })(self, $scope.get('SceneManager')); (function($base, $super) { function $ConcludedScene(){}; var self = $ConcludedScene = $klass($base, $super, 'ConcludedScene', $ConcludedScene); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Scene')); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene/paused"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_accessor']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $PausedSceneManager(){}; var self = $PausedSceneManager = $klass($base, $super, 'PausedSceneManager', $PausedSceneManager); var def = self.$$proto, $scope = self.$$scope; def.state = def.prompt = nil; def.$scene_class = function() { var self = this; return $scope.get('PausedScene'); }; def.$data_class = function() { var self = this; return $scope.get('PausedSceneData'); }; def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "Paused"); }; return (def.$prompt = function() { var $a, self = this; return ((($a = self.prompt) !== false && $a !== nil) ? $a : self.prompt = "Press enter to continue..."); }, nil) && 'prompt'; })(self, $scope.get('SceneManager')); (function($base, $super) { function $PausedSceneData(){}; var self = $PausedSceneData = $klass($base, $super, 'PausedSceneData', $PausedSceneData); var def = self.$$proto, $scope = self.$$scope; return self.$attr_accessor("next_cue") })(self, $scope.get('SceneData')); (function($base, $super) { function $PausedScene(){}; var self = $PausedScene = $klass($base, $super, 'PausedScene', $PausedScene); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Scene')); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene/multiplechoice"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_accessor', '$each', '$push', '$options', '$prompt=', '$join', '$input=', '$index=', '$selection=', '$to_i', '$nil?', '$[]', '$tell', '$call', '$data']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $MultipleChoiceSceneManager(){}; var self = $MultipleChoiceSceneManager = $klass($base, $super, 'MultipleChoiceSceneManager', $MultipleChoiceSceneManager); var def = self.$$proto, $scope = self.$$scope; def.state = nil; def.$data_class = function() { var self = this; return $scope.get('MultipleChoiceSceneData'); }; def.$scene_class = function() { var self = this; return $scope.get('MultipleChoiceScene'); }; return (def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "MultipleChoice"); }, nil) && 'state'; })(self, $scope.get('SceneManager')); (function($base, $super) { function $MultipleChoiceSceneData(){}; var self = $MultipleChoiceSceneData = $klass($base, $super, 'MultipleChoiceSceneData', $MultipleChoiceSceneData); var def = self.$$proto, $scope = self.$$scope; def.options = nil; self.$attr_accessor("index", "selection", "options"); return (def.$options = function() { var $a, self = this; return ((($a = self.options) !== false && $a !== nil) ? $a : self.options = []); }, nil) && 'options'; })(self, $scope.get('SceneData')); (function($base, $super) { function $MultipleChoiceScene(){}; var self = $MultipleChoiceScene = $klass($base, $super, 'MultipleChoiceScene', $MultipleChoiceScene); var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2; def.prompt = def.data = def.end_prompt = def.finish = nil; def.$initialize = TMP_1 = function(manager, key) {var $zuper = $slice.call(arguments, 0); var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil; TMP_1.$$p = null; Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper); return self.end_prompt = ((($a = self.prompt) !== false && $a !== nil) ? $a : "Enter a choice:"); }; def.$start = TMP_2 = function(actor) {var $zuper = $slice.call(arguments, 0); var $a, $b, TMP_3, $c, self = this, $iter = TMP_2.$$p, $yield = $iter || nil, list = nil, index = nil; TMP_2.$$p = null; Opal.find_super_dispatcher(self, 'start', TMP_2, $iter).apply(self, $zuper); list = []; index = 1; ($a = ($b = self.data.$options()).$each, $a.$$p = (TMP_3 = function(o){var self = TMP_3.$$s || this; if (o == null) o = nil; list.$push("" + (index) + ". " + (o)); return index = $rb_plus(index, 1);}, TMP_3.$$s = self, TMP_3), $a).call($b); return (($a = ["" + (list.$join("\n")) + "\n" + (self.end_prompt)]), $c = self.data, $c['$prompt='].apply($c, $a), $a[$a.length-1]); }; return (def.$finish = function(actor, input) { var $a, $b, self = this, index = nil; (($a = [input]), $b = self.data, $b['$input='].apply($b, $a), $a[$a.length-1]); (($a = [nil]), $b = self.data, $b['$index='].apply($b, $a), $a[$a.length-1]); (($a = [nil]), $b = self.data, $b['$selection='].apply($b, $a), $a[$a.length-1]); index = input.$to_i(); if ((($a = self.data.$options()['$[]']($rb_minus(index, 1))['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return actor.$tell("That's not a valid selection.") } else { if ((($a = self.finish['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; (($a = [$rb_minus(index, 1)]), $b = self.data, $b['$index='].apply($b, $a), $a[$a.length-1]); (($a = [self.data.$options()['$[]']($rb_minus(index, 1))]), $b = self.data, $b['$selection='].apply($b, $a), $a[$a.length-1]); return self.finish.$call(actor, self.$data()); }; }, nil) && 'finish'; })(self, $scope.get('Scene')); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/scene/yesorno"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_accessor', '$input=', '$answer=', '$==', '$[]', '$downcase', '$nil?', '$answer', '$tell', '$call', '$data']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $YesOrNoSceneManager(){}; var self = $YesOrNoSceneManager = $klass($base, $super, 'YesOrNoSceneManager', $YesOrNoSceneManager); var def = self.$$proto, $scope = self.$$scope; def.state = def.prompt = nil; def.$scene_class = function() { var self = this; return $scope.get('YesOrNoScene'); }; def.$data_class = function() { var self = this; return $scope.get('YesOrNoSceneData'); }; def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = "YesOrNo"); }; return (def.$prompt = function() { var $a, self = this; return ((($a = self.prompt) !== false && $a !== nil) ? $a : self.prompt = "Enter Yes Or No:"); }, nil) && 'prompt'; })(self, $scope.get('SceneManager')); (function($base, $super) { function $YesOrNoSceneData(){}; var self = $YesOrNoSceneData = $klass($base, $super, 'YesOrNoSceneData', $YesOrNoSceneData); var def = self.$$proto, $scope = self.$$scope; return self.$attr_accessor("answer") })(self, $scope.get('SceneData')); (function($base, $super) { function $YesOrNoScene(){}; var self = $YesOrNoScene = $klass($base, $super, 'YesOrNoScene', $YesOrNoScene); var def = self.$$proto, $scope = self.$$scope; def.data = def.finish = nil; return (def.$finish = function(actor, input) { var $a, $b, self = this; (($a = [input]), $b = self.data, $b['$input='].apply($b, $a), $a[$a.length-1]); (($a = [nil]), $b = self.data, $b['$answer='].apply($b, $a), $a[$a.length-1]); if (input.$downcase()['$[]'](0, 1)['$==']("y")) { (($a = ["yes"]), $b = self.data, $b['$answer='].apply($b, $a), $a[$a.length-1]) } else if (input.$downcase()['$[]'](0, 1)['$==']("n")) { (($a = ["no"]), $b = self.data, $b['$answer='].apply($b, $a), $a[$a.length-1])}; if ((($a = self.data.$answer()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return actor.$tell("Please enter Yes or No.") } else { if ((($a = self.finish['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; return self.finish.$call(actor, self.$data()); }; }, nil) && 'finish' })(self, $scope.get('Scene')); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/action"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_reader', '$!', '$kind_of?', '$to_s', '$==', '$nil?', '$raise', '$length', '$arity', '$send', '$each', '$specificity', '$call', '$push', '$signature', '$gsub', '$join', '$private', '$new', '$class', '$superclass']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Action(){}; var self = $Action = $klass($base, $super, 'Action', $Action); var def = self.$$proto, $scope = self.$$scope, TMP_1; def.proc = def.queries = def.command = def.key = nil; self.$attr_reader("order_key", "caller", "queries"); (Opal.cvars['@@order_key_seed'] = 0); def.$initialize = TMP_1 = function(story, command, queries) { var $a, $b, $c, self = this, $iter = TMP_1.$$p, proc = $iter || nil; queries = $slice.call(arguments, 2); TMP_1.$$p = null; if ((($a = command['$kind_of?']($scope.get('Symbol'))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { command = command.$to_s(); if (command['$==']("")) { command = nil};}; self.plot = story; self.order_key = (($a = Opal.cvars['@@order_key_seed']) == null ? nil : $a); (Opal.cvars['@@order_key_seed'] = $rb_plus((($a = Opal.cvars['@@order_key_seed']) == null ? nil : $a), 1)); self.proc = proc; if ((($a = ((($b = command['$kind_of?']($scope.get('Symbol'))['$=='](false)) ? command['$nil?']()['$!']() : $b))) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Action commands must be symbols")}; if ((($a = self.proc['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = ($b = ($rb_plus(queries.$length(), 1)['$=='](self.proc.$arity())['$!']()), $b !== false && $b !== nil ?((($c = queries.$length()['$=='](0)) ? self.proc.$arity()['$=='](-1)['$!']() : $c)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { self.$raise("Number of queries is not compatible with proc arguments")}}; self.command = command; self.queries = queries; if ((($a = story['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return story.$send("add_action", self) } else { return nil }; }; def.$block = function() { var self = this; return self.proc; }; def.$specificity = function() { var $a, $b, TMP_2, self = this, spec = nil, magnitude = nil; spec = 0; magnitude = 1; ($a = ($b = self.queries).$each, $a.$$p = (TMP_2 = function(q){var self = TMP_2.$$s || this, $a; if (q == null) q = nil; if ((($a = q['$kind_of?']((($scope.get('Query')).$$scope.get('Base')))) !== nil && (!$a.$$is_boolean || $a == true))) { return spec = $rb_plus(spec, ($rb_times(q.$specificity(), magnitude))) } else { return spec = $rb_plus(spec, magnitude) }}, TMP_2.$$s = self, TMP_2), $a).call($b); return spec; }; def.$verb = function() { var self = this; return self.command; }; def.$command = function() { var self = this; return self.command; }; def.$key = function() { var self = this; return self.key; }; def.$execute = function(args) { var $a, self = this; args = $slice.call(arguments, 0); return ($a = self.proc).$call.apply($a, [].concat(args)); }; def.$signature = function() { var $a, $b, TMP_3, self = this, sig = nil; sig = ["" + (self.command)]; ($a = ($b = self.queries).$each, $a.$$p = (TMP_3 = function(q){var self = TMP_3.$$s || this; if (q == null) q = nil; return sig.$push(q.$signature())}, TMP_3.$$s = self, TMP_3), $a).call($b); return sig.$join(", ").$gsub(/Gamefic::/, ""); }; self.$private(); return (Opal.defs(self, '$explode', function(entity) { var $a, $b, self = this, arr = nil, cls = nil; arr = $scope.get('Array').$new(); arr.$push(entity); cls = entity.$class(); while ((($b = cls['$==']($scope.get('Object'))['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) { arr.$push(cls); cls = cls.$superclass();}; arr.$push($scope.get('String')); return arr.$push(nil); }), nil) && 'explode'; })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/meta"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Meta(){}; var self = $Meta = $klass($base, $super, 'Meta', $Meta); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Action')) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/syntax/match"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; Opal.add_stubs(['$attr_reader']); return (function($base, $super) { function $Match(){}; var self = $Match = $klass($base, $super, 'Match', $Match); var def = self.$$proto, $scope = self.$$scope; self.$attr_reader("verb", "arguments"); return (def.$initialize = function(verb, arguments$) { var self = this; self.verb = verb; return self["arguments"] = arguments$; }, nil) && 'initialize'; })((($scope.get('Gamefic')).$$scope.get('Syntax')), null) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/syntax"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $range = Opal.range; Opal.add_stubs(['$autoload', '$attr_reader', '$join', '$split_words', '$length', '$==', '$[]', '$!', '$nil?', '$to_sym', '$to_s', '$each', '$match', '$push', '$index', '$new', '$send', '$to_i', '$signature', '$translate']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Syntax(){}; var self = $Syntax = $klass($base, $super, 'Syntax', $Syntax); var def = self.$$proto, $scope = self.$$scope; def.token_count = def.regexp = def.replace = def.verb = nil; self.$autoload("Match", "gamefic/syntax/match"); self.$attr_reader("token_count", "first_word", "verb", "template", "command"); (Opal.cvars['@@phrase'] = "([\\w\\W\\s\\S]*?)"); def.$initialize = function(plot, template, command) { var $a, $b, TMP_1, $c, TMP_2, self = this, words = nil, command_words = nil, tokens = nil, variable_tokens = nil, last_token_is_reg = nil, subs = nil, index = nil; command = $slice.call(arguments, 2); command = command.$join(" "); words = template.$split_words(); self.token_count = words.$length(); command_words = command.$split_words(); self.verb = nil; if (words['$[]'](0)['$[]'](0)['$=='](":")) { self.token_count = $rb_minus(self.token_count, 1); self.first_word = ""; } else { if ((($a = command_words['$[]'](0)['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.verb = command_words['$[]'](0).$to_sym()}; self.first_word = words['$[]'](0).$to_s(); }; self.command = command_words.$join(" "); self.template = words.$join(" "); tokens = []; variable_tokens = []; last_token_is_reg = false; ($a = ($b = words).$each, $a.$$p = (TMP_1 = function(w){var self = TMP_1.$$s || this, $a; if (w == null) w = nil; if ((($a = w.$match(/^:[a-z0-9_]+$/i)) !== nil && (!$a.$$is_boolean || $a == true))) { variable_tokens.$push(w); if (last_token_is_reg !== false && last_token_is_reg !== nil) { return nil; } else { tokens.$push((($a = Opal.cvars['@@phrase']) == null ? nil : $a)); return last_token_is_reg = true; }; } else { tokens.$push(w); return last_token_is_reg = false; }}, TMP_1.$$s = self, TMP_1), $a).call($b); subs = []; index = 0; ($a = ($c = command_words).$each, $a.$$p = (TMP_2 = function(t){var self = TMP_2.$$s || this; if (t == null) t = nil; if (t['$[]'](0)['$=='](":")) { index = $rb_plus(variable_tokens.$index(t), 1); return subs.$push("{$" + (index) + "}"); } else { return subs.$push(t) }}, TMP_2.$$s = self, TMP_2), $a).call($c); self.replace = subs.$join(" "); self.regexp = $scope.get('Regexp').$new("^" + (tokens.$join(" ")) + "$"); if ((($a = plot['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return plot.$send("add_syntax", self) } else { return nil }; }; def.$translate = function(text) { var $a, $b, TMP_3, self = this, m = nil, arguments$ = nil; m = text.$match(self.regexp); if ((($a = m['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; arguments$ = []; ($a = ($b = self.replace.$to_s().$split_words()).$each, $a.$$p = (TMP_3 = function(r){var self = TMP_3.$$s || this, $a; if (r == null) r = nil; if ((($a = r.$match(/^\{\$[0-9]+\}$/)) !== nil && (!$a.$$is_boolean || $a == true))) { return arguments$.$push(m['$[]'](r['$[]']($range(2, -2, false)).$to_i())) } else { return arguments$.$push(r) }}, TMP_3.$$s = self, TMP_3), $a).call($b); return (($scope.get('Syntax')).$$scope.get('Match')).$new(self.verb, arguments$); }; def.$signature = function() { var self = this; return [self.regexp, self.replace]; }; def['$=='] = function(other) { var self = this; return self.$signature()['$=='](other.$signature()); }; return (Opal.defs(self, '$match', function(text, syntaxes) { var $a, $b, TMP_4, self = this, matches = nil; matches = []; ($a = ($b = syntaxes).$each, $a.$$p = (TMP_4 = function(syntax){var self = TMP_4.$$s || this, $a, result = nil; if (syntax == null) syntax = nil; result = syntax.$translate(text); if ((($a = result['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return matches.$push(result) } else { return nil };}, TMP_4.$$s = self, TMP_4), $a).call($b); return matches; }), nil) && 'match'; })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/rule"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; Opal.add_stubs(['$attr_reader', '$call']); (function($base, $super) { function $Rule(){}; var self = $Rule = $klass($base, $super, 'Rule', $Rule); var def = self.$$proto, $scope = self.$$scope, TMP_1; def.block = nil; self.$attr_reader("caller"); def.$initialize = TMP_1 = function(name) { var self = this, $iter = TMP_1.$$p, block = $iter || nil; TMP_1.$$p = null; self.name = name; return self.block = block; }; return (def.$test = function(actor, verb, arguments$) { var self = this; return self.block.$call(actor, verb, arguments$); }, nil) && 'test'; })(self, null); return (function($base, $super) { function $Assert(){}; var self = $Assert = $klass($base, $super, 'Assert', $Assert); var def = self.$$proto, $scope = self.$$scope; return nil; })(self, $scope.get('Rule')); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/director/order"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$attr_reader']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Order(){}; var self = $Order = $klass($base, $super, 'Order', $Order); var def = self.$$proto, $scope = self.$$scope; self.$attr_reader("actor", "action", "arguments"); return (def.$initialize = function(actor, action, arguments$) { var self = this; self.actor = actor; self.action = action; return self["arguments"] = arguments$; }, nil) && 'initialize'; })($scope.get('Director'), null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/director/parser"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$require', '$shift', '$actions_with_verb', '$plot', '$to_sym', '$each', '$==', '$length', '$queries', '$validate', '$[]', '$push', '$new', '$unshift', '$definitely', '$tell', '$join_or', '$to_s', '$match', '$syntaxes', '$verb', '$bind_contexts_in_result', '$arguments', '$action', '$private', '$clone', '$execute_query', '$optional?', '$last', '$pop', '$nil?', '$kind_of?', '$execute', '$objects', '$remainder', '$raise', '$uniq!', '$times']); self.$require("gamefic/director/order"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Director(){}; var self = $Director = $klass($base, $super, 'Director', $Director); var def = self.$$proto, $scope = self.$$scope; return (function($base) { var self = $module($base, 'Parser'); var def = self.$$proto, $scope = self.$$scope; Opal.defs(self, '$from_tokens', function(actor, tokens) { var $a, $b, TMP_1, self = this, options = nil, command = nil, actions = nil; options = []; command = tokens.$shift(); actions = actor.$plot().$actions_with_verb(command.$to_sym()); ($a = ($b = actions).$each, $a.$$p = (TMP_1 = function(action){var self = TMP_1.$$s || this, $a, $b, TMP_2, valid = nil, index = nil; if (action == null) action = nil; if (action.$queries().$length()['$=='](tokens.$length())) { valid = true; index = 0; ($a = ($b = action.$queries()).$each, $a.$$p = (TMP_2 = function(query){var self = TMP_2.$$s || this; if (query == null) query = nil; if (query.$validate(actor, tokens['$[]'](index))['$=='](false)) { valid = false; return ($breaker.$v = nil, $breaker);}; return index = $rb_plus(index, 1);}, TMP_2.$$s = self, TMP_2), $a).call($b); if (valid !== false && valid !== nil) { return options.$push($scope.get('Order').$new(actor, action, tokens)) } else { return nil }; } else { return nil }}, TMP_1.$$s = self, TMP_1), $a).call($b); if (options.$length()['$=='](0)) { tokens.$unshift(command)}; return options; }); Opal.defs(self, '$from_string', function(actor, command) { var $a, $b, TMP_3, $c, TMP_5, self = this, base = nil, options = nil, matches = nil; base = (($scope.get('Query')).$$scope.get('Base')).$new(); self.disambiguator = ($a = ($b = $scope.get('Meta')).$new, $a.$$p = (TMP_3 = function(actor, entities){var self = TMP_3.$$s || this, $a, $b, TMP_4, definites = nil; if (actor == null) actor = nil;if (entities == null) entities = nil; definites = []; ($a = ($b = entities).$each, $a.$$p = (TMP_4 = function(entity){var self = TMP_4.$$s || this; if (entity == null) entity = nil; return definites.$push(entity.$definitely())}, TMP_4.$$s = self, TMP_4), $a).call($b); return actor.$tell("I don't know which you mean: " + (definites.$join_or()) + ".");}, TMP_3.$$s = self, TMP_3), $a).call($b, nil, nil, base); options = []; if (command.$to_s()['$==']("")) { return options}; matches = $scope.get('Syntax').$match(command, actor.$plot().$syntaxes()); ($a = ($c = matches).$each, $a.$$p = (TMP_5 = function(match){var self = TMP_5.$$s || this, $a, $b, TMP_6, actions = nil; if (match == null) match = nil; actions = actor.$plot().$actions_with_verb(match.$verb()); return ($a = ($b = actions).$each, $a.$$p = (TMP_6 = function(action){var self = TMP_6.$$s || this, $a, $b, TMP_7, orders = nil; if (action == null) action = nil; orders = self.$bind_contexts_in_result(actor, match.$arguments(), action); return ($a = ($b = orders).$each, $a.$$p = (TMP_7 = function(order){var self = TMP_7.$$s || this, $a, $b, TMP_8, valid = nil, args = nil, invalid_argument = nil; if (self.disambiguator == null) self.disambiguator = nil; if (order == null) order = nil; valid = true; args = $scope.get('Array').$new(); invalid_argument = nil; ($a = ($b = order.$arguments()).$each, $a.$$p = (TMP_8 = function(a){var self = TMP_8.$$s || this; if (a == null) a = nil; if ($rb_gt(a.$length(), 1)) { invalid_argument = a; valid = false; return ($breaker.$v = nil, $breaker);}; return args.$push(a['$[]'](0));}, TMP_8.$$s = self, TMP_8), $a).call($b); if (valid !== false && valid !== nil) { return options.$push($scope.get('Order').$new(actor, order.$action(), args)) } else { return options.$unshift($scope.get('Order').$new(actor, self.disambiguator, [invalid_argument])) };}, TMP_7.$$s = self, TMP_7), $a).call($b);}, TMP_6.$$s = self, TMP_6), $a).call($b);}, TMP_5.$$s = self, TMP_5), $a).call($c); return options; }); self.$private(); Opal.defs(self, '$bind_contexts_in_result', function(actor, handler, action) { var $a, $b, $c, self = this, queries = nil, objects = nil, num_nil = nil; queries = action.$queries().$clone(); objects = self.$execute_query(actor, handler.$clone(), queries, action); num_nil = 0; while ((($b = (($c = objects.$length()['$=='](0)) ? queries.$last()['$optional?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) { num_nil = $rb_plus(num_nil, 1); queries.$pop(); objects = self.$execute_query(actor, handler.$clone(), queries, action, num_nil);}; return objects; }); Opal.defs(self, '$execute_query', function(actor, arguments$, queries, action, num_nil) { var $a, $b, TMP_9, $c, TMP_10, $d, TMP_11, self = this, prepared = nil, objects = nil, valid = nil, last_remainder = nil; if (num_nil == null) { num_nil = 0 } if ((($a = action.$verb()['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { } else { arguments$.$shift() }; prepared = $scope.get('Array').$new(); objects = $scope.get('Array').$new(); valid = true; last_remainder = nil; ($a = ($b = queries.$clone()).$each, $a.$$p = (TMP_9 = function(context){var self = TMP_9.$$s || this, $a, $b, arg = nil, result = nil; if (context == null) context = nil; arg = ((($a = arguments$.$shift()) !== false && $a !== nil) ? $a : last_remainder); if ((($a = ((($b = arg['$nil?']()) !== false && $b !== nil) ? $b : arg['$=='](""))) !== nil && (!$a.$$is_boolean || $a == true))) { valid = false; return nil;;}; if (context['$==']($scope.get('String'))) { return prepared.$push([arg]) } else if ((($a = context['$kind_of?']((($scope.get('Query')).$$scope.get('Base')))) !== nil && (!$a.$$is_boolean || $a == true))) { result = context.$execute(actor, arg); if (result.$objects().$length()['$=='](0)) { valid = false; return nil;; } else { prepared.$push(result.$objects()); return last_remainder = result.$remainder(); }; } else { return self.$raise($scope.get('TypeError').$new("Action parameters must inherit from Query::Base")) };}, TMP_9.$$s = self, TMP_9), $a).call($b); if (valid['$=='](true)) { ($a = ($c = prepared).$each, $a.$$p = (TMP_10 = function(p){var self = TMP_10.$$s || this; if (p == null) p = nil; return p['$uniq!']()}, TMP_10.$$s = self, TMP_10), $a).call($c); ($a = ($d = num_nil).$times, $a.$$p = (TMP_11 = function(){var self = TMP_11.$$s || this; return prepared.$push([nil])}, TMP_11.$$s = self, TMP_11), $a).call($d); objects.$push($scope.get('Order').$new(actor, action, prepared));}; return objects; }); })(self) })(self, null) })(self); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/director/delegate"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$shift', '$nil?', '$push', '$send', '$clone', '$arguments', '$unshift', '$execute', '$action', '$pop', '$==', '$length', '$!', '$kind_of?', '$[]', '$each_pair', '$test', '$verb', '$asserts', '$plot', '$proceed']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Director(){}; var self = $Director = $klass($base, $super, 'Director', $Director); var def = self.$$proto, $scope = self.$$scope; return (function($base, $super) { function $Delegate(){}; var self = $Delegate = $klass($base, $super, 'Delegate', $Delegate); var def = self.$$proto, $scope = self.$$scope; def.orders = def.actor = nil; def.$initialize = function(actor, orders) { var self = this; self.actor = actor; return self.orders = orders; }; def.$proceed = function() { var $a, self = this, order = nil, arguments$ = nil; order = self.orders.$shift(); if ((($a = order['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; self.actor.$send("delegate_stack").$push(self); arguments$ = order.$arguments().$clone(); arguments$.$unshift(self.actor); ($a = order.$action()).$execute.apply($a, [].concat(arguments$)); return self.actor.$send("delegate_stack").$pop(); }; return (def.$execute = function() {try { var $a, $b, TMP_1, self = this; if (self.orders.$length()['$=='](0)) { return nil}; if ((($a = self.orders['$[]'](0).$action()['$kind_of?']($scope.get('Meta'))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { ($a = ($b = self.actor.$plot().$asserts()).$each_pair, $a.$$p = (TMP_1 = function(name, rule){var self = TMP_1.$$s || this, result = nil; if (self.actor == null) self.actor = nil; if (self.orders == null) self.orders = nil; if (name == null) name = nil;if (rule == null) rule = nil; result = rule.$test(self.actor, self.orders['$[]'](0).$action().$verb(), self.orders['$[]'](0).$arguments()); if (result['$=='](false)) { Opal.ret(nil) } else { return nil };}, TMP_1.$$s = self, TMP_1), $a).call($b)}; return self.$proceed(); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, nil) && 'execute'; })(self, null) })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/director"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$autoload', '$length', '$from_tokens', '$==', '$from_string', '$strip', '$join', '$[]', '$new', '$execute']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Director(){}; var self = $Director = $klass($base, $super, 'Director', $Director); var def = self.$$proto, $scope = self.$$scope; self.$autoload("Parser", "gamefic/director/parser"); self.$autoload("Delegate", "gamefic/director/delegate"); self.$autoload("Order", "gamefic/director/order"); return (Opal.defs(self, '$dispatch', function(actor, args) { var self = this, orders = nil, first_order = nil, del = nil; args = $slice.call(arguments, 1); orders = []; if ($rb_gt(args.$length(), 1)) { orders = $scope.get('Parser').$from_tokens(actor, args)}; if (orders.$length()['$=='](0)) { orders = $scope.get('Parser').$from_string(actor, args.$join(" ").$strip())}; first_order = orders['$[]'](0); del = $scope.get('Delegate').$new(actor, orders); del.$execute(); return first_order; }), nil) && 'dispatch'; })(self, null) })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/engine"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2; Opal.add_stubs(['$post_initialize', '$new', '$introduce', '$character', '$print', '$output', '$state', '$!', '$==', '$scene', '$turn', '$ready', '$key', '$select', '$stream', '$prompt', '$data', '$input', '$update', '$attr_reader', '$connect', '$clone', '$flush', '$gets', '$push', '$strip', '$shift', '$recv', '$queue']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Engine(){}; var self = $Engine = $klass($base, $super, 'Engine', $Engine); var def = self.$$proto, $scope = self.$$scope; def.plot = def.user = nil; def.$initialize = function(plot) { var self = this; self.plot = plot; return self.$post_initialize(); }; def.$post_initialize = function() { var self = this; return self.user = $scope.get('User').$new(self.plot); }; def.$run = function() { var $a, $b, self = this; self.plot.$introduce(self.user.$character()); self.$print(self.user.$state().$output()); while ((($b = self.user.$character().$scene().$state()['$==']("Concluded")['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) { self.$turn()}; }; return (def.$turn = function() { var $a, self = this; self.plot.$ready(); self.$print(self.user.$state().$output()); if ((($a = self.user.$character().$scene().$key()['$==']("test")['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { if ((($a = self.user.$character().$scene().$state()['$==']("Concluded")['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { self.user.$stream().$select(self.user.$character().$scene().$data().$prompt()); self.user.$state().$input();}}; self.plot.$update(); return self.$print(self.user.$state().$output()); }, nil) && 'turn'; })(self, null); (function($base, $super) { function $User(){}; var self = $User = $klass($base, $super, 'User', $User); var def = self.$$proto, $scope = self.$$scope; def.plot = def.character = def.stream = def.state = nil; self.$attr_reader("state", "character", "story"); def.$initialize = function(plot) { var self = this; self.plot = plot; self.character = $scope.get('Character').$new(self.plot, $hash2(["name", "synonyms", "proper_named"], {"name": "yourself", "synonyms": "self myself you me", "proper_named": true})); self.character.$connect(self); return self.$post_initialize(); }; def.$post_initialize = function() { var self = this; self.stream = $scope.get('UserStream').$new(); return self.state = $scope.get('UserState').$new(self); }; def.$stream = function() { var $a, self = this; return ((($a = self.stream) !== false && $a !== nil) ? $a : self.stream = $scope.get('UserStream').$new()); }; def.$state = function() { var $a, self = this; return ((($a = self.state) !== false && $a !== nil) ? $a : self.state = $scope.get('UserState').$new(self)); }; def['$state='] = function(state_class) { var self = this; return self.state = state_class.$new(self); }; def.$refresh = function() { var self = this; return nil; }; return (def.$quit = function() { var self = this; return nil; }, nil) && 'quit'; })(self, null); (function($base, $super) { function $UserStream(){}; var self = $UserStream = $klass($base, $super, 'UserStream', $UserStream); var def = self.$$proto, $scope = self.$$scope; def.buffer = def.queue = nil; def.$initialize = function() { var self = this; self.queue = $scope.get('Array').$new(); return self.buffer = ""; }; def.$flush = function() { var self = this, tmp = nil; tmp = self.buffer.$clone(); self.buffer = ""; return tmp; }; def.$send = function(data) { var self = this; return self.buffer = $rb_plus(self.buffer, data); }; def.$select = function(prompt) { var self = this, line = nil; self.$print("" + (prompt) + " "); $scope.get('STDOUT').$flush(); line = $scope.get('STDIN').$gets(); return self.queue.$push(line.$strip()); }; return (def.$recv = function() { var self = this; return self.queue.$shift(); }, nil) && 'recv'; })(self, null); (function($base, $super) { function $UserState(){}; var self = $UserState = $klass($base, $super, 'UserState', $UserState); var def = self.$$proto, $scope = self.$$scope; def.user = nil; self.$attr_reader("user"); def.$initialize = function(user) { var self = this; return self.user = user; }; def.$input = function() { var $a, self = this, line = nil; line = self.user.$stream().$recv(); if ((($a = line['$=='](nil)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.user.$character().$queue().$push(line) } else { return nil }; }; return (def.$output = function() { var self = this; return self.user.$stream().$flush(); }, nil) && 'output'; })(self, null); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/direction"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2; Opal.add_stubs(['$attr_accessor', '$each', '$send', '$!', '$nil?', '$reverse', '$reverse=', '$adjective', '$adverb', '$[]', '$new']); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Direction(){}; var self = $Direction = $klass($base, $super, 'Direction', $Direction); var def = self.$$proto, $scope = self.$$scope; def.adjective = def.name = def.adverb = nil; self.$attr_accessor("name", "adjective", "adverb", "reverse"); def.$initialize = function(args) { var $a, $b, TMP_1, $c, self = this, proper_named = nil; if (args == null) { args = $hash2([], {}) } ($a = ($b = args).$each, $a.$$p = (TMP_1 = function(key, value){var self = TMP_1.$$s || this; if (key == null) key = nil;if (value == null) value = nil; return self.$send("" + (key) + "=", value)}, TMP_1.$$s = self, TMP_1), $a).call($b); if ((($a = self.$reverse()['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { (($a = [self]), $c = self.$reverse(), $c['$reverse='].apply($c, $a), $a[$a.length-1])}; return proper_named = true; }; def.$adjective = function() { var $a, self = this; return ((($a = self.adjective) !== false && $a !== nil) ? $a : self.name); }; def.$adverb = function() { var $a, self = this; return ((($a = self.adverb) !== false && $a !== nil) ? $a : self.name); }; def['$reverse='] = function(dir) { var self = this; return self.reverse = dir; }; def.$synonyms = function() { var self = this; return "" + (self.$adjective()) + " " + (self.$adverb()); }; def.$to_s = function() { var self = this; return self.name; }; return (Opal.defs(self, '$find', function(str) { var self = this, x = nil; x = $hash2(["north", "south", "west", "east", "up", "down", "northwest", "northeast", "southwest", "southeast"], {"north": $scope.get('NORTH'), "south": $scope.get('SOUTH'), "west": $scope.get('WEST'), "east": $scope.get('EAST'), "up": $scope.get('UP'), "down": $scope.get('DOWN'), "northwest": $scope.get('NORTHWEST'), "northeast": $scope.get('NORTHEAST'), "southwest": $scope.get('SOUTHWEST'), "southeast": $scope.get('SOUTHEAST')}); return x['$[]'](str); }), nil) && 'find'; })(self, null); Opal.cdecl($scope, 'NORTH', $scope.get('Direction').$new($hash2(["name", "adjective"], {"name": "north", "adjective": "northern"}))); Opal.cdecl($scope, 'SOUTH', $scope.get('Direction').$new($hash2(["name", "adjective", "reverse"], {"name": "south", "adjective": "southern", "reverse": $scope.get('NORTH')}))); Opal.cdecl($scope, 'WEST', $scope.get('Direction').$new($hash2(["name", "adjective"], {"name": "west", "adjective": "western"}))); Opal.cdecl($scope, 'EAST', $scope.get('Direction').$new($hash2(["name", "adjective", "reverse"], {"name": "east", "adjective": "eastern", "reverse": $scope.get('WEST')}))); Opal.cdecl($scope, 'NORTHWEST', $scope.get('Direction').$new($hash2(["name", "adjective"], {"name": "northwest", "adjective": "northwestern"}))); Opal.cdecl($scope, 'SOUTHEAST', $scope.get('Direction').$new($hash2(["name", "adjective", "reverse"], {"name": "southeast", "adjective": "southeastern", "reverse": $scope.get('NORTHWEST')}))); Opal.cdecl($scope, 'NORTHEAST', $scope.get('Direction').$new($hash2(["name", "adjective"], {"name": "northeast", "adjective": "northeastern"}))); Opal.cdecl($scope, 'SOUTHWEST', $scope.get('Direction').$new($hash2(["name", "adjective", "reverse"], {"name": "southwest", "adjective": "southwestern", "reverse": $scope.get('NORTHEAST')}))); Opal.cdecl($scope, 'UP', $scope.get('Direction').$new($hash2(["name", "adjective"], {"name": "up", "adjective": "upwards"}))); Opal.cdecl($scope, 'DOWN', $scope.get('Direction').$new($hash2(["name", "adjective", "reverse"], {"name": "down", "adjective": "downwards", "reverse": $scope.get('UP')}))); })(self) }; /* Generated by Opal 0.8.0 */ Opal.modules["json"] = function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $hash2 = Opal.hash2, $klass = Opal.klass; Opal.add_stubs(['$new', '$push', '$[]=', '$[]', '$create_id', '$json_create', '$attr_accessor', '$create_id=', '$===', '$parse', '$generate', '$from_object', '$to_json', '$responds_to?', '$to_io', '$write', '$to_s', '$to_a', '$strftime']); (function($base) { var self = $module($base, 'JSON'); var def = self.$$proto, $scope = self.$$scope, $a, $b; var $parse = JSON.parse, $hasOwn = Opal.hasOwnProperty; function to_opal(value, options) { switch (typeof value) { case 'string': return value; case 'number': return value; case 'boolean': return !!value; case 'null': return nil; case 'object': if (!value) return nil; if (value.$$is_array) { var arr = (options.array_class).$new(); for (var i = 0, ii = value.length; i < ii; i++) { (arr).$push(to_opal(value[i], options)); } return arr; } else { var hash = (options.object_class).$new(); for (var k in value) { if ($hasOwn.call(value, k)) { (hash)['$[]='](k, to_opal(value[k], options)); } } var klass; if ((klass = (hash)['$[]']($scope.get('JSON').$create_id())) != nil) { klass = Opal.cget(klass); return (klass).$json_create(hash); } else { return hash; } } } }; (function(self) { var $scope = self.$$scope, def = self.$$proto; return self.$attr_accessor("create_id") })(self.$singleton_class()); (($a = ["json_class"]), $b = self, $b['$create_id='].apply($b, $a), $a[$a.length-1]); Opal.defs(self, '$[]', function(value, options) { var $a, self = this; if (options == null) { options = $hash2([], {}) } if ((($a = $scope.get('String')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) { return self.$parse(value, options) } else { return self.$generate(value, options) }; }); Opal.defs(self, '$parse', function(source, options) { var self = this; if (options == null) { options = $hash2([], {}) } return self.$from_object($parse(source), options); }); Opal.defs(self, '$parse!', function(source, options) { var self = this; if (options == null) { options = $hash2([], {}) } return self.$parse(source, options); }); Opal.defs(self, '$from_object', function(js_object, options) { var $a, $b, $c, self = this; if (options == null) { options = $hash2([], {}) } ($a = "object_class", $b = options, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, $scope.get('Hash')))); ($a = "array_class", $b = options, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, $scope.get('Array')))); return to_opal(js_object, options.smap); }); Opal.defs(self, '$generate', function(obj, options) { var self = this; if (options == null) { options = $hash2([], {}) } return obj.$to_json(options); }); Opal.defs(self, '$dump', function(obj, io, limit) { var $a, self = this, string = nil; if (io == null) { io = nil } if (limit == null) { limit = nil } string = self.$generate(obj); if (io !== false && io !== nil) { if ((($a = io['$responds_to?']("to_io")) !== nil && (!$a.$$is_boolean || $a == true))) { io = io.$to_io()}; io.$write(string); return io; } else { return string }; }); })(self); (function($base, $super) { function $Object(){}; var self = $Object = $klass($base, $super, 'Object', $Object); var def = self.$$proto, $scope = self.$$scope; return (Opal.defn(self, '$to_json', function() { var self = this; return self.$to_s().$to_json(); }), nil) && 'to_json' })(self, null); (function($base) { var self = $module($base, 'Enumerable'); var def = self.$$proto, $scope = self.$$scope; Opal.defn(self, '$to_json', function() { var self = this; return self.$to_a().$to_json(); }) })(self); (function($base, $super) { function $Array(){}; var self = $Array = $klass($base, $super, 'Array', $Array); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; var result = []; for (var i = 0, length = self.length; i < length; i++) { result.push((self[i]).$to_json()); } return '[' + result.join(', ') + ']'; }, nil) && 'to_json' })(self, null); (function($base, $super) { function $Boolean(){}; var self = $Boolean = $klass($base, $super, 'Boolean', $Boolean); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; return (self == true) ? 'true' : 'false'; }, nil) && 'to_json' })(self, null); (function($base, $super) { function $Hash(){}; var self = $Hash = $klass($base, $super, 'Hash', $Hash); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; var inspect = [], keys = self.keys, _map = self.map, smap = self.smap, map, khash; for (var i = 0, length = keys.length; i < length; i++) { var key = keys[i]; if (key.$$is_string) { map = smap; khash = key; } else { map = _map; khash = key.$hash(); } inspect.push((key).$to_s().$to_json() + ':' + (map[khash]).$to_json()); } return '{' + inspect.join(', ') + '}'; ; }, nil) && 'to_json' })(self, null); (function($base, $super) { function $NilClass(){}; var self = $NilClass = $klass($base, $super, 'NilClass', $NilClass); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; return "null"; }, nil) && 'to_json' })(self, null); (function($base, $super) { function $Numeric(){}; var self = $Numeric = $klass($base, $super, 'Numeric', $Numeric); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; return self.toString(); }, nil) && 'to_json' })(self, null); (function($base, $super) { function $String(){}; var self = $String = $klass($base, $super, 'String', $String); var def = self.$$proto, $scope = self.$$scope; return Opal.defn(self, '$to_json', def.$inspect) })(self, null); (function($base, $super) { function $Time(){}; var self = $Time = $klass($base, $super, 'Time', $Time); var def = self.$$proto, $scope = self.$$scope; return (def.$to_json = function() { var self = this; return self.$strftime("%FT%T%z").$to_json(); }, nil) && 'to_json' })(self, null); return (function($base, $super) { function $Date(){}; var self = $Date = $klass($base, $super, 'Date', $Date); var def = self.$$proto, $scope = self.$$scope; def.$to_json = function() { var self = this; return self.$to_s().$to_json(); }; return (def.$as_json = function() { var self = this; return self.$to_s(); }, nil) && 'as_json'; })(self, null); }; /* Generated by Opal 0.8.0 */ Opal.modules["gamefic/snapshots"] = function(Opal) { Opal.dynamic_require_severity = "error"; function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range; Opal.add_stubs(['$require', '$attr_accessor', '$each', '$to_s', '$end_with?', '$[]', '$==', '$respond_to?', '$send', '$[]=', '$serialize_obj', '$serialized_attributes', '$each_pair', '$session', '$push', '$length', '$shift', '$generate', '$parse', '$!', '$unserialize', '$to_sym', '$private', '$nil?', '$kind_of?', '$can_serialize?', '$each_index', '$raise', '$index', '$name', '$match', '$to_i', '$find']); self.$require("json"); return (function($base) { var self = $module($base, 'Gamefic'); var def = self.$$proto, $scope = self.$$scope; (function($base, $super) { function $Snapshots(){}; var self = $Snapshots = $klass($base, $super, 'Snapshots', $Snapshots); var def = self.$$proto, $scope = self.$$scope; def.history = def.entities = nil; self.$attr_accessor("history"); def.$initialize = function(entities) { var self = this; self.history = []; return self.entities = entities; }; def.$save = function(entities) { var $a, $b, TMP_1, self = this, store = nil, index = nil, json = nil; store = []; index = 0; ($a = ($b = entities).$each, $a.$$p = (TMP_1 = function(e){var self = TMP_1.$$s || this, $a, $b, TMP_2, $c, TMP_3, hash = nil; if (e == null) e = nil; hash = $hash2([], {}); ($a = ($b = e.$serialized_attributes()).$each, $a.$$p = (TMP_2 = function(m){var self = TMP_2.$$s || this, $a, con = nil, xxx = nil, error = nil; if (m == null) m = nil; con = m.$to_s(); if ((($a = con['$end_with?']("?")) !== nil && (!$a.$$is_boolean || $a == true))) { con = con['$[]']($range(0, -2, false))}; if (e['$respond_to?'](m)['$=='](true)) { try { xxx = e.$send(m); if (xxx['$=='](false)) { return hash['$[]='](con, false) } else if (xxx !== false && xxx !== nil) { return hash['$[]='](con, self.$serialize_obj(xxx)) } else { return hash['$[]='](con, nil) }; } catch ($err) {if (Opal.rescue($err, [$scope.get('Exception')])) {error = $err; return hash['$[]='](con, nil) }else { throw $err; } } } else { return nil };}, TMP_2.$$s = self, TMP_2), $a).call($b); hash['$[]=']("session", $hash2([], {})); ($a = ($c = e.$session()).$each_pair, $a.$$p = (TMP_3 = function(k, v){var self = TMP_3.$$s || this; if (k == null) k = nil;if (v == null) v = nil; return hash['$[]']("session")['$[]='](k, self.$serialize_obj(v))}, TMP_3.$$s = self, TMP_3), $a).call($c); store.$push(hash); return index = $rb_plus(index, 1);}, TMP_1.$$s = self, TMP_1), $a).call($b); if ($rb_gt(self.history.$length(), 10)) { self.history.$shift()}; json = $scope.get('JSON').$generate(store); return json; }; def.$restore = function(snapshot) { var $a, $b, TMP_4, self = this, data = nil, index = nil; data = $scope.get('JSON').$parse(snapshot); index = 0; return ($a = ($b = data).$each, $a.$$p = (TMP_4 = function(hash){var self = TMP_4.$$s || this, $a, $b, TMP_5, $c, TMP_6; if (hash == null) hash = nil; ($a = ($b = hash).$each_pair, $a.$$p = (TMP_5 = function(k, v){var self = TMP_5.$$s || this, $a; if (self.entities == null) self.entities = nil; if (k == null) k = nil;if (v == null) v = nil; if ((($a = k.$to_s()['$==']("session")['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { return self.entities['$[]'](index).$send("" + (k) + "=", self.$unserialize(v)) } else { return nil }}, TMP_5.$$s = self, TMP_5), $a).call($b); ($a = ($c = hash['$[]']("session")).$each_pair, $a.$$p = (TMP_6 = function(k, v){var self = TMP_6.$$s || this; if (self.entities == null) self.entities = nil; if (k == null) k = nil;if (v == null) v = nil; return self.entities['$[]'](index).$session()['$[]='](k.$to_sym(), self.$unserialize(v))}, TMP_6.$$s = self, TMP_6), $a).call($c); return index = $rb_plus(index, 1);}, TMP_4.$$s = self, TMP_4), $a).call($b); }; def.$blacklist = function() { var self = this; return ["children", "session", "scene", "object_of_pronoun", "test_queue", "test_queue_scene", "test_queue_length", "testing"]; }; self.$private(); def['$can_serialize?'] = function(obj) {try { var $a, $b, $c, TMP_7, self = this, allowed = nil; if ((($a = (((($b = ((($c = obj['$=='](true)) !== false && $c !== nil) ? $c : obj['$=='](false))) !== false && $b !== nil) ? $b : obj['$nil?']()))) !== nil && (!$a.$$is_boolean || $a == true))) { return true}; allowed = [$scope.get('String'), $scope.get('Fixnum'), $scope.get('Float'), $scope.get('Numeric'), $scope.get('Entity'), $scope.get('Direction'), $scope.get('Hash'), $scope.get('Array'), $scope.get('Symbol')]; ($a = ($b = allowed).$each, $a.$$p = (TMP_7 = function(a){var self = TMP_7.$$s || this, $a; if (a == null) a = nil; if ((($a = obj['$kind_of?'](a)) !== nil && (!$a.$$is_boolean || $a == true))) { Opal.ret(true) } else { return nil }}, TMP_7.$$s = self, TMP_7), $a).call($b); return false; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }; def.$serialize_obj = function(obj) { var $a, $b, TMP_8, $c, TMP_9, self = this, hash = nil, arr = nil; if ((($a = obj['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { return nil}; if (obj['$=='](false)) { return false}; if ((($a = obj['$kind_of?']($scope.get('Hash'))) !== nil && (!$a.$$is_boolean || $a == true))) { hash = $hash2([], {}); ($a = ($b = obj).$each_pair, $a.$$p = (TMP_8 = function(k, v){var self = TMP_8.$$s || this, $a, $b; if (k == null) k = nil;if (v == null) v = nil; if ((($a = ($b = self['$can_serialize?'](k), $b !== false && $b !== nil ?self['$can_serialize?'](v) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { return hash['$[]='](self.$serialize_obj(k), self.$serialize_obj(v)) } else { return nil }}, TMP_8.$$s = self, TMP_8), $a).call($b); return hash; } else if ((($a = obj['$kind_of?']($scope.get('Array'))) !== nil && (!$a.$$is_boolean || $a == true))) { arr = []; ($a = ($c = obj).$each_index, $a.$$p = (TMP_9 = function(i){var self = TMP_9.$$s || this, $a; if (i == null) i = nil; if ((($a = self['$can_serialize?'](obj['$[]'](i))) !== nil && (!$a.$$is_boolean || $a == true))) { return arr['$[]='](i, self.$serialize_obj(obj['$[]'](i))) } else { return self.$raise("Bad array in snapshot") }}, TMP_9.$$s = self, TMP_9), $a).call($c); return arr; } else if ((($a = obj['$kind_of?']($scope.get('Entity'))) !== nil && (!$a.$$is_boolean || $a == true))) { return "#" } else if ((($a = obj['$kind_of?']($scope.get('Direction'))) !== nil && (!$a.$$is_boolean || $a == true))) { return "#"}; return obj; }; return (def.$unserialize = function(obj) { var $a, $b, TMP_10, $c, TMP_11, self = this, hash = nil, arr = nil, i = nil; if ((($a = obj['$kind_of?']($scope.get('Hash'))) !== nil && (!$a.$$is_boolean || $a == true))) { hash = $hash2([], {}); ($a = ($b = obj).$each_pair, $a.$$p = (TMP_10 = function(k, v){var self = TMP_10.$$s || this; if (k == null) k = nil;if (v == null) v = nil; return hash['$[]='](self.$unserialize(k), self.$unserialize(v))}, TMP_10.$$s = self, TMP_10), $a).call($b); return hash; } else if ((($a = obj['$kind_of?']($scope.get('Array'))) !== nil && (!$a.$$is_boolean || $a == true))) { arr = []; ($a = ($c = obj).$each_index, $a.$$p = (TMP_11 = function(i){var self = TMP_11.$$s || this; if (i == null) i = nil; return arr['$[]='](i, self.$unserialize(obj['$[]'](i)))}, TMP_11.$$s = self, TMP_11), $a).call($c); return arr; } else if ((($a = obj.$to_s().$match(/^#$/)) !== nil && (!$a.$$is_boolean || $a == true))) { i = obj['$[]']($range(6, -2, false)).$to_i(); return self.entities['$[]'](i); } else if ((($a = obj.$to_s().$match(/^#$/)) !== nil && (!$a.$$is_boolean || $a == true))) { return $scope.get('Direction').$find(obj['$[]']($range(6, -2, false))) } else { return obj }; }, nil) && 'unserialize'; })(self, null) })(self); }; /* Generated by Opal 0.8.0 */ (function(Opal) { Opal.dynamic_require_severity = "error"; var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$require']); self.$require("gamefic/core_ext/array"); self.$require("gamefic/core_ext/string"); self.$require("gamefic/keywords"); self.$require("gamefic/serialized"); self.$require("gamefic/entity"); self.$require("gamefic/character"); self.$require("gamefic/scene"); self.$require("gamefic/scene/active"); self.$require("gamefic/scene/concluded"); self.$require("gamefic/scene/paused"); self.$require("gamefic/scene/multiplechoice"); self.$require("gamefic/scene/yesorno"); self.$require("gamefic/action"); self.$require("gamefic/meta"); self.$require("gamefic/syntax"); self.$require("gamefic/query"); self.$require("gamefic/rule"); self.$require("gamefic/director"); self.$require("gamefic/plot"); self.$require("gamefic/engine"); self.$require("gamefic/direction"); return self.$require("gamefic/snapshots"); })(Opal);