gamefic-sdk 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/html/core/engine.js +16 -61
- data/html/sinatra/engine.js +51 -0
- data/html/skins/standard/index.html.erb +1 -1
- data/html/skins/standard/play.js +20 -4
- data/html/skins/standard/style.css +3 -0
- data/lib/gamefic-sdk.rb +2 -2
- data/lib/gamefic-sdk/debug/plot.rb +1 -1
- data/lib/gamefic-sdk/platform.rb +1 -0
- data/lib/gamefic-sdk/platform/sinatra.rb +100 -0
- data/lib/gamefic-sdk/platform/web.rb +19 -12
- data/lib/gamefic-sdk/platform/web/app_config.rb +5 -6
- data/lib/gamefic-sdk/platform/web/engine.rb +41 -0
- data/lib/gamefic-sdk/platform/web/user.rb +19 -0
- data/lib/gamefic-sdk/server.rb +67 -0
- data/lib/gamefic-sdk/shell.rb +50 -10
- data/lib/gamefic-sdk/shell/init.rb +7 -2
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scripts/autosuggest.plot.rb +5 -11
- data/scripts/clothing/actions/wear.plot.rb +1 -1
- data/scripts/clothing/entities/clothing.plot.rb +1 -1
- data/scripts/clothing/entities/coat.plot.rb +1 -1
- data/scripts/clothing/entities/gloves.plot.rb +1 -1
- data/scripts/clothing/entities/hat.plot.rb +1 -1
- data/scripts/clothing/entities/pants.plot.rb +1 -1
- data/scripts/clothing/entities/shirt.plot.rb +1 -1
- data/scripts/clothing/entities/shoes.plot.rb +1 -1
- data/scripts/save-restore.plot.rb +1 -0
- data/scripts/snapshots.plot.rb +1 -1
- data/scripts/standard.plot.rb +1 -1
- data/scripts/standard/actions/close.plot.rb +2 -2
- data/scripts/standard/actions/drop.plot.rb +6 -2
- data/scripts/standard/actions/give.plot.rb +12 -17
- data/scripts/standard/actions/go.plot.rb +7 -6
- data/scripts/standard/actions/lock.plot.rb +3 -3
- data/scripts/standard/actions/look-under.plot.rb +1 -1
- data/scripts/standard/actions/look.plot.rb +13 -8
- data/scripts/standard/actions/nil.plot.rb +1 -1
- data/scripts/standard/actions/place.plot.rb +2 -1
- data/scripts/standard/actions/read.plot.rb +1 -1
- data/scripts/standard/actions/search.plot.rb +1 -0
- data/scripts/standard/actions/take.plot.rb +1 -1
- data/scripts/standard/actions/talk.plot.rb +4 -4
- data/scripts/standard/actions/unlock.plot.rb +6 -6
- data/scripts/standard/actions/use.plot.rb +4 -4
- data/scripts/standard/entities/character.plot.rb +0 -2
- data/scripts/standard/entities/container.plot.rb +1 -4
- data/scripts/standard/entities/door.plot.rb +1 -3
- data/scripts/standard/entities/entity.plot.rb +0 -1
- data/scripts/standard/entities/exterior.plot.rb +1 -1
- data/scripts/standard/entities/fixture.plot.rb +1 -1
- data/scripts/standard/entities/item.plot.rb +1 -1
- data/scripts/standard/entities/portal.plot.rb +2 -3
- data/scripts/standard/entities/receptacle.plot.rb +1 -2
- data/scripts/standard/entities/room.plot.rb +4 -6
- data/scripts/standard/entities/rubble.plot.rb +1 -1
- data/scripts/standard/entities/scenery.plot.rb +1 -1
- data/scripts/standard/entities/supporter.plot.rb +2 -2
- data/scripts/standard/modules/attachable.plot.rb +1 -1
- data/scripts/standard/modules/auto_takes.plot.rb +1 -1
- data/scripts/standard/modules/darkenable.plot.rb +1 -1
- data/scripts/standard/modules/enterable.plot.rb +1 -1
- data/scripts/standard/modules/explicit_exits.plot.rb +1 -1
- data/scripts/standard/modules/itemizable.plot.rb +1 -1
- data/scripts/standard/modules/lockable.plot.rb +1 -1
- data/scripts/standard/modules/openable.plot.rb +4 -1
- data/scripts/standard/modules/parent-room.plot.rb +1 -1
- data/scripts/standard/modules/portable.plot.rb +1 -1
- data/scripts/standard/modules/transparent.plot.rb +1 -1
- data/scripts/standard/plural/actions/place.plot.rb +2 -2
- data/scripts/standard/queries.plot.rb +21 -4
- data/scripts/standard/use.plot.rb +26 -8
- data/scripts/suggestible.plot.rb +17 -17
- metadata +58 -10
- data/lib/gamefic-sdk/platform/web/gamefic_opal.rb +0 -45
- data/scripts/standard/queries/from_expression.plot.rb +0 -16
- data/scripts/standard/queries/reachable.plot.rb +0 -48
- data/scripts/standard/queries/room.plot.rb +0 -17
- data/scripts/standard/queries/visible.plot.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c508e4dd9e43547d441742324b0cc6b0ec4a65
|
4
|
+
data.tar.gz: 0f27b939bb4792bfb2089d60fe501d390db3cdad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad44738b0f41716518caa6e47d17bf48246ff1adf9a8a5db34abc1c11e07b86d575007665ed748080dee9ff33e0e25de8b5b914f6bf97afd6032f1d8a99830b
|
7
|
+
data.tar.gz: 68f1a505049cd573c61c611247f89a85cfae8d50c2abc82dbe39acedd16c41a04103383bf5be371a7920ac059aad321236cd4520a9840f80026e0f4095918c0e
|
data/html/core/engine.js
CHANGED
@@ -1,74 +1,29 @@
|
|
1
1
|
var Gamefic = (function() {
|
2
|
+
var updateCallbacks = [];
|
2
3
|
var startCallbacks = [];
|
3
|
-
var inputCallbacks = [];
|
4
|
-
var finishCallbacks = [];
|
5
|
-
var responseCallbacks = {};
|
6
|
-
var lastInput = null;
|
7
|
-
var lastPrompt = null;
|
8
|
-
var getResponse = function(withOutput) {
|
9
|
-
var r = {
|
10
|
-
output: (withOutput ? Opal.GameficOpal.$static_user().$flush() : null),
|
11
|
-
//state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$type(),
|
12
|
-
state: Opal.GameficOpal.$static_character().$scene().$type(),
|
13
|
-
prompt: lastPrompt,
|
14
|
-
input: lastInput,
|
15
|
-
testing: (Opal.GameficOpal.$static_character().$queue().$length() > 0)
|
16
|
-
}
|
17
|
-
return r;
|
18
|
-
}
|
19
|
-
var doReady = function(response) {
|
20
|
-
startCallbacks.forEach(function(callback) {
|
21
|
-
callback(response);
|
22
|
-
});
|
23
|
-
}
|
24
|
-
var handle = function(response) {
|
25
|
-
var handler = responseCallbacks[response.state] || responseCallbacks['Active'];
|
26
|
-
handler(response);
|
27
|
-
}
|
28
4
|
return {
|
29
5
|
start: function() {
|
30
|
-
|
31
|
-
|
32
|
-
lastPrompt = Opal.GameficOpal.$static_character().$prompt();
|
33
|
-
this.update('');
|
34
|
-
},
|
35
|
-
update: function(input) {
|
36
|
-
if (input != null) {
|
37
|
-
Opal.GameficOpal.$static_character().$queue().$push(input);
|
38
|
-
}
|
39
|
-
lastInput = input;
|
40
|
-
var response = getResponse(false);
|
41
|
-
inputCallbacks.forEach(function(callback) {
|
42
|
-
callback(response);
|
6
|
+
startCallbacks.forEach((callback) => {
|
7
|
+
callback();
|
43
8
|
});
|
44
|
-
Opal.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
var
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
response.output = updateResponse.output + response.output;
|
53
|
-
handle(response);
|
54
|
-
finishCallbacks.forEach(function(callback) {
|
55
|
-
callback(response);
|
9
|
+
Opal.gvars.engine.$run();
|
10
|
+
},
|
11
|
+
update: function(response) {
|
12
|
+
console.log('Called the Gamefic update');
|
13
|
+
var state = JSON.parse(response);
|
14
|
+
console.log('Output: ' + state.output);
|
15
|
+
updateCallbacks.forEach(function(callback) {
|
16
|
+
callback(state);
|
56
17
|
});
|
57
|
-
|
58
|
-
|
59
|
-
|
18
|
+
},
|
19
|
+
receive: function(input) {
|
20
|
+
Opal.gvars.engine.$receive(input);
|
60
21
|
},
|
61
22
|
onStart: function(callback) {
|
62
23
|
startCallbacks.push(callback);
|
63
24
|
},
|
64
|
-
|
65
|
-
|
66
|
-
},
|
67
|
-
onFinish: function(callback) {
|
68
|
-
finishCallbacks.push(callback);
|
69
|
-
},
|
70
|
-
handleResponse: function(state, callback) {
|
71
|
-
responseCallbacks[state] = callback;
|
25
|
+
onUpdate: function(callback) {
|
26
|
+
updateCallbacks.push(callback);
|
72
27
|
},
|
73
28
|
save: function(filename, data) {
|
74
29
|
var json = Opal.JSON.$generate(data);
|
@@ -0,0 +1,51 @@
|
|
1
|
+
var Gamefic = (function() {
|
2
|
+
var startCallbacks = [];
|
3
|
+
var updateCallbacks = [];
|
4
|
+
return {
|
5
|
+
start: function() {
|
6
|
+
var that = this;
|
7
|
+
$.post('/start', function(response) {
|
8
|
+
startCallbacks.forEach(function(callback) {
|
9
|
+
callback();
|
10
|
+
});
|
11
|
+
that.update(response);
|
12
|
+
});
|
13
|
+
},
|
14
|
+
update: function(response) {
|
15
|
+
updateCallbacks.forEach(function(callback) {
|
16
|
+
callback(response);
|
17
|
+
});
|
18
|
+
},
|
19
|
+
receive: function(input) {
|
20
|
+
var that = this;
|
21
|
+
$.post('/update', {command: input}, function(response) {
|
22
|
+
console.log(JSON.stringify(response));
|
23
|
+
that.update(response);
|
24
|
+
}).fail(function(response) {
|
25
|
+
console.log('An error occurred');
|
26
|
+
});
|
27
|
+
},
|
28
|
+
onUpdate: function(callback) {
|
29
|
+
updateCallbacks.push(callback);
|
30
|
+
},
|
31
|
+
onStart: function(callback) {
|
32
|
+
updateCallbacks.push(callback);
|
33
|
+
},
|
34
|
+
save: function(filename, data) {
|
35
|
+
var json = Opal.JSON.$generate(data);
|
36
|
+
localStorage.setItem(filename, json);
|
37
|
+
Opal.GameficOpal.$static_character().$tell('Game saved.');
|
38
|
+
},
|
39
|
+
restore: function(filename) {
|
40
|
+
var data = Opal.JSON.$parse(localStorage.getItem(filename));
|
41
|
+
var metadata = data.$fetch('metadata');
|
42
|
+
// HACK Converting hashes to strings for JavaScript comparison
|
43
|
+
if (metadata.$to_s() != Opal.GameficOpal.$static_plot().$metadata().$to_s()) {
|
44
|
+
Opal.GameficOpal.$static_character().$tell('The saved data is not compatible with this version of the game.');
|
45
|
+
return Opal.nil;
|
46
|
+
} else {
|
47
|
+
return data;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})();
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<div id="gamefic_console">
|
10
10
|
<div id="gamefic_output">
|
11
11
|
</div>
|
12
|
-
<div id="gamefic_controls">
|
12
|
+
<div id="gamefic_controls" class="working">
|
13
13
|
<form action="">
|
14
14
|
<span id="gamefic_prompt"></span>
|
15
15
|
<input type="text" name="command" id="gamefic_command" autocomplete="off" />
|
data/html/skins/standard/play.js
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
$(function() {
|
2
|
+
console.log('starting play');
|
2
3
|
$('#gamefic_controls form').submit(function(event) {
|
4
|
+
$('#gamefic_controls').addClass('working');
|
3
5
|
event.preventDefault();
|
4
|
-
Gamefic.
|
6
|
+
Gamefic.receive($('#gamefic_command').val());
|
7
|
+
$('#gamefic_command').val('');
|
8
|
+
$('#gamefic_controls').removeClass('working');
|
5
9
|
});
|
6
|
-
Gamefic.onStart(function(response) {
|
10
|
+
/*Gamefic.onStart(function(response) {
|
7
11
|
var prompt = response.prompt;
|
8
12
|
if (prompt == '>') {
|
9
13
|
prompt = 'What do you want to do?'
|
@@ -18,7 +22,7 @@ $(function() {
|
|
18
22
|
$('#gamefic_controls').addClass('working');
|
19
23
|
});
|
20
24
|
Gamefic.onFinish(function(response) {
|
21
|
-
if (!response.
|
25
|
+
if (!response.busy) {
|
22
26
|
$('#gamefic_controls').removeClass('working');
|
23
27
|
}
|
24
28
|
$('#gamefic_command').val('');
|
@@ -62,7 +66,19 @@ $(function() {
|
|
62
66
|
if (!$(this).hasClass('disabled')) {
|
63
67
|
Gamefic.update($(this).attr('data-command'));
|
64
68
|
}
|
69
|
+
});*/
|
70
|
+
Gamefic.onUpdate((state) => {
|
71
|
+
console.log('Doing the update with ' + state['output']);
|
72
|
+
console.log(JSON.stringify(state));
|
73
|
+
$('#gamefic_output').append(state['output']);
|
74
|
+
if (state.scene == 'Conclusion') {
|
75
|
+
$('#gamefic_console').addClass('concluded');
|
76
|
+
}
|
65
77
|
});
|
78
|
+
console.log('Starting Gamefic');
|
66
79
|
Gamefic.start();
|
67
|
-
|
80
|
+
//console.log('Started!');
|
81
|
+
$('#gamefic_controls').removeClass('working');
|
82
|
+
//$('#gamefic_command').focus();
|
83
|
+
console.log('finished play');
|
68
84
|
});
|
data/lib/gamefic-sdk.rb
CHANGED
@@ -5,10 +5,10 @@ require 'gamefic-sdk/debug'
|
|
5
5
|
require 'gamefic-sdk/version'
|
6
6
|
|
7
7
|
module Gamefic::Sdk
|
8
|
+
autoload :Server, 'gamefic-sdk/server'
|
9
|
+
|
8
10
|
HTML_TEMPLATE_PATH = File.realpath(File.dirname(__FILE__) + "/../html/")
|
9
11
|
GLOBAL_SCRIPT_PATH = File.realpath(File.dirname(__FILE__) + "/../scripts/")
|
10
|
-
# @deprecated
|
11
|
-
GLOBAL_IMPORT_PATH = GLOBAL_SCRIPT_PATH
|
12
12
|
LIB_PATH = File.dirname(__FILE__)
|
13
13
|
end
|
14
14
|
|
@@ -4,7 +4,7 @@ module Gamefic::Sdk::Debug
|
|
4
4
|
class Plot < Gamefic::Plot
|
5
5
|
attr_reader :main_dir
|
6
6
|
def post_initialize
|
7
|
-
meta :debug, Query::Text.new(
|
7
|
+
meta :debug, Query::Text.new(/^unused$/) do |actor, text|
|
8
8
|
unused = []
|
9
9
|
actions.each { |a|
|
10
10
|
if !a.standard? and !a.executed?
|
data/lib/gamefic-sdk/platform.rb
CHANGED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'gamefic'
|
2
|
+
require 'gamefic-sdk'
|
3
|
+
|
4
|
+
module Gamefic::Sdk
|
5
|
+
|
6
|
+
class Platform::Sinatra < Platform::Web
|
7
|
+
autoload :AppConfig, 'gamefic-sdk/platform/web/app_config'
|
8
|
+
|
9
|
+
def build
|
10
|
+
STDERR.puts "Building for Sinatra"
|
11
|
+
target_dir = config['target_dir']
|
12
|
+
build_dir = config['build_dir']
|
13
|
+
html_dir = app_config.html_dir
|
14
|
+
|
15
|
+
FileUtils.mkdir_p target_dir
|
16
|
+
copy_html_files target_dir
|
17
|
+
render_index target_dir
|
18
|
+
copy_assets build_dir, target_dir
|
19
|
+
copy_media source_dir, target_dir
|
20
|
+
FileUtils.cp_r File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'sinatra', 'engine.js'), File.join(target_dir, 'core', 'engine.js')
|
21
|
+
end
|
22
|
+
|
23
|
+
def clean
|
24
|
+
FileUtils.remove_entry_secure config['build_dir'] if File.exist?(config['build_dir'])
|
25
|
+
FileUtils.mkdir_p config['build_dir']
|
26
|
+
puts "#{config['build_dir']} cleaned."
|
27
|
+
end
|
28
|
+
|
29
|
+
def app_config
|
30
|
+
@app_config ||= AppConfig.new source_dir, config, ["core/engine.js"]
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def resolve filename, paths
|
36
|
+
absolute = nil
|
37
|
+
paths.each { |path|
|
38
|
+
if File.file?("#{path}/#{filename}")
|
39
|
+
absolute = File.join(path, filename)
|
40
|
+
break
|
41
|
+
end
|
42
|
+
}
|
43
|
+
raise "#{filename} not found" if absolute.nil?
|
44
|
+
absolute
|
45
|
+
end
|
46
|
+
|
47
|
+
# Copy everything in source except config and template
|
48
|
+
def copy_html_files target_dir
|
49
|
+
Dir.entries(app_config.html_dir).each { |entry|
|
50
|
+
if entry != 'index.rb' and entry != 'index.html.erb' and entry != '.' and entry != '..'
|
51
|
+
FileUtils.mkdir_p target_dir + '/' + File.dirname(entry)
|
52
|
+
FileUtils.cp_r "#{app_config.html_dir}/#{entry}", "#{target_dir}/#{entry}"
|
53
|
+
end
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_index target_dir
|
58
|
+
# Render index
|
59
|
+
File.open(target_dir + "/index.html", "w") do |file|
|
60
|
+
file << app_config.render
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def copy_assets build_dir, target_dir
|
65
|
+
paths = app_config.resource_paths
|
66
|
+
paths.push build_dir
|
67
|
+
app_config.javascripts.each { |js|
|
68
|
+
absolute = resolve(js, paths)
|
69
|
+
FileUtils.mkdir_p target_dir + "/" + File.dirname(js)
|
70
|
+
FileUtils.cp_r absolute, target_dir + "/" + js
|
71
|
+
}
|
72
|
+
app_config.stylesheets.each { |css|
|
73
|
+
absolute = resolve(css, paths)
|
74
|
+
FileUtils.mkdir_p target_dir + "/" + File.dirname(css)
|
75
|
+
FileUtils.cp_r absolute, target_dir + "/" + css
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def copy_media source_dir, target_dir
|
80
|
+
# Copy media
|
81
|
+
pc = PlotConfig.new "#{source_dir}/config.yaml"
|
82
|
+
pc.media_paths.each { |path|
|
83
|
+
if File.directory?(path)
|
84
|
+
FileUtils.mkdir_p target_dir + "/media"
|
85
|
+
Dir.entries(path).each { |entry|
|
86
|
+
if entry != '.' and entry != '..'
|
87
|
+
FileUtils.mkdir_p target_dir + "/media/" + File.dirname(entry)
|
88
|
+
FileUtils.cp_r path + "/" + entry, target_dir + "/media/" + entry
|
89
|
+
end
|
90
|
+
}
|
91
|
+
end
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
def metadata_code
|
96
|
+
"\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'gamefic'
|
2
2
|
require 'gamefic-sdk'
|
3
3
|
require 'opal'
|
4
|
+
require 'uglifier'
|
4
5
|
|
5
6
|
module Gamefic::Sdk
|
6
7
|
|
@@ -15,7 +16,7 @@ module Gamefic::Sdk
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def app_config
|
18
|
-
@app_config ||= AppConfig.new source_dir, config
|
19
|
+
@app_config ||= AppConfig.new source_dir, config, ["core/opal.js", "core/gamefic.js", "core/static.js", "core/scripts.js", "core/engine.js"]
|
19
20
|
end
|
20
21
|
|
21
22
|
def build
|
@@ -71,9 +72,9 @@ module Gamefic::Sdk
|
|
71
72
|
# Opal core
|
72
73
|
if !File.exist?(build_dir + "/core/opal.js")
|
73
74
|
File.open(build_dir + "/core/opal.js", "w") do |file|
|
74
|
-
file <<
|
75
|
-
|
76
|
-
|
75
|
+
file << Uglifier.compile(
|
76
|
+
Opal::Builder.build('opal').to_s + "\n" + Opal::Builder.build('json').to_s + "\n" + Opal::Builder.build('native').to_s
|
77
|
+
)
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
@@ -83,7 +84,7 @@ module Gamefic::Sdk
|
|
83
84
|
Opal.use_gem 'gamefic'
|
84
85
|
if !File.exist?(build_dir + "/core/gamefic.js")
|
85
86
|
File.open(build_dir + "/core/gamefic.js", "w") do |file|
|
86
|
-
file << Opal::Builder.build('gamefic').to_s
|
87
|
+
file << Uglifier.compile(Opal::Builder.build('gamefic').to_s)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
@@ -93,26 +94,32 @@ module Gamefic::Sdk
|
|
93
94
|
Opal.append_path Gamefic::Sdk::LIB_PATH
|
94
95
|
if !File.exist?(build_dir + "/core/static.js")
|
95
96
|
File.open(build_dir + "/core/static.js", "w") do |file|
|
96
|
-
file << Opal::Builder.build('gamefic-sdk/platform/web/gamefic_opal')
|
97
|
+
#file << Opal::Builder.build('gamefic-sdk/platform/web/gamefic_opal')
|
98
|
+
file << Uglifier.compile(
|
99
|
+
Opal::Builder.build('gamefic-sdk/platform/web/engine').to_s + "\n" + Opal::Builder.build('gamefic-sdk/platform/web/user').to_s
|
100
|
+
)
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
105
|
def build_scripts_js build_dir
|
102
|
-
# Plot scripts
|
103
106
|
File.open("#{build_dir}/scripts.rb", 'w') do |file|
|
104
|
-
file << "
|
107
|
+
file << "module Gamefic\n"
|
108
|
+
file << "$scripts = {}\n"
|
105
109
|
plot.imported_scripts.each { |script|
|
106
|
-
file << "
|
110
|
+
file << "$scripts['#{script.path}'] = proc {\n"
|
107
111
|
file << script.read
|
108
|
-
file << "\
|
112
|
+
file << "\n}\n"
|
109
113
|
}
|
114
|
+
file << "$source = Gamefic::Source::Text.new($scripts)\n"
|
115
|
+
file << "$plot = Gamefic::Plot.new($source)\n"
|
116
|
+
file << "$plot.script 'main'\n"
|
117
|
+
file << "$engine = Gamefic::Engine::Web.new($plot)\n"
|
110
118
|
file << "end\n"
|
111
|
-
file << metadata_code
|
112
119
|
end
|
113
120
|
Opal.append_path build_dir
|
114
121
|
File.open(build_dir + "/core/scripts.js", 'w') do |file|
|
115
|
-
file << Opal::Builder.build('scripts')
|
122
|
+
file << Uglifier.compile(Opal::Builder.build('scripts').to_s)
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'erb'
|
2
|
-
require 'gamefic/stage'
|
3
2
|
|
4
3
|
module Gamefic
|
5
4
|
module Sdk
|
6
5
|
class Gamefic::Sdk::Platform::Web::AppConfig
|
7
|
-
include
|
6
|
+
include Plot::Theater
|
8
7
|
attr_reader :javascripts, :stylesheets, :resource_paths, :source_dir, :config, :html_dir
|
9
|
-
expose :javascripts, :stylesheets, :resource_paths
|
8
|
+
#expose :javascripts, :stylesheets, :resource_paths
|
10
9
|
|
11
|
-
# @param
|
12
|
-
def initialize source_dir, config
|
10
|
+
# @param source_dir [String] The directory containing the resources (config file, HTML template, etc.) for this build
|
11
|
+
def initialize source_dir, config, js
|
13
12
|
@javascripts = []
|
14
13
|
@stylesheets = []
|
15
14
|
@source_dir = source_dir
|
@@ -19,7 +18,7 @@ module Gamefic
|
|
19
18
|
@resource_paths = ["#{html_dir}", Gamefic::Sdk::HTML_TEMPLATE_PATH]
|
20
19
|
config_file = "#{html_dir}/index.rb"
|
21
20
|
stage File.read(config_file), config_file
|
22
|
-
javascripts.
|
21
|
+
javascripts.concat js
|
23
22
|
end
|
24
23
|
|
25
24
|
# @return [BuildConfig::Data]
|