gamefic-standard 2.4.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +41 -40
  3. data/.rspec-opal +2 -0
  4. data/CHANGELOG.md +7 -0
  5. data/README.md +64 -60
  6. data/Rakefile +14 -6
  7. data/gamefic-standard.gemspec +6 -3
  8. data/lib/gamefic-standard/actions/attack.rb +28 -0
  9. data/lib/gamefic-standard/actions/close.rb +14 -10
  10. data/lib/gamefic-standard/actions/drop.rb +20 -16
  11. data/lib/gamefic-standard/actions/enter.rb +29 -19
  12. data/lib/gamefic-standard/actions/go.rb +51 -47
  13. data/lib/gamefic-standard/actions/help.rb +52 -0
  14. data/lib/gamefic-standard/actions/insert.rb +33 -29
  15. data/lib/gamefic-standard/actions/inventory.rb +12 -8
  16. data/lib/gamefic-standard/actions/leave.rb +43 -39
  17. data/lib/gamefic-standard/actions/lock.rb +21 -17
  18. data/lib/gamefic-standard/actions/look.rb +117 -96
  19. data/lib/gamefic-standard/actions/move.rb +24 -0
  20. data/lib/gamefic-standard/actions/nil.rb +16 -15
  21. data/lib/gamefic-standard/actions/open.rb +5 -5
  22. data/lib/gamefic-standard/actions/place.rb +4 -4
  23. data/lib/gamefic-standard/actions/quit.rb +4 -8
  24. data/lib/gamefic-standard/actions/repeat.rb +14 -0
  25. data/lib/gamefic-standard/actions/save-restore-undo.rb +18 -0
  26. data/lib/gamefic-standard/actions/search.rb +5 -5
  27. data/lib/gamefic-standard/actions/take.rb +15 -4
  28. data/lib/gamefic-standard/actions/talk.rb +16 -4
  29. data/lib/gamefic-standard/actions/unlock.rb +10 -6
  30. data/lib/gamefic-standard/actions/wait.rb +3 -1
  31. data/lib/gamefic-standard/actions.rb +5 -0
  32. data/lib/gamefic-standard/articles.rb +2 -7
  33. data/lib/gamefic-standard/direction.rb +2 -3
  34. data/lib/gamefic-standard/entities/container.rb +2 -0
  35. data/lib/gamefic-standard/entities/door.rb +2 -0
  36. data/lib/gamefic-standard/entities/fixture.rb +2 -1
  37. data/lib/gamefic-standard/entities/item.rb +2 -0
  38. data/lib/gamefic-standard/entities/portal.rb +2 -0
  39. data/lib/gamefic-standard/entities/receptacle.rb +2 -0
  40. data/lib/gamefic-standard/entities/room.rb +21 -36
  41. data/lib/gamefic-standard/entities/rubble.rb +2 -1
  42. data/lib/gamefic-standard/entities/scenery.rb +2 -0
  43. data/lib/gamefic-standard/entities/supporter.rb +2 -0
  44. data/lib/gamefic-standard/entities/thing.rb +2 -0
  45. data/lib/gamefic-standard/give.rb +15 -14
  46. data/lib/gamefic-standard/grammar/pronoun.rb +80 -80
  47. data/lib/gamefic-standard/introduction.rb +8 -0
  48. data/lib/gamefic-standard/modules/enterable.rb +2 -0
  49. data/lib/gamefic-standard/modules/lockable.rb +3 -1
  50. data/lib/gamefic-standard/modules/standardized.rb +10 -12
  51. data/lib/gamefic-standard/modules.rb +0 -1
  52. data/lib/gamefic-standard/queries.rb +7 -20
  53. data/lib/gamefic-standard/version.rb +1 -1
  54. data/lib/gamefic-standard.rb +26 -8
  55. data/spec-opal/spec_helper.rb +32 -0
  56. metadata +33 -13
  57. data/lib/gamefic-standard/modules/use.rb +0 -45
  58. data/lib/gamefic-standard/test.rb +0 -34
