gamefic-sdk 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc2343107a5dea13bfcba8360aedc82ddb160c0
|
4
|
+
data.tar.gz: c05803ac75db4669c5ad9bca1be55c25fe18cf2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79a03c3289a33bc3265003397b907dfb4a490e1f507ba8ab280250cc64523117b570f86801645935633c38c66a26ec735f11617c2310ed6c4592a4a4b8510b2
|
7
|
+
data.tar.gz: 88592b51eacef05cdf084fb60a3d67b12a4af437ed7611cb1b3333676b255be580e53e9a9acff9bb983eed904d4d334f26aaac80d28ebff32f2aa3dda71d766c
|
data/html/core/engine.js
CHANGED
@@ -7,11 +7,11 @@ var Gamefic = (function() {
|
|
7
7
|
var lastPrompt = null;
|
8
8
|
var getResponse = function(withOutput) {
|
9
9
|
var r = {
|
10
|
-
output: (withOutput ? Opal.GameficOpal.$
|
11
|
-
state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$
|
10
|
+
output: (withOutput ? Opal.GameficOpal.$static_user().$flush() : null),
|
11
|
+
state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$type(),
|
12
12
|
prompt: lastPrompt,
|
13
13
|
input: lastInput,
|
14
|
-
testing: (Opal.GameficOpal.$
|
14
|
+
testing: (Opal.GameficOpal.$static_character().$queue().$length() > 0)
|
15
15
|
}
|
16
16
|
return r;
|
17
17
|
}
|
@@ -26,9 +26,9 @@ var Gamefic = (function() {
|
|
26
26
|
}
|
27
27
|
return {
|
28
28
|
start: function() {
|
29
|
-
Opal.GameficOpal.$load_scripts();
|
30
|
-
Opal.GameficOpal.$static_plot().$introduce(Opal.GameficOpal.$
|
31
|
-
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$
|
29
|
+
Opal.GameficOpal.$load_scripts();
|
30
|
+
Opal.GameficOpal.$static_plot().$introduce(Opal.GameficOpal.$static_character());
|
31
|
+
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
|
32
32
|
var response = getResponse(true);
|
33
33
|
doReady(response);
|
34
34
|
handle(response);
|
@@ -38,7 +38,7 @@ var Gamefic = (function() {
|
|
38
38
|
},
|
39
39
|
update: function(input) {
|
40
40
|
if (input != null) {
|
41
|
-
Opal.GameficOpal.$
|
41
|
+
Opal.GameficOpal.$static_character().$queue().$push(input);
|
42
42
|
}
|
43
43
|
lastInput = input;
|
44
44
|
var response = getResponse(false);
|
@@ -47,20 +47,23 @@ var Gamefic = (function() {
|
|
47
47
|
});
|
48
48
|
Opal.GameficOpal.$static_plot().$update();
|
49
49
|
Opal.GameficOpal.$static_plot().$ready();
|
50
|
-
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$
|
50
|
+
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
|
51
51
|
response = getResponse(true);
|
52
52
|
var updateResponse = response;
|
53
53
|
doReady(response);
|
54
|
-
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$
|
54
|
+
lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
|
55
55
|
response = getResponse(true);
|
56
56
|
response.output = updateResponse.output + response.output;
|
57
57
|
handle(response);
|
58
58
|
finishCallbacks.forEach(function(callback) {
|
59
59
|
callback(response);
|
60
60
|
});
|
61
|
-
var testCommand = Opal.GameficOpal.$
|
61
|
+
/*var testCommand = Opal.GameficOpal.$static_character().$queue().$shift();
|
62
62
|
if (typeof testCommand == 'string') {
|
63
63
|
setTimeout("Gamefic.update(" + JSON.stringify(testCommand) + ");", 1);
|
64
|
+
}*/
|
65
|
+
if (Opal.GameficOpal.$static_character().$queue().$length() > 0) {
|
66
|
+
setTimeout("Gamefic.update();", 1);
|
64
67
|
}
|
65
68
|
},
|
66
69
|
onStart: function(callback) {
|
@@ -78,14 +81,14 @@ var Gamefic = (function() {
|
|
78
81
|
save: function(filename, data) {
|
79
82
|
var json = Opal.JSON.$generate(data);
|
80
83
|
localStorage.setItem(filename, json);
|
81
|
-
Opal.GameficOpal.$
|
84
|
+
Opal.GameficOpal.$static_character().$tell('Game saved.');
|
82
85
|
},
|
83
86
|
restore: function(filename) {
|
84
87
|
var data = Opal.JSON.$parse(localStorage.getItem(filename));
|
85
88
|
var metadata = data.$fetch('metadata');
|
86
89
|
// HACK Converting hashes to strings for JavaScript comparison
|
87
90
|
if (metadata.$to_s() != Opal.GameficOpal.$static_plot().$metadata().$to_s()) {
|
88
|
-
Opal.GameficOpal.$
|
91
|
+
Opal.GameficOpal.$static_character().$tell('The saved data is not compatible with this version of the game.');
|
89
92
|
return Opal.nil;
|
90
93
|
} else {
|
91
94
|
return data;
|
@@ -83,7 +83,7 @@ module Gamefic::Sdk
|
|
83
83
|
Opal.use_gem 'gamefic'
|
84
84
|
if !File.exist?(build_dir + "/core/gamefic.js")
|
85
85
|
File.open(build_dir + "/core/gamefic.js", "w") do |file|
|
86
|
-
|
86
|
+
file << Opal::Builder.build('gamefic').to_s
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'gamefic/query/expression'
|
3
3
|
require 'gamefic/query/matches'
|
4
4
|
require 'gamefic/grammar/verb_set'
|
5
|
-
require 'gamefic/scene/multiple_choice/input'
|
6
5
|
|
7
6
|
# HACK Opal doesn't recognize classes and modules declared from scripts
|
8
7
|
def Object.const_missing sym
|
@@ -13,19 +12,25 @@ module GameficOpal
|
|
13
12
|
def self.static_plot
|
14
13
|
@@static_plot ||= WebPlot.new(Gamefic::Source::Text.new)
|
15
14
|
end
|
16
|
-
def self.
|
17
|
-
@@
|
15
|
+
def self.static_character
|
16
|
+
if @@static_character.nil?
|
17
|
+
@@static_character = static_plot.make Gamefic::Character, name: 'player', synonyms: 'me you myself yourself self'
|
18
|
+
@@static_character.connect static_user
|
19
|
+
end
|
20
|
+
@@static_character
|
21
|
+
end
|
22
|
+
def self.static_user
|
23
|
+
@@static_user ||= WebUser.new
|
18
24
|
end
|
19
|
-
|
20
25
|
class WebPlot < Gamefic::Plot
|
21
26
|
def script path
|
22
27
|
# Stub
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
26
|
-
class WebUser < Gamefic::User
|
31
|
+
class WebUser < Gamefic::User::Base
|
27
32
|
def save filename, data
|
28
|
-
data[:metadata] =
|
33
|
+
data[:metadata] = GameficOpal.static_character.plot.metadata
|
29
34
|
`Gamefic.save(filename, data);`
|
30
35
|
end
|
31
36
|
def restore filename
|
@@ -33,9 +38,7 @@ module GameficOpal
|
|
33
38
|
return data
|
34
39
|
end
|
35
40
|
def test_queue
|
36
|
-
|
41
|
+
GameficOpal.static_character[:test_queue] || []
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
41
|
-
GameficOpal.static_plot.script 'main'
|
data/lib/gamefic-sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gamefic
|