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
@@ -6,11 +6,11 @@ respond :talk, Use.itself do |actor, yourself|
6
6
  actor.perform :talk
7
7
  end
8
8
 
9
- respond :talk, Use.family do |actor, thing|
9
+ respond :talk, Use.available do |actor, thing|
10
10
  actor.tell "Nothing happens."
11
11
  end
12
12
 
13
- respond :talk, Use.family(Character) do |actor, character|
13
+ respond :talk, Use.available(Character) do |actor, character|
14
14
  if actor == character
15
15
  actor.perform :talk
16
16
  else
@@ -18,14 +18,10 @@ respond :talk, Use.family(Character) do |actor, character|
18
18
  end
19
19
  end
20
20
 
21
- respond :talk, Use.family(Character), Query::Text.new do |actor, character, text|
22
- actor.perform :talk, character
23
- end
24
-
25
- xlate "talk to :character", "talk :character"
26
- xlate "talk to :character about :subject", "talk :character :subject"
27
- xlate "ask :character :subject", "talk :character :subject"
28
- xlate "ask :character about :subject", "talk :character :subject"
29
- xlate "tell :character :subject", "talk :character :subject"
30
- xlate "tell :character about :subject", "talk :character :subject"
31
- xlate "ask :character for :subject", "talk :character :subject"
21
+ interpret "talk to :character", "talk :character"
22
+ interpret "talk to :character about :subject", "talk :character :subject"
23
+ interpret "ask :character :subject", "talk :character :subject"
24
+ interpret "ask :character about :subject", "talk :character :subject"
25
+ interpret "tell :character :subject", "talk :character :subject"
26
+ interpret "tell :character about :subject", "talk :character :subject"
27
+ interpret "ask :character for :subject", "talk :character :subject"
@@ -0,0 +1,4 @@
1
+ # @gamefic.script standard/clothing
2
+
3
+ script 'standard/clothing/entities'
4
+ script 'standard/clothing/actions'
@@ -0,0 +1,4 @@
1
+ script 'standard/clothing/actions/doff'
2
+ script 'standard/clothing/actions/drop'
3
+ script 'standard/clothing/actions/inventory'
4
+ script 'standard/clothing/actions/wear'
@@ -1,8 +1,8 @@
1
- respond :drop, Query::Children.new(Clothing) do |actor, clothing|
2
- if clothing.attached?
3
- actor.perform :doff, clothing
4
- end
5
- if !clothing.attached?
6
- actor.proceed
7
- end
8
- end
1
+ respond :drop, Query::Children.new(Clothing) do |actor, clothing|
2
+ if clothing.attached?
3
+ actor.perform :doff, clothing
4
+ end
5
+ if !clothing.attached?
6
+ actor.proceed
7
+ end
8
+ end
@@ -1,14 +1,14 @@
1
- respond :inventory do |actor|
2
- if actor.children.length > 0
3
- carried = actor.children.that_are_not(:attached?)
4
- worn = actor.children.that_are(:attached?)
5
- if carried.length > 0
6
- actor.tell "You are carrying #{carried.join_and}."
7
- end
8
- if worn.length > 0
9
- actor.tell "You are wearing #{worn.join_and}."
10
- end
11
- else
12
- actor.tell "You aren't carrying anything."
13
- end
14
- end
1
+ respond :inventory do |actor|
2
+ if actor.children.length > 0
3
+ carried = actor.children.that_are_not(:attached?)
4
+ worn = actor.children.that_are(:attached?)
5
+ if carried.length > 0
6
+ actor.tell "You are carrying #{carried.join_and}."
7
+ end
8
+ if worn.length > 0
9
+ actor.tell "You are wearing #{worn.join_and}."
10
+ end
11
+ else
12
+ actor.tell "You aren't carrying anything."
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ respond :wear, Use.available(Clothing) do |actor, clothing|
2
+ if clothing.parent != actor
3
+ actor.tell "You don't have #{the clothing}."
4
+ end
5
+ if clothing.attached?
6
+ actor.tell "You're already wearing #{the clothing}."
7
+ else
8
+ already = actor.children.that_are(clothing.class).that_are(:attached?)
9
+ if already.length == 0
10
+ clothing.attached = true
11
+ actor.tell "You put on #{the clothing}."
12
+ else
13
+ actor.tell "You're already wearing #{an already[0]}."
14
+ end
15
+ end
16
+ end
17
+
18
+ xlate "put on :clothing", "wear :clothing"
19
+ xlate "put :clothing on", "wear :clothing"
20
+ xlate "don :clothing", "wear :clothing"
@@ -0,0 +1,7 @@
1
+ script 'standard/clothing/entities/clothing'
2
+ script 'standard/clothing/entities/coat'
3
+ script 'standard/clothing/entities/gloves'
4
+ script 'standard/clothing/entities/hat'
5
+ script 'standard/clothing/entities/pants'
6
+ script 'standard/clothing/entities/shirt'
7
+ script 'standard/clothing/entities/shoes'
@@ -1,5 +1,3 @@
1
- script 'standard/entities/item'
2
-
3
1
  class Clothing < Item