@@ -1,35 +1,39 @@
1
- Gamefic.script do
2
- respond :insert, Use.available, Use.available do |actor, thing, target|
3
- actor.tell "You can't put #{the thing} inside #{the target}."
4
- end
1
+ module Gamefic
2
+ module Standard
3
+ script do
4
+ respond :insert, available, available do |actor, thing, target|
5
+ actor.tell "You can't put #{the thing} inside #{the target}."
6
+ end
5
7
 
6
- respond :insert, Use.available, Use.available(Receptacle) do |actor, thing, receptacle|
7
- actor.execute :take, thing unless thing.parent == actor
8
- next unless thing.parent == actor
9
- thing.parent = receptacle
10
- actor.tell "You put #{the thing} in #{the receptacle}."
11
- end
8
+ respond :insert, available, available(Receptacle) do |actor, thing, receptacle|
9
+ actor.execute :take, thing unless thing.parent == actor
10
+ next unless thing.parent == actor
11
+ thing.parent = receptacle
12
+ actor.tell "You put #{the thing} in #{the receptacle}."
13
+ end
12
14
 
13
- respond :insert, Use.available, Use.available(Container) do |actor, _thing, container|
14
- if container.open?
15
- actor.proceed
16
- else
17
- actor.tell "#{The container} is closed."
18
- end
19
- end
15
+ respond :insert, available, available(Container) do |actor, _thing, container|
16
+ if container.open?
17
+ actor.proceed
18
+ else
19
+ actor.tell "#{The container} is closed."
20
+ end
21
+ end
20
22
 
21
- interpret "drop :item in :container", "insert :item :container"
22
- interpret "put :item in :container", "insert :item :container"
23
- interpret "place :item in :container", "insert :item :container"
24
- interpret "insert :item in :container", "insert :item :container"
23
+ interpret "drop :item in :container", "insert :item :container"
24
+ interpret "put :item in :container", "insert :item :container"
25
+ interpret "place :item in :container", "insert :item :container"
26
+ interpret "insert :item in :container", "insert :item :container"
25
27
 
26
- interpret "drop :item inside :container", "insert :item :container"
27
- interpret "put :item inside :container", "insert :item :container"
28
- interpret "place :item inside :container", "insert :item :container"
29
- interpret "insert :item inside :container", "insert :item :container"
28
+ interpret "drop :item inside :container", "insert :item :container"
29
+ interpret "put :item inside :container", "insert :item :container"
30
+ interpret "place :item inside :container", "insert :item :container"
31
+ interpret "insert :item inside :container", "insert :item :container"
30
32
 
31
- interpret "drop :item into :container", "insert :item :container"
32
- interpret "put :item into :container", "insert :item :container"
33
- interpret "place :item into :container", "insert :item :container"
34
- interpret "insert :item into :container", "insert :item :container"
33
+ interpret "drop :item into :container", "insert :item :container"
34
+ interpret "put :item into :container", "insert :item :container"
35
+ interpret "place :item into :container", "insert :item :container"
36
+ interpret "insert :item into :container", "insert :item :container"
37
+ end
38
+ end
35
39
  end
@@ -1,11 +1,15 @@
1
- Gamefic.script do
2
- respond :inventory do |actor|
3
- if actor.children.length > 0
4
- actor.tell "You are carrying #{actor.children.join_and}."
5
- else
6
- actor.tell "You aren't carrying anything."
1
+ module Gamefic
2
+ module Standard
3
+ script do
4
+ respond :inventory do |actor|
5
+ if actor.children.length > 0
6
+ actor.tell "You are carrying #{actor.children.join_and}."
7
+ else
8
+ actor.tell "You aren't carrying anything."
9
+ end
10
+ end
11
+
12
+ interpret "i", "inventory"
7
13
  end
8
14
  end
9
-
10
- interpret "i", "inventory"
11
15
  end
