gamefic-sdk 1.6.0 → 1.7.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 +89 -20
- data/html/sinatra/engine.js +27 -13
- data/html/skins/hypertext/index.html +0 -2
- data/html/skins/standard/play.js +0 -66
- data/lib/gamefic-sdk.rb +2 -1
- data/lib/gamefic-sdk/build.rb +11 -19
- data/lib/gamefic-sdk/config.rb +126 -0
- data/lib/gamefic-sdk/platform.rb +12 -0
- data/lib/gamefic-sdk/platform/base.rb +35 -33
- data/lib/gamefic-sdk/platform/gfic.rb +5 -18
- data/lib/gamefic-sdk/platform/sinatra.rb +29 -31
- data/lib/gamefic-sdk/platform/web.rb +72 -65
- data/lib/gamefic-sdk/platform/web/app_config.rb +48 -48
- data/lib/gamefic-sdk/platform/web/engine.rb +10 -7
- data/lib/gamefic-sdk/platform/web/user.rb +3 -3
- data/lib/gamefic-sdk/server.rb +17 -19
- data/lib/gamefic-sdk/shell.rb +68 -16
- data/lib/gamefic-sdk/shell/init.rb +3 -19
- data/lib/gamefic-sdk/shell/test.rb +9 -14
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scripts/save-restore-undo.plot.rb +25 -0
- data/scripts/snapshots.plot.rb +16 -14
- data/scripts/standard.plot.rb +3 -5
- data/scripts/standard/actions.plot.rb +1 -11
- data/scripts/standard/actions/drop.plot.rb +1 -1
- data/scripts/standard/actions/enter.plot.rb +4 -16
- data/scripts/standard/actions/go.plot.rb +2 -36
- data/scripts/standard/actions/insert.plot.rb +7 -21
- data/scripts/standard/actions/inventory.plot.rb +2 -1
- data/scripts/standard/actions/leave.plot.rb +7 -18
- data/scripts/standard/actions/look.plot.rb +45 -44
- data/scripts/standard/actions/nil.plot.rb +1 -1
- data/scripts/standard/actions/take.plot.rb +10 -28
- data/scripts/standard/actions/talk.plot.rb +9 -13
- data/scripts/standard/clothing.plot.rb +4 -0
- data/scripts/standard/clothing/actions.plot.rb +4 -0
- data/scripts/{clothing → standard/clothing}/actions/doff.plot.rb +0 -0
- data/scripts/{clothing → standard/clothing}/actions/drop.plot.rb +8 -8
- data/scripts/{clothing → standard/clothing}/actions/inventory.plot.rb +14 -14
- data/scripts/standard/clothing/actions/wear.plot.rb +20 -0
- data/scripts/standard/clothing/entities.plot.rb +7 -0
- data/scripts/{clothing → standard/clothing}/entities/clothing.plot.rb +0 -2
- data/scripts/standard/clothing/entities/coat.plot.rb +3 -0
- data/scripts/standard/clothing/entities/gloves.plot.rb +3 -0
- data/scripts/standard/clothing/entities/hat.plot.rb +3 -0
- data/scripts/standard/clothing/entities/pants.plot.rb +3 -0
- data/scripts/standard/clothing/entities/shirt.plot.rb +3 -0
- data/scripts/standard/clothing/entities/shoes.plot.rb +3 -0
- data/scripts/standard/container.plot.rb +28 -0
- data/scripts/{debug.plot.rb → standard/container/actions.plot.rb} +0 -0
- data/scripts/standard/container/entities.plot.rb +5 -0
- data/scripts/standard/direction.plot.rb +1 -2
- data/scripts/{edible.plot.rb → standard/edible.plot.rb} +5 -3
- data/scripts/standard/entities.plot.rb +3 -3
- data/scripts/standard/entities/character.plot.rb +9 -6
- data/scripts/standard/entities/fixture.plot.rb +1 -1
- data/scripts/standard/entities/item.plot.rb +2 -4
- data/scripts/standard/entities/portal.plot.rb +9 -5
- data/scripts/standard/entities/receptacle.plot.rb +1 -1
- data/scripts/standard/entities/room.plot.rb +5 -5
- data/scripts/standard/entities/scenery.plot.rb +2 -4
- data/scripts/standard/entities/supporter.plot.rb +4 -7
- data/scripts/standard/entities/thing.plot.rb +7 -0
- data/scripts/standard/{actions/give.plot.rb → give.plot.rb} +27 -25
- data/scripts/standard/lockable.plot.rb +79 -0
- data/scripts/standard/modules.plot.rb +2 -4
- data/scripts/standard/modules/attachable.plot.rb +1 -0
- data/scripts/standard/modules/locale_description.plot.rb +20 -0
- data/scripts/standard/{use.plot.rb → modules/use.plot.rb} +51 -47
- data/scripts/standard/openable.plot.rb +43 -0
- data/scripts/standard/pathfinder.plot.rb +11 -6
- data/scripts/standard/test.plot.rb +2 -0
- data/scripts/undo.plot.rb +13 -11
- metadata +30 -65
- data/lib/gamefic-sdk/plot_config.rb +0 -25
- data/scripts/ansi.plot.rb +0 -13
- data/scripts/autosuggest.plot.rb +0 -165
- data/scripts/clothing.plot.rb +0 -2
- data/scripts/clothing/actions.plot.rb +0 -4
- data/scripts/clothing/actions/wear.plot.rb +0 -19
- data/scripts/clothing/entities.plot.rb +0 -7
- data/scripts/clothing/entities/coat.plot.rb +0 -5
- data/scripts/clothing/entities/gloves.plot.rb +0 -5
- data/scripts/clothing/entities/hat.plot.rb +0 -5
- data/scripts/clothing/entities/pants.plot.rb +0 -5
- data/scripts/clothing/entities/shirt.plot.rb +0 -5
- data/scripts/clothing/entities/shoes.plot.rb +0 -5
- data/scripts/cover.plot.rb +0 -30
- data/scripts/furniture.plot.rb +0 -35
- data/scripts/hints.plot.rb +0 -31
- data/scripts/hypertext.plot.rb +0 -280
- data/scripts/media.plot.rb +0 -17
- data/scripts/multimedia.plot.rb +0 -41
- data/scripts/questions.plot.rb +0 -17
- data/scripts/room-modes.plot.rb +0 -48
- data/scripts/rough-sizes.plot.rb +0 -36
- data/scripts/save-restore.plot.rb +0 -22
- data/scripts/standard/actions/close.plot.rb +0 -16
- data/scripts/standard/actions/lock.plot.rb +0 -59
- data/scripts/standard/actions/look-under.plot.rb +0 -8
- data/scripts/standard/actions/open.plot.rb +0 -34
- data/scripts/standard/actions/read.plot.rb +0 -3
- data/scripts/standard/actions/search.plot.rb +0 -40
- data/scripts/standard/actions/show.plot.rb +0 -13
- data/scripts/standard/actions/unlock.plot.rb +0 -77
- data/scripts/standard/actions/use.plot.rb +0 -25
- data/scripts/standard/entities/container.plot.rb +0 -8
- data/scripts/standard/entities/door.plot.rb +0 -51
- data/scripts/standard/entities/entity.plot.rb +0 -12
- data/scripts/standard/entities/exterior.plot.rb +0 -5
- data/scripts/standard/modules/darkenable.plot.rb +0 -6
- data/scripts/standard/modules/lockable.plot.rb +0 -25
- data/scripts/standard/modules/openable.plot.rb +0 -15
- data/scripts/standard/modules/transparent.plot.rb +0 -6
- data/scripts/standard/plural.plot.rb +0 -2
- data/scripts/standard/plural/actions.plot.rb +0 -4
- data/scripts/standard/plural/actions/drop.plot.rb +0 -126
- data/scripts/standard/plural/actions/insert.plot.rb +0 -60
- data/scripts/standard/plural/actions/place.plot.rb +0 -37
- data/scripts/standard/plural/actions/take.plot.rb +0 -175
- data/scripts/standard/plural/queries.plot.rb +0 -5
- data/scripts/standard/plural/queries/ambiguous_visible.plot.rb +0 -13
- data/scripts/standard/plural/queries/any_expression.plot.rb +0 -17
- data/scripts/standard/plural/queries/many_visible.plot.rb +0 -13
- data/scripts/standard/plural/queries/not_expression.plot.rb +0 -16
- data/scripts/standard/plural/queries/plural_visible.plot.rb +0 -22
- data/scripts/suggestible.plot.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7395294d50944bd37c3f1876c55c6a946bbcf9ee
|
4
|
+
data.tar.gz: fdf9b3cbb95019b3279687b987522edc0ff3794f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b760a05656461913ac13ce5623c21c30ab8918e8afe822d3365811cb10d0e011064f4e4b7c6055d20c79586dfd395c2b9cfc3b771553d558dcd84cec17091f20
|
7
|
+
data.tar.gz: 86b311a43a5658c4fad44f8180c56ab5b1b32b5312aa3172d652a890d2c86f07c116010ee0272ddee200a1285df089ee69decabd7d5d21919ea26685a7d108c4
|
data/html/core/engine.js
CHANGED
@@ -1,45 +1,114 @@
|
|
1
1
|
var Gamefic = (function() {
|
2
2
|
var updateCallbacks = [];
|
3
3
|
var startCallbacks = [];
|
4
|
+
var loggingUrl = null;
|
5
|
+
var logId = null;
|
6
|
+
var logAlias = null;
|
7
|
+
var lastPrompt = null;
|
8
|
+
var lastInput = null;
|
9
|
+
|
10
|
+
var _start = function() {
|
11
|
+
startCallbacks.forEach((callback) => {
|
12
|
+
callback();
|
13
|
+
});
|
14
|
+
Opal.gvars.engine.$run();
|
15
|
+
}
|
16
|
+
|
17
|
+
var _canLog = function() {
|
18
|
+
if (!loggingUrl) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
var a = document.createElement('a');
|
22
|
+
a.href = loggingUrl;
|
23
|
+
return (a.host == window.location.host);
|
24
|
+
}
|
25
|
+
|
26
|
+
var _logAlias = function(name) {
|
27
|
+
logAlias = name || logAlias || 'anonymous';
|
28
|
+
return logAlias;
|
29
|
+
}
|
4
30
|
return {
|
31
|
+
enableLogging: function(url) {
|
32
|
+
loggingUrl = url || '//gamefic.com/game/log';
|
33
|
+
return loggingUrl;
|
34
|
+
},
|
35
|
+
|
36
|
+
logAlias: function(name) {
|
37
|
+
return _logAlias(name);
|
38
|
+
},
|
39
|
+
|
40
|
+
canLog: function() {
|
41
|
+
return _canLog();
|
42
|
+
},
|
43
|
+
|
5
44
|
start: function() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
45
|
+
if (loggingUrl) {
|
46
|
+
if (_canLog()) {
|
47
|
+
$.post(loggingUrl, { alias: _logAlias() }, function(response) {
|
48
|
+
logId = response.id;
|
49
|
+
_start();
|
50
|
+
}).fail(function(response) {
|
51
|
+
console.warn('Logging failed.');
|
52
|
+
console.warn(response);
|
53
|
+
_start();
|
54
|
+
});
|
55
|
+
} else {
|
56
|
+
console.warn('Logging was not activated for ' + loggingUrl);
|
57
|
+
_start();
|
58
|
+
}
|
59
|
+
} else {
|
60
|
+
_start();
|
61
|
+
}
|
10
62
|
},
|
11
|
-
|
12
|
-
|
13
|
-
var state = JSON.parse(
|
14
|
-
|
63
|
+
|
64
|
+
update: function(json) {
|
65
|
+
var state = JSON.parse(json);
|
66
|
+
state.last_prompt = lastPrompt;
|
67
|
+
state.last_input = lastInput;
|
68
|
+
if (logId) {
|
69
|
+
$.post(loggingUrl + '/' + logId + '.json', { _method: 'PUT', state: state }, function(response) {
|
70
|
+
|
71
|
+
}).fail(function(response) {
|
72
|
+
console.warn('Logging update failed.');
|
73
|
+
console.warn(response);
|
74
|
+
logId = null;
|
75
|
+
});
|
76
|
+
}
|
15
77
|
updateCallbacks.forEach(function(callback) {
|
16
78
|
callback(state);
|
17
79
|
});
|
80
|
+
lastPrompt = state.prompt;
|
18
81
|
},
|
82
|
+
|
19
83
|
receive: function(input) {
|
84
|
+
lastInput = input;
|
20
85
|
Opal.gvars.engine.$receive(input);
|
21
86
|
},
|
87
|
+
|
22
88
|
onStart: function(callback) {
|
23
89
|
startCallbacks.push(callback);
|
24
90
|
},
|
91
|
+
|
25
92
|
onUpdate: function(callback) {
|
26
93
|
updateCallbacks.push(callback);
|
27
94
|
},
|
95
|
+
|
28
96
|
save: function(filename, data) {
|
29
|
-
|
30
|
-
localStorage.setItem(filename, json);
|
31
|
-
Opal.GameficOpal.$static_character().$tell('Game saved.');
|
97
|
+
localStorage.setItem(filename, Opal.JSON.$generate(data));
|
32
98
|
},
|
99
|
+
|
33
100
|
restore: function(filename) {
|
34
|
-
var
|
35
|
-
var
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
101
|
+
var json = localStorage.getItem(filename);
|
102
|
+
var snapshot = Opal.JSON.$parse(json);
|
103
|
+
Opal.gvars.plot.$restore(snapshot);
|
104
|
+
Opal.gvars.engine.$user().$character().$flush();
|
105
|
+
Opal.gvars.engine.$user().$character().$cue(Opal.gvars.plot.$default_scene());
|
106
|
+
Opal.gvars.plot.$update();
|
107
|
+
Opal.gvars.plot.$ready();
|
108
|
+
Opal.gvars.engine.$user().$character().$tell('Game restored to last available turn.');
|
109
|
+
var state = Opal.gvars.engine.$user().$character().$state();
|
110
|
+
var json = state.$to_json();
|
111
|
+
this.update(json);
|
43
112
|
}
|
44
113
|
}
|
45
114
|
})();
|
data/html/sinatra/engine.js
CHANGED
@@ -2,6 +2,18 @@ var Gamefic = (function() {
|
|
2
2
|
var startCallbacks = [];
|
3
3
|
var updateCallbacks = [];
|
4
4
|
return {
|
5
|
+
enableLogging: function() {
|
6
|
+
|
7
|
+
},
|
8
|
+
|
9
|
+
logAlias: function() {
|
10
|
+
|
11
|
+
},
|
12
|
+
|
13
|
+
canLog: function() {
|
14
|
+
return false;
|
15
|
+
},
|
16
|
+
|
5
17
|
start: function() {
|
6
18
|
var that = this;
|
7
19
|
$.post('/start', function(response) {
|
@@ -11,41 +23,43 @@ var Gamefic = (function() {
|
|
11
23
|
that.update(response);
|
12
24
|
});
|
13
25
|
},
|
26
|
+
|
14
27
|
update: function(response) {
|
15
28
|
updateCallbacks.forEach(function(callback) {
|
16
29
|
callback(response);
|
17
30
|
});
|
18
31
|
},
|
32
|
+
|
19
33
|
receive: function(input) {
|
20
34
|
var that = this;
|
21
35
|
$.post('/update', {command: input}, function(response) {
|
22
|
-
console.log(JSON.stringify(response));
|
23
36
|
that.update(response);
|
24
37
|
}).fail(function(response) {
|
25
38
|
console.log('An error occurred');
|
26
39
|
});
|
27
40
|
},
|
41
|
+
|
28
42
|
onUpdate: function(callback) {
|
29
43
|
updateCallbacks.push(callback);
|
30
44
|
},
|
45
|
+
|
31
46
|
onStart: function(callback) {
|
32
47
|
updateCallbacks.push(callback);
|
33
48
|
},
|
49
|
+
|
34
50
|
save: function(filename, data) {
|
35
|
-
|
36
|
-
localStorage.setItem(filename,
|
37
|
-
Opal.GameficOpal.$static_character().$tell('Game saved.');
|
51
|
+
console.log('Saving ' + data);
|
52
|
+
localStorage.setItem(filename, data);
|
38
53
|
},
|
54
|
+
|
39
55
|
restore: function(filename) {
|
40
|
-
var
|
41
|
-
var
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
return data;
|
48
|
-
}
|
56
|
+
var json = localStorage.getItem(filename);
|
57
|
+
var data = JSON.parse(json);
|
58
|
+
var that = this;
|
59
|
+
$.post('/restore', {snapshot: JSON.stringify(data)}, function(response) {
|
60
|
+
console.log('Restored a snapshot.');
|
61
|
+
that.update(response);
|
62
|
+
});
|
49
63
|
}
|
50
64
|
}
|
51
65
|
})();
|
@@ -81,7 +81,6 @@
|
|
81
81
|
});
|
82
82
|
$('#objects a, #incidentals a').each(function() {
|
83
83
|
var name = $(this).text().replace(/^(a |an |the )/i, '');
|
84
|
-
console.log('Object: ' + name);
|
85
84
|
var regexp = new RegExp(name, 'g');
|
86
85
|
var command = $(this).attr('data-command');
|
87
86
|
html.find('*').each(function() {
|
@@ -93,7 +92,6 @@
|
|
93
92
|
});
|
94
93
|
$('#portals a').not('.disabled').each(function() {
|
95
94
|
var name = $(this).attr('id').replace(/^(a |an |the )/i, '');
|
96
|
-
console.log('Object: ' + name);
|
97
95
|
var regexp = new RegExp(name, 'g');
|
98
96
|
var command = $(this).attr('data-command');
|
99
97
|
html.find('*').each(function() {
|
data/html/skins/standard/play.js
CHANGED
@@ -7,78 +7,12 @@ $(function() {
|
|
7
7
|
$('#gamefic_command').val('');
|
8
8
|
$('#gamefic_controls').removeClass('working');
|
9
9
|
});
|
10
|
-
/*Gamefic.onStart(function(response) {
|
11
|
-
var prompt = response.prompt;
|
12
|
-
if (prompt == '>') {
|
13
|
-
prompt = 'What do you want to do?'
|
14
|
-
}
|
15
|
-
$('#gamefic_prompt').html(prompt);
|
16
|
-
$('#gamefic_output a[rel="gamefic"]').addClass('disabled');
|
17
|
-
});
|
18
|
-
Gamefic.onInput(function(response) {
|
19
|
-
if (response.input != null) {
|
20
|
-
$('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
|
21
|
-
}
|
22
|
-
$('#gamefic_controls').addClass('working');
|
23
|
-
});
|
24
|
-
Gamefic.onFinish(function(response) {
|
25
|
-
if (!response.busy) {
|
26
|
-
$('#gamefic_controls').removeClass('working');
|
27
|
-
}
|
28
|
-
$('#gamefic_command').val('');
|
29
|
-
$('#gamefic_command').focus();
|
30
|
-
var outputElement = document.getElementById('gamefic_output');
|
31
|
-
$('#gamefic_output').animate({
|
32
|
-
scrollTop: outputElement.scrollHeight
|
33
|
-
}, 500);
|
34
|
-
});
|
35
|
-
Gamefic.handleResponse('Active', function(response) {
|
36
|
-
$('#gamefic_output').append(response.output);
|
37
|
-
});
|
38
|
-
Gamefic.handleResponse('YesOrNo', function(response) {
|
39
|
-
$('#gamefic_output').append(response.output);
|
40
|
-
$('#gamefic_output').append('<p>(<a href="#" rel="gamefic" data-command="yes">Yes</a> or <a href="#" rel="gamefic" data-command="no">No</a>)</p>');
|
41
|
-
});
|
42
|
-
Gamefic.handleResponse('MultipleChoice', function(response) {
|
43
|
-
var jq = $('<div/>');
|
44
|
-
jq.html(response.output);
|
45
|
-
jq.find('ol.multiple_choice li').each(function() {
|
46
|
-
var item = $(this).text();
|
47
|
-
var link = $('<a/>');
|
48
|
-
link.attr('href', '#');
|
49
|
-
link.attr('rel', 'gamefic');
|
50
|
-
link.attr('data-command', item);
|
51
|
-
link.text(item);
|
52
|
-
$(this).html(link);
|
53
|
-
});
|
54
|
-
$('#gamefic_output').append(jq);
|
55
|
-
});
|
56
|
-
Gamefic.handleResponse('Conclusion', function(response) {
|
57
|
-
if (response.input != null) {
|
58
|
-
$('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
|
59
|
-
}
|
60
|
-
$('#gamefic_console').addClass('concluded');
|
61
|
-
$('#gamefic_output').append(response.output);
|
62
|
-
$('#gamefic_controls').hide();
|
63
|
-
});
|
64
|
-
$('#gamefic_output').on('click', 'a[rel="gamefic"]', function(event) {
|
65
|
-
event.preventDefault();
|
66
|
-
if (!$(this).hasClass('disabled')) {
|
67
|
-
Gamefic.update($(this).attr('data-command'));
|
68
|
-
}
|
69
|
-
});*/
|
70
10
|
Gamefic.onUpdate((state) => {
|
71
|
-
console.log('Doing the update with ' + state['output']);
|
72
|
-
console.log(JSON.stringify(state));
|
73
11
|
$('#gamefic_output').append(state['output']);
|
74
12
|
if (state.scene == 'Conclusion') {
|
75
13
|
$('#gamefic_console').addClass('concluded');
|
76
14
|
}
|
77
15
|
});
|
78
|
-
console.log('Starting Gamefic');
|
79
16
|
Gamefic.start();
|
80
|
-
//console.log('Started!');
|
81
17
|
$('#gamefic_controls').removeClass('working');
|
82
|
-
//$('#gamefic_command').focus();
|
83
|
-
console.log('finished play');
|
84
18
|
});
|
data/lib/gamefic-sdk.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'gamefic'
|
2
2
|
require 'gamefic-sdk/platform'
|
3
|
-
require 'gamefic-sdk/plot_config'
|
3
|
+
#require 'gamefic-sdk/plot_config'
|
4
4
|
require 'gamefic-sdk/debug'
|
5
5
|
require 'gamefic-sdk/version'
|
6
6
|
|
7
7
|
module Gamefic::Sdk
|
8
8
|
autoload :Server, 'gamefic-sdk/server'
|
9
|
+
autoload :Config, 'gamefic-sdk/config'
|
9
10
|
|
10
11
|
HTML_TEMPLATE_PATH = File.realpath(File.dirname(__FILE__) + "/../html/")
|
11
12
|
GLOBAL_SCRIPT_PATH = File.realpath(File.dirname(__FILE__) + "/../scripts/")
|
data/lib/gamefic-sdk/build.rb
CHANGED
@@ -4,34 +4,26 @@ module Gamefic::Sdk
|
|
4
4
|
|
5
5
|
module Build
|
6
6
|
def self.release directory, quiet = false
|
7
|
-
config =
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
config = Gamefic::Sdk::Config.load(directory)
|
8
|
+
if config.auto_import?
|
9
|
+
puts "Importing scripts..."
|
10
|
+
Shell.start ['import', directory, '--quiet']
|
11
11
|
end
|
12
|
-
|
13
|
-
platforms = YAML.load(File.read(build_file))
|
14
|
-
platforms.each_pair { |k, v|
|
15
|
-
v['name'] = k
|
16
|
-
cls = Gamefic::Sdk::Platform.const_get(v['platform'])
|
17
|
-
plat = cls.new(directory, v)
|
12
|
+
config.targets.each_pair { |k, v|
|
18
13
|
puts "Building #{k}..." unless quiet
|
14
|
+
plat = Gamefic::Sdk::Platform.load(config, k)
|
19
15
|
plat.build
|
20
16
|
}
|
21
|
-
puts "Build#{
|
17
|
+
puts "Build#{config.targets.length > 1 ? 's' : ''} complete." unless quiet
|
22
18
|
end
|
23
19
|
def self.clean directory
|
24
|
-
|
25
|
-
config
|
26
|
-
config.each_pair { |k, v|
|
27
|
-
v['name'] = k
|
20
|
+
config = Gamefic::Sdk::Config.load(directory)
|
21
|
+
config.targets.each_pair { |k, v|
|
28
22
|
puts "Cleaning #{k}..."
|
29
|
-
|
30
|
-
platform_dir = File.join(directory, "release", k)
|
31
|
-
cls = Gamefic::Sdk::Platform.const_get(v['platform'])
|
32
|
-
plat = cls.new(directory, v)
|
23
|
+
plat = Gamefic::Sdk::Platform.load(config, k)
|
33
24
|
plat.clean
|
34
25
|
}
|
26
|
+
puts "Done."
|
35
27
|
end
|
36
28
|
end
|
37
29
|
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Gamefic
|
5
|
+
module Sdk
|
6
|
+
class Config
|
7
|
+
attr_reader :source_dir
|
8
|
+
attr_reader :data
|
9
|
+
|
10
|
+
def initialize directory, data = {}
|
11
|
+
@source_dir = directory
|
12
|
+
@data = data
|
13
|
+
|
14
|
+
@source_dir.freeze
|
15
|
+
@data.freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
# The game's title.
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
def title
|
22
|
+
@title ||= (data['title'] || 'Untitled')
|
23
|
+
end
|
24
|
+
|
25
|
+
# The game's author.
|
26
|
+
#
|
27
|
+
# @return [String]
|
28
|
+
def author
|
29
|
+
@author ||= (data['author'] || 'Anonymous')
|
30
|
+
end
|
31
|
+
|
32
|
+
# The absolute path to the project's script directory.
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
def script_path
|
36
|
+
@script_paths ||= Pathname.new(source_dir).join(data['script_path'] || './scripts').to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
# The absolute path to the project's import directory.
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
def import_path
|
43
|
+
@import_paths ||= Pathname.new(source_dir).join(data['import_path'] || './imports').to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
# The absolute path to the project's media directory.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
def media_path
|
50
|
+
@media_path ||= Pathname.new(source_dir).join(data['media_path'] || './media').to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
# The absolute path to the project's build directory.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
def build_path
|
57
|
+
@build_path ||= Pathname.new(source_dir).join(data['build_path'] || './build').to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
# The absolute path to the project's release directory.
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
def release_path
|
64
|
+
@release_path ||= Pathname.new(source_dir).join(data['release_path'] || './release').to_s
|
65
|
+
end
|
66
|
+
|
67
|
+
def auto_import?
|
68
|
+
@auto_import ||= (data['auto_import'] || true)
|
69
|
+
end
|
70
|
+
|
71
|
+
# A hash of each target's name and its configuration options.
|
72
|
+
#
|
73
|
+
# @return [Hash]
|
74
|
+
def targets
|
75
|
+
@targets ||= (data['targets'] || {})
|
76
|
+
end
|
77
|
+
|
78
|
+
# A universal unique identifier for the project.
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
def uuid
|
82
|
+
if @uuid.nil?
|
83
|
+
if File.file?(File.join source_dir, '.uuid')
|
84
|
+
@@uuid = File.read(File.join source_dir, '.uuid').strip
|
85
|
+
end
|
86
|
+
end
|
87
|
+
@uuid
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [Gamefic::Sdk::Config]
|
91
|
+
def self.load directory
|
92
|
+
config = {}
|
93
|
+
['config.yml', 'config.yaml'].each do |cy|
|
94
|
+
config_file = File.join(directory, cy)
|
95
|
+
if File.exist?(config_file)
|
96
|
+
config = YAML.load(File.read(config_file))
|
97
|
+
break
|
98
|
+
end
|
99
|
+
end
|
100
|
+
Config.new(directory, config)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.generate author = 'Anonymous', title = 'Untitled'
|
104
|
+
<<-EOS
|
105
|
+
title: #{title}
|
106
|
+
author: #{author}
|
107
|
+
|
108
|
+
script_path: ./scripts
|
109
|
+
import_path: ./imports
|
110
|
+
media_path: ./media
|
111
|
+
|
112
|
+
build_path: ./build
|
113
|
+
release_path: ./release
|
114
|
+
|
115
|
+
targets:
|
116
|
+
web:
|
117
|
+
platform: Web
|
118
|
+
html: ./html
|
119
|
+
gfic:
|
120
|
+
platform: Gfic
|
121
|
+
filename: game.gfic
|
122
|
+
EOS
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|