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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/html/core/engine.js +89 -20
  3. data/html/sinatra/engine.js +27 -13
  4. data/html/skins/hypertext/index.html +0 -2
  5. data/html/skins/standard/play.js +0 -66
  6. data/lib/gamefic-sdk.rb +2 -1
  7. data/lib/gamefic-sdk/build.rb +11 -19
  8. data/lib/gamefic-sdk/config.rb +126 -0
  9. data/lib/gamefic-sdk/platform.rb +12 -0
  10. data/lib/gamefic-sdk/platform/base.rb +35 -33
  11. data/lib/gamefic-sdk/platform/gfic.rb +5 -18
  12. data/lib/gamefic-sdk/platform/sinatra.rb +29 -31
  13. data/lib/gamefic-sdk/platform/web.rb +72 -65
  14. data/lib/gamefic-sdk/platform/web/app_config.rb +48 -48
  15. data/lib/gamefic-sdk/platform/web/engine.rb +10 -7
  16. data/lib/gamefic-sdk/platform/web/user.rb +3 -3
  17. data/lib/gamefic-sdk/server.rb +17 -19
  18. data/lib/gamefic-sdk/shell.rb +68 -16
  19. data/lib/gamefic-sdk/shell/init.rb +3 -19
  20. data/lib/gamefic-sdk/shell/test.rb +9 -14
  21. data/lib/gamefic-sdk/version.rb +1 -1
  22. data/scripts/save-restore-undo.plot.rb +25 -0
  23. data/scripts/snapshots.plot.rb +16 -14
  24. data/scripts/standard.plot.rb +3 -5
  25. data/scripts/standard/actions.plot.rb +1 -11
  26. data/scripts/standard/actions/drop.plot.rb +1 -1
  27. data/scripts/standard/actions/enter.plot.rb +4 -16
  28. data/scripts/standard/actions/go.plot.rb +2 -36
  29. data/scripts/standard/actions/insert.plot.rb +7 -21
  30. data/scripts/standard/actions/inventory.plot.rb +2 -1
  31. data/scripts/standard/actions/leave.plot.rb +7 -18
  32. data/scripts/standard/actions/look.plot.rb +45 -44
  33. data/scripts/standard/actions/nil.plot.rb +1 -1
  34. data/scripts/standard/actions/take.plot.rb +10 -28
  35. data/scripts/standard/actions/talk.plot.rb +9 -13
  36. data/scripts/standard/clothing.plot.rb +4 -0
  37. data/scripts/standard/clothing/actions.plot.rb +4 -0
  38. data/scripts/{clothing → standard/clothing}/actions/doff.plot.rb +0 -0
  39. data/scripts/{clothing → standard/clothing}/actions/drop.plot.rb +8 -8
  40. data/scripts/{clothing → standard/clothing}/actions/inventory.plot.rb +14 -14
  41. data/scripts/standard/clothing/actions/wear.plot.rb +20 -0
  42. data/scripts/standard/clothing/entities.plot.rb +7 -0
  43. data/scripts/{clothing → standard/clothing}/entities/clothing.plot.rb +0 -2
  44. data/scripts/standard/clothing/entities/coat.plot.rb +3 -0
  45. data/scripts/standard/clothing/entities/gloves.plot.rb +3 -0
  46. data/scripts/standard/clothing/entities/hat.plot.rb +3 -0
  47. data/scripts/standard/clothing/entities/pants.plot.rb +3 -0
  48. data/scripts/standard/clothing/entities/shirt.plot.rb +3 -0
  49. data/scripts/standard/clothing/entities/shoes.plot.rb +3 -0
  50. data/scripts/standard/container.plot.rb +28 -0
  51. data/scripts/{debug.plot.rb → standard/container/actions.plot.rb} +0 -0
  52. data/scripts/standard/container/entities.plot.rb +5 -0
  53. data/scripts/standard/direction.plot.rb +1 -2
  54. data/scripts/{edible.plot.rb → standard/edible.plot.rb} +5 -3
  55. data/scripts/standard/entities.plot.rb +3 -3
  56. data/scripts/standard/entities/character.plot.rb +9 -6
  57. data/scripts/standard/entities/fixture.plot.rb +1 -1
  58. data/scripts/standard/entities/item.plot.rb +2 -4
  59. data/scripts/standard/entities/portal.plot.rb +9 -5
  60. data/scripts/standard/entities/receptacle.plot.rb +1 -1
  61. data/scripts/standard/entities/room.plot.rb +5 -5
  62. data/scripts/standard/entities/scenery.plot.rb +2 -4
  63. data/scripts/standard/entities/supporter.plot.rb +4 -7
  64. data/scripts/standard/entities/thing.plot.rb +7 -0
  65. data/scripts/standard/{actions/give.plot.rb → give.plot.rb} +27 -25
  66. data/scripts/standard/lockable.plot.rb +79 -0
  67. data/scripts/standard/modules.plot.rb +2 -4
  68. data/scripts/standard/modules/attachable.plot.rb +1 -0
  69. data/scripts/standard/modules/locale_description.plot.rb +20 -0
  70. data/scripts/standard/{use.plot.rb → modules/use.plot.rb} +51 -47
  71. data/scripts/standard/openable.plot.rb +43 -0
  72. data/scripts/standard/pathfinder.plot.rb +11 -6
  73. data/scripts/standard/test.plot.rb +2 -0
  74. data/scripts/undo.plot.rb +13 -11
  75. metadata +30 -65
  76. data/lib/gamefic-sdk/plot_config.rb +0 -25
  77. data/scripts/ansi.plot.rb +0 -13
  78. data/scripts/autosuggest.plot.rb +0 -165
  79. data/scripts/clothing.plot.rb +0 -2
  80. data/scripts/clothing/actions.plot.rb +0 -4
  81. data/scripts/clothing/actions/wear.plot.rb +0 -19
  82. data/scripts/clothing/entities.plot.rb +0 -7
  83. data/scripts/clothing/entities/coat.plot.rb +0 -5
  84. data/scripts/clothing/entities/gloves.plot.rb +0 -5
  85. data/scripts/clothing/entities/hat.plot.rb +0 -5
  86. data/scripts/clothing/entities/pants.plot.rb +0 -5
  87. data/scripts/clothing/entities/shirt.plot.rb +0 -5
  88. data/scripts/clothing/entities/shoes.plot.rb +0 -5
  89. data/scripts/cover.plot.rb +0 -30
  90. data/scripts/furniture.plot.rb +0 -35
  91. data/scripts/hints.plot.rb +0 -31
  92. data/scripts/hypertext.plot.rb +0 -280
  93. data/scripts/media.plot.rb +0 -17
  94. data/scripts/multimedia.plot.rb +0 -41
  95. data/scripts/questions.plot.rb +0 -17
  96. data/scripts/room-modes.plot.rb +0 -48
  97. data/scripts/rough-sizes.plot.rb +0 -36
  98. data/scripts/save-restore.plot.rb +0 -22
  99. data/scripts/standard/actions/close.plot.rb +0 -16
  100. data/scripts/standard/actions/lock.plot.rb +0 -59
  101. data/scripts/standard/actions/look-under.plot.rb +0 -8
  102. data/scripts/standard/actions/open.plot.rb +0 -34
  103. data/scripts/standard/actions/read.plot.rb +0 -3
  104. data/scripts/standard/actions/search.plot.rb +0 -40
  105. data/scripts/standard/actions/show.plot.rb +0 -13
  106. data/scripts/standard/actions/unlock.plot.rb +0 -77
  107. data/scripts/standard/actions/use.plot.rb +0 -25
  108. data/scripts/standard/entities/container.plot.rb +0 -8
  109. data/scripts/standard/entities/door.plot.rb +0 -51
  110. data/scripts/standard/entities/entity.plot.rb +0 -12
  111. data/scripts/standard/entities/exterior.plot.rb +0 -5
  112. data/scripts/standard/modules/darkenable.plot.rb +0 -6
  113. data/scripts/standard/modules/lockable.plot.rb +0 -25
  114. data/scripts/standard/modules/openable.plot.rb +0 -15
  115. data/scripts/standard/modules/transparent.plot.rb +0 -6
  116. data/scripts/standard/plural.plot.rb +0 -2
  117. data/scripts/standard/plural/actions.plot.rb +0 -4
  118. data/scripts/standard/plural/actions/drop.plot.rb +0 -126
  119. data/scripts/standard/plural/actions/insert.plot.rb +0 -60
  120. data/scripts/standard/plural/actions/place.plot.rb +0 -37
  121. data/scripts/standard/plural/actions/take.plot.rb +0 -175
  122. data/scripts/standard/plural/queries.plot.rb +0 -5
  123. data/scripts/standard/plural/queries/ambiguous_visible.plot.rb +0 -13
  124. data/scripts/standard/plural/queries/any_expression.plot.rb +0 -17
  125. data/scripts/standard/plural/queries/many_visible.plot.rb +0 -13
  126. data/scripts/standard/plural/queries/not_expression.plot.rb +0 -16
  127. data/scripts/standard/plural/queries/plural_visible.plot.rb +0 -22
  128. data/scripts/suggestible.plot.rb +0 -54
