gamefic-sdk 1.0.0 → 1.0.1

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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/html/core/engine.js +89 -0
  3. data/html/core/jquery.js +5 -0
  4. data/html/core/jquery.modal.css +44 -0
  5. data/html/core/jquery.modal.js +225 -0
  6. data/html/core/js.cookie.js +137 -0
  7. data/html/skins/hypertext/compass.png +0 -0
  8. data/html/skins/hypertext/index.html +151 -0
  9. data/html/skins/hypertext/style.css +74 -0
  10. data/html/skins/minimal/index.html.erb +22 -0
  11. data/html/skins/minimal/play.js +36 -0
  12. data/html/skins/minimal/style.css +8 -0
  13. data/html/skins/multimedia/close.png +0 -0
  14. data/html/skins/multimedia/index.html +179 -0
  15. data/html/skins/multimedia/mobile.css +10 -0
  16. data/html/skins/multimedia/spinner.gif +0 -0
  17. data/html/skins/multimedia/style.css +186 -0
  18. data/html/skins/standard/index.html.erb +23 -0
  19. data/html/skins/standard/play.js +68 -0
  20. data/html/skins/standard/style.css +70 -0
  21. data/lib/gamefic-sdk/version.rb +1 -1
  22. data/scripts/ansi.plot.rb +13 -0
  23. data/scripts/autosuggest.plot.rb +171 -0
  24. data/scripts/clothing.plot.rb +2 -0
  25. data/scripts/clothing/actions.plot.rb +4 -0
  26. data/scripts/clothing/actions/doff.plot.rb +12 -0
  27. data/scripts/clothing/actions/drop.plot.rb +8 -0
  28. data/scripts/clothing/actions/inventory.plot.rb +14 -0
  29. data/scripts/clothing/actions/wear.plot.rb +19 -0
  30. data/scripts/clothing/entities.plot.rb +7 -0
  31. data/scripts/clothing/entities/clothing.plot.rb +7 -0
  32. data/scripts/clothing/entities/coat.plot.rb +5 -0
  33. data/scripts/clothing/entities/gloves.plot.rb +5 -0
  34. data/scripts/clothing/entities/hat.plot.rb +5 -0
  35. data/scripts/clothing/entities/pants.plot.rb +5 -0
  36. data/scripts/clothing/entities/shirt.plot.rb +5 -0
  37. data/scripts/clothing/entities/shoes.plot.rb +5 -0
  38. data/scripts/cover.plot.rb +30 -0
  39. data/scripts/debug.plot.rb +0 -0
  40. data/scripts/edible.plot.rb +19 -0
  41. data/scripts/furniture.plot.rb +35 -0
  42. data/scripts/hints.plot.rb +31 -0
  43. data/scripts/hypertext.plot.rb +280 -0
  44. data/scripts/media.plot.rb +17 -0
  45. data/scripts/multimedia.plot.rb +41 -0
  46. data/scripts/questions.plot.rb +17 -0
  47. data/scripts/room-modes.plot.rb +48 -0
  48. data/scripts/rough-sizes.plot.rb +36 -0
  49. data/scripts/save-restore.plot.rb +21 -0
  50. data/scripts/snapshots.plot.rb +14 -0
  51. data/scripts/standard.plot.rb +12 -0
  52. data/scripts/standard/actions.plot.rb +23 -0
  53. data/scripts/standard/actions/close.plot.rb +16 -0
  54. data/scripts/standard/actions/drop.plot.rb +11 -0
  55. data/scripts/standard/actions/enter.plot.rb +31 -0
  56. data/scripts/standard/actions/give.plot.rb +26 -0
  57. data/scripts/standard/actions/go.plot.rb +81 -0
  58. data/scripts/standard/actions/insert.plot.rb +47 -0
  59. data/scripts/standard/actions/inventory.plot.rb +8 -0
  60. data/scripts/standard/actions/leave.plot.rb +41 -0
  61. data/scripts/standard/actions/lock.plot.rb +59 -0
  62. data/scripts/standard/actions/look-under.plot.rb +8 -0
  63. data/scripts/standard/actions/look.plot.rb +102 -0
  64. data/scripts/standard/actions/nil.plot.rb +35 -0
  65. data/scripts/standard/actions/open.plot.rb +34 -0
  66. data/scripts/standard/actions/place.plot.rb +36 -0
  67. data/scripts/standard/actions/quit.plot.rb +11 -0
  68. data/scripts/standard/actions/read.plot.rb +3 -0
  69. data/scripts/standard/actions/search.plot.rb +39 -0
  70. data/scripts/standard/actions/show.plot.rb +13 -0
  71. data/scripts/standard/actions/take.plot.rb +49 -0
  72. data/scripts/standard/actions/talk.plot.rb +31 -0
  73. data/scripts/standard/actions/unlock.plot.rb +77 -0
  74. data/scripts/standard/actions/use.plot.rb +25 -0
  75. data/scripts/standard/actions/wait.plot.rb +3 -0
  76. data/scripts/standard/entities.plot.rb +12 -0
  77. data/scripts/standard/entities/character.plot.rb +9 -0
  78. data/scripts/standard/entities/container.plot.rb +11 -0
  79. data/scripts/standard/entities/door.plot.rb +53 -0
  80. data/scripts/standard/entities/entity.plot.rb +13 -0
  81. data/scripts/standard/entities/exterior.plot.rb +5 -0
  82. data/scripts/standard/entities/fixture.plot.rb +3 -0
  83. data/scripts/standard/entities/item.plot.rb +5 -0
  84. data/scripts/standard/entities/portal.plot.rb +37 -0
  85. data/scripts/standard/entities/receptacle.plot.rb +4 -0
  86. data/scripts/standard/entities/room.plot.rb +47 -0
  87. data/scripts/standard/entities/rubble.plot.rb +11 -0
  88. data/scripts/standard/entities/scenery.plot.rb +5 -0
  89. data/scripts/standard/entities/supporter.plot.rb +10 -0
  90. data/scripts/standard/modules.plot.rb +11 -0
  91. data/scripts/standard/modules/attachable.plot.rb +11 -0
  92. data/scripts/standard/modules/auto_takes.plot.rb +50 -0
  93. data/scripts/standard/modules/darkenable.plot.rb +6 -0
  94. data/scripts/standard/modules/enterable.plot.rb +15 -0
  95. data/scripts/standard/modules/explicit_exits.plot.rb +15 -0
  96. data/scripts/standard/modules/itemizable.plot.rb +18 -0
  97. data/scripts/standard/modules/lockable.plot.rb +25 -0
  98. data/scripts/standard/modules/openable.plot.rb +9 -0
  99. data/scripts/standard/modules/parent-room.plot.rb +9 -0
  100. data/scripts/standard/modules/portable.plot.rb +6 -0
  101. data/scripts/standard/modules/transparent.plot.rb +6 -0
  102. data/scripts/standard/pathfinder.plot.rb +60 -0
  103. data/scripts/standard/plural.plot.rb +2 -0
  104. data/scripts/standard/plural/actions.plot.rb +4 -0
  105. data/scripts/standard/plural/actions/drop.plot.rb +126 -0
  106. data/scripts/standard/plural/actions/insert.plot.rb +68 -0
  107. data/scripts/standard/plural/actions/place.plot.rb +37 -0
  108. data/scripts/standard/plural/actions/take.plot.rb +175 -0
  109. data/scripts/standard/plural/queries.plot.rb +5 -0
  110. data/scripts/standard/plural/queries/ambiguous_visible.plot.rb +13 -0
  111. data/scripts/standard/plural/queries/any_expression.plot.rb +17 -0
  112. data/scripts/standard/plural/queries/many_visible.plot.rb +13 -0
  113. data/scripts/standard/plural/queries/not_expression.plot.rb +16 -0
  114. data/scripts/standard/plural/queries/plural_visible.plot.rb +22 -0
  115. data/scripts/standard/queries.plot.rb +4 -0
  116. data/scripts/standard/queries/from_expression.plot.rb +16 -0
  117. data/scripts/standard/queries/reachable.plot.rb +48 -0
  118. data/scripts/standard/queries/room.plot.rb +17 -0
  119. data/scripts/standard/queries/visible.plot.rb +45 -0
  120. data/scripts/standard/rules.plot.rb +1 -0
  121. data/scripts/standard/rules/has-enough-light.plot.rb +12 -0
  122. data/scripts/standard/test.plot.rb +8 -0
  123. data/scripts/standard/use.plot.rb +29 -0
  124. data/scripts/suggestible.plot.rb +42 -0
  125. data/scripts/undo.plot.rb +11 -0
  126. metadata +149 -25
