gamefic-sdk 1.7.0 → 2.0.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 (115) hide show
  1. checksums.yaml +5 -5
  2. data/bin/gamefic +16 -0
  3. data/lib/gamefic-sdk.rb +4 -24
  4. data/lib/gamefic-sdk/diagram.rb +205 -0
  5. data/lib/gamefic-sdk/scaffold.rb +54 -0
  6. data/lib/gamefic-sdk/server.rb +81 -65
  7. data/lib/gamefic-sdk/shell.rb +22 -129
  8. data/lib/gamefic-sdk/tasks.rb +40 -0
  9. data/lib/gamefic-sdk/tasks/common.rb +21 -0
  10. data/lib/gamefic-sdk/tasks/ruby.rb +99 -0
  11. data/lib/gamefic-sdk/tasks/web.rb +82 -0
  12. data/lib/gamefic-sdk/version.rb +5 -5
  13. metadata +123 -139
  14. data/bin/gfk +0 -6
  15. data/html/core/engine.js +0 -114
  16. data/html/core/jquery.js +0 -5
  17. data/html/core/jquery.modal.css +0 -44
  18. data/html/core/jquery.modal.js +0 -225
  19. data/html/core/js.cookie.js +0 -137
  20. data/html/sinatra/engine.js +0 -65
  21. data/html/skins/hypertext/compass.png +0 -0
  22. data/html/skins/hypertext/index.html +0 -149
  23. data/html/skins/hypertext/style.css +0 -74
  24. data/html/skins/minimal/index.html.erb +0 -22
  25. data/html/skins/minimal/index.rb +0 -4
  26. data/html/skins/minimal/play.js +0 -36
  27. data/html/skins/minimal/style.css +0 -8
  28. data/html/skins/multimedia/close.png +0 -0
  29. data/html/skins/multimedia/index.html +0 -179
  30. data/html/skins/multimedia/mobile.css +0 -10
  31. data/html/skins/multimedia/spinner.gif +0 -0
  32. data/html/skins/multimedia/style.css +0 -186
  33. data/html/skins/standard/index.html.erb +0 -22
  34. data/html/skins/standard/index.rb +0 -4
  35. data/html/skins/standard/play.js +0 -18
  36. data/html/skins/standard/style.css +0 -73
  37. data/lib/gamefic-sdk/build.rb +0 -30
  38. data/lib/gamefic-sdk/config.rb +0 -126
  39. data/lib/gamefic-sdk/debug.rb +0 -4
  40. data/lib/gamefic-sdk/debug/action.rb +0 -30
  41. data/lib/gamefic-sdk/debug/plot.rb +0 -23
  42. data/lib/gamefic-sdk/platform.rb +0 -22
  43. data/lib/gamefic-sdk/platform/base.rb +0 -68
  44. data/lib/gamefic-sdk/platform/gfic.rb +0 -27
  45. data/lib/gamefic-sdk/platform/sinatra.rb +0 -98
  46. data/lib/gamefic-sdk/platform/web.rb +0 -176
  47. data/lib/gamefic-sdk/platform/web/app_config.rb +0 -81
  48. data/lib/gamefic-sdk/platform/web/engine.rb +0 -44
  49. data/lib/gamefic-sdk/platform/web/user.rb +0 -19
  50. data/lib/gamefic-sdk/shell/init.rb +0 -83
  51. data/lib/gamefic-sdk/shell/test.rb +0 -32
  52. data/scripts/save-restore-undo.plot.rb +0 -25
  53. data/scripts/snapshots.plot.rb +0 -16
  54. data/scripts/standard.plot.rb +0 -10
  55. data/scripts/standard/actions.plot.rb +0 -13
  56. data/scripts/standard/actions/drop.plot.rb +0 -19
  57. data/scripts/standard/actions/enter.plot.rb +0 -19
  58. data/scripts/standard/actions/go.plot.rb +0 -48
  59. data/scripts/standard/actions/insert.plot.rb +0 -37
  60. data/scripts/standard/actions/inventory.plot.rb +0 -9
  61. data/scripts/standard/actions/leave.plot.rb +0 -30
  62. data/scripts/standard/actions/look.plot.rb +0 -108
  63. data/scripts/standard/actions/nil.plot.rb +0 -36
  64. data/scripts/standard/actions/place.plot.rb +0 -41
  65. data/scripts/standard/actions/quit.plot.rb +0 -11
  66. data/scripts/standard/actions/take.plot.rb +0 -31
  67. data/scripts/standard/actions/talk.plot.rb +0 -27
  68. data/scripts/standard/actions/wait.plot.rb +0 -3
  69. data/scripts/standard/clothing.plot.rb +0 -4
  70. data/scripts/standard/clothing/actions.plot.rb +0 -4
  71. data/scripts/standard/clothing/actions/doff.plot.rb +0 -12
  72. data/scripts/standard/clothing/actions/drop.plot.rb +0 -8
  73. data/scripts/standard/clothing/actions/inventory.plot.rb +0 -14
  74. data/scripts/standard/clothing/actions/wear.plot.rb +0 -20
  75. data/scripts/standard/clothing/entities.plot.rb +0 -7
  76. data/scripts/standard/clothing/entities/clothing.plot.rb +0 -5
  77. data/scripts/standard/clothing/entities/coat.plot.rb +0 -3
  78. data/scripts/standard/clothing/entities/gloves.plot.rb +0 -3
  79. data/scripts/standard/clothing/entities/hat.plot.rb +0 -3
  80. data/scripts/standard/clothing/entities/pants.plot.rb +0 -3
  81. data/scripts/standard/clothing/entities/shirt.plot.rb +0 -3
  82. data/scripts/standard/clothing/entities/shoes.plot.rb +0 -3
  83. data/scripts/standard/container.plot.rb +0 -28
  84. data/scripts/standard/container/actions.plot.rb +0 -0
  85. data/scripts/standard/container/entities.plot.rb +0 -5
  86. data/scripts/standard/direction.plot.rb +0 -55
  87. data/scripts/standard/edible.plot.rb +0 -21
  88. data/scripts/standard/entities.plot.rb +0 -12
  89. data/scripts/standard/entities/character.plot.rb +0 -10
  90. data/scripts/standard/entities/fixture.plot.rb +0 -3
  91. data/scripts/standard/entities/item.plot.rb +0 -3
  92. data/scripts/standard/entities/portal.plot.rb +0 -44
  93. data/scripts/standard/entities/receptacle.plot.rb +0 -3
  94. data/scripts/standard/entities/room.plot.rb +0 -57
  95. data/scripts/standard/entities/rubble.plot.rb +0 -11
  96. data/scripts/standard/entities/scenery.plot.rb +0 -3
  97. data/scripts/standard/entities/supporter.plot.rb +0 -7
  98. data/scripts/standard/entities/thing.plot.rb +0 -7
  99. data/scripts/standard/give.plot.rb +0 -27
  100. data/scripts/standard/lockable.plot.rb +0 -79
  101. data/scripts/standard/modules.plot.rb +0 -9
  102. data/scripts/standard/modules/attachable.plot.rb +0 -12
  103. data/scripts/standard/modules/auto_takes.plot.rb +0 -50
  104. data/scripts/standard/modules/enterable.plot.rb +0 -15
  105. data/scripts/standard/modules/explicit_exits.plot.rb +0 -15
  106. data/scripts/standard/modules/itemizable.plot.rb +0 -18
  107. data/scripts/standard/modules/locale_description.plot.rb +0 -20
  108. data/scripts/standard/modules/parent-room.plot.rb +0 -9
  109. data/scripts/standard/modules/portable.plot.rb +0 -11
  110. data/scripts/standard/modules/use.plot.rb +0 -51
  111. data/scripts/standard/openable.plot.rb +0 -43
  112. data/scripts/standard/pathfinder.plot.rb +0 -65
  113. data/scripts/standard/queries.plot.rb +0 -21
  114. data/scripts/standard/test.plot.rb +0 -10
  115. data/scripts/undo.plot.rb +0 -13
