gamefic-sdk 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,10 @@
1
+ #gamefic, #image, #text-container, #controls {
2
+ width: 100%;
3
+ min-width: 0;
4
+ max-width: none;
5
+ }
6
+ #gamefic {
7
+ -webkit-box-shadow: none;
8
+ -moz-box-shadow: none;
9
+ box-shadow: none;
10
+ }
Binary file
@@ -0,0 +1,186 @@
1
+ html {
2
+ margin: 0;
3
+ padding: 0;
4
+ font-family: Arial, sans-serif;
5
+ font-size: 12pt;
6
+ }
7
+ body {
8
+ margin: 0;
9
+ padding: 0;
10
+ background-color: #E3E7EA;
11
+ }
12
+ body.loading {
13
+ width: 100%;
14
+ height: 100%;
15
+ background-image: url('loading-large.gif');
16
+ background-position: center center;
17
+ background-repeat: no-repeat;
18
+ }
19
+ #gamefic_console {
20
+ width: 80%;
21
+ min-width: 600px;
22
+ max-width: 1024px;
23
+ overflow: hidden;
24
+ margin: 0 auto;
25
+ background-color: #FFFFFF;
26
+ -webkit-box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
27
+ -moz-box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
28
+ box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
29
+ }
30
+ #titlebar {
31
+ margin: 0 auto;
32
+ padding: 1px;
33
+ height: 20px;
34
+ background-color: #0D1046;
35
+ color: #FFFFFF;
36
+ }
37
+ #titlebar h1 {
38
+ margin: 0 0 0 10px;
39
+ height: 20px;
40
+ font-size: 14px;
41
+ font-weight: normal
42
+ }
43
+ #image-container {
44
+ margin: 0 auto;
45
+ padding: 0;
46
+ background-color: #FFFFFF;
47
+ border: 1px solid #A0A0A0;
48
+ display: none;
49
+ }
50
+ #image {
51
+ max-width: 100%;
52
+ max-height: 100%;
53
+ margin: 0 auto;
54
+ padding: 0;
55
+ background-repeat: no-repeat;
56
+ background-position: top center;
57
+ background-size: 100% 100%;
58
+ display: none;
59
+ }
60
+ #image-container.loading {
61
+ background-image: url('loading-circle.gif');
62
+ background-position: center center;
63
+ background-repeat: no-repeat;
64
+ background-size: auto auto;
65
+ }
66
+ #image-container.loading image {
67
+ visibility: hidden;
68
+ }
69
+ #text-container {
70
+ border-top: 1px solid #A0A0A0
71
+ background-color: #FFFFFF;
72
+ overflow: auto;
73
+ }
74
+ #text {
75
+ margin: 1em;
76
+ }
77
+ #text kbd {
78
+ font-family: Courier, Monospace;
79
+ font-weight: bold;
80
+ color: green;
81
+ }
82
+ #text kbd.logged {
83
+ color: gray;
84
+ }
85
+ #text blockquote {
86
+ margin: 1em 1em 1em 0;
87
+ padding: 0 0 0 1em;
88
+ border-left: 2px solid #E0E0E0;
89
+ color: #303030;
90
+ }
91
+ #controls {
92
+ border-top: 1px solid #A0A0A0;
93
+ background-color: #FFFFFF;
94
+ }
95
+ #prompt, #concluded {
96
+ margin: 4px 0 4px 0;
97
+ padding: 6px 0 0 10px;
98
+ background-color: #FFFFFF;
99
+ background-position: 10px 8px;
100
+ background-repeat: no-repeat;
101
+ font-size: 10pt;
102
+ height: 14pt;
103
+ font-weight: bold;
104
+ }
105
+ #commandform, #dialogform {
106
+ position: relative;
107
+ background-color: #FFFFFF;
108
+ padding: 0 0 10px 0;
109
+ }
110
+ #commandline-container, #dialogline-container {
111
+ margin-left: 10px;
112
+ margin-right: 80px;
113
+ height: 2em;
114
+ }
115
+ #gamefic_command, #dialogline {
116
+ width: 100%;
117
+ margin: 0;
118
+ padding: 0;
119
+ font-size: 14pt;
120
+ border: 1px solid #909090;
121
+ }
122
+ #commandenter, #dialogenter {
123
+ position: absolute;
124
+ font-size: 12pt;
125
+ right: 10px;
126
+ top: 0;
127
+ margin: 0;
128
+ padding: 0;
129
+ border: 1px solid black;
130
+ width: 60px;
131
+ }
132
+ .hidden {
133
+ display: none;
134
+ }
135
+ a.disabled {
136
+ color: gray;
137
+ text-decoration: none;
138
+ }
139
+ .error {
140
+ color: red;
141
+ }
142
+ .hint {
143
+ font-style: italic;
144
+ }
145
+ #prompt.hint {
146
+ color: red;
147
+ font-weight: bold;
148
+ }
149
+ kbd a {
150
+ color: green;
151
+ }
152
+ noscript p {
153
+ font-weight: bold;
154
+ text-align: center;
155
+ }
156
+ #image_cacher {
157
+ position: absolute;
158
+ top: 10000;
159
+ }
160
+ #dialog {
161
+ display: none;
162
+ }
163
+ #dialog nav p {
164
+ text-align: center;
165
+ }
166
+ #dialog nav p a {
167
+ margin: 0 1em 0 1em;
168
+ }
169
+ ol.multiple-choice {
170
+ list-style: none;
171
+ margin: 1em 0 1em 0.5em;
172
+ padding: 0;
173
+ }
174
+ ol.multiple-choice li {
175
+ margin: 0.5em 0 0.5em 0;
176
+ padding: 0;
177
+ list-style-type: decimal;
178
+ }
179
+ #dialog.loading * {
180
+ visibility: hidden;
181
+ }
182
+ #dialog.loading {
183
+ background-image: url('loading.gif');
184
+ background-position: center center;
185
+ background-repeat: no-repeat;
186
+ }
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title><%= title %> by <%= author %></title>
6
+ <%= stylesheet_tags %>
7
+ </head>
8
+ <body>
9
+ <div id="gamefic_console">
10
+ <div id="gamefic_output">
11
+ </div>
12
+ <div id="gamefic_controls">
13
+ <form action="">
14
+ <span id="gamefic_prompt"></span>
15
+ <input type="text" name="command" id="gamefic_command" autocomplete="off" />
16
+ <!--<input type="submit" id="gamefic_submit" value="Enter" />-->
17
+ <button type="submit" id="gamefic_submit">Enter</button>
18
+ </form>
19
+ </div>
20
+ </div>
21
+ <%= javascript_tags %>
22
+ </body>
23
+ </html>
@@ -0,0 +1,68 @@
1
+ $(function() {
2
+ $('#gamefic_controls form').submit(function(event) {
3
+ event.preventDefault();
4
+ Gamefic.update($('#gamefic_command').val());
5
+ });
6
+ Gamefic.onStart(function(response) {
7
+ var prompt = response.prompt;
8
+ if (prompt == '>') {
9
+ prompt = 'What do you want to do?'
10
+ }
11
+ $('#gamefic_prompt').html(prompt);
12
+ $('#gamefic_output a[rel="gamefic"]').addClass('disabled');
13
+ });
14
+ Gamefic.onInput(function(response) {
15
+ if (response.input != null) {
16
+ $('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
17
+ }
18
+ $('#gamefic_controls').addClass('working');
19
+ });
20
+ Gamefic.onFinish(function(response) {
21
+ if (!response.testing) {
22
+ $('#gamefic_controls').removeClass('working');
23
+ }
24
+ $('#gamefic_command').val('');
25
+ $('#gamefic_command').focus();
26
+ var outputElement = document.getElementById('gamefic_output');
27
+ $('#gamefic_output').animate({
28
+ scrollTop: outputElement.scrollHeight
29
+ }, 500);
30
+ });
31
+ Gamefic.handleResponse('Active', function(response) {
32
+ $('#gamefic_output').append(response.output);
33
+ });
34
+ Gamefic.handleResponse('YesOrNo', function(response) {
35
+ $('#gamefic_output').append(response.output);
36
+ $('#gamefic_output').append('<p>(<a href="#" rel="gamefic" data-command="yes">Yes</a> or <a href="#" rel="gamefic" data-command="no">No</a>)</p>');
37
+ });
38
+ Gamefic.handleResponse('MultipleChoice', function(response) {
39
+ var jq = $('<div/>');
40
+ jq.html(response.output);
41
+ jq.find('ol.multiple_choice li').each(function() {
42
+ var item = $(this).text();
43
+ var link = $('<a/>');
44
+ link.attr('href', '#');
45
+ link.attr('rel', 'gamefic');
46
+ link.attr('data-command', item);
47
+ link.text(item);
48
+ $(this).html(link);
49
+ });
50
+ $('#gamefic_output').append(jq);
51
+ });
52
+ Gamefic.handleResponse('Conclusion', function(response) {
53
+ if (response.input != null) {
54
+ $('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
55
+ }
56
+ $('#gamefic_console').addClass('concluded');
57
+ $('#gamefic_output').append(response.output);
58
+ $('#gamefic_controls').hide();
59
+ });
60
+ $('#gamefic_output').on('click', 'a[rel="gamefic"]', function(event) {
61
+ event.preventDefault();
62
+ if (!$(this).hasClass('disabled')) {
63
+ Gamefic.update($(this).attr('data-command'));
64
+ }
65
+ });
66
+ Gamefic.start();
67
+ $('#gamefic_command').focus();
68
+ });
@@ -0,0 +1,70 @@
1
+ html {
2
+ margin: 0;
3
+ padding: 0;
4
+ font-family: Arial, sans-serif;
5
+ font-size: 12pt;
6
+ }
7
+ body {
8
+ margin: 0;
9
+ padding: 0;
10
+ background-color: #E3E7EA;
11
+ }
12
+ #gamefic_console {
13
+ width: 80%;
14
+ min-width: 600px;
15
+ max-width: 1024px;
16
+ overflow: hidden;
17
+ margin: 0 auto;
18
+ background-color: #FFFFFF;
19
+ -webkit-box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
20
+ -moz-box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
21
+ box-shadow: 4px 4px 4px 0px rgba(0,0,0,0.75);
22
+ }
23
+ #gamefic_command {
24
+ width: calc(100% - 80px);
25
+ margin: 0;
26
+ padding: 0;
27
+ font-size: 14pt;
28
+ border: 1px solid #909090;
29
+ }
30
+ #gamefic_output {
31
+ min-height: 600px;
32
+ max-height: 80vh;
33
+ overflow: auto;
34
+ padding: 1em;
35
+ }
36
+ #gamefic_output figure {
37
+ margin: 0;
38
+ padding: 0;
39
+ }
40
+ #gamefic_output img {
41
+ max-width: 100%;
42
+ display: block;
43
+ margin: 0 auto;
44
+ overflow: hidden;
45
+ }
46
+ #gamefic_controls {
47
+ border-top: 1px solid #909090;
48
+ overflow: hidden;
49
+ padding: 1em;
50
+ }
51
+ #gamefic_prompt {
52
+ font-size: 10pt;
53
+ }
54
+ #gamefic_controls input {
55
+ font-size: 14pt;
56
+ height: 24px;
57
+ border: 1px solid #303030;
58
+ }
59
+ #gamefic_controls button {
60
+ display: inline-block;
61
+ font-size: 14pt;
62
+ line-height: normal !important;
63
+ height: 26px;
64
+ width: 72px;
65
+ border: 1px solid #303030;
66
+ margin: 0;
67
+ padding: 0;
68
+ color: #303030;
69
+ vertical-align: top;
70
+ }
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ meta :ansi do |actor|
2
+ actor.tell "Ansi is #{ansi ? 'ON' : 'OFF'}."
3
+ end
4
+
5
+ meta :ansi, Query::Text.new('on') do |actor, string|
6
+ actor.ansi = true
7
+ actor.tell "Ansi is ON."
8
+ end
9
+
10
+ meta :ansi, Query::Text.new('off') do |actor, string|
11
+ actor.ansi = false
12
+ actor.tell "Ansi is OFF."
13
+ end
@@ -0,0 +1,171 @@
1
+ script 'suggestible'
2
+
3
+ module Gamefic::Autosuggest
4
+ def suggest_from entity
5
+ suggest_take_from entity
6
+ suggest_examine_from entity
7
+ end
8
+ def suggest_take_from entity
9
+ portables = entity.children.that_are(:portable?)
10
+ portables.each { |p|
11
+ suggest "take #{p.definitely}"
12
+ }
13
+ end
14
+ def suggest_examine_from entity
15
+ entity.children.that_are_not(Portal).that_are_not(self).each { |e|
16
+ suggest "examine #{e.definitely}"
17
+ }
18
+ end
19
+ end
20
+
21
+ class Gamefic::Character
22
+ include Autosuggest
23
+ end
24
+
25
+ on_player_update do |actor|
26
+ if actor.scene == :active
27
+ actor.suggest "look around"
28
+ actor.suggest "inventory"
29
+ actor.room.children.that_are(Portal).each { |entity|
30
+ if entity.direction
31
+ actor.suggest "go #{entity.direction}"
32
+ else
33
+ actor.suggest "go to #{the entity.destination}"
34
+ end
35
+ }
36
+ Use.visible.context_from(actor).that_are_not(Portal).each { |entity|
37
+ actor.suggest "examine #{the entity}"
38
+ }
39
+ Use.visible.context_from(actor).that_are(:portable?).each { |entity|
40
+ actor.suggest "take #{the entity}"
41
+ }
42
+ Use.visible.context_from(actor).that_are(Container).that_are_not(:open?).each { |entity|
43
+ actor.suggest "close #{the entity}"
44
+ }
45
+ Use.visible.context_from(actor).that_are(Container).that_are(:open?).each { |entity|
46
+ actor.suggest "search #{the entity}"
47
+ actor.suggest "close #{the entity}"
48
+ }
49
+ Use.siblings.context_from(actor).that_are(Enterable).that_are(:enterable?).each { |entity|
50
+ actor.suggest "#{entity.enter_verb} #{the entity}"
51
+ }
52
+ Use.siblings.context_from(actor).that_are(Character).that_are_not(actor).each { |entity|
53
+ actor.suggest "talk to #{the entity}"
54
+ }
55
+ if (actor.parent != actor.room)
56
+ actor.suggest "#{actor.parent.leave_verb} #{the actor.parent}"
57
+ end
58
+ actor.children.that_are_not(:attached?).each { |entity|
59
+ actor.suggest "drop #{the entity}"
60
+ Use.siblings.context_from(actor).that_are(Supporter).each { |supporter|
61
+ actor.suggest "put #{the entity} on #{the supporter}"
62
+ }
63
+ Use.siblings.context_from(actor).that_are(Receptacle).each { |receptacle|
64
+ actor.suggest "put #{the entity} in #{the receptacle}"
65
+ }
66
+ }
67
+ vicinity = actor.parent.children.that_are_not(Portal)
68
+ if actor.parent != actor.room
69
+ vicinity.concat actor.room.children.that_are_not(Portal)
70
+ end
71
+ vicinity = vicinity - [actor]
72
+ vicinity.each { |e|
73
+ actor.suggest "examine #{the e}"
74
+ }
75
+ end
76
+ end
77
+
78
+ respond :look, Use.visible(Supporter) do |actor, supporter|
79
+ actor.proceed
80
+ actor.suggest_from supporter
81
+ end
82
+
83
+ respond :look, Use.visible(Receptacle) do |actor, receptacle|
84
+ actor.proceed
85
+ # Include suggestions from the receptacle if they're visible
86
+ # (e.g., the receptacle is not a closed opaque container)
87
+ available = Use.visible.context_from(actor) & receptacle.children
88
+ if available.length > 0
89
+ actor.suggest_from receptacle
90
+ end
91
+ end
92
+
93
+ respond :look, Use.visible(Container) do |actor, container|
94
+ actor.proceed
95
+ if container.open?
96
+ actor.suggest "close #{the container}"
97
+ else
98
+ if container.locked?
99
+ actor.suggest "unlock #{the container}"
100
+ else
101
+ actor.suggest "open #{the container}"
102
+ if !container.lock_key.nil?
103
+ actor.suggest "lock #{the container}"
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ respond :look, Use.visible(Character) do |actor, character|
110
+ actor.proceed
111
+ actor.suggest "talk to #{the character}"
112
+ end
113
+
114
+ respond :look, Use.room do |actor, room|
115
+ actor.proceed
116
+ actor.suggest_from room
117
+ end
118
+
119
+ respond :look, Use.visible(:portable?) do |actor, thing|
120
+ actor.proceed
121
+ actor.suggest "take #{the thing}"
122
+ end
123
+
124
+ respond :inventory do |actor|
125
+ actor.proceed
126
+ carried = actor.children.that_are_not(:attached?)
127
+ carried.each { |e|
128
+ actor.suggest "drop #{the e}"
129
+ actor.suggest "examine #{the e}"
130
+ }
131
+ reachable = Use.reachable.context_from(actor)
132
+ reachable.that_are(Supporter).each { |supporter|
133
+ carried.each { |thing|
134
+ actor.suggest "put #{the thing} on #{the supporter}"
135
+ }
136
+ }
137
+ reachable.that_are(Receptacle).each { |receptacle|
138
+ carried.each { |thing|
139
+ actor.suggest "put #{the thing} in #{the receptacle}"
140
+ }
141
+ }
142
+ end
143
+
144
+ respond :drop, Use.children do |actor, thing|
145
+ actor.proceed
146
+ actor.quietly :inventory
147
+ end
148
+
149
+ respond :search, Use.reachable(Receptacle) do |actor, receptacle|
150
+ actor.proceed
151
+ actor.children.that_are_not(:attached?).each { |e|
152
+ actor.suggest "put #{the e} in #{the receptacle}"
153
+ }
154
+ end
155
+
156
+ respond :search, Use.reachable(Container) do |actor, container|
157
+ if container.open?
158
+ actor.proceed
159
+ else
160
+ if container.has_description?
161
+ actor.tell container.description
162
+ end
163
+ if container.locked?
164
+ actor.tell "#{The container} is locked."
165
+ actor.suggest "unlock #{the container}"
166
+ else
167
+ actor.tell "#{The container} is closed."
168
+ actor.suggest "open #{the container}"
169
+ end
170
+ end
171
+ end