4
2
  def worn?
5
3
  self.parent.kind_of?(Character) and self.attached?
@@ -0,0 +1,3 @@
1
+ class Coat < Clothing
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Gloves < Clothing
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Hat < Clothing
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Pants < Clothing
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Shirt < Clothing
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Shoes < Clothing
2
+
3
+ end
@@ -0,0 +1,28 @@
1
+ # @gamefic.script standard/container
2
+
3
+ script 'standard/openable'
4
+ script 'standard/lockable'
5
+ #script 'standard/container/entities'
6
+ #script 'standard/container/actions'
7
+
8
+ class Container < Receptacle
9
+ include Openable
10
+ include Lockable
11
+ #include Transparent
12
+ end
13
+
14
+ respond :insert, Use.available, Use.available(Container) do |actor, thing, container|
15
+ if container.open?
16
+ actor.proceed
17
+ else
18
+ actor.tell "#{The container} is closed."
19
+ end
20
+ end
21
+
22
+ respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
23
+ actor.tell "#{The container} is closed."
24
+ end
25
+
26
+ respond :enter, Use.siblings(Container, :enterable?, :closed?) do |actor, container|
27
+ actor.tell "#{The container} is closed."
28
+ end
@@ -0,0 +1,5 @@
1
+ class Container < Receptacle
2
+ include Openable
3
+ include Lockable
4
+ #include Transparent
5
+ end
@@ -1,4 +1,4 @@
1
- class ::Gamefic::Direction
1
+ class Direction
2
2
  attr_accessor :name, :adjective, :adverb, :reverse
3
3
 
4
4
  def initialize args = {}
@@ -52,5 +52,4 @@ class ::Gamefic::Direction
52
52
  compass[dir.to_s.downcase.to_sym]
53
53
  end
54
54
  end
55
-
56
55
  end
@@ -1,3 +1,5 @@
1
+ # @gamefic.script standard/edible
2
+
1
3
  module Edibility
2
4
  attr_writer :edible
3
5
  def edible?
@@ -5,15 +7,15 @@ module Edibility
5
7
  end
6
8
  end
7
9
 
8
- class Gamefic::Entity
10
+ class Thing
9
11
  include Edibility
10
12
  end
11
13
 
12
- respond :eat, Use.reachable do |actor, item|
14
+ respond :eat, Use.available do |actor, item|
13
15
  actor.tell "You can't eat #{the item}."
14
16
  end
15
17
 
16
- respond :eat, Use.reachable(:edible?) do |actor, item|
18
+ respond :eat, Use.available(:edible?) do |actor, item|
17
19
  actor.tell "You eat #{the item}."
18
20
  destroy item
19
21
  end
@@ -1,7 +1,7 @@
1
- script 'standard/entities/entity'
1
+ script 'standard/entities/thing'
2
2
  script 'standard/entities/character'
3
- script 'standard/entities/container'
4
- script 'standard/entities/door'
3
+ #script 'standard/entities/container'
4
+ #script 'standard/entities/door'
5
5
  script 'standard/entities/fixture'
6
6
  script 'standard/entities/item'
7
7
  script 'standard/entities/portal'
@@ -1,7 +1,10 @@
1
- class Gamefic::Character
2
- include ParentRoom
3
- include Attachable
4
- include Itemizable
5
- include AutoTakes
6
-
1
+ class Character < Thing
2
+ #include ParentRoom
3
+ #include Attachable
4
+ #include Itemizable
5
+ #include AutoTakes
6
+ #include LocaleDescription
7
+ include Gamefic::Active
7
8
  end
9
+
10
+ player_class Character
@@ -1,3 +1,3 @@
1
- class Fixture < Gamefic::Entity
1
+ class Fixture < Thing
2
2
 
3
3
  end
@@ -1,5 +1,3 @@
1
- class Item < Gamefic::Entity
2
- def pre_initialize
3
- self.portable = true
4
- end
1
+ class Item < Thing
2
+ set_default portable: true
5
3
  end
@@ -1,4 +1,4 @@
1
- class Portal < Gamefic::Entity
1
+ class Portal < Thing
2
2
  attr_accessor :destination
3
3
 
4
4
  # Find the portal in the destination that returns to this portal's parent
@@ -16,7 +16,7 @@ class Portal < Gamefic::Entity
16
16
  end
17
17
  nil
18
18
  end
19
-
19
+
20
20
  # Get the ordinal direction of this Portal
21
21
  # Portals have distinct direction and name properties so games can display a
22
22
  # bare compass direction for exits, e.g., "south" vs. "the southern door."
@@ -25,7 +25,7 @@ class Portal < Gamefic::Entity
25
25
  def direction
26
26
  @direction
