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,81 +0,0 @@
1
- require 'erb'
2
-
3
- module Gamefic
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 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
- end
54
- end
55
-
56
- class Gamefic::Sdk::Platform::Web::AppConfig::Data
57
- attr_reader :author, :title, :javascripts, :stylesheets
58
- def initialize config, javascripts, stylesheets
59
- @author = config.author
60
- @title = config.title
61
- @javascripts = javascripts
62
- @stylesheets = stylesheets
63
- end
64
- def javascript_tags
65
- result = ""
66
- javascripts.each { |js|
67
- result += "<script type=\"text/javascript\" src=\"#{js}\"></script>"
68
- }
69
- result
70
- end
71
- def stylesheet_tags
72
- result = ""
73
- stylesheets.each { |css|
74
- result += "<link rel=\"stylesheet\" type=\"text/css\" href=\"#{css}\" />"
75
- }
76
- result
77
- end
78
- def get_binding
79
- binding()
80
- end
81
- end
@@ -1,44 +0,0 @@
1
- # @hack Explicit requires for Opal
2
- require 'gamefic/plot/playbook'
3
- require 'gamefic/plot/darkroom'
4
- require 'gamefic/grammar'
5
- require 'gamefic/query'
6
- require 'gamefic/grammar/verb_set'
7
- require 'gamefic/grammar/conjugator'
8
-
9
- module Gamefic
10
- module Engine
11
- class Web < Gamefic::Engine::Base
12
- attr_reader :user
13
-
14
- def post_initialize
15
- self.user_class = Gamefic::User::Web
16
- end
17
-
18
- def run
19
- connect
20
- plot.introduce @user.character
21
- plot.ready
22
- @user.update
23
- end
24
-
25
- def turn
26
- @plot.ready
27
- @user.update
28
- update unless @user.character.queue.empty?
29
- end
30
-
31
- def receive input
32
- @user.character.queue.push input unless input.nil?
33
- update
34
- end
35
-
36
- private
37
-
38
- def update
39
- @plot.update
40
- turn
41
- end
42
- end
43
- end
44
- end
@@ -1,19 +0,0 @@
1
- module Gamefic
2
- module User
3
- class Web < Gamefic::User::Base
4
- def update
5
- `Gamefic.update(#{character.state.to_json});`
6
- end
7
-
8
- def save filename, data
9
- #data[:metadata] = GameficOpal.static_plot.metadata
10
- `Gamefic.save(filename, data);`
11
- end
12
-
13
- def restore filename
14
- data = `Gamefic.restore(filename);`
15
- return data
16
- end
17
- end
18
- end
19
- end
@@ -1,83 +0,0 @@
1
- require 'securerandom'
2
- require 'fileutils'
3
-
4
- module Gamefic
5
- module Sdk
6
- class Shell
7
- class Init
8
- def initialize(directory:, standard: true, quiet: false, scripts: [], webskin: 'standard', webdir: nil, title: nil, author: nil)
9
- @quiet = quiet
10
- @directory = directory
11
- @html = webskin
12
- @webdir = webdir
13
- @scripts = []
14
- @scripts.push('standard') if standard
15
- @scripts += scripts if scripts
16
- @platforms = ['Gfic', 'Web']
17
- @title = title
18
- @author = author
19
- end
20
-
21
- def run
22
- make_game_directories
23
- write_main_script
24
- write_test_script
25
- write_config_yaml
26
- write_uuid_file
27
- copy_html_skin
28
- puts "Game directory '#{@directory}' initialized." unless @quiet
29
- end
30
-
31
- private
32
-
33
- def make_game_directories
34
- if File.exist?(@directory)
35
- raise "#{@directory} is a file." if File.file?(@directory)
36
- raise "#{@directory} is not an empty directory." unless Dir["#{@directory}/*"].empty?
37
- else
38
- Dir.mkdir(@directory)
39
- end
40
-
41
- Dir.mkdir(File.join(@directory, 'scripts'))
42
- Dir.mkdir(File.join(@directory, 'imports'))
43
- Dir.mkdir(File.join(@directory, 'media'))
44
- end
45
-
46
- def write_main_script
47
- main_file = File.join(@directory, 'scripts', 'main.plot.rb')
48
- File.open(main_file, 'w') do |file|
49
- @scripts.each do |script|
50
- file.puts "script '#{script}'"
51
- end
52
- end
53
- end
54
-
55
- def write_test_script
56
- File.open("#{@directory}/scripts/test.plot.rb", 'w') do |file|
57
- file.puts "script 'standard/test'"
58
- end
59
- end
60
-
61
- def write_config_yaml
62
- File.open("#{@directory}/config.yml", 'w') do |file|
63
- file << Gamefic::Sdk::Config.generate
64
- end
65
- end
66
-
67
- def write_uuid_file
68
- uuid = SecureRandom.uuid
69
- File.open("#{@directory}/.uuid", "w") { |f| f.write uuid }
70
- end
71
-
72
- def copy_html_skin
73
- Dir.mkdir("#{@directory}/html")
74
- if @webdir.nil?
75
- FileUtils.cp_r(Dir[Gamefic::Sdk::HTML_TEMPLATE_PATH + '/skins/' + @html + '/*'], "#{@directory}/html")
76
- else
77
- FileUtils.cp_r(Dir[File.join(File.realpath(@webdir), '*')], "#{@directory}/html")
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,32 +0,0 @@
1
- require 'gamefic/engine/tty'
2
-
3
- module Gamefic
4
- module Sdk
5
- class Shell
6
- class Test
7
- def initialize(directory:)
8
- @path = directory
9
- raise "Invalid path: #{@path}" unless File.exist?(@path)
10
- end
11
-
12
- def run
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]
20
- plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
21
- plot.script 'main'
22
- # @todo Debug is temporarily disabled.
23
- #plot.script 'debug'
24
- engine = Engine::Tty.new plot
25
- engine.connect
26
- puts "\n"
27
- engine.run
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,25 +0,0 @@
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
@@ -1,16 +0,0 @@
1
- # @gamefic.script snapshots
2
-
3
- module Snapshots
4
- def self.history
5
- @history ||= []
6
- end
7
- end
8
-
9
- last_snapshot = nil
10
-
11
- on_player_ready do |actor|
12
- if (actor.last_action.nil? or !actor.last_action.meta?) and !last_snapshot.nil?
13
- Snapshots.history.push last_snapshot
14
- end
15
- last_snapshot = save
16
- end
@@ -1,10 +0,0 @@
1
- # @gamefic.script standard
2
- # A general-purpose library that provides common actions and entities for
3
- # interactive fiction. Designed to be suitable for parser-based text
4
- # adventures, but easily extensible for other formats.
5
-
6
- script 'standard/queries'
7
- script 'standard/modules'
8
- script 'standard/direction'
9
- script 'standard/entities'
10
- script 'standard/actions'
@@ -1,13 +0,0 @@
1
- script 'standard/actions/nil'
2
- script 'standard/actions/drop'
3
- script 'standard/actions/enter'
4
- script 'standard/actions/go'
5
- script 'standard/actions/insert'
6
- script 'standard/actions/inventory'
7
- script 'standard/actions/leave'
8
- script 'standard/actions/look'
9
- script 'standard/actions/place'
10
- script 'standard/actions/quit'
11
- script 'standard/actions/take'
12
- script 'standard/actions/talk'
13
- script 'standard/actions/wait'
@@ -1,19 +0,0 @@
1
- respond :drop, Use.family() do |actor, thing|
2
- if thing.parent != actor
3
- actor.tell "#{you.contract you.pronoun.Subj + ' ' + you.verb.be} not carrying #{the thing}."
4
- else
5
- actor.proceed
6
- end
7
- end
8
-
9
- respond :drop, Use.children do |actor, thing|
10
- if thing.sticky?
11
- actor.tell thing.sticky_message || "#{you.pronoun.Subj} #{you.verb.need} to keep #{the thing} for now."
12
- else
13
- thing.parent = actor.parent
14
- actor.tell "#{you.pronoun.Subj} drop #{the thing}."
15
- end
16
- end
17
-
18
- interpret "put down :thing", "drop :thing"
19
- interpret "put :thing down", "drop :thing"
@@ -1,19 +0,0 @@
1
- respond :enter, Use.siblings do |actor, thing|
2
- actor.tell "#{The thing} #{you.contract "can not"} accommodate #{you.pronoun.obj}."
3
- end
4
-
5
- respond :enter, Use.siblings(Enterable, :enterable?) do |actor, supporter|
6
- actor.parent = supporter
7
- actor.tell "#{you.pronoun.Subj} #{you.verb[supporter.enter_verb]} #{the supporter}."
8
- end
9
-
10
- respond :enter, Use.parent do |actor, container|
11
- actor.tell "#{you.contract(you.pronoun.subj + ' ' + you.verb.be).cap_first} already in #{the container}."
12
- end
13
-
14
- respond :enter, Use.parent(Supporter) do |actor, supporter|
15
- actor.tell "#{you.pronoun.Subj} #{you.verb[supporter.enter_verb]} #{the supporter} already."
16
- end
17
-
18
- interpret "get on :thing", "enter :thing"
19
- interpret "get in :thing", "enter :thing"
@@ -1,48 +0,0 @@
1
- respond :go, Use.siblings(Portal) do |actor, portal|
2
- if actor.parent != actor.room
3
- actor.perform :leave
4
- end
5
- if actor.parent == actor.room
6
- if portal.destination.nil?
7
- actor.tell "That portal leads nowhere."
8
- else
9
- actor.parent = portal.destination
10
- if !portal.direction.nil?
11
- actor.tell "#{you.pronoun.Subj} go #{portal.direction}"
12
- end
13
- actor.perform :look, actor.room
14
- end
15
- end
16
- end
17
-
18
- respond :go, Use.text do |actor, string|
19
- actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} see any exit \"#{string}\" from here."
20
- end
21
-
22
- respond :go do |actor|
23
- actor.tell "Where do you want to go?"
24
- end
25
-
26
- xlate "north", "go north"
27
- xlate "south", "go south"
28
- xlate "west", "go west"
29
- xlate "east", "go east"
30
- xlate "up", "go up"
31
- xlate "down", "go down"
32
- xlate "northwest", "go northwest"
33
- xlate "northeast", "go northeast"
34
- xlate "southwest", "go southwest"
35
- xlate "southeast", "go southeast"
36
-
37
- xlate "n", "go north"
38
- xlate "s", "go south"
39
- xlate "w", "go west"
40
- xlate "e", "go east"
41
- xlate "u", "go up"
42
- xlate "d", "go down"
43
- xlate "nw", "go northwest"
44
- xlate "ne", "go northeast"
45
- xlate "sw", "go southwest"
46
- xlate "se", "go southeast"
47
-
48
- interpret "go to :place", "go :place"
@@ -1,37 +0,0 @@
1
- script 'standard'
2
-
3
- respond :insert, Use.available, Use.available do |actor, thing, target|
4
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.can + ' not'} put #{the thing} inside #{the target}."
5
- end
6
-
7
- respond :insert, Use.children, Use.available(Receptacle) do |actor, thing, receptacle|
8
- if thing.sticky?
9
- actor.tell thing.sticky_message || "#{you.pronoun.Subj} #{you.verb.need} to keep #{the thing} for now."
10
- else
11
- actor.tell "#{you.pronoun.Subj} put #{the thing} in #{the receptacle}."
12
- thing.parent = receptacle
13
- end
14
- end
15
-
16
- respond :insert, Use.available, Use.available(Receptacle) do |actor, thing, receptacle|
17
- if thing.parent == actor
18
- actor.proceed
19
- else
20
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} have #{the thing}."
21
- end
22
- end
23
-
24
- interpret "drop :item in :container", "insert :item :container"
25
- interpret "put :item in :container", "insert :item :container"
26
- interpret "place :item in :container", "insert :item :container"
27
- interpret "insert :item in :container", "insert :item :container"
28
-
29
- interpret "drop :item inside :container", "insert :item :container"
30
- interpret "put :item inside :container", "insert :item :container"
31
- interpret "place :item inside :container", "insert :item :container"
32
- interpret "insert :item inside :container", "insert :item :container"
33
-
34
- interpret "drop :item into :container", "insert :item :container"
35
- interpret "put :item into :container", "insert :item :container"
36
- interpret "place :item into :container", "insert :item :container"
37
- interpret "insert :item into :container", "insert :item :container"