@@ -1,4 +0,0 @@
1
- module Gamefic::Sdk::Debug
2
- autoload :Plot, 'gamefic-sdk/debug/plot'
3
- autoload :Action, 'gamefic-sdk/debug/action'
4
- end
@@ -1,30 +0,0 @@
1
- require 'gamefic'
2
-
3
- module Gamefic::Sdk
4
- module Debug
5
- class Action < Gamefic::Action
6
- attr_reader :source_location
7
- def initialize(command, *queries, &proc)
8
- super
9
- @executed = false
10
- caller.each { |c|
11
- if c.end_with?(":in `stage'")
12
- @source_location = c[0..-12]
13
- break
14
- end
15
- }
16
- end
17
- def execute *args
18
- super
19
- @executed = true
20
- end
21
- def executed?
22
- @executed
23
- end
24
- def standard?
25
- return false if source_location.nil?
26
- source_location.start_with?(Gamefic::Sdk::GLOBAL_IMPORT_PATH)
27
- end
28
- end
29
- end
30
- end
@@ -1,23 +0,0 @@
1
- require 'gamefic'
2
-
3
- module Gamefic::Sdk::Debug
4
- class Plot < Gamefic::Plot
5
- attr_reader :main_dir
6
- def post_initialize
7
- meta :debug, Query::Text.new(/^unused$/) do |actor, text|
8
- unused = []
9
- actions.each { |a|
10
- if !a.standard? and !a.executed?
11
- unused.push "#{a.verb}:#{a.source_location}"
12
- end
13
- }
14
- actor.tell "#{unused.join("\r\n")}"
15
- end
16
- end
17
- def action(command, *queries, &proc)
18
- act = Gamefic::Sdk::Debug::Action.new(command, *queries, &proc)
19
- playbook.send :add_action, act
20
- act
21
- end
22
- end
23
- end
@@ -1,22 +0,0 @@
1
- module Gamefic::Sdk
2
-
3
- module Platform
4
- autoload :Base, 'gamefic-sdk/platform/base'
5
- autoload :Gfic, 'gamefic-sdk/platform/gfic'
6
- autoload :Web, 'gamefic-sdk/platform/web'
7
- autoload :Sinatra, 'gamefic-sdk/platform/sinatra'
8
-
9
- #def self.load directory, platform
10
- # config_file = File.join(directory, 'config.yaml')
11
- #end
12
-
13
- def self.load config, name
14
- target = config.targets[name]
15
- raise ArgumentError.new("Config does not have a target '#{name}'") if target.nil?
16
- cls = Gamefic::Sdk::Platform.const_get(target['platform'])
17
- raise ArgumentError.new("Platform '#{target['platform']}' not found") if target.nil?
18
- cls.new(config: config, target: target.merge('name' => name))
19
- end
20
- end
21
-
22
- end
@@ -1,68 +0,0 @@
1
- require 'gamefic-sdk'
2
- require 'gamefic-sdk/debug/plot'
3
- #require 'gamefic-sdk/plot_config'
4
- require 'pathname'
5
-
6
- module Gamefic::Sdk
7
- class Platform::Base
8
- # @return [Gamefic::Sdk::Config]
9
- attr_reader :config
10
-
11
- # @return [Hash]
12
- attr_reader :target
13
-
14
- #def initialize config, name = nil
15
- def initialize config: Gamefic::Sdk::Config.new, target: {}
16
- #@source_dir = source_dir
17
- #@name = name
18
- #@config = config
19
- #@config.freeze
20
- @config = config
21
- @target = target
22
- end
23
-
24
- def name
25
- @name ||= (target['name'] || self.class.to_s.split('::').last.downcase)
26
- end
27
-
28
- def build_target
29
- @build_target ||= File.join(config.build_path, name)
30
- end
31
-
32
- def release_target
33
- @release_target ||= File.join(config.release_path, name)
34
- end
35
-
36
- # @return [Gamefic::Plot]
37
- def plot
38
- if @plot.nil?
39
- paths = [config.script_path, config.import_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
40
- # @todo: Should really use Gamefic::Sdk::Debug::Plot or just Gamfic::Plot?
41
- @plot = Gamefic::Sdk::Debug::Plot.new(Gamefic::Source::File.new(*paths))
42
- @plot.script 'main'
43
- end
44
- @plot
45
- end
46
-
47
- def build
48
- # Platforms need to build/compile the deployment here.
49
- raise "The base Platform class does not have a build method"
50
- end
51
-
52
- def clean
53
- puts "Nothing to do for this platform."
54
- end
55
-
56
- # Get a hash of build metadata.
57
- #
58
- # @return [Hash]
59
- def metadata
60
- hash = {}
61
- hash[:uuid] = config.uuid
62
- hash[:gamefic_version] = "#{Gamefic::VERSION}"
63
- hash[:sdk_version] = "#{Gamefic::Sdk::VERSION}"
64
- hash[:build_date] = "#{DateTime.now}"
65
- hash
66
- end
67
- end
68
- end
@@ -1,27 +0,0 @@
1
- require 'zip'
2
- require 'tempfile'
3
- require 'yaml'
4
-
5
- module Gamefic::Sdk
6
-
7
- class Platform::Gfic < Platform::Base
8
- def build
9
- FileUtils.rm filename if File.file?(filename)
10
- FileUtils.mkdir_p release_target
11
- Zip::File.open(filename, Zip::File::CREATE) do |zipfile|
12
- plot.imported_scripts.each { |script|
13
- zipfile.add File.join('scripts', "#{script.path}.plot.rb"), script.absolute_path
14
- }
15
- Tempfile.open('metadata.yaml') do |file|
16
- file.puts metadata.to_yaml
17
- zipfile.add "metadata.yaml", file.path
18
- end
19
- end
20
- end
21
-
22
- def filename
23
- @filename ||= File.join(release_target, (target['filename'] || 'game.gfic'))
24
- end
25
- end
26
-
27
- end
@@ -1,98 +0,0 @@
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
- FileUtils.mkdir_p release_target
12
- copy_html_files
13
- render_index
14
- copy_assets
15
- copy_media
16
- FileUtils.cp_r File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'sinatra', 'engine.js'), File.join(release_target, 'core', 'engine.js')
17
- end
18
-
19
- #def clean
20
- # FileUtils.remove_entry_secure config['build_path'] if File.exist?(config['build_path'])
21
- # FileUtils.mkdir_p config['build_path']
22
- # puts "#{config['build_path']} cleaned."
23
- #end
24
-
25
- def app_config
26
- @app_config ||= AppConfig.new config.source_dir, config, ["core/engine.js"]
27
- end
28
-
29
- private
30
-
31
- def resolve filename, paths
32
- absolute = nil
33
- paths.each { |path|
34
- if File.file?("#{path}/#{filename}")
35
- absolute = File.join(path, filename)
36
- break
37
- end
38
- }
39
- raise "#{filename} not found" if absolute.nil?
40
- absolute
41
- end
42
-
43
- # Copy everything in source except config and template
44
- def copy_html_files
45
- Dir.entries(app_config.html_dir).each { |entry|
46
- if entry != 'index.rb' and entry != 'index.html.erb' and entry != '.' and entry != '..'
47
- FileUtils.mkdir_p release_target + '/' + File.dirname(entry)
48
- FileUtils.cp_r "#{app_config.html_dir}/#{entry}", "#{release_target}/#{entry}"
49
- end
50
- }
51
- end
52
-
53
- def render_index
54
- # Render index
55
- File.open(release_target + "/index.html", "w") do |file|
56
- file << app_config.render
57
- end
58
- end
59
-
60
- def copy_assets
61
- paths = app_config.resource_paths
62
- paths.push build_target
63
- app_config.javascripts.each { |js|
64
- absolute = resolve(js, paths)
65
- FileUtils.mkdir_p release_target + "/" + File.dirname(js)
66
- FileUtils.cp_r absolute, release_target + "/" + js
67
- }
68
- app_config.stylesheets.each { |css|
69
- absolute = resolve(css, paths)
70
- FileUtils.mkdir_p release_target + "/" + File.dirname(css)
71
- FileUtils.cp_r absolute, release_target + "/" + css
72
- }
73
- end
74
-
75
- =begin
76
- def copy_media
77
- # Copy media
78
- pc = PlotConfig.new "#{source_dir}/config.yaml"
79
- pc.media_paths.each { |path|
80
- if File.directory?(path)
81
- FileUtils.mkdir_p release_target + "/media"
82
- Dir.entries(path).each { |entry|
83
- if entry != '.' and entry != '..'
84
- FileUtils.mkdir_p release_target + "/media/" + File.dirname(entry)
85
- FileUtils.cp_r path + "/" + entry, release_target + "/media/" + entry
86
- end
87
- }
88
- end
89
- }
90
- end
91
- =end
92
-
93
- def metadata_code
94
- "\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
95
- end
96
- end
97
-
98
- end
@@ -1,176 +0,0 @@
1
- require 'gamefic'
2
- require 'gamefic-sdk'
3
- require 'opal'
4
- require 'uglifier'
5
-
6
- module Gamefic::Sdk
7
-
8
- class Platform::Web < Platform::Base
9
- autoload :AppConfig, 'gamefic-sdk/platform/web/app_config'
10
-
11
- def app_config
12
- @app_config ||= AppConfig.new config.source_dir, config, ["core/opal.js", "core/gamefic.js", "core/static.js", "core/scripts.js", "core/engine.js"]
13
- end
14
-
15
- def build
16
- FileUtils.mkdir_p release_target
17
- FileUtils.mkdir_p build_target
18
- copy_html_files
19
- build_opal_js
20
- build_gamefic_js
21
- build_static_js
22
- build_scripts_js
23
- render_index
24
- copy_assets
25
- copy_media
26
- end
27
-
28
- def clean
29
- FileUtils.remove_entry_secure build_target if File.exist?(build_target)
30
- puts "#{name} cleaned."
31
- end
32
-
33
- def html_dir
34
- if @html_dir.nil?
35
- local_dir = (target['html'] ? target['html'] : 'html')
36
- @html_dir = Pathname.new(config.source_dir).join(local_dir).to_s
37
- @html_dir = nil unless Dir.exist?(@html_dir)
38
- if @html_dir.nil?
39
- @html_dir = File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'skins', 'standard')
40
- end
41
- end
42
- @html_dir
43
- end
44
-
45
- private
46
-
47
- def resolve filename, paths
48
- absolute = nil
49
- paths.each { |path|
50
- if File.file?("#{path}/#{filename}")
51
- absolute = File.join(path, filename)
52
- break
53
- end
54
- }
55
- raise "#{filename} not found" if absolute.nil?
56
- absolute
57
- end
58
-
59
- # Copy everything in source except config and template
60
- def copy_html_files
61
- #Dir.entries(app_config.html_dir).each { |entry|
62
- Dir.entries(html_dir).each { |entry|
63
- if entry != 'index.rb' and entry != 'index.html.erb' and entry != '.' and entry != '..'
64
- FileUtils.mkdir_p release_target + '/' + File.dirname(entry)
65
- FileUtils.cp_r "#{app_config.html_dir}/#{entry}", "#{release_target}/#{entry}"
66
- end
67
- }
68
- end
69
-
70
- def build_opal_js
71
- # Make sure core exists in build directory
72
- FileUtils.mkdir_p build_target + "/core"
73
- # Opal core
74
- if !File.exist?(build_target + "/core/opal.js")
75
- File.open(build_target + "/core/opal.js", "w") do |file|
76
- file << Uglifier.compile(
77
- Opal::Builder.build('opal').to_s + "\n" + Opal::Builder.build('json').to_s + "\n" + Opal::Builder.build('native').to_s
78
- )
79
- end
80
- end
81
- end
82
-
83
- def build_gamefic_js
84
- # Gamefic core
85
- Opal.use_gem 'gamefic'
86
- if !File.exist?(build_target + "/core/gamefic.js")
87
- File.open(build_target + "/core/gamefic.js", "w") do |file|
88
- file << Uglifier.compile(Opal::Builder.build('gamefic').to_s)
89
- end
90
- end
91
- end
92
-
93
- def build_static_js
94
- Opal.append_path Gamefic::Sdk::LIB_PATH
95
- if !File.exist?(build_target + "/core/static.js")
96
- File.open(build_target + "/core/static.js", "w") do |file|
97
- file << Uglifier.compile(
98
- Opal::Builder.build('gamefic-sdk/platform/web/engine').to_s + "\n" + Opal::Builder.build('gamefic-sdk/platform/web/user').to_s
99
- )
100
- end
101
- end
102
- end
103
-
104
- def build_scripts_js
105
- File.open("#{build_target}/scripts.rb", 'w') do |file|
106
- #file << "def Module.const_missing sym\n"
107
- #file << "puts 'From Object to Gamefic'\n"
108
- #file << "Gamefic.const_get sym\n"
109
- #file << "end\n"
110
- file << "module Gamefic\n"
111
- file << "$scripts = {}\n"
112
- plot.imported_scripts.each { |script|
113
- file << "$scripts['#{script.path}'] = proc {\n"
114
- file << script.read
115
- file << "\n}\n"
116
- }
117
- file << "$source = Gamefic::Source::Text.new($scripts)\n"
118
- file << "$plot = Gamefic::Plot.new($source)\n"
119
- file << "$plot.script 'main'\n"
120
- file << "$engine = Gamefic::Engine::Web.new($plot)\n"
121
- file << "end\n"
122
- file << "$plot.stage do\n"
123
- file << "def self.const_missing sym\n"
124
- file << "Gamefic.const_get sym\n"
125
- file << "end\n"
126
- file << "end\n"
127
- #file << "def $plot.theater.const_missing sym\n"
128
- #file << 'puts "Trying to get #{sym} from object"' + "\n"
129
- #file << "Object.const_get sym\n"
130
- #file << "end\n"
131
- end
132
- Opal.append_path build_target
133
- File.open(build_target + "/core/scripts.js", 'w') do |file|
134
- file << Uglifier.compile(Opal::Builder.build('scripts').to_s)
135
- end
136
- end
137
-
138
- def render_index
139
- # Render index
140
- File.open(release_target + "/index.html", "w") do |file|
141
- file << app_config.render
142
- end
143
- end
144
-
145
- def copy_assets
146
- paths = app_config.resource_paths
147
- paths.push build_target
148
- app_config.javascripts.each { |js|
149
- absolute = resolve(js, paths)
150
- FileUtils.mkdir_p release_target + "/" + File.dirname(js)
151
- FileUtils.cp_r absolute, release_target + "/" + js
152
- }
153
- app_config.stylesheets.each { |css|
154
- absolute = resolve(css, paths)
155
- FileUtils.mkdir_p release_target + "/" + File.dirname(css)
156
- FileUtils.cp_r absolute, release_target + "/" + css
157
- }
158
- end
159
-
160
- def copy_media
161
- FileUtils.mkdir_p release_target + "/media"
162
- return unless File.directory?(config.media_path)
163
- Dir.entries(config.media_path).each { |entry|
164
- if entry != '.' and entry != '..'
165
- FileUtils.mkdir_p release_target + "/media/" + File.dirname(entry)
166
- FileUtils.cp_r config.media_path + "/" + entry, release_target + "/media/" + entry
167
- end
168
- }
169
- end
170
-
171
- def metadata_code
172
- "\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
173
- end
174
- end
175
-
176
- end