27
27
  end
28
-
28
+
29
29
  def direction= d
30
30
  @direction = Direction.find(d)
31
31
  end
@@ -33,8 +33,12 @@ class Portal < Gamefic::Entity
33
33
  def name
34
34
  @name || (direction.nil? ? destination.name : direction.name)
35
35
  end
36
-
36
+
37
+ def instruction
38
+ direction || (destination ? "to #{destination.definitely}" : name)
39
+ end
40
+
37
41
  def synonyms
38
- "#{super} #{@direction} #{!direction.nil? ? direction.synonyms : ''}"
42
+ "#{super} #{@destination} #{@direction} #{!direction.nil? ? direction.synonyms : ''}"
39
43
  end
40
44
  end
@@ -1,3 +1,3 @@
1
- class Receptacle < Gamefic::Entity
1
+ class Receptacle < Thing
2
2
  include Enterable
3
3
  end
@@ -1,5 +1,4 @@
1
- class Room < Gamefic::Entity
2
- include Darkenable
1
+ class Room < Thing
3
2
  include ExplicitExits
4
3
 
5
4
  def connect(destination, direction = nil, type = Portal, two_way = true)
@@ -13,20 +12,21 @@ class Room < Gamefic::Entity
13
12
  def synonyms
14
13
  @synonyms.to_s + " around here room"
15
14
  end
16
-
15
+
17
16
  def tell(message)
18
17
  children.each { |c|
19
18
  c.tell message
20
19
  }
21
20
  end
22
-
21
+
23
22
  def find_portal(direction)
24
23
  d = direction.to_s
25
24
  portals = children.that_are(Portal).delete_if { |p| p.direction.to_s != d }
26
25
  portals[0]
27
26
  end
28
-
27
+
29
28
  private
29
+
30
30
  def connect2 destination, direction:nil, type:Portal, two_way:true
31
31
  if direction.nil?
32
32
  portal = type.new :parent => self, :destination => destination
@@ -1,5 +1,3 @@
1
- class Scenery < Gamefic::Entity
2
- def pre_initialize
3
- self.itemized = false
4
- end
1
+ class Scenery < Thing
2
+ set_default itemized: false
5
3
  end
@@ -1,10 +1,7 @@
1
- class Supporter < Gamefic::Entity
1
+ class Supporter < Thing
2
2
  include Enterable
3
3
 
4
- def initialize(args = {})
5
- self.enter_verb = "get on"
6
- self.leave_verb = "get off"
7
- self.inside_verb = "be on"
8
- super
9
- end
4
+ set_default enter_verb: 'get on'
5
+ set_default leave_verb: 'get off'
6
+ set_default inside_verb: 'be on'
10
7
  end
@@ -0,0 +1,7 @@
1
+ class Thing < Gamefic::Entity
2
+ include Portable
3
+ include Itemizable
4
+ include ParentRoom
5
+ include Attachable
6
+ include LocaleDescription
7
+ end
@@ -1,25 +1,27 @@
1
- respond :give, Use.available, Query::Children.new do |actor, character, gift|
2
- actor.tell "Nothing happens."
3
- end
4
-
5
- respond :give, Use.available(Character), Use.available do |actor, character, gift|
6
- if gift.sticky?
7
- actor.tell gift.sticky_message || "#{you.pronoun.Subj} #{you.verb.need} to keep #{the gift} for now."
8
- else
9
- actor.tell "#{The character} doesn't want #{the gift}."
10
- end
11
- end
12
-
13
- respond :give, Use.available(Character), Use.available do |actor, character, gift|
14
- if gift.parent == actor
15
- actor.proceed
16
- else
17
- actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} have #{the gift}."
18
- end
19
- end
20
-
21
- respond :give, Use.text, Use.available do |actor, character, gift|
22
- actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} see any \"#{character}\" here."
23
- end
24
-
25
- interpret "give :gift to :character", "give :character :gift"
1
+ # @gamefic.script standard/give
2
+
3
+ respond :give, Use.available, Query::Children.new do |actor, character, gift|
4
+ actor.tell "Nothing happens."
5
+ end
6
+
7
+ respond :give, Use.available(Character), Use.available do |actor, character, gift|
8
+ if gift.sticky?
9
+ actor.tell gift.sticky_message || "#{you.pronoun.Subj} #{you.verb.need} to keep #{the gift} for now."
10
+ else
11
+ actor.tell "#{The character} doesn't want #{the gift}."
12
+ end
13
+ end
14
+
15
+ respond :give, Use.available(Character), Use.available do |actor, character, gift|
16
+ if gift.parent == actor
17
+ actor.proceed
18
+ else
19
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} have #{the gift}."
20
+ end
21
+ end
22
+
23
+ respond :give, Use.text, Use.available do |actor, character, gift|
24
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} see any \"#{character}\" here."
25
+ end
26
+
27
+ interpret "give :gift to :character", "give :character :gift"