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.
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
@@ -1,17 +0,0 @@
1
- module Gamefic::Image
2
- attr_accessor :image
3
- end
4
-
5
- class Gamefic::Entity
6
- include Image
7
- end
8
-
9
- module Gamefic::ImageViewer
10
- def show_image filename
11
- tell "<figure><img src=\"media/#{filename}\" /></figure>"
12
- end
13
- end
14
-
15
- class Gamefic::Character
16
- include ImageViewer
17
- end
@@ -1,41 +0,0 @@
1
- class Gamefic::Entity
2
- attr_accessor :image
3
- def has_image?
4
- (@image.to_s != '')
5
- end
6
- end
7
-
8
- class Gamefic::Character
9
- attr_writer :sees_image
10
- def sees_image?
11
- (@sees_image != false)
12
- end
13
- def show_image(filename)
14
- stream "<img src=\"#{filename}\" />";
15
- @sees_image = true
16
- end
17
- def play_sound(filename, loop = false)
18
- # TODO: Implement
19
- end
20
- def play_ambient(filename, loop = false)
21
- # TODO: Implement
22
- end
23
- end
24
-
25
- assert_action :clear_last_image do |actor, action|
26
- actor.sees_image = false
27
- true
28
- end
29
-
30
- respond :look, Query::Visible.new() do |actor, subject|
31
- actor.proceed
32
- if subject.has_image?
33
- actor.show_image subject.image
34
- end
35
- end
36
-
37
- on_player_update do |actor|
38
- if !actor.sees_image? and actor.room.has_image?
39
- actor.show_image actor.room.image
40
- end
41
- end
@@ -1,17 +0,0 @@
1
- respond :what, Query::Text.new do |actor, question|
2
- actor.tell "It looks like you're asking a question. Try giving a command instead. Use HELP for more information."
3
- end
4
-
5
- respond :what, Query::Reachable.new do |actor, thing|
6
- actor.tell "It looks like you want information about #{the thing}. Try looking at it."
7
- end
8
-
9
- xlate "where :question", "what :question"
10
- xlate "when :question", "what :question"
11
- xlate "why :question", "what :question"
12
- xlate "who :question", "what :question"
13
-
14
- xlate "what is :thing", "look :thing"
15
- xlate "what's :thing", "look :thing"
16
- xlate "who is :thing", "look :thing"
17
- xlate "who's :thing", "look :thing"
@@ -1,48 +0,0 @@
1
- module RoomModes
2
- attr_writer :description_mode
3
- def description_seen
4
- @description_seen ||= Array.new
5
- end
6
- def description_seen=(value)
7
- if value.kind_of?(Array)
8
- @description_seen = value
9
- else
10
- raise "Character#description_seen must be an Array"
11
- end
12
- end
13
- def description_mode
14
- @description_mode ||= "verbose"
15
- end
16
- end
17
-
18
- class Character
19
- include RoomModes
20
- end
21
-
22
- respond :go, Query::Siblings.new(Portal) do |actor, portal|
23
- actor.tell "You go #{portal.name}."
24
- actor.parent = portal.destination
25
- if actor.description_mode == "superbrief" or (actor.description_mode == "brief" and actor.description_seen.include?(actor.parent))
26
- actor.tell actor.parent.name.cap_first
27
- else
28
- actor.perform "look"
29
- end
30
- if actor.description_seen.include?(actor.parent) == false
31
- actor.description_seen.push actor.parent
32
- end
33
- end
34
-
35
- meta :brief do |actor|
36
- actor.description_mode = "brief"
37
- actor.tell "You are now in BRIEF mode. Detailed descriptions of rooms will only be displayed the first time you visit them. Other options are SUPERBRIEF and VERBOSE."
38
- end
39
-
40
- meta :verbose do |actor|
41
- actor.description_mode = "verbose"
42
- actor.tell "You are now in VERBOSE mode. Detailed descriptions will be displayed every time you enter a room. Other options are BRIEF and SUPERBRIEF."
43
- end
44
-
45
- meta :superbrief do |actor|
46
- actor.description_mode = "superbrief"
47
- actor.tell "You are now in SUPERBRIEF mode. Detailed room descriptions will never be displayed unless you LOOK AROUND. Other options are BRIEF and VERBOSE."
48
- end
@@ -1,36 +0,0 @@
1
- module Roughly
2
- XSMALL = 1
3
- SMALL = 2
4
- MEDIUM = 3
5
- LARGE = 4
6
- XLARGE = 5
7
- end
8
-
9
- class Entity
10
- attr_writer :size
11
- def size
12
- @size ||= (is?(:portable) ? Roughly::SMALL : Roughly::MEDIUM)
13
- end
14
- end
15
-
16
- class Room
17
- def size
18
- @size ||= Roughly::XLARGE
19
- end
20
- end
21
-
22
- respond :drop_in, Query::Children.new(), Query::Reachable.new(Container) do |actor, thing, container|
23
- if container.size <= thing.size
24
- actor.tell "#{The thing} can't fit in #{the container}."
25
- else
26
- actor.proceed
27
- end
28
- end
29
-
30
- respond :drop_on, Query::Children.new(), Query::Reachable.new(Supporter) do |actor, thing, supporter|
31
- if supporter.size < thing.size
32
- actor.tell "#{The supporter} can't accommodate #{the thing}."
33
- else
34
- actor.proceed
35
- end
36
- end
@@ -1,22 +0,0 @@
1
- script 'snapshots'
2
-
3
- meta :save do |actor|
4
- actor.perform :save, "game.sav"
5
- end
6
-
7
- meta :save, Query::Text.new() do |actor, filename|
8
- actor.user.save filename, save
9
- actor.tell "Game saved."
10
- end
11
-
12
- meta :restore do |actor|
13
- actor.perform :restore, "game.sav"
14
- end
15
-
16
- meta :restore, Query::Text.new() do |actor, filename|
17
- data = actor.user.restore(filename)
18
- if !data.nil?
19
- restore data
20
- actor.tell "Game restored."
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- respond :close, Query::Text.new() do |actor, string|
2
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} see any \"#{string}\" here."
3
- end
4
-
5
- respond :close, Use.reachable() do |actor, thing|
6
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.can + ' not'} close #{the thing}."
7
- end
8
-
9
- respond :close, Use.reachable(Openable) do |actor, container|
10
- if !container.open?
11
- actor.tell "It's already closed."
12
- else
13
- actor.tell "#{you.pronoun.Subj} close #{the container}."
14
- container.open = false
15
- end
16
- end
@@ -1,59 +0,0 @@
1
- respond :lock, Query::Text.new() do |actor, string|
2
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} see any \"#{string}\" here."
3
- end
4
-
5
- respond :lock, Use.family() do |actor, thing|
6
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.can + ' not'} lock #{the thing}."
7
- end
8
-
9
- respond :lock, Use.family(Lockable, :has_lock_key?) do |actor, container|
10
- # Portable containers need to be picked up before they are locked.
11
- if container.portable? and container.parent != actor
12
- actor.perform :take, container
13
- if container.parent != actor
14
- break
15
- end
16
- end
17
- if container.locked?
18
- actor.tell "It's already locked."
19
- else
20
- #if container.is?(:auto_lockable)
21
- key = nil
22
- if container.lock_key.nil? == false
23
- if container.lock_key.parent == actor
24
- key = container.lock_key
25
- end
26
- end
27
- if key.nil?
28
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} have any way to lock #{the container}."
29
- else
30
- actor.tell "#{you.pronoun.Subj} #{you.verb.lock} #{the container} with #{the key}."
31
- container.locked = true
32
- end
33
- #else
34
- # actor.tell "What do you want to lock #{the container} with?"
35
- #end
36
- end
37
- end
38
-
39
- respond :lock, Use.family(Lockable, :has_lock_key?), Query::Children.new do |actor, container, key|
40
- if container.locked == false
41
- if container.lock_key == key
42
- #if container.is?(:not_auto_lockable)
43
- # container.is :auto_lockable
44
- # actor.perform :lock, container
45
- # container.is :not_auto_lockable
46
- #else
47
- # actor.perform :lock, container
48
- #end
49
- actor.tell "#{you.pronoun.Subj} #{you.verb.lock} #{the container} with #{the key}."
50
- container.locked = true
51
- else
52
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.can + ' not'} lock #{the container} with #{the key}."
53
- end
54
- else
55
- actor.tell "It's already locked."
56
- end
57
- end
58
-
59
- xlate "lock :container with :key", "lock :container :key"
@@ -1,8 +0,0 @@
1
- script 'standard/actions/look'
2
-
3
- respond :look_under, Use.family() do |actor, thing|
4
- actor.tell "There's nothing to see under #{the thing}."
5
- end
6
-
7
- interpret "look beneath :thing", "look under :thing"
8
- interpret "look below :thing", "look under :thing"
@@ -1,34 +0,0 @@
1
- respond :open, Use.text do |actor, string|
2
- actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} see any \"#{string}\" here."
3
- end
4
-
5
- respond :open, Use.reachable() do |actor, thing|
6
- actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.can + ' not')} open #{the thing}."
7
- end
8
-
9
- respond :open, Use.reachable(Openable) do |actor, container|
10
- # Portable containers need to be picked up before they are opened.
11
- if container.portable? and container.parent != actor
12
- actor.perform :take, container
13
- if container.parent != actor
14
- break
15
- end
16
- end
17
- if !container.open?
18
- actor.tell "#{you.pronoun.Subj} #{you.verb['open']} #{the container}."
19
- container.open = true
20
- if container.children.that_are_not(:attached?).length > 0
21
- actor.perform :search, container
22
- end
23
- else
24
- actor.tell "It's already open."
25
- end
26
- end
27
-
28
- respond :open, Use.reachable(Openable, Lockable) do |actor, container|
29
- if container.locked?
30
- actor.tell "#{The container} is locked."
31
- else
32
- actor.proceed
33
- end
34
- end
@@ -1,3 +0,0 @@
1
- respond :read, Use.family do |actor, thing|
2
- actor.perform :look, thing
3
- end
@@ -1,40 +0,0 @@
1
- respond :search, Use.reachable(Receptacle) do |actor, receptacle|
2
- # TODO Show the contents of the receptacle
3
- contents = receptacle.children.that_are_not(:attached?)
4
- if contents.length > 0
5
- actor.tell "Inside #{contents.length > 1 ? 'are' : 'is'} #{contents.join_and}."
6
- else
7
- actor.tell "#{The receptacle} #{receptacle.verb.be} empty."
8
- end
9
- end
10
-
11
- respond :search, Use.reachable(Container) do |actor, container|
12
- next unless container.kind_of?(Container)
13
- if container.open? or container.transparent?
14
- actor.proceed
15
- else
16
- actor.tell "#{The container} #{container.verb.be} closed."
17
- end
18
- end
19
-
20
- respond :search, Use.reachable do |actor, thing|
21
- actor.perform :look, thing
22
- end
23
-
24
- respond :search, Use.room do |actor, room|
25
- actor.perform :look, room
26
- end
27
-
28
- respond :search, Use.reachable do |actor, entity|
29
- attached = entity.children.that_are(:attached?).that_are(Container)
30
- if attached.length > 1
31
- actor.tell "#{you.pronoun.Subj} #{you.verb.can} search #{attached.join_or}"
32
- elsif attached.length == 1
33
- actor.perform :search, attached[0]
34
- else
35
- actor.proceed
36
- end
37
- end
38
-
39
- interpret "look in :thing", "search :thing"
40
- interpret "look inside :thing", "search :thing"
@@ -1,13 +0,0 @@
1
- respond :show, Use.reachable(Character), Use.children do |actor, character, thing|
2
- actor.tell "#{The character} isn't interested in #{the thing}."
3
- end
4
-
5
- respond :show, Use.reachable, Use.children do |actor, witness, thing|
6
- actor.tell "Nothing happens."
7
- end
8
-
9
- respond :show, Use.children, Use.text do |actor, thing, text|
10
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} see any \"#{text}\" here."
11
- end
12
-
13
- interpret "show :thing to :character", "show :character :thing"
@@ -1,77 +0,0 @@
1
- respond :unlock, Query::Text.new() do |actor, string|
2
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} see any \"#{string}\" here."
3
- end
4
-
5
- respond :unlock, Use.family() do |actor, thing|
6
- actor.tell "#{you.pronoun.Subj} can't unlock #{the thing}."
7
- end
8
-
9
- respond :unlock, Use.family(Lockable) do |actor, container|
10
- # Portable containers need to be picked up before they are unlocked.
11
- if container.portable? and container.parent != actor
12
- actor.perform :take, container
13
- if container.parent != actor
14
- break
15
- end
16
- end
17
- if container.locked? == false
18
- actor.tell "#{The container} isn't locked."
19
- else
20
- #if container.is?(:auto_lockable)
21
- key = nil
22
- if container.lock_key.nil? == false
23
- if container.lock_key.parent == actor
24
- key = container.lock_key
25
- end
26
- end
27
- if key.nil?
28
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} have any way to unlock #{the container}."
29
- else
30
- actor.tell "#{you.pronoun.Subj} #{you.verb.unlock} #{the container} with #{the key}."
31
- container.locked = false
32
- end
33
- #takeelse
34
- # actor.tell "What do you want to unlock #{the container} with?"
35
- #end
36
- end
37
- end
38
-
39
- respond :unlock, Use.family(Lockable), Query::Text.new do |actor, container, thing|
40
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.do + ' not'} have anything called '#{thing}.'"
41
- end
42
-
43
- respond :unlock, Use.family(Lockable, :has_lock_key?), Query::Children.new do |actor, container, key|
44
- if container.is?(:locked)
45
- if container.key == key
46
- #if container.is?(:not_auto_lockable)
47
- # container.is :auto_lockable
48
- # actor.perform :unlock, container
49
- # container.is :not_auto_lockable
50
- #else
51
- actor.perform :unlock, container
52
- #end
53
- else
54
- actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.can + ' not'} unlock #{the container} with #{the key}."
55
- end
56
- else
57
- actor.tell "#{The container} isn't locked."
58
- end
59
- end
60
-
61
- respond :open, Use.family(Lockable, :has_lock_key?), Query::Children.new do |actor, container, key|
62
- if container.is?(:locked)
63
- actor.perform :unlock, container, key
64
- if !container.is?(:locked)
65
- actor.perform :open, container
66
- end
67
- else
68
- actor.perform :open, container
69
- end
70
- end
71
-
72
- respond :use, Query::Children.new, Use.family(Lockable, :has_lock_key?) do |actor, key, container|
73
- actor.perform :unlock, container, key
74
- end
75
-
76
- xlate "unlock :container with :key", "unlock :container :key"
77
- xlate "open :container with :key", "open :container :key"