@@ -1,46 +1,50 @@
1
- Gamefic.script do
2
- respond :leave, Use.parent do |actor, thing|
3
- actor.tell "There's no way out of #{the thing}."
4
- end
1
+ module Gamefic
2
+ module Standard
3
+ script do
4
+ respond :leave, parent do |actor, thing|
5
+ actor.tell "There's no way out of #{the thing}."
6
+ end
5
7
 
6
- respond :leave, Use.parent(Enterable, :enterable?) do |actor, thing|
7
- actor.tell "You leave #{the thing}."
8
- actor.parent = thing.parent
9
- end
8
+ respond :leave, parent(Enterable, proc(&:enterable?)) do |actor, thing|
9
+ actor.tell "You leave #{the thing}."
10
+ actor.parent = thing.parent
11
+ end
10
12
 
11
- respond :leave, Use.parent(Supporter, :enterable?) do |actor, thing|
12
- actor.tell "You get off #{the thing}."
13
- actor.parent = thing.parent
14
- end
13
+ respond :leave, parent(Supporter, proc(&:enterable?)) do |actor, thing|
14
+ actor.tell "You get off #{the thing}."
15
+ actor.parent = thing.parent
16
+ end
15
17
 
16
- respond :leave, Use.room do |actor, room|
17
- portals = room.children.that_are(Portal)
18
- if portals.length == 0
19
- actor.tell "You don't see any obvious exits."
20
- elsif portals.length == 1
21
- actor.execute :go, portals[0]
22
- else
23
- actor.tell "I don't know which way you want to go: #{portals.join_or}."
24
- end
25
- end
18
+ respond :leave, room do |actor, room|
19
+ portals = room.children.that_are(Portal)
20
+ if portals.length == 0
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.join_or}."
26
+ end
27
+ end
26
28
 
27
- respond :leave do |actor|
28
- if actor.parent
29
- actor.execute :leave, actor.parent
30
- else
31
- actor.tell "You don't see any obvious exits."
32
- end
33
- end
29
+ respond :leave do |actor|
30
+ if actor.parent
31
+ actor.execute :leave, actor.parent
32
+ else
33
+ actor.tell "You don't see any obvious exits."
34
+ end
35
+ end
34
36
 
35
- respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
36
- actor.execute :open, container
37
- actor.proceed if container.open?
38
- end
37
+ respond :leave, parent(Container, proc(&:enterable?), proc(&:closed?)) do |actor, container|
38
+ actor.execute :open, container
39
+ actor.proceed if container.open?
40
+ end
39
41
 
40
- interpret "exit", "leave"
41
- interpret "exit :supporter", "leave :supporter"
42
- interpret "get on :supporter", "enter :supporter"
43
- interpret "get off :supporter", "leave :supporter"
44
- interpret "get out :container", "leave :container"
45
- interpret "get out of :container", "leave :container"
42
+ interpret "exit", "leave"
43
+ interpret "exit :supporter", "leave :supporter"
44
+ interpret "get on :supporter", "enter :supporter"
45
+ interpret "get off :supporter", "leave :supporter"
46
+ interpret "get out :container", "leave :container"
47
+ interpret "get out of :container", "leave :container"
48
+ end
49
+ end
46
50
  end
@@ -1,21 +1,25 @@
1
- Gamefic.script do
2
- respond :lock, Use.available do |actor, thing|
3
- actor.tell "You can't lock #{the thing}."
4
- end
1
+ module Gamefic
2
+ module Standard
3
+ script do
4
+ respond :lock, available do |actor, thing|
5
+ actor.tell "You can't lock #{the thing}."
6
+ end
5
7
 
6
- respond :lock, Use.available(Lockable, :has_lock_key?), Use.children do |actor, thing, key|
7
- if thing.lock_key == key
8
- thing.locked = true
9
- actor.tell "You lock ##{the thing} with #{the key}."
10
- else
11
- actor.tell "You can't lock #{the thing} with #{the key}."
12
- end
13
- end
8
+ respond :lock, available(Lockable, proc(&:has_lock_key?)), children do |actor, thing, key|
9
+ if thing.lock_key == key
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}."
14
+ end
15
+ end
14
16
 