@@ -0,0 +1,6 @@
1
+ module Gamefic::Darkenable
2
+ attr_writer :dark
3
+ def dark?
4
+ @dark ||= false
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ module Gamefic::Enterable
2
+ attr_writer :enterable, :leave_verb, :enter_verb, :inside_verb
3
+ def enterable?
4
+ @enterable ||= false
5
+ end
6
+ def inside_verb
7
+ @inside_verb ||= "be in"
8
+ end
9
+ def enter_verb
10
+ @enter_verb ||= "enter"
11
+ end
12
+ def leave_verb
13
+ @leave_verb ||= "leave"
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Gamefic::ExplicitExits
2
+ attr_writer :explicit_exits
3
+ def explicit_exits?
4
+ @explicit_exits ||= ExplicitExits.default
5
+ end
6
+ def self.default
7
+ if @default.nil?
8
+ @default = true
9
+ end
10
+ @default
11
+ end
12
+ def self.default=(bool)
13
+ @default = bool
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Gamefic::Itemizable
2
+ attr_writer :itemized
3
+ def itemized?
4
+ if @itemized.nil?
5
+ @itemized = Itemizable.default
6
+ end
7
+ @itemized
8
+ end
9
+ def self.default
10
+ if @default.nil?
11
+ @default = true
12
+ end
13
+ @default
14
+ end
15
+ def self.default=(bool)
16
+ @default = bool
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ script 'standard/modules/openable'
2
+
3
+ module Gamefic::Lockable
4
+ include Openable
5
+ attr_reader :lock_key
6
+ def locked=(bool)
7
+ @locked = bool
8
+ if @locked == true
9
+ self.open = false
10
+ end
11
+ end
12
+ def open=(bool)
13
+ @open = bool
14
+ @locked = false if @open == true
15
+ end
16
+ def locked?
17
+ @locked ||= false
18
+ end
19
+ def has_lock_key?
20
+ !@lock_key.nil?
21
+ end
22
+ def lock_key=(entity)
23
+ @lock_key = entity
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module Gamefic::Openable
2
+ attr_writer :open, :openable
3
+ def open?
4
+ @open ||= false
5
+ end
6
+ def closed?
7
+ !open?
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Gamefic::ParentRoom
2
+ def room
3
+ p = parent
4
+ while !p.kind_of?(Room) and !p.nil?
5
+ p = p.parent
6
+ end
7
+ p
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module Gamefic::Portable
2
+ attr_writer :portable
3
+ def portable?
4
+ @portable ||= false
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Gamefic::Transparent
2
+ attr_writer :transparent
3
+ def transparent?
4
+ @transparent ||= false
5
+ end
6
+ end
@@ -0,0 +1,60 @@
1
+ # Pathfinders provide the shortest route between two locations. The
2
+ # destination needs to be accessible from the origin through portals. Note
3
+ # that Pathfinders do not take into account portals that characters cannot
4
+ # traverse, such as locked doors.
5
+ #
6
+ class Gamefic::Pathfinder
7
+ # @return [Room]
8
+ attr_reader :origin
9
+ # @return [Room]
10
+ attr_reader :destination
11
+
12
+ def initialize origin, destination
13
+ @origin = origin
14
+ @destination = destination
15
+ @path = nil
16
+ @paths = [[@origin]]
17
+ @visited = []
18
+ if @origin == @destination
19
+ @path = []
20
+ else
21
+ while @path.nil? and @paths.length > 0
22
+ embark
23
+ end
24
+ end
25
+ end
26
+ # @return [Array<Room>]
27
+ def path
28
+ # @path is nil if the path is invalid, but #path should return an empty
29
+ # array instead.
30
+ @path || []
31
+ end
32
+ # @return [Boolean]
33
+ def valid?
34
+ path.length > 0 or origin == destination
35
+ end
36
+ private
37
+ def embark
38
+ new_paths = []
39
+ @paths.each { |path|
40
+ last = path.last
41
+ portals = last.children.that_are(Portal)
42
+ portals.each { |portal|
43
+ new_path = path.clone
44
+ if !@visited.include?(portal.destination)
45
+ new_path.push portal.destination
46
+ @visited.push portal.destination
47
+ if portal.destination == @destination
48
+ @path = new_path
49
+ @path.shift
50
+ break
51
+ end
52
+ new_paths.push new_path
53
+ end
54
+ }
55
+ path.push nil
56
+ }
57
+ @paths += new_paths
58
+ @paths.delete_if{|path| path.last.nil?}
59
+ end
60
+ end
@@ -0,0 +1,2 @@
1
+ script 'standard/plural/queries'
2
+ script 'standard/plural/actions'
@@ -0,0 +1,4 @@
1
+ script 'standard/plural/actions/drop'
2
+ script 'standard/plural/actions/insert'
3
+ script 'standard/plural/actions/place'
4
+ script 'standard/plural/actions/take'
@@ -0,0 +1,126 @@
1
+ respond :drop, Use.many_children do |actor, things|
2
+ dropped = []
3
+ things.each { |thing|
4
+ buffer = actor.quietly :drop, thing
5
+ if thing.parent == actor
6
+ actor.tell buffer
7
+ else
8
+ dropped.push thing
9
+ end
10
+ }
11
+ if dropped.length > 0
12
+ actor.tell "#{you.pronoun.Subj} drop #{dropped.join_and}."
13
+ end
14
+ end
15
+
16
+ respond :drop, Use.text("all", "everything") do |actor, text|
17
+ children = actor.children.that_are_not(:attached?)
18
+ if children.length == 0
19
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} have anything to drop."
20
+ else
21
+ dropped = []
22
+ children.each { |child|
23
+ buffer = actor.quietly :drop, child
24
+ if child.parent != actor
25
+ dropped.push child
26
+ else
27
+ actor.tell buffer
28
+ end
29
+ }
30
+ if dropped.length > 0
31
+ actor.tell "#{you.pronoun.Subj} drop #{dropped.join_and}."
32
+ end
33
+ end
34
+ end
35
+
36
+ respond :drop, Use.text("all", "everything"), Use.text("but", "except"), Use.children do |actor, text1, text2, exception|
37
+ children = actor.children.that_are_not(:attached?)
38
+ if children.length == 0
39
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} have anything to drop."
40
+ else
41
+ dropped = []
42
+ children.each { |child|
43
+ next if exception == child
44
+ buffer = actor.quietly :drop, child
45
+ if child.parent != actor
46
+ dropped.push child
47
+ else
48
+ actor.tell buffer
49
+ end
50
+ }
51
+ if dropped.length > 0
52
+ actor.tell "#{you.pronoun.Subj} drop #{dropped.join_and}."
53
+ end
54
+ end
55
+ end
56
+
57
+ respond :drop, Use.text("all", "everything"), Use.text("but", "except"), Use.text do |actor, text1, text2, text3|
58
+ actor.tell "I understand you want to drop #{text1} but don't know what you're trying to exclude with \"#{text3}.\""
59
+ end
60
+
61
+ respond :drop, Use.text("all", "everything"), Use.text("but", "except"), Use.many_children do |actor, text1, text2, exceptions|
62
+ children = actor.children.that_are_not(:attached?)
63
+ if children.length == 0
64
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.do + ' not')} have anything to drop."
65
+ else
66
+ dropped = []
67
+ children.each { |child|
68
+ next if exceptions.include?(child)
69
+ buffer = actor.quietly :drop, child
70
+ if child.parent != actor
71
+ dropped.push child
72
+ else
73
+ actor.tell buffer
74
+ end
75
+ }
76
+ if dropped.length > 0
77
+ actor.tell "#{you.pronoun.Subj} drop #{dropped.join_and}."
78
+ end
79
+ end
80
+ end
81
+
82
+ respond :drop, Use.text("all", "everything"), Use.text("but", "except"), Use.plural_children do |actor, text1, text2, exceptions|
83
+ children = actor.children.that_are_not(:attached?)
84
+ actor.perform :drop, children - exceptions
85
+ end
86
+
87
+ respond :drop, Use.text("all", "everything"), Use.text("but", "except"), Use.any_expression, Use.ambiguous_children do |actor, text1, text2, text3, exceptions|
88
+ children = actor.children.that_are_not(:attached?)
89
+ actor.perform :drop, children - exceptions
90
+ end
91
+
92
+ respond :drop, Use.any_expression, Use.ambiguous_children do |actor, text1, things|
93
+ filtered = things.clone
94
+ filtered.delete_if{|t| t.parent != actor}
95
+ if filtered.length == 0
96
+ actor.tell "#{you.pronoun.Subj} #{you.contract(you.verb.be + ' not')} carrying anything that matches your terms."
97
+ else
98
+ dropped = []
99
+ things.each { |thing|
100
+ if thing.parent == actor
101
+ buffer = actor.quietly :drop, thing
102
+ if thing.parent == actor
103
+ actor.tell buffer
104
+ else
105
+ dropped.push thing
106
+ end
107
+ end
108
+ }
109
+ if dropped.length > 0
110
+ actor.tell "#{you.pronoun.Subj} #{you.verb.drop} #{dropped.join_and}."
111
+ end
112
+ end
113
+ end
114
+
115
+ respond :drop, Use.any_expression, Use.ambiguous_children, Use.text("except", "but"), Use.any_expression, Use.ambiguous_children do |actor, _, things, _, exceptions|
116
+ actor.perform :drop, things - exceptions
117
+ end
118
+
119
+ respond :drop, Use.not_expression, Use.ambiguous_children do |actor, _, exceptions|
120
+ children = actor.children
121
+ actor.perform :drop, children - exceptions
122
+ end
123
+
124
+ respond :drop, Use.plural_children do |actor, things|
125
+ actor.perform "drop #{things.join(' and ')}"
126
+ end
@@ -0,0 +1,68 @@
1
+ respond :insert, Use.text("all", "everything"), Use.reachable(Receptacle) do |actor, text, receptacle|
2
+ children = actor.children.that_are_not(:attached?)
3
+ if children.length == 0
4
+ actor.tell "#{you.pronoun.Subj} #{you.contract you.verb.be + ' not'} carrying anything to put in #{the receptacle}."
5
+ else
6
+ inserted = []
7
+ children.each { |child|
8
+ buffer = actor.quietly :insert, child, receptacle
9
+ if child.parent != receptacle
10
+ actor.tell buffer
11
+ else
12
+ inserted.push child
13
+ end
14
+ }
15
+ if inserted.length > 0
16
+ actor.tell "#{you.pronoun.Subj} put #{inserted.join_and} in #{the receptacle}."
17
+ end
18
+ end
19
+ end
20
+
21
+ respond :insert, Use.many_children, Use.reachable(Receptacle) do |actor, children, receptacle|
22
+ inserted = []
23
+ children.each { |child|
24
+ buffer = actor.quietly :insert, child, receptacle
25
+ if child.parent != receptacle
26
+ actor.tell buffer
27
+ else
28
+ inserted.push child
29
+ end
30
+ }
31
+ if inserted.length > 0
32
+ actor.tell "#{you.pronoun.Subj} put #{inserted.join_and} in #{the receptacle}."
33
+ end
34
+ end
35
+
36
+ respond :insert, Use.many_children, Use.reachable(Container) do |actor, children, container|
37
+ if container.open?
38
+ actor.proceed
39
+ else
40
+ actor.tell "#{The container} is closed."
41
+ end
42
+ end
43
+
44
+ respond :insert, Use.any_expression, Use.ambiguous_children, Use.reachable(Receptacle) do |actor, _, children, _, receptacle|
45
+ actor.perform :insert, children, receptacle
46
+ end
47
+
48
+ respond :insert, Use.any_expression, Use.ambiguous_children, Use.reachable(Receptacle) do |actor, _, children, _, receptacle|
49
+ actor.perform :insert, children, receptacle
50
+ end
51
+
52
+ respond :insert, Use.text("everything", "all"), Use.text("except", "but"), Use.ambiguous_children, Use.reachable(Receptacle) do |actor, _, _, exceptions, receptacle|
53
+ children = Use.children.context_from(actor).that_are_not(:attached?)
54
+ actor.perform :insert, children - exceptions, receptacle
55
+ end
56
+
57
+ respond :insert, Use.any_expression, Use.ambiguous_children, Use.reachable(Receptacle) do |actor, _, children, receptacle|
58
+ actor.perform :insert, children, receptacle
59
+ end
60
+
61
+ respond :insert, Use.not_expression, Use.ambiguous_children, Use.reachable(Receptacle) do |actor, _, exceptions, receptacle|
62
+ children = Use.children.context_from(actor).that_are_not(:attached?)
63
+ actor.perform :insert, children - exceptions, receptacle
64
+ end
65
+
66
+ respond :insert, Use.plural_children, Use.reachable(Receptacle) do |actor, children, receptacle|
67
+ actor.perform :insert, children, receptacle
68
+ end
@@ -0,0 +1,37 @@
1
+ respond :place, Use.many_children, Use.reachable(Supporter) do |actor, children, supporter|
2
+ placed = []
3
+ children.each { |child|
4
+ buffer = actor.quietly :place, child, supporter
5
+ if child.parent != supporter
6
+ actor.tell buffer
7
+ else
8
+ placed.push child
9
+ end
10
+ }
11
+ if placed.length > 0
12
+ actor.tell "You put #{placed.join_and} on #{the supporter}."
13
+ end
14
+ end
15
+
16
+ respond :place, Use.any_expression, Use.ambiguous_children, Use.reachable(Supporter) do |actor, _, children, supporter|
17
+ actor.perform :place, children, supporter
18
+ end
19
+
20
+ respond :place, Use.text("all", "everything"), Use.reachable(Supporter) do |actor, _, supporter|
21
+ children = Use.children.context_from(actor).that_are_not(:attached?)
22
+ actor.perform :place, children, supporter
23
+ end
24
+
25
+ respond :place, Use.text("all", "everything"), Use.text("except", "but"), Use.ambiguous_children, Use.reachable(Supporter) do |actor, _, _, exceptions, supporter|
26
+ children = Use.children.context_from(actor).that_are_not(:attached?)
27
+ actor.perform :place, children - exceptions, supporter
28
+ end
29
+
30
+ respond :place, Use.not_expression, Use.ambiguous_children, Use.reachable(Supporter) do |actor, _, exceptions, supporter|
31
+ children = Use.children.context_from(actor).that_are_not(:attached?)
32
+ actor.perform :place, children - exceptions, supporter
33
+ end
34
+
35
+ respond :place, Use.plural_children, Use.reachable(Supporter) do |actor, children, supporter|
36
+ actor.perform :place, children, supporter
37
+ end
@@ -0,0 +1,175 @@
1
+ respond :take, Use.many_visible do |actor, things|
2
+ filtered = things.clone
3
+ filtered.delete_if{ |t| t.parent == actor }
4
+ if filtered.length == 0
5
+ output = "There's nothing to take that matches your terms." + (things.length > 0 ? "(You're already carrying #{things.join_and}.)" : '')
6
+ actor.tell output
7
+ else
8
+ taken = []
9
+ filtered.each { |thing|
10
+ buffer = actor.quietly :take, thing
11
+ if thing.parent != actor
12
+ actor.tell buffer
13
+ else
14
+ taken.push thing
15
+ end
16
+ }
17
+ if taken.length > 0
18
+ actor.tell "#{you.pronoun.Subj} #{you.verb.take} #{taken.join_and}."
19
+ end
20
+ end
21
+ end
22
+
23
+ respond :take, Use.text("all", "everything") do |actor, text|
24
+ children = actor.parent.children.that_are_not(:attached?).that_are(:portable?)
25
+ if actor.parent != actor.room and actor.parent.kind_of?(Supporter)
26
+ children += actor.room.children.that_are_not(:attached?).that_are(:portable?)
27
+ end
28
+ if children.length == 0
29
+ actor.tell "There's nothing obvious to take."
30
+ else
31
+ taken = []
32
+ children.each { |child|
33
+ buffer = actor.quietly :take, child
34
+ if child.parent == actor
35
+ taken.push child
36
+ else
37
+ actor.tell buffer
38
+ end
39
+ }
40
+ if taken.length > 0
41
+ actor.tell "#{you.pronoun.Subj} #{you.verb.take} #{taken.join_and}."
42
+ end
43
+ end
44
+ end
45
+
46
+ respond :take, Use.text("all", "everything"), Use.text do |actor, text1, text2|
47
+ actor.tell "I understand that you want to take #{text1} but did not understand \"#{text2}.\""
48
+ end
49
+
50
+ respond :take, Use.text("all", "everything"), Use.text("but", "except"), Use.visible do |actor, text1, text2, exception|
51
+ children = actor.parent.children.that_are_not(:attached?).that_are(:portable?)
52
+ if actor.parent != actor.room and actor.parent.kind_of?(Supporter)
53
+ children += actor.room.children.that_are_not(:attached?).that_are(:portable?)
54
+ end
55
+ if children.length == 0
56
+ actor.tell "There's nothing obvious to take."
57
+ else
58
+ taken = []
59
+ children.each { |child|
60
+ next if exception == child
61
+ buffer = actor.quietly :take, child
62
+ if child.parent == actor
63
+ taken.push child
64
+ else
65
+ actor.tell buffer
66
+ end
67
+ }
68
+ if taken.length > 0
69
+ actor.tell "#{you.pronoun.Subj} #{you.verb.take} #{taken.join_and}."
70
+ end
71
+ end
72
+ end
73
+
74
+ respond :take, Use.any_expression, Use.ambiguous_visible(:portable?) do |actor, text, things|
75
+ filtered = things.clone
76
+ filtered.delete_if{|t| t.parent == actor}
77
+ if filtered.length == 0
78
+ actor.tell "There's nothing to take that matches your terms. (#{you.contract you.pronoun.Subj + ' are'} already carrying #{things.join_and}.)"
79
+ #elsif filtered.length == 1
80
+ # actor.proceed
81
+ else
82
+ taken = []
83
+ filtered.each { |thing|
84
+ buffer = actor.quietly :take, thing
85
+ if thing.parent != actor
86
+ actor.tell buffer
87
+ else
88
+ taken.push thing
89
+ end
90
+ }
91
+ if taken.length > 0
92
+ actor.tell "#{you.pronoun.Subj} #{you.verb.take} #{taken.join_and}."
93
+ end
94
+ end
95
+ end
96
+
97
+ respond :take, Use.any_expression, Use.ambiguous_visible, Use.text("except", "but"), Use.any_expression, Use.ambiguous_visible do |actor, _, things, _, _, exceptions|
98
+ actor.perform :take, things - exceptions
99
+ end
100
+
101
+ respond :take, Use.text("all", "everything"), Use.text("but", "except"), Use.many_visible do |actor, text1, text2, exceptions|
102
+ visible = Use.many_visible.context_from(actor)
103
+ actor.perform :take, visible - exceptions
104
+ end
105
+
106
+ respond :take, Use.text("all", "everything"), Use.text("but", "except"), Use.any_expression, Use.ambiguous_visible do |actor, _, _, _, exceptions|
107
+ visible = Use.many_visible.context_from(actor)
108
+ actor.perform :take, visible - exceptions
109
+ end
110
+
111
+ respond :take, Use.text("all", "everything"), Use.text("but", "except"), Use.text do |actor, _, _, exceptions|
112
+ actor.tell "I don't understand what you're trying to exclude with \"#{exceptions}.\""
113
+ end
114
+
115
+ respond :take, Use.text("all", "everything"), Use.text("but", "except"), Use.plural_visible do |actor, _, _, exceptions|
116
+ visible = Use.visible.context_from(actor)
117
+ actor.perform :take, visible - exceptions
118
+ end
119
+
120
+ respond :take, Use.any_expression, Use.ambiguous_visible, Use.text("except", "but"), Use.visible do |actor, text1, things, text2, exception|
121
+ actor.perform :take, things - [exception]
122
+ end
123
+
124
+ respond :take, Use.any_expression, Use.ambiguous_visible, Use.text("except", "but"), Use.ambiguous_visible do |actor, text1, things, text2, exceptions|
125
+ actor.perform :take, things - exceptions
126
+ end
127
+
128
+ respond :take, Use.any_expression, Use.ambiguous_visible, Use.text("except", "but"), Use.plural_visible do |actor, text1, things, text2, exceptions|
129
+ actor.perform :take, things - exceptions
130
+ end
131
+
132
+ respond :take, Use.any_expression, Use.ambiguous_visible, Use.text("except", "but"), Use.any_expression, Use.ambiguous_visible do |actor, _, things, _, _, exceptions|
133
+ actor.perform :take, things - exceptions
134
+ end
135
+
136
+ respond :take, Use.ambiguous_visible, Use.text("things", "items", "stuff") do |actor, things, _|
137
+ actor.perform :take, things
138
+ end
139
+
140
+ respond :take, Use.plural_visible do |actor, things|
141
+ actor.perform :take, things
142
+ end
143
+
144
+ respond :take, Use.not_expression, Use.ambiguous_visible do |actor, _, exceptions|
145
+ visible = Use.visible.context_from(actor)
146
+ actor.perform :take, visible - exceptions
147
+ end
148
+
149
+ respond :take, Use.text("all", "everything"), Use.from_expression, Use.reachable(Receptacle) do |actor, _, _, receptacle|
150
+ children = receptacle.children.that_are_not(:attached?)
151
+ if children.length == 0
152
+ actor.tell "There's nothing inside #{the receptacle}."
153
+ else
154
+ taken = []
155
+ children.each { |child|
156
+ buffer = actor.quietly :take, child
157
+ if child.parent != actor
158
+ actor.tell buffer
159
+ else
160
+ taken.push child
161
+ end
162
+ }
163
+ if taken.length > 0
164
+ actor.tell "#{you.pronoun.Subj} #{you.verb.take} #{taken.join_and} from #{the receptacle}."
165
+ end
166
+ end
167
+ end
168
+
169
+ respond :take, Use.text("all","everything"), Use.reachable(Container) do |actor, text, container|
170
+ if container.open?
171
+ actor.proceed
172
+ else
173
+ actor.tell "#{The container} is closed."
174
+ end
175
+ end