@@ -2,54 +2,54 @@ require 'erb'
2
2
 
3
3
  module Gamefic
4
4
  module Sdk
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 @game_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['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/minimal"
46
- end
47
- if !File.directory?(dir)
48
- raise "Could not resolve HTML directory"
49
- end
50
- dir
51
- end
52
- end
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
- @plot.introduce @character
18
- @plot.ready
19
- @user.update @character.state
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 @character.state
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 state
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
 
@@ -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
- paths = config_path(settings.source_dir).script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
12
- config = YAML.load(File.read(File.join(settings.source_dir, 'config.yaml')))
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
- @@plot.script 'debug'
17
- sinatra = Gamefic::Sdk::Platform::Sinatra.new(settings.source_dir, config)
15
+ #@@plot.script 'debug'
16
+ sinatra = Gamefic::Sdk::Platform::Sinatra.new(config: config)
18
17
  sinatra.build
19
- File.read File.join(sinatra.config['target_dir'], 'index.html')
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 = Character.new(name: 'player', synonyms: 'me myself self you yourself', description: 'As good-looking as ever.')
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
@@ -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-scripts [DIRECTORY_NAME]', 'Copy external scripts to the local scripts directory'
62
- def import_scripts(directory_name = '.')
63
- config_yaml = File.join(directory_name, 'config.yaml')
64
- if File.exist?(config_yaml)
65
- config_path = PlotConfig.new config_yaml
66
- else
67
- config_path = PlotConfig.new
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, 'scripts', "#{s.path}.plot.rb"))
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 'reset-package [DIRECTORY_NAME]', 'Reset package.yaml to the default values'
84
- def reset_config(directory_name = '.')
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.yaml", 'w') do |file|
73
- file.puts "title: #{@title || 'Untitled'}",
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
- paths = config_path.script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
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
- plot.script 'debug'
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
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.6.0'
3
+ VERSION = '1.7.0'
4
4
  end
5
5
  end
@@ -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