15
- respond :lock, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
16
- actor.execute :take, key if key.parent != actor
17
- actor.proceed if key.parent == actor
18
- end
17
+ respond :lock, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
18
+ actor.execute :take, key if key.parent != actor
19
+ actor.proceed if key.parent == actor
20
+ end
19
21
 
20
- interpret "lock :container with :key", "lock :container :key"
22
+ interpret "lock :container with :key", "lock :container :key"
23
+ end
24
+ end
21
25
  end
@@ -1,112 +1,133 @@
1
- Gamefic.script do
2
- respond :look, Use.text(/^here$/i) do |actor, _|
3
- actor.execute :look, actor.room
4
- end
1
+ module Gamefic
2
+ module Standard
3
+ script do
4
+ respond :look do |actor|
5
+ actor.execute :look, actor.room
6
+ end
5
7
 
6
- respond :look, Use.itself do |actor, _|
7
- actor.tell actor.description
8
- actor.execute :inventory
9
- end
8
+ respond :look, myself do |actor, _|
9
+ actor.tell actor.description
10
+ actor.execute :inventory
11
+ end
10
12
 
11
- respond :look, Use.available(Thing) do |actor, thing|
12
- actor.tell thing.description
13
- thing.children.that_are(:attached?).that_are(:itemized?).each do |item|
14
- actor.tell "#{An item} is attached to #{the thing}."
15
- end
16
- end
13
+ respond :look, available(Thing) do |actor, thing|
14
+ actor.tell thing.description
15
+ thing.children.that_are(proc(&:attached?)).that_are(proc(&:itemized?)).each do |item|
16
+ actor.tell "#{An item} is attached to #{the thing}."
17
+ end
18
+ end
17
19
 
18
- respond :look, Use.available(Supporter) do |actor, thing|
19
- itemized = thing.children.that_are_not(:attached?).that_are(:itemized?)
20
- # If the supporter does not have a description but it does contain
21
- # itemized things, avoid saying there's nothing special about it.
22
- actor.proceed if thing.has_description? || itemized.empty?
23
- actor.tell "You see #{itemized.join_and} on #{the thing}." unless itemized.empty?
24
- end
20
+ respond :look, available(Supporter) do |actor, thing|
21
+ itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
22
+ # If the supporter does not have a description but it does contain
23
+ # itemized things, avoid saying there's nothing special about it.
24
+ actor.proceed if thing.has_description? || itemized.empty?
25
+ actor.tell "You see #{itemized.join_and} on #{the thing}." unless itemized.empty?
26
+ end
25
27
 
26
- respond :look, Use.available(Receptacle) do |actor, thing|
27
- actor.proceed
28
- if thing.accessible?
29
- itemized = thing.children.that_are_not(:attached?).that_are(:itemized?)
30
- actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
31
- end
32
- end
28
+ respond :look, available(Receptacle) do |actor, thing|
29
+ actor.proceed
30
+ if thing.accessible?
31
+ itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
32
+ actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
33
+ end
34
+ end
33
35
 
34
- respond :look, Use.parent(Supporter, :enterable?) do |actor, supporter|
35
- actor.proceed
36
- actor.tell "You are currently on #{the supporter}."
37
- end
36
+ respond :look, parent(Supporter, proc(&:enterable?)) do |actor, supporter|
37
+ actor.proceed
38
+ actor.tell "You are currently on #{the supporter}."
39
+ end
38
40
 
39
- respond :look, Use.available(Thing, Openable) do |actor, thing|
40
- actor.proceed
41
- actor.tell "#{The thing} is #{thing.open? ? 'open' : 'closed'}."
42
- end
41
+ respond :look, available(Thing, Openable) do |actor, thing|
42
+ actor.tell thing.description if thing.has_description?
43
+ actor.tell "#{The thing} is #{thing.open? ? 'open' : 'closed'}."
44
+ next if thing.closed? || thing.children.empty?
43
45
 
