gamefic-sdk 1.6.0 → 1.7.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 +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
@@ -2,54 +2,54 @@ require 'erb'
|
|
2
2
|
|
3
3
|
module Gamefic
|
4
4
|
module Sdk
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
5
|
+
class Gamefic::Sdk::Platform::Web::AppConfig
|
6
|
+
include Plot::Theater
|
7
|
+
attr_reader :javascripts, :stylesheets, :resource_paths, :source_dir, :config, :html_dir
|
8
|
+
#expose :javascripts, :stylesheets, :resource_paths
|
9
|
+
|
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
|
12
|
+
@javascripts = []
|
13
|
+
@stylesheets = []
|
14
|
+
@source_dir = source_dir
|
15
|
+
@config = config
|
16
|
+
@html_dir = resolve_html_dir
|
17
|
+
#@game_config = PlotConfig.new("#{source_dir}/config.yaml")
|
18
|
+
@resource_paths = ["#{html_dir}", Gamefic::Sdk::HTML_TEMPLATE_PATH]
|
19
|
+
config_file = "#{html_dir}/index.rb"
|
20
|
+
stage File.read(config_file), config_file
|
21
|
+
javascripts.concat js
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [BuildConfig::Data]
|
25
|
+
def data
|
26
|
+
Data.new config, @javascripts, @stylesheets
|
27
|
+
end
|
28
|
+
|
29
|
+
# Render HTML using the build config data
|
30
|
+
#
|
31
|
+
# @return [String] The resulting HTML
|
32
|
+
def render
|
33
|
+
erb = ERB.new(File.read(html_dir + "/index.html.erb"))
|
34
|
+
erb.result data.get_binding
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def resolve_html_dir
|
40
|
+
dir = "#{source_dir}/html"
|
41
|
+
if !File.directory?(dir) and config.data['html_skin'].to_s != ''
|
42
|
+
dir = "#{Gamefic::Sdk::HTML_TEMPLATE_PATH}/skins/#{config['html_skin']}"
|
43
|
+
end
|
44
|
+
if !File.directory?(dir)
|
45
|
+
dir = "#{Gamefic::Sdk::HTML_TEMPLATE_PATH}/skins/standard"
|
46
|
+
end
|
47
|
+
if !File.directory?(dir)
|
48
|
+
raise "Could not resolve HTML directory"
|
49
|
+
end
|
50
|
+
dir
|
51
|
+
end
|
52
|
+
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# @hack Explicit requires for Opal
|
2
2
|
require 'gamefic/plot/playbook'
|
3
|
+
require 'gamefic/plot/darkroom'
|
3
4
|
require 'gamefic/grammar'
|
4
5
|
require 'gamefic/query'
|
5
6
|
require 'gamefic/grammar/verb_set'
|
@@ -7,26 +8,28 @@ require 'gamefic/grammar/conjugator'
|
|
7
8
|
|
8
9
|
module Gamefic
|
9
10
|
module Engine
|
10
|
-
class Web < Gamefic::Engine::Base
|
11
|
+
class Web < Gamefic::Engine::Base
|
12
|
+
attr_reader :user
|
13
|
+
|
11
14
|
def post_initialize
|
12
15
|
self.user_class = Gamefic::User::Web
|
13
16
|
end
|
14
17
|
|
15
18
|
def run
|
16
19
|
connect
|
17
|
-
|
18
|
-
|
19
|
-
@user.update
|
20
|
+
plot.introduce @user.character
|
21
|
+
plot.ready
|
22
|
+
@user.update
|
20
23
|
end
|
21
24
|
|
22
25
|
def turn
|
23
26
|
@plot.ready
|
24
|
-
@user.update
|
25
|
-
update unless @character.queue.empty?
|
27
|
+
@user.update
|
28
|
+
update unless @user.character.queue.empty?
|
26
29
|
end
|
27
30
|
|
28
31
|
def receive input
|
29
|
-
@character.queue.push input unless input.nil?
|
32
|
+
@user.character.queue.push input unless input.nil?
|
30
33
|
update
|
31
34
|
end
|
32
35
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Gamefic
|
2
2
|
module User
|
3
3
|
class Web < Gamefic::User::Base
|
4
|
-
def update
|
5
|
-
`Gamefic.update(#{state.to_json});`
|
4
|
+
def update
|
5
|
+
`Gamefic.update(#{character.state.to_json});`
|
6
6
|
end
|
7
7
|
|
8
8
|
def save filename, data
|
9
|
-
data[:metadata] = GameficOpal.static_plot.metadata
|
9
|
+
#data[:metadata] = GameficOpal.static_plot.metadata
|
10
10
|
`Gamefic.save(filename, data);`
|
11
11
|
end
|
12
12
|
|
data/lib/gamefic-sdk/server.rb
CHANGED
@@ -6,23 +6,21 @@ module Gamefic
|
|
6
6
|
|
7
7
|
class Server < Sinatra::Base
|
8
8
|
set :port, 4342
|
9
|
-
|
9
|
+
|
10
10
|
get '/' do
|
11
|
-
|
12
|
-
|
13
|
-
config['name'] = 'sinatra'
|
11
|
+
config = Gamefic::Sdk::Config.load(settings.source_dir)
|
12
|
+
paths = [config.script_path, config.import_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
|
14
13
|
@@plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
|
15
14
|
@@plot.script 'main'
|
16
|
-
|
17
|
-
sinatra = Gamefic::Sdk::Platform::Sinatra.new(
|
15
|
+
#@@plot.script 'debug'
|
16
|
+
sinatra = Gamefic::Sdk::Platform::Sinatra.new(config: config)
|
18
17
|
sinatra.build
|
19
|
-
File.read File.join(sinatra.
|
18
|
+
File.read File.join(sinatra.release_target, 'index.html')
|
20
19
|
end
|
21
20
|
|
22
21
|
post '/start' do
|
23
22
|
content_type :json
|
24
|
-
@@character =
|
25
|
-
@@character.connect User::Base.new
|
23
|
+
@@character = @@plot.player_class.new(name: 'player', synonyms: 'me myself self you yourself', description: 'As good-looking as ever.')
|
26
24
|
@@plot.introduce @@character
|
27
25
|
@@plot.ready
|
28
26
|
@@character.state.to_json
|
@@ -36,6 +34,16 @@ module Gamefic
|
|
36
34
|
@@character.state.merge(input: params['command']).to_json
|
37
35
|
end
|
38
36
|
|
37
|
+
post '/restore' do
|
38
|
+
content_type :json
|
39
|
+
snapshot = JSON.parse(params['snapshot'], symbolize_names: true)
|
40
|
+
@@plot.restore snapshot
|
41
|
+
@@character.cue @@plot.default_scene
|
42
|
+
@@plot.update
|
43
|
+
@@plot.ready
|
44
|
+
@@character.state.to_json
|
45
|
+
end
|
46
|
+
|
39
47
|
class << self
|
40
48
|
|
41
49
|
def run!
|
@@ -51,16 +59,6 @@ module Gamefic
|
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def config_path dir
|
58
|
-
if File.directory?(dir)
|
59
|
-
PlotConfig.new File.join(dir, 'config.yaml')
|
60
|
-
else
|
61
|
-
PlotConfig.new
|
62
|
-
end
|
63
|
-
end
|
64
62
|
end
|
65
63
|
|
66
64
|
end
|
data/lib/gamefic-sdk/shell.rb
CHANGED
@@ -9,7 +9,8 @@ module Gamefic
|
|
9
9
|
|
10
10
|
map %w[--version -v] => :version
|
11
11
|
map [:create, :new] => :init
|
12
|
-
|
12
|
+
map ['scripts'] => :script
|
13
|
+
|
13
14
|
desc "--version, -v", "Print the version"
|
14
15
|
def version
|
15
16
|
puts "gamefic-sdk #{Gamefic::Sdk::VERSION}"
|
@@ -58,31 +59,32 @@ module Gamefic
|
|
58
59
|
Gamefic::Sdk::Build.clean(directory_name)
|
59
60
|
end
|
60
61
|
|
61
|
-
desc 'import
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
FileUtils.mkdir_p(File.join(directory_name, 'scripts'))
|
70
|
-
paths = config_path.script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
|
62
|
+
desc 'import [DIRECTORY_NAME]', 'Copy external scripts to the project'
|
63
|
+
option :quiet, type: :boolean, aliases: :q, desc: 'Suppress output'
|
64
|
+
def import(directory_name = '.')
|
65
|
+
config = Gamefic::Sdk::Config.load directory_name
|
66
|
+
FileUtils.remove_entry_secure config.import_path if File.exist?(config.import_path)
|
67
|
+
FileUtils.mkdir_p config.import_path
|
68
|
+
paths = [config.script_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
|
71
69
|
plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
|
72
70
|
plot.script 'main'
|
73
71
|
plot.imported_scripts.each { |s|
|
72
|
+
next unless s.absolute_path.start_with?(Gamefic::Sdk::GLOBAL_SCRIPT_PATH)
|
74
73
|
src = File.absolute_path(s.absolute_path)
|
75
|
-
dst = File.absolute_path(File.join(directory_name, '
|
74
|
+
dst = File.absolute_path(File.join(directory_name, 'imports', "#{s.path}.plot.rb"))
|
76
75
|
next if src == dst
|
77
|
-
puts "Importing #{s.path}"
|
76
|
+
puts "Importing #{s.path}" unless options[:quiet]
|
78
77
|
FileUtils.mkdir_p(File.dirname(dst))
|
79
78
|
FileUtils.cp_r(src, dst)
|
80
79
|
}
|
81
80
|
end
|
82
81
|
|
83
|
-
desc '
|
84
|
-
def
|
85
|
-
|
82
|
+
desc 'default-config [DIRECTORY_NAME]', 'Create or overwrite config.yml with default values'
|
83
|
+
def default_config(directory_name = '.')
|
84
|
+
File.open(File.join(directory_name, 'config.yml'), 'w') do |file|
|
85
|
+
file << Gamefic::Sdk::Config.generate
|
86
|
+
end
|
87
|
+
puts "Default config.yml created."
|
86
88
|
end
|
87
89
|
|
88
90
|
desc 'webskins', 'List the available skins for the Web platform'
|
@@ -91,6 +93,56 @@ module Gamefic
|
|
91
93
|
puts File.basename(d)
|
92
94
|
}
|
93
95
|
end
|
96
|
+
|
97
|
+
desc 'script [PATH]', 'List or document the scripts in the SDK'
|
98
|
+
def script path = nil
|
99
|
+
if path.nil?
|
100
|
+
s = []
|
101
|
+
Dir[File.join GLOBAL_SCRIPT_PATH, '**', '*.rb'].each { |f|
|
102
|
+
c = File.read(f)
|
103
|
+
c.each_line { |l|
|
104
|
+
match = l.match(/[\s]*#[\s]*@gamefic.script[ ]+([a-z0-9\/]+)/)
|
105
|
+
unless match.nil?
|
106
|
+
s.push(match[1])
|
107
|
+
end
|
108
|
+
}
|
109
|
+
}
|
110
|
+
puts s.sort.join("\n")
|
111
|
+
else
|
112
|
+
document_script path
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def document_script path
|
119
|
+
f = File.join(GLOBAL_SCRIPT_PATH, "#{path}.plot.rb")
|
120
|
+
if File.exist?(f)
|
121
|
+
c = File.read(f)
|
122
|
+
doc = ''
|
123
|
+
in_comment = false
|
124
|
+
c.each_line { |l|
|
125
|
+
if in_comment
|
126
|
+
break unless l.start_with?('#')
|
127
|
+
doc += "#{l[2..-1]}"
|
128
|
+
else
|
129
|
+
match = l.match(/[\s]*#[\s]*@gamefic.script[ ]+([a-z0-9\/]+)/)
|
130
|
+
in_comment = true unless match.nil?
|
131
|
+
end
|
132
|
+
}
|
133
|
+
if in_comment
|
134
|
+
puts ''
|
135
|
+
puts path
|
136
|
+
puts ''
|
137
|
+
puts doc unless doc == ''
|
138
|
+
puts '' unless doc == ''
|
139
|
+
else
|
140
|
+
puts "Path '#{path}' is not documented."
|
141
|
+
end
|
142
|
+
else
|
143
|
+
puts "Script path '#{path}' does not exist."
|
144
|
+
end
|
145
|
+
end
|
94
146
|
end
|
95
147
|
end
|
96
148
|
end
|
@@ -22,7 +22,6 @@ module Gamefic
|
|
22
22
|
make_game_directories
|
23
23
|
write_main_script
|
24
24
|
write_test_script
|
25
|
-
write_build_yaml
|
26
25
|
write_config_yaml
|
27
26
|
write_uuid_file
|
28
27
|
copy_html_skin
|
@@ -40,6 +39,7 @@ module Gamefic
|
|
40
39
|
end
|
41
40
|
|
42
41
|
Dir.mkdir(File.join(@directory, 'scripts'))
|
42
|
+
Dir.mkdir(File.join(@directory, 'imports'))
|
43
43
|
Dir.mkdir(File.join(@directory, 'media'))
|
44
44
|
end
|
45
45
|
|
@@ -58,25 +58,9 @@ module Gamefic
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def write_build_yaml
|
62
|
-
File.open("#{@directory}/build.yaml", 'w') do |file|
|
63
|
-
file.puts "web:",
|
64
|
-
" platform: Web",
|
65
|
-
"gfic:",
|
66
|
-
" platform: Gfic",
|
67
|
-
" filename: game.gfic"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
61
|
def write_config_yaml
|
72
|
-
File.open("#{@directory}/config.
|
73
|
-
file
|
74
|
-
"author: #{@author || 'Anonymous'}",
|
75
|
-
"",
|
76
|
-
"script_paths:",
|
77
|
-
" - ./scripts",
|
78
|
-
"media_paths:",
|
79
|
-
" - ./media"
|
62
|
+
File.open("#{@directory}/config.yml", 'w') do |file|
|
63
|
+
file << Gamefic::Sdk::Config.generate
|
80
64
|
end
|
81
65
|
end
|
82
66
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'gamefic-sdk/plot_config'
|
2
1
|
require 'gamefic/engine/tty'
|
3
2
|
|
4
3
|
module Gamefic
|
@@ -8,29 +7,25 @@ module Gamefic
|
|
8
7
|
def initialize(directory:)
|
9
8
|
@path = directory
|
10
9
|
raise "Invalid path: #{@path}" unless File.exist?(@path)
|
11
|
-
puts "Loading..."
|
12
10
|
end
|
13
11
|
|
14
12
|
def run
|
15
|
-
|
13
|
+
puts "Loading..."
|
14
|
+
config = Gamefic::Sdk::Config.new(@path)
|
15
|
+
if config.auto_import?
|
16
|
+
puts "Importing scripts..."
|
17
|
+
Shell.start ['import', @path, '--quiet']
|
18
|
+
end
|
19
|
+
paths = [config.script_path, config.import_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
|
16
20
|
plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
|
17
21
|
plot.script 'main'
|
18
|
-
|
22
|
+
# @todo Debug is temporarily disabled.
|
23
|
+
#plot.script 'debug'
|
19
24
|
engine = Engine::Tty.new plot
|
20
25
|
engine.connect
|
21
26
|
puts "\n"
|
22
27
|
engine.run
|
23
28
|
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def config_path
|
28
|
-
if File.directory?(@path)
|
29
|
-
PlotConfig.new File.join(@path, 'config.yaml')
|
30
|
-
else
|
31
|
-
PlotConfig.new
|
32
|
-
end
|
33
|
-
end
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
data/lib/gamefic-sdk/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# @gamefic.script save-restore-undo
|
2
|
+
# SAVE, RESTORE, and UNDO actions.
|
3
|
+
|
4
|
+
script 'snapshots'
|
5
|
+
|
6
|
+
respond :save do |actor|
|
7
|
+
snap = save
|
8
|
+
actor.user.save 'save.dat', snap
|
9
|
+
actor.tell "Game saved."
|
10
|
+
end
|
11
|
+
|
12
|
+
respond :restore do |actor|
|
13
|
+
actor.user.restore 'save.dat'
|
14
|
+
actor.tell "Game restored."
|
15
|
+
end
|
16
|
+
|
17
|
+
respond :undo do |actor|
|
18
|
+
snap = Snapshots.history.last
|
19
|
+
if snap.nil?
|
20
|
+
actor.tell "Nothing to undo."
|
21
|
+
else
|
22
|
+
restore snap
|
23
|
+
actor.tell "Last action undone."
|
24
|
+
end
|
25
|
+
end
|