gamefic-standard 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Rakefile +5 -2
- data/gamefic-standard.gemspec +13 -11
- data/lib/gamefic-standard/actions/attack.rb +23 -19
- data/lib/gamefic-standard/actions/close.rb +16 -10
- data/lib/gamefic-standard/actions/drop.rb +31 -16
- data/lib/gamefic-standard/actions/enter.rb +32 -26
- data/lib/gamefic-standard/actions/give.rb +41 -0
- data/lib/gamefic-standard/actions/go.rb +47 -43
- data/lib/gamefic-standard/actions/insert.rb +42 -28
- data/lib/gamefic-standard/actions/inventory.rb +13 -8
- data/lib/gamefic-standard/actions/leave.rb +44 -37
- data/lib/gamefic-standard/actions/lock.rb +22 -16
- data/lib/gamefic-standard/actions/look.rb +123 -104
- data/lib/gamefic-standard/actions/move.rb +18 -14
- data/lib/gamefic-standard/actions/nil.rb +62 -52
- data/lib/gamefic-standard/actions/open.rb +34 -24
- data/lib/gamefic-standard/actions/place.rb +35 -20
- data/lib/gamefic-standard/actions/pronouns.rb +26 -18
- data/lib/gamefic-standard/actions/quit.rb +17 -7
- data/lib/gamefic-standard/actions/repeat.rb +17 -9
- data/lib/gamefic-standard/actions/save-restore-undo.rb +19 -11
- data/lib/gamefic-standard/actions/search.rb +31 -21
- data/lib/gamefic-standard/actions/take.rb +47 -34
- data/lib/gamefic-standard/actions/talk.rb +45 -31
- data/lib/gamefic-standard/actions/unlock.rb +31 -21
- data/lib/gamefic-standard/actions/wait.rb +15 -5
- data/lib/gamefic-standard/actions.rb +33 -0
- data/lib/gamefic-standard/articles.rb +45 -37
- data/lib/gamefic-standard/enterable.rb +13 -0
- data/lib/gamefic-standard/entities/character.rb +3 -0
- data/lib/gamefic-standard/entities/container.rb +2 -2
- data/lib/gamefic-standard/entities/door.rb +13 -13
- data/lib/gamefic-standard/entities/portal.rb +1 -1
- data/lib/gamefic-standard/entities/receptacle.rb +1 -1
- data/lib/gamefic-standard/entities/room.rb +20 -5
- data/lib/gamefic-standard/entities/supporter.rb +1 -1
- data/lib/gamefic-standard/entities/thing.rb +1 -5
- data/lib/gamefic-standard/introduction.rb +14 -4
- data/lib/gamefic-standard/lockable.rb +36 -0
- data/lib/gamefic-standard/openable.rb +33 -0
- data/lib/gamefic-standard/pathfinder.rb +75 -55
- data/lib/gamefic-standard/standardized.rb +65 -0
- data/lib/gamefic-standard/version.rb +1 -1
- data/lib/gamefic-standard.rb +10 -3
- metadata +36 -13
- data/lib/gamefic-standard/give.rb +0 -21
- data/lib/gamefic-standard/grammar/attributes.rb +0 -37
- data/lib/gamefic-standard/grammar/pronoun.rb +0 -101
- data/lib/gamefic-standard/grammar.rb +0 -2
- data/lib/gamefic-standard/modules/enterable.rb +0 -9
- data/lib/gamefic-standard/modules/lockable.rb +0 -34
- data/lib/gamefic-standard/modules/openable.rb +0 -19
- data/lib/gamefic-standard/modules/standardized.rb +0 -57
- data/lib/gamefic-standard/modules.rb +0 -6
- data/spec-opal/spec_helper.rb +0 -32
@@ -1,50 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gamefic
|
2
4
|
module Standard
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
5
|
+
module Actions
|
6
|
+
module Leave
|
7
|
+
extend Gamefic::Scriptable
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
respond :leave, parent do |actor, thing|
|
10
|
+
actor.tell "There's no way out of #{the thing}."
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
respond :leave, parent(Enterable, proc(&:enterable?)) do |actor, thing|
|
14
|
+
actor.tell "You leave #{the thing}."
|
15
|
+
actor.parent = thing.parent
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
actor.tell "You don't see any obvious exits."
|
22
|
-
elsif portals.length == 1
|
23
|
-
actor.execute :go, portals[0]
|
24
|
-
else
|
25
|
-
actor.tell "I don't know which way you want to go: #{portals.map(&:definitely).join_or}."
|
18
|
+
respond :leave, parent(Supporter, proc(&:enterable?)) do |actor, thing|
|
19
|
+
actor.tell "You get off #{the thing}."
|
20
|
+
actor.parent = thing.parent
|
26
21
|
end
|
27
|
-
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
respond :leave, room do |actor, room|
|
24
|
+
portals = room.children.that_are(Portal)
|
25
|
+
if portals.length == 0
|
26
|
+
actor.tell "You don't see any obvious exits."
|
27
|
+
elsif portals.length == 1
|
28
|
+
actor.execute :go, portals[0]
|
29
|
+
else
|
30
|
+
actor.tell "I don't know which way you want to go: #{portals.map(&:instruction).join_or}."
|
31
|
+
end
|
34
32
|
end
|
35
|
-
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
respond :leave do |actor|
|
35
|
+
if actor.parent
|
36
|
+
actor.execute :leave, actor.parent
|
37
|
+
else
|
38
|
+
actor.tell "You don't see any obvious exits."
|
39
|
+
end
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
respond :leave, parent(Container, proc(&:enterable?), proc(&:closed?)) do |actor, container|
|
43
|
+
actor.execute :open, container
|
44
|
+
actor.proceed if container.open?
|
45
|
+
end
|
46
|
+
|
47
|
+
interpret 'exit', 'leave'
|
48
|
+
interpret 'exit :supporter', 'leave :supporter'
|
49
|
+
interpret 'get on :supporter', 'enter :supporter'
|
50
|
+
interpret 'get off :supporter', 'leave :supporter'
|
51
|
+
interpret 'get out :container', 'leave :container'
|
52
|
+
interpret 'get out of :container', 'leave :container'
|
53
|
+
interpret 'out', 'leave'
|
54
|
+
end
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
@@ -1,25 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gamefic
|
2
4
|
module Standard
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
5
|
+
module Actions
|
6
|
+
module Lock
|
7
|
+
extend Gamefic::Scriptable
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
thing.locked = true
|
11
|
-
actor.tell "You lock ##{the thing} with #{the key}."
|
12
|
-
else
|
13
|
-
actor.tell "You can't lock #{the thing} with #{the key}."
|
9
|
+
respond :lock, available do |actor, thing|
|
10
|
+
actor.tell "You can't lock #{the thing}."
|
14
11
|
end
|
15
|
-
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
respond :lock, available(Lockable, proc(&:has_lock_key?)), children do |actor, thing, key|
|
14
|
+
if thing.lock_key == key
|
15
|
+
thing.locked = true
|
16
|
+
actor.tell "You lock ##{the thing} with #{the key}."
|
17
|
+
else
|
18
|
+
actor.tell "You can't lock #{the thing} with #{the key}."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
respond :lock, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
|
23
|
+
actor.execute :take, key if key.parent != actor
|
24
|
+
actor.proceed if key.parent == actor
|
25
|
+
end
|
21
26
|
|
22
|
-
|
27
|
+
interpret "lock :container with :key", "lock :container :key"
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -1,133 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gamefic
|
2
4
|
module Standard
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
5
|
+
module Actions
|
6
|
+
module Look
|
7
|
+
extend Gamefic::Scriptable
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
respond :look do |actor|
|
10
|
+
actor.execute :look, actor.room
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
actor.tell "#{An item} is attached to #{the thing}."
|
13
|
+
respond :look, myself do |actor, _|
|
14
|
+
actor.tell actor.description
|
15
|
+
actor.execute :inventory
|
17
16
|
end
|
18
|
-
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
18
|
+
respond :look, available(Thing) do |actor, thing|
|
19
|
+
actor.tell thing.description
|
20
|
+
thing.children.that_are(proc(&:attached?)).that_are(proc(&:itemized?)).each do |item|
|
21
|
+
actor.tell "#{An item} is attached to #{the thing}."
|
22
|
+
end
|
23
|
+
end
|
27
24
|
|
28
|
-
|
29
|
-
actor.proceed
|
30
|
-
if thing.accessible?
|
25
|
+
respond :look, available(Supporter) do |actor, thing|
|
31
26
|
itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
|
32
|
-
|
27
|
+
# If the supporter does not have a description but it does contain
|
28
|
+
# itemized things, avoid saying there's nothing special about it.
|
29
|
+
actor.proceed if thing.has_description? || itemized.empty?
|
30
|
+
actor.tell "You see #{itemized.join_and} on #{the thing}." unless itemized.empty?
|
33
31
|
end
|
34
|
-
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
respond :look, available(Receptacle) do |actor, thing|
|
34
|
+
actor.proceed
|
35
|
+
actor.tell "You're currently in #{the thing}." if actor.parent == thing
|
36
|
+
next unless actor.parent == thing || thing.accessible?
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
actor.tell "#{The thing} is #{thing.open? ? 'open' : 'closed'}."
|
44
|
-
next if thing.closed? || thing.children.empty?
|
38
|
+
itemized = thing.children.that_are_not(actor, proc(&:attached?)).that_are(proc(&:itemized?))
|
39
|
+
next if itemized.empty?
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
if actor.parent == thing
|
42
|
+
actor.tell "You see #{itemized.join_and} here." unless itemized.empty?
|
43
|
+
else
|
44
|
+
actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
|
45
|
+
end
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
48
|
+
respond :look, parent(Supporter, proc(&:enterable?)) do |actor, supporter|
|
49
|
+
actor.proceed
|
50
|
+
actor.tell "You are currently on #{the supporter}."
|
51
|
+
end
|
55
52
|
|
56
|
-
actor
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
respond :look, available(Thing, Openable) do |actor, thing|
|
54
|
+
actor.tell thing.description if thing.has_description?
|
55
|
+
actor.tell "#{The thing} is #{thing.open? ? 'open' : 'closed'}."
|
56
|
+
next if thing.closed? || thing.children.empty?
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
next unless room
|
58
|
+
actor.tell "You see #{thing.children.join_and}."
|
59
|
+
end
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
charsum = []
|
68
|
-
chars.each do |char|
|
69
|
-
if char.locale_description.nil?
|
70
|
-
charsum.push char
|
71
|
-
else
|
72
|
-
with_locales.push char
|
73
|
-
end
|
61
|
+
respond :look, room do |actor, _room|
|
62
|
+
actor.execute :_describe_room
|
74
63
|
end
|
75
|
-
|
76
|
-
|
64
|
+
|
65
|
+
meta :_describe_room do |actor|
|
66
|
+
next unless actor.room
|
67
|
+
|
68
|
+
actor.tell "<strong>#{actor.room.name.cap_first}</strong>"
|
69
|
+
actor.tell actor.room.description if actor.room.has_description?
|
70
|
+
actor.execute :_itemize_room
|
77
71
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
|
73
|
+
meta :_itemize_room do |actor|
|
74
|
+
room = actor.room
|
75
|
+
next unless room
|
76
|
+
|
77
|
+
with_locales = []
|
78
|
+
chars = room.children.that_are(Character).that_are(proc(&:itemized?)) - [actor]
|
79
|
+
charsum = []
|
80
|
+
chars.each do |char|
|
81
|
+
if char.locale_description.nil?
|
82
|
+
charsum.push char
|
83
|
+
else
|
84
|
+
with_locales.push char
|
85
|
+
end
|
85
86
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
portals = room.children.that_are(Portal).that_are(proc(&:itemized?))
|
95
|
-
if portals.length > 0
|
96
|
-
if portals.length == 1
|
97
|
-
p = portals[0]
|
98
|
-
actor.tell "There is an exit #{p.instruction}."
|
87
|
+
if charsum.length > 0
|
88
|
+
actor.tell "#{charsum.join_and.cap_first} #{charsum.length == 1 ? 'is' : 'are'} here."
|
89
|
+
end
|
90
|
+
items = room.children.that_are(proc(&:itemized?)) - [actor] - room.children.that_are(Character) - room.children.that_are(Portal)
|
91
|
+
itemsum = []
|
92
|
+
items.each do |item|
|
93
|
+
if item.locale_description.nil?
|
94
|
+
itemsum.push item
|
99
95
|
else
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
with_locales.push item
|
97
|
+
end
|
98
|
+
end
|
99
|
+
actor.tell "You see #{itemsum.join_and}." if itemsum.length > 0
|
100
|
+
with_locales.each do |entity|
|
101
|
+
actor.tell entity.locale_description
|
102
|
+
end
|
103
|
+
if room.explicit_exits?
|
104
|
+
portals = room.children.that_are(Portal).that_are(proc(&:itemized?))
|
105
|
+
if portals.length > 0
|
106
|
+
if portals.length == 1
|
107
|
+
p = portals[0]
|
108
|
+
actor.tell "There is an exit #{p.instruction}."
|
109
|
+
else
|
110
|
+
dirs = []
|
111
|
+
portals.each do |p|
|
112
|
+
dirs.push p.instruction
|
113
|
+
end
|
114
|
+
order = %w[north northeast east southeast south southwest west northwest up
|
115
|
+
down]
|
116
|
+
dirs.sort! { |a, b| (order.index(a.to_s) || order.length) <=> (order.index(b.to_s) || order.length) }
|
117
|
+
actor.tell "There are exits #{dirs.join_and(', ')}."
|
103
118
|
end
|
104
|
-
order = ['north', 'northeast', 'east', 'southeast', 'south', 'southwest', 'west', 'northwest', 'up', 'down']
|
105
|
-
dirs.sort! { |a, b| (order.index(a.to_s) || order.length) <=> (order.index(b.to_s) || order.length) }
|
106
|
-
actor.tell "There are exits #{dirs.join_and(', ')}."
|
107
119
|
end
|
108
120
|
end
|
121
|
+
actor.execute :_look_parent_from_room
|
109
122
|
end
|
110
|
-
|
111
|
-
|
112
|
-
actor.parent.
|
113
|
-
|
114
|
-
|
123
|
+
|
124
|
+
meta :_look_parent_from_room do |actor|
|
125
|
+
next unless actor.parent.is_a?(Supporter) || actor.parent.is_a?(Receptacle)
|
126
|
+
|
127
|
+
preposition = actor.parent.is_a?(Supporter) ? 'on' : 'in'
|
128
|
+
siblings = actor.parent.children.that_are_not(actor)
|
129
|
+
if siblings.empty?
|
130
|
+
actor.tell "You're #{preposition} #{the actor.parent}."
|
131
|
+
else
|
132
|
+
actor.tell "You're #{preposition} #{the actor.parent}, along with #{siblings.join_and}."
|
133
|
+
end
|
115
134
|
end
|
116
|
-
end
|
117
135
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
136
|
+
interpret 'look around', 'look'
|
137
|
+
interpret 'look here', 'look'
|
138
|
+
interpret 'l', 'look'
|
139
|
+
|
140
|
+
interpret 'look at :thing', 'look :thing'
|
141
|
+
interpret 'look on :thing', 'look :thing'
|
142
|
+
interpret 'look under :thing', 'look :thing'
|
143
|
+
interpret 'look beneath :thing', 'look :thing'
|
144
|
+
interpret 'look around :thing', 'look :thing'
|
145
|
+
interpret 'l :thing', 'look :thing'
|
146
|
+
interpret 'examine :thing', 'look :thing'
|
147
|
+
interpret 'x :thing', 'look :thing'
|
148
|
+
interpret 'inspect :thing', 'look :thing'
|
149
|
+
end
|
131
150
|
end
|
132
151
|
end
|
133
152
|
end
|
@@ -2,23 +2,27 @@
|
|
2
2
|
|
3
3
|
module Gamefic
|
4
4
|
module Standard
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
module Actions
|
6
|
+
module Move
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :move, Thing do |actor, thing|
|
10
|
+
if thing.portable?
|
11
|
+
actor.tell 'Maybe you want to <em>take</em> it?'
|
12
|
+
else
|
13
|
+
actor.tell "You can't move #{the thing}."
|
14
|
+
end
|
11
15
|
end
|
12
|
-
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
respond :move, children(Thing) do |actor, thing|
|
18
|
+
actor.tell "You're already carrying #{the thing}."
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
interpret 'push :thing', 'move :thing'
|
22
|
+
interpret 'pull :thing', 'move :thing'
|
23
|
+
interpret 'drag :thing', 'move :thing'
|
24
|
+
interpret 'lift :thing', 'move :thing'
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,60 +1,70 @@
|
|
1
|
-
|
2
|
-
meta nil, plaintext do |actor, string|
|
3
|
-
next if string.strip.empty?
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Nil
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
meta nil, plaintext do |actor, string|
|
10
|
+
next if string.strip.empty?
|
11
|
+
|
12
|
+
words = string.keywords
|
13
|
+
list = actor.epic.synonyms
|
14
|
+
if list.include?(words[0]&.to_sym)
|
15
|
+
if words.length > 1
|
16
|
+
result = myself.query(actor, words[1..-1].join(' '))
|
17
|
+
found = [result.match].compact
|
18
|
+
avail = available(ambiguous: true)
|
19
|
+
result = avail.query(actor, result.remainder)
|
20
|
+
until result.match.nil?
|
21
|
+
found.concat result.match
|
22
|
+
result = avail.query(actor, result.remainder)
|
23
|
+
end
|
24
|
+
if found.empty?
|
25
|
+
verbs = actor.epic
|
26
|
+
.syntaxes
|
27
|
+
.select { |syn| syn.synonym == words[0].to_sym }
|
28
|
+
.map(&:verb)
|
29
|
+
resps = actor.epic.responses_for(*verbs)
|
30
|
+
if resps.any? { |resp| !resp.queries.empty? }
|
31
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
|
32
|
+
else
|
33
|
+
actor.tell %[I recognize "#{words[0]}" but not with the rest of your sentence. (Maybe it's a one-word command?)]
|
34
|
+
end
|
35
|
+
elsif result.remainder != ''
|
36
|
+
actor.tell %(I recognize "#{string.sub(/#{result.remainder}$/, '').strip}" as a command but was confused by "#{result.remainder}.")
|
37
|
+
elsif found.one?
|
38
|
+
verbs = actor.epic
|
39
|
+
.syntaxes
|
40
|
+
.select { |syn| syn.synonym == words[0].to_sym }
|
41
|
+
.map(&:verb)
|
42
|
+
resps = actor.epic.responses_for(*verbs)
|
43
|
+
if resps.any? { |resp| !resp.queries.empty? }
|
44
|
+
actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
|
45
|
+
else
|
46
|
+
actor.tell %[I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together. (Maybe "#{words[0]}" is a one-word command?)]
|
47
|
+
end
|
48
|
+
else
|
49
|
+
verbs = actor.epic
|
50
|
+
.syntaxes
|
51
|
+
.select { |syn| syn.synonym == words[0].to_sym }
|
52
|
+
.map(&:verb)
|
53
|
+
resps = actor.epic.responses_for(*verbs)
|
54
|
+
if resps.any? { |resp| !resp.queries.empty? }
|
55
|
+
actor.tell %(I recognize "#{words[0]}" but I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
|
56
|
+
else
|
57
|
+
actor.tell %[I recognize "#{words[0]}" but not with the rest of your sentence. (Maybe it's a one-word command?)]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
|
62
|
+
end
|
49
63
|
else
|
50
|
-
actor.tell %
|
64
|
+
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
51
65
|
end
|
52
66
|
end
|
53
|
-
else
|
54
|
-
actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
|
55
67
|
end
|
56
|
-
else
|
57
|
-
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
58
68
|
end
|
59
69
|
end
|
60
70
|
end
|
@@ -1,29 +1,39 @@
|
|
1
|
-
|
2
|
-
respond :open, available do |actor, thing|
|
3
|
-
actor.tell "You can't open #{the thing}."
|
4
|
-
end
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
thing.open = true
|
12
|
-
end
|
13
|
-
end
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Open
|
7
|
+
extend Gamefic::Scriptable
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
actor.proceed
|
20
|
-
end
|
21
|
-
end
|
9
|
+
respond :open, available do |actor, thing|
|
10
|
+
actor.tell "You can't open #{the thing}."
|
11
|
+
end
|
22
12
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
respond :open, available(Openable) do |actor, thing|
|
14
|
+
if thing.open?
|
15
|
+
actor.tell "#{The thing} is already open."
|
16
|
+
else
|
17
|
+
actor.tell "You open #{the thing}."
|
18
|
+
thing.open = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
respond :open, available(Lockable) do |actor, thing|
|
23
|
+
if thing.locked?
|
24
|
+
actor.tell "#{The thing} is locked."
|
25
|
+
else
|
26
|
+
actor.proceed
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
respond :open, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
|
31
|
+
actor.execute :unlock, thing, key
|
32
|
+
actor.execute :open, thing if thing.unlocked?
|
33
|
+
end
|
27
34
|
|
28
|
-
|
35
|
+
interpret 'open :thing with :key', 'open :thing :key'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
29
39
|
end
|