44
- respond :look, Use.room do |actor, room|
45
- actor.tell "<strong>#{room.name.cap_first}</strong>"
46
- actor.tell room.description if room.has_description?
47
- actor.execute :_itemize_room
48
- end
46
+ actor.tell "You see #{thing.children.join_and}."
47
+ end
49
48
 
50
- meta :_itemize_room do |actor|
51
- room = actor.room
52
- next if room.nil?
53
- with_locales = []
54
- chars = room.children.that_are(Character).that_are(:itemized?) - [actor]
55
- charsum = []
56
- chars.each do |char|
57
- if char.locale_description.nil?
58
- charsum.push char
59
- else
60
- with_locales.push char
49
+ respond :look, room do |actor, room|
50
+ actor.execute :_describe_room
61
51
  end
62
- end
63
- if charsum.length > 0
64
- actor.tell "#{charsum.join_and.cap_first} #{charsum.length == 1 ? 'is' : 'are'} here."
65
- end
66
- items = room.children.that_are(:itemized?) - [actor] - room.children.that_are(Character) - room.children.that_are(Portal)
67
- itemsum = []
68
- items.each do |item|
69
- if item.locale_description.nil?
70
- itemsum.push item
71
- else
72
- with_locales.push item
52
+
53
+ meta :_describe_room do |actor|
54
+ next unless actor.room
55
+
56
+ actor.tell "<strong>#{actor.room.name.cap_first}</strong>"
57
+ actor.tell actor.room.description if actor.room.has_description?
58
+ actor.execute :_itemize_room
73
59
  end
74
- end
75
- if itemsum.length > 0
76
- actor.tell "You see #{itemsum.join_and}."
77
- end
78
- with_locales.each { |entity|
79
- actor.tell entity.locale_description
80
- }
81
- if room.explicit_exits?
82
- portals = room.children.that_are(Portal).that_are(:itemized?)
83
- if portals.length > 0
84
- if portals.length == 1
85
- p = portals[0]
86
- actor.tell "There is an exit #{p.instruction}."
87
- else
88
- dirs = []
89
- portals.each do |p|
90
- dirs.push p.instruction
60
+
61
+ meta :_itemize_room do |actor|
62
+ room = actor.room
63
+ next unless room
64
+
65
+ with_locales = []
66
+ chars = room.children.that_are(Character).that_are(proc(&:itemized?)) - [actor]
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
74
+ end
75
+ if charsum.length > 0
76
+ actor.tell "#{charsum.join_and.cap_first} #{charsum.length == 1 ? 'is' : 'are'} here."
77
+ end
78
+ items = room.children.that_are(proc(&:itemized?)) - [actor] - room.children.that_are(Character) - room.children.that_are(Portal)
79
+ itemsum = []
80
+ items.each do |item|
81
+ if item.locale_description.nil?
82
+ itemsum.push item
83
+ else
84
+ with_locales.push item
91
85
  end
92
- actor.tell "There are exits #{dirs.join_and(', ')}."
86
+ end
87
+ if itemsum.length > 0
88
+ actor.tell "You see #{itemsum.join_and}."
89
+ end
90
+ with_locales.each { |entity|
91
+ actor.tell entity.locale_description
92
+ }
93
+ if room.explicit_exits?
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}."
99
+ else
100
+ dirs = []
101
+ portals.each do |p|
102
+ dirs.push p.instruction
103
+ 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
+ end
108
+ end
109
+ end
110
+ if actor.parent.is_a?(Supporter)
111
+ actor.tell "You are on #{the actor.parent}."
112
+ actor.parent.children.that_are_not(actor).each { |s|
113
+ actor.tell "#{A s} is on #{the actor.parent}."
114
+ }
93
115
  end
94
116
  end
95
- end
96
- if actor.parent.is_a?(Supporter)
97
- actor.tell "You are on #{the actor.parent}."
98
- actor.parent.children.that_are_not(actor).each { |s|
99
- actor.tell "#{A s} is on #{the actor.parent}."
100
- }
101
- end
102
- end
103
117
 
104
- interpret 'look around', 'look here'
105
- interpret 'look', 'look here'
106
- interpret 'l', 'look here'
118
+ interpret 'look around', 'look'
119
+ interpret 'look here', 'look'
120
+ interpret 'l', 'look'
107
121
 
108
- interpret 'look at :thing', 'look :thing'
109
- interpret 'l :thing', 'look :thing'
110
- interpret 'examine :thing', 'look :thing'
111
- interpret 'x :thing', 'look :thing'
122
+ interpret 'look at :thing', 'look :thing'
123
+ interpret 'look on :thing', 'look :thing'
124
+ interpret 'look under :thing', 'look :thing'
125
+ interpret 'look beneath :thing', 'look :thing'
126
+ interpret 'look around :thing', 'look :thing'
127
+ interpret 'l :thing', 'look :thing'
128
+ interpret 'examine :thing', 'look :thing'
129
+ interpret 'x :thing', 'look :thing'
130
+ interpret 'inspect :thing', 'look :thing'
131
+ end
132
+ end
112
133
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gamefic
4
+ module Standard
5
+ script do
6
+ respond :move, Thing do |actor, thing|
7
+ if thing.portable?
8
+ actor.tell "Maybe you want to <em>take</em> it?"
9
+ else
10
+ actor.tell "You can't move #{the thing}."
11
+ end
12
+ end
13
+
14
+ respond :move, children(Thing) do |actor, thing|
15
+ actor.tell "You're already carrying #{the thing}."
16
+ end
17
+
18
+ interpret "push :thing", "move :thing"
19
+ interpret "pull :thing", "move :thing"
20
+ interpret "drag :thing", "move :thing"
21
+ interpret "lift :thing", "move :thing"
22
+ end
23
+ end
24
+ end
@@ -1,23 +1,24 @@
1
- Gamefic.script do
2
- meta nil, Gamefic::Query::Text.new do |actor, string|
3
- words = string.split_words
4
- # @todo There should probably be an Active#verbs or Active#command_words method
5
- list = actor.playbooks.flat_map(&:syntaxes).flat_map(&:first_word)
6
- if list.include?(words[0])
1
+ Gamefic::Standard.script do
2
+ meta nil, plaintext do |actor, string|
3
+ words = string.keywords
4
+ list = actor.epic.synonyms
5
+ if list.include?(words[0]&.to_sym)
7
6
  if words.length > 1
8
- found = Gamefic::Query::Available.new.resolve(actor, words[1..-1].join(' ')).objects
7
+ found = []
8
+ avail = available(ambiguous: true)
9
+ result = avail.query(actor, words[1..-1].join(' '))
10
+ until result.match.nil?
11
+ found.concat result.match
12
+ result = avail.query(actor, result.remainder)
13
+ end
9
14
  if found.empty?
10
- actions = []
11
- actor.playbooks.reverse.each { |p| actions.concat p.actions_for(words[0].to_sym) }
12
- if actions.any? { |a| a.queries.one? && !a.queries.first.is_a?(Gamefic::Query::Text) }
13
- actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
14
- else
15
- actor.tell %(I recognize "#{words[0]}" as a verb but could not understand the rest of your sentence.)
16
- end
15
+ actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
16
+ elsif result.remainder != ''
17
+ actor.tell %(I recognize "#{words[0]}" as a verb but was confused by "#{result.remainder}.")
17
18
  elsif found.one?
18
19
  actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
19
20
  else
20
- actor.tell %(I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
21
+ actor.tell %(I recognize "#{words[0]}" but I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
21
22
  end
22
23
  else
23
24
  actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
@@ -1,9 +1,9 @@
1
- Gamefic.script do
2
- respond :open, Use.available do |actor, thing|
1
+ Gamefic::Standard.script do
2
+ respond :open, available do |actor, thing|
3
3
  actor.tell "You can't open #{the thing}."
4
4
  end
5
5
 
6
- respond :open, Use.available(Openable) do |actor, thing|
6
+ respond :open, available(Openable) do |actor, thing|
7
7
  if thing.open?
8
8
  actor.tell "#{The thing} is already open."
9
9
  else
@@ -12,7 +12,7 @@ Gamefic.script do
12
12
  end
13
13
  end
14
14
 
15
- respond :open, Use.available(Lockable) do |actor, thing|
15
+ respond :open, available(Lockable) do |actor, thing|
16
16
  if thing.locked?
17
17
  actor.tell "#{The thing} is locked."
18
18
  else
@@ -20,7 +20,7 @@ Gamefic.script do
20
20
  end
21
21
  end
22
22
 
23
- respond :open, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
23
+ respond :open, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
24
24
  actor.execute :unlock, thing, key
25
25
  actor.execute :open, thing if thing.unlocked?
26
26
  end
@@ -1,16 +1,16 @@
1
- Gamefic.script do
2
- respond :place, Use.children, Use.reachable do |actor, thing, supporter|
1
+ Gamefic::Standard.script do
2
+ respond :place, children, available do |actor, thing, supporter|
3
3
  actor.tell "You can't put #{the thing} on #{the supporter}."
4
4
  end
5
5
 
6
- respond :place, Use.available, Use.available(Supporter) do |actor, thing, supporter|
6
+ respond :place, available, available(Supporter) do |actor, thing, supporter|
7
7
  actor.execute :take, thing unless thing.parent == actor
8
8
  next unless thing.parent == actor
9
9
  thing.parent = supporter
10
10
  actor.tell "You put #{the thing} on #{the supporter}."
11
11
  end
12
12
 
13
- respond :place, Use.children, Use.reachable(Supporter) do |actor, thing, supporter|
13
+ respond :place, children, available(Supporter) do |actor, thing, supporter|
14
14
  thing.parent = supporter
15
15
  actor.tell "You put #{the thing} on #{the supporter}."
16
16
  end
@@ -1,14 +1,10 @@
1
- Gamefic.script do
2
- confirm_quit = yes_or_no do |actor, data|
3
- if data.yes?
4
- actor.cue default_conclusion
5
- else
6
- actor.cue default_scene
7
- end
1
+ Gamefic::Standard.script do
2
+ yes_or_no :standard_confirm_quit do |actor, props|
3
+ actor.cue :default_conclusion if props.yes?
8
4
  end
9
5
 
10
6
  meta :quit do |actor|
11
7
  actor.tell "Are you sure you want to quit?"
12
- actor.cue confirm_quit
8
+ actor.cue :standard_confirm_quit
13
9
  end
14
10
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gamefic::Standard.script do
4
+ meta :repeat do |actor|
5
+ if actor.last_input && !actor.last_input.empty?
6
+ actor.tell "Repeating <kbd>\"#{actor.last_input}\"</kbd>..."
7
+ actor.queue.push actor.last_input
8
+ else
9
+ actor.tell "You don't have a previous command to repeat right now."
10
+ end
11
+ end
12
+
13
+ interpret 'again', 'repeat'
14
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gamefic::Standard.script do
4
+ # Save, Restore, and Undo need to be handled by the game client. They have
5
+ # default implementations here to make them available in help.
6
+
7
+ meta :save do |actor|
8
+ actor.tell "<kbd>Save</kbd> is not available."
9
+ end
10
+
11
+ meta :restore do |actor|
12
+ actor.tell "<kbd>Restore</kbd> is not available."
13
+ end
14
+
15
+ meta :undo do |actor|
16
+ actor.tell "<kbd>Undo</kbd> is not available."
17
+ end
18
+ end