gamefic-standard 3.2.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Rakefile +11 -5
- data/gamefic-standard.gemspec +15 -13
- data/lib/gamefic/standard/actions/attack.rb +32 -0
- data/lib/gamefic/standard/actions/close.rb +24 -0
- data/lib/gamefic/standard/actions/drop.rb +39 -0
- data/lib/gamefic/standard/actions/enter.rb +34 -0
- data/lib/gamefic/standard/actions/give.rb +38 -0
- data/lib/gamefic/standard/actions/go.rb +63 -0
- data/lib/gamefic/standard/actions/insert.rb +53 -0
- data/lib/gamefic/standard/actions/inventory.rb +20 -0
- data/lib/gamefic/standard/actions/leave.rb +57 -0
- data/lib/gamefic/standard/actions/lock.rb +31 -0
- data/lib/gamefic/standard/actions/look.rb +149 -0
- data/lib/gamefic/standard/actions/mount.rb +29 -0
- data/lib/gamefic/standard/actions/move.rb +28 -0
- data/lib/gamefic/standard/actions/nil.rb +37 -0
- data/lib/gamefic/standard/actions/open.rb +39 -0
- data/lib/gamefic/standard/actions/place.rb +39 -0
- data/lib/gamefic/standard/actions/pronouns.rb +34 -0
- data/lib/gamefic/standard/actions/quit.rb +24 -0
- data/lib/gamefic/standard/actions/repeat.rb +28 -0
- data/lib/gamefic/standard/actions/save-restore-undo.rb +26 -0
- data/lib/gamefic/standard/actions/search.rb +36 -0
- data/lib/gamefic/standard/actions/take.rb +54 -0
- data/lib/gamefic/standard/actions/talk.rb +51 -0
- data/lib/gamefic/standard/actions/unlock.rb +35 -0
- data/lib/gamefic/standard/actions/wait.rb +17 -0
- data/lib/gamefic/standard/actions.rb +57 -0
- data/lib/gamefic/standard/articles.rb +52 -0
- data/lib/gamefic/standard/enterable.rb +13 -0
- data/lib/gamefic/standard/entities/character.rb +14 -0
- data/lib/gamefic/standard/entities/container.rb +16 -0
- data/lib/gamefic/standard/entities/door.rb +46 -0
- data/lib/gamefic/standard/entities/fixture.rb +8 -0
- data/lib/gamefic/standard/entities/item.rb +11 -0
- data/lib/gamefic/standard/entities/portal.rb +50 -0
- data/lib/gamefic/standard/entities/receptacle.rb +9 -0
- data/lib/gamefic/standard/entities/room.rb +55 -0
- data/lib/gamefic/standard/entities/rubble.rb +16 -0
- data/lib/gamefic/standard/entities/scenery.rb +13 -0
- data/lib/gamefic/standard/entities/supporter.rb +9 -0
- data/lib/gamefic/standard/entities/thing.rb +9 -0
- data/lib/gamefic/standard/entities.rb +18 -0
- data/lib/gamefic/standard/introduction.rb +18 -0
- data/lib/gamefic/standard/lockable.rb +44 -0
- data/lib/gamefic/standard/openable.rb +33 -0
- data/lib/gamefic/standard/pathfinder.rb +82 -0
- data/lib/gamefic/standard/queries.rb +24 -0
- data/lib/gamefic/standard/standardized.rb +65 -0
- data/lib/{gamefic-standard → gamefic/standard}/version.rb +1 -1
- data/lib/gamefic/standard.rb +32 -0
- data/lib/gamefic-standard.rb +1 -27
- metadata +83 -58
- data/lib/gamefic-standard/actions/attack.rb +0 -28
- data/lib/gamefic-standard/actions/close.rb +0 -18
- data/lib/gamefic-standard/actions/drop.rb +0 -24
- data/lib/gamefic-standard/actions/enter.rb +0 -36
- data/lib/gamefic-standard/actions/go.rb +0 -59
- data/lib/gamefic-standard/actions/insert.rb +0 -39
- data/lib/gamefic-standard/actions/inventory.rb +0 -15
- data/lib/gamefic-standard/actions/leave.rb +0 -50
- data/lib/gamefic-standard/actions/lock.rb +0 -25
- data/lib/gamefic-standard/actions/look.rb +0 -133
- data/lib/gamefic-standard/actions/move.rb +0 -24
- data/lib/gamefic-standard/actions/nil.rb +0 -60
- data/lib/gamefic-standard/actions/open.rb +0 -29
- data/lib/gamefic-standard/actions/place.rb +0 -24
- data/lib/gamefic-standard/actions/pronouns.rb +0 -28
- data/lib/gamefic-standard/actions/quit.rb +0 -10
- data/lib/gamefic-standard/actions/repeat.rb +0 -14
- data/lib/gamefic-standard/actions/save-restore-undo.rb +0 -18
- data/lib/gamefic-standard/actions/search.rb +0 -26
- data/lib/gamefic-standard/actions/take.rb +0 -40
- data/lib/gamefic-standard/actions/talk.rb +0 -37
- data/lib/gamefic-standard/actions/unlock.rb +0 -25
- data/lib/gamefic-standard/actions/wait.rb +0 -7
- data/lib/gamefic-standard/actions.rb +0 -23
- data/lib/gamefic-standard/articles.rb +0 -42
- data/lib/gamefic-standard/entities/character.rb +0 -2
- data/lib/gamefic-standard/entities/container.rb +0 -8
- data/lib/gamefic-standard/entities/door.rb +0 -42
- data/lib/gamefic-standard/entities/fixture.rb +0 -4
- data/lib/gamefic-standard/entities/item.rb +0 -7
- data/lib/gamefic-standard/entities/portal.rb +0 -46
- data/lib/gamefic-standard/entities/receptacle.rb +0 -5
- data/lib/gamefic-standard/entities/room.rb +0 -46
- data/lib/gamefic-standard/entities/rubble.rb +0 -12
- data/lib/gamefic-standard/entities/scenery.rb +0 -9
- data/lib/gamefic-standard/entities/supporter.rb +0 -5
- data/lib/gamefic-standard/entities/thing.rb +0 -9
- data/lib/gamefic-standard/entities.rb +0 -12
- 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/introduction.rb +0 -8
- 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/lib/gamefic-standard/pathfinder.rb +0 -62
- data/lib/gamefic-standard/queries.rb +0 -12
- data/spec-opal/spec_helper.rb +0 -32
- /data/lib/{gamefic-standard → gamefic/standard}/direction.rb +0 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Mount
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :mount, siblings do |actor, thing|
|
10
|
+
actor.tell "#{The thing} can't accommodate you."
|
11
|
+
end
|
12
|
+
|
13
|
+
respond :mount, siblings(Supporter, proc(&:enterable?)) do |actor, supporter|
|
14
|
+
actor.put supporter, :on
|
15
|
+
actor.tell "You get on #{the supporter}."
|
16
|
+
end
|
17
|
+
|
18
|
+
respond :mount, parent(Supporter) do |actor, supporter|
|
19
|
+
actor.tell "You're already on #{the supporter}."
|
20
|
+
end
|
21
|
+
|
22
|
+
interpret 'get on :thing', 'mount :thing'
|
23
|
+
interpret 'sit on :thing', 'mount :thing'
|
24
|
+
interpret 'lie on :thing', 'mount :thing'
|
25
|
+
interpret 'stand on :thing', 'mount :thing'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
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
|
15
|
+
end
|
16
|
+
|
17
|
+
respond :move, children(Thing) do |actor, thing|
|
18
|
+
actor.tell "You're already carrying #{the thing}."
|
19
|
+
end
|
20
|
+
|
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
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
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
|
+
if actor.can?(words[0])
|
14
|
+
if words.length > 1
|
15
|
+
possible = [actor] + available.span(actor)
|
16
|
+
result = Scanner.scan(possible, words[1..-1].join(' '))
|
17
|
+
if result.matched.empty?
|
18
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
|
19
|
+
elsif result.remainder != ''
|
20
|
+
actor.tell %(I recognize "#{string.sub(/#{result.remainder}$/,
|
21
|
+
'').strip}" as a command but was confused by "#{result.remainder}.")
|
22
|
+
elsif result.matched.one?
|
23
|
+
actor.tell %(I recognize "#{words[0]}" and "#{result.matched.first.name}" but could not understand them together.)
|
24
|
+
else
|
25
|
+
actor.tell %(I recognize "#{words[0]}" but I'm not sure if "#{words[1..-1].join(' ')}" means #{result.matched.map(&:definitely).join_or}.)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Open
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :open, available do |actor, thing|
|
10
|
+
actor.tell "You can't open #{the thing}."
|
11
|
+
end
|
12
|
+
|
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
|
34
|
+
|
35
|
+
interpret 'open :thing with :key', 'open :thing :key'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Place
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :place, children, available do |actor, thing, supporter|
|
10
|
+
actor.tell "You can't put #{the thing} on #{the supporter}."
|
11
|
+
end
|
12
|
+
|
13
|
+
respond :place, available, available(Supporter) do |actor, thing, supporter|
|
14
|
+
actor.execute :take, thing unless thing.parent == actor
|
15
|
+
next unless thing.parent == actor
|
16
|
+
|
17
|
+
thing.put supporter, :on
|
18
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
19
|
+
end
|
20
|
+
|
21
|
+
respond :place, children, available(Supporter) do |actor, thing, supporter|
|
22
|
+
thing.put supporter, :on
|
23
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
24
|
+
end
|
25
|
+
|
26
|
+
respond :place, children, room do |actor, thing|
|
27
|
+
actor.execute :drop, thing
|
28
|
+
end
|
29
|
+
|
30
|
+
interpret 'put :thing on :supporter', 'place :thing :supporter'
|
31
|
+
interpret 'put :thing down on :supporter', 'place :thing :supporter'
|
32
|
+
interpret 'set :thing on :supporter', 'place :thing :supporter'
|
33
|
+
interpret 'set :thing down on :supporter', 'place :thing :supporter'
|
34
|
+
interpret 'drop :thing on :supporter', 'place :thing :supporter'
|
35
|
+
interpret 'place :thing on :supporter', 'place :thing :supporter'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Pronouns
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
introduction do |actor|
|
10
|
+
actor[:standard_pronoun_targets] = []
|
11
|
+
end
|
12
|
+
|
13
|
+
after_command do |actor, command|
|
14
|
+
next unless command.verb
|
15
|
+
|
16
|
+
actor[:standard_pronoun_targets].replace command.arguments.that_are(Thing)
|
17
|
+
end
|
18
|
+
|
19
|
+
meta nil, plaintext do |actor, string|
|
20
|
+
keywords = string.keywords
|
21
|
+
next actor.proceed unless actor.can?(keywords.first)
|
22
|
+
|
23
|
+
xlation = keywords[1..].map do |word|
|
24
|
+
next word unless %w[him her it them].include?(word)
|
25
|
+
|
26
|
+
actor[:standard_pronoun_targets].find { |obj| obj.objective == word }
|
27
|
+
end
|
28
|
+
next actor.proceed if xlation.any?(&:nil?) || xlation.that_are(Thing).empty?
|
29
|
+
actor.perform "#{keywords[0]} #{xlation.join(' ')}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Quit
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
ConfirmQuit = yes_or_no do
|
10
|
+
on_start do |actor|
|
11
|
+
actor.tell 'Are you sure you want to quit?'
|
12
|
+
end
|
13
|
+
on_finish do |actor, props|
|
14
|
+
actor.cue default_conclusion if props.yes?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
meta :quit do |actor|
|
19
|
+
actor.cue ConfirmQuit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Repeat
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
after_command do |actor, command|
|
10
|
+
next if command.verb == :repeat || command.input.nil?
|
11
|
+
|
12
|
+
actor[:standard_repeatable_command] = command.input
|
13
|
+
end
|
14
|
+
|
15
|
+
meta :repeat do |actor|
|
16
|
+
if actor[:standard_repeatable_command]
|
17
|
+
actor.tell "Repeating <kbd>\"#{actor[:standard_repeatable_command]}\"</kbd>..."
|
18
|
+
actor.perform actor[:standard_repeatable_command]
|
19
|
+
else
|
20
|
+
actor.tell "You don't have a previous command to repeat right now."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
interpret 'again', 'repeat'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module SaveRestoreUndo
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
# Save, Restore, and Undo need to be handled by the game client. They have
|
10
|
+
# default implementations here to make them available in help.
|
11
|
+
|
12
|
+
meta :save do |actor|
|
13
|
+
actor.tell '<kbd>Save</kbd> is not available.'
|
14
|
+
end
|
15
|
+
|
16
|
+
meta :restore do |actor|
|
17
|
+
actor.tell '<kbd>Restore</kbd> is not available.'
|
18
|
+
end
|
19
|
+
|
20
|
+
meta :undo do |actor|
|
21
|
+
actor.tell '<kbd>Undo</kbd> is not available.'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Search
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :search, available(Thing) do |actor, thing|
|
10
|
+
actor.execute :look, thing
|
11
|
+
end
|
12
|
+
|
13
|
+
respond :search, available(Receptacle) do |actor, thing|
|
14
|
+
itemized = thing.accessible.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
|
15
|
+
if itemized.empty?
|
16
|
+
actor.tell "There's nothing inside #{the thing}."
|
17
|
+
else
|
18
|
+
actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
respond :search, available(Container, proc(&:closed?)) do |actor, container|
|
23
|
+
actor.execute :open, container
|
24
|
+
if container.open?
|
25
|
+
actor.proceed
|
26
|
+
else
|
27
|
+
actor.tell "You can't see inside #{the container}."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
interpret 'look inside :thing', 'search :thing'
|
32
|
+
interpret 'look in :thing', 'search :thing'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Take
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :take, available do |actor, thing|
|
10
|
+
if thing.parent == actor
|
11
|
+
actor.tell "You're already carrying #{the thing}."
|
12
|
+
elsif thing.portable?
|
13
|
+
if actor.parent != thing.parent
|
14
|
+
actor.tell "You take #{the thing} from #{the thing.parent}."
|
15
|
+
else
|
16
|
+
actor.tell "You take #{the thing}."
|
17
|
+
end
|
18
|
+
thing.parent = actor
|
19
|
+
else
|
20
|
+
actor.tell "You can't take #{the thing}."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
respond :take, available(proc(&:attached?)) do |actor, thing|
|
25
|
+
actor.tell "#{The thing} is attached to #{the thing.parent}."
|
26
|
+
end
|
27
|
+
|
28
|
+
respond :take, available(Rubble) do |actor, rubble|
|
29
|
+
actor.tell "You don't have any use for #{the rubble}."
|
30
|
+
end
|
31
|
+
|
32
|
+
respond :take, plaintext(/^(all|everything)$/) do |actor, _all|
|
33
|
+
items = Gamefic::Query::Family.new
|
34
|
+
.span(actor)
|
35
|
+
.select(&:portable?)
|
36
|
+
.reject { |item| actor.flatten.include?(item) }
|
37
|
+
if items.empty?
|
38
|
+
actor.tell "You don't see anything you can carry."
|
39
|
+
else
|
40
|
+
items.each { |item| actor.execute :take, item }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
interpret 'get :thing', 'take :thing'
|
45
|
+
interpret 'pick up :thing', 'take :thing'
|
46
|
+
interpret 'pick :thing up', 'take :thing'
|
47
|
+
interpret 'carry :thing', 'take :thing'
|
48
|
+
interpret 'gather :thing', 'take :thing'
|
49
|
+
interpret 'hold :thing', 'take :thing'
|
50
|
+
interpret 'collect :thing', 'take :thing'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Talk
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :talk do |actor|
|
10
|
+
actor.execute :talk, actor
|
11
|
+
end
|
12
|
+
|
13
|
+
respond :talk, myself do |actor, _yourself|
|
14
|
+
actor.tell 'You talk to yourself.'
|
15
|
+
end
|
16
|
+
|
17
|
+
respond :talk, available do |actor, _thing|
|
18
|
+
actor.tell 'Nothing happens.'
|
19
|
+
end
|
20
|
+
|
21
|
+
respond :talk, Character do |actor, character|
|
22
|
+
actor.tell "#{The character} has nothing to say."
|
23
|
+
end
|
24
|
+
|
25
|
+
respond :talk, available, plaintext do |actor, thing, _text|
|
26
|
+
actor.execute :talk, thing
|
27
|
+
end
|
28
|
+
|
29
|
+
respond :talk, Character, plaintext do |actor, character, _text|
|
30
|
+
actor.execute :talk, character
|
31
|
+
end
|
32
|
+
|
33
|
+
interpret 'talk to :character', 'talk :character'
|
34
|
+
interpret 'talk to :character about :subject', 'talk :character :subject'
|
35
|
+
interpret 'ask :character :subject', 'talk :character :subject'
|
36
|
+
interpret 'ask :character about :subject', 'talk :character :subject'
|
37
|
+
interpret 'tell :character :subject', 'talk :character :subject'
|
38
|
+
interpret 'tell :character about :subject', 'talk :character :subject'
|
39
|
+
interpret 'ask :character for :subject', 'talk :character :subject'
|
40
|
+
interpret 'speak :character', 'talk :character'
|
41
|
+
interpret 'speak to :character', 'talk :character'
|
42
|
+
interpret 'speak :character :subject', 'talk :character :subject'
|
43
|
+
interpret 'speak :character about :subject', 'talk :character :subject'
|
44
|
+
interpret 'speak to :character about :subject', 'talk :character :subject'
|
45
|
+
interpret 'speak to :character :subject', 'talk :character :subject'
|
46
|
+
interpret 'discuss :subject :character', 'talk :character :subject'
|
47
|
+
interpret 'discuss :subject with :character', 'talk :character :subject'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Unlock
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :unlock, available(Lockable) do |actor, thing|
|
10
|
+
if thing.has_lock_key? && actor.children.include?(thing.lock_key)
|
11
|
+
actor.execute :unlock, thing, thing.lock_key
|
12
|
+
else
|
13
|
+
actor.tell "You can't unlock #{the thing}."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
respond :unlock, available(Lockable, proc(&:has_lock_key?)), children do |actor, thing, key|
|
18
|
+
if thing.lock_key == key
|
19
|
+
thing.locked = false
|
20
|
+
actor.tell "You unlock #{the thing} with #{the key}."
|
21
|
+
else
|
22
|
+
actor.tell "You can't unlock #{the thing} with #{the key}."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
respond :unlock, available(Lockable, proc(&:has_lock_key?)), available do |actor, _thing, key|
|
27
|
+
actor.execute :take, key if key.parent != actor
|
28
|
+
actor.proceed if key.parent == actor
|
29
|
+
end
|
30
|
+
|
31
|
+
interpret 'unlock :container with :key', 'unlock :container :key'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
module Actions
|
6
|
+
module Wait
|
7
|
+
extend Gamefic::Scriptable
|
8
|
+
|
9
|
+
respond :wait do |actor|
|
10
|
+
actor.tell 'Time passes.'
|
11
|
+
end
|
12
|
+
|
13
|
+
interpret 'z', 'wait'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'gamefic/standard/actions/nil'
|
2
|
+
require 'gamefic/standard/actions/attack'
|
3
|
+
require 'gamefic/standard/actions/drop'
|
4
|
+
require 'gamefic/standard/actions/enter'
|
5
|
+
require 'gamefic/standard/actions/mount'
|
6
|
+
require 'gamefic/standard/actions/open'
|
7
|
+
require 'gamefic/standard/actions/close'
|
8
|
+
require 'gamefic/standard/actions/lock'
|
9
|
+
require 'gamefic/standard/actions/unlock'
|
10
|
+
require 'gamefic/standard/actions/go'
|
11
|
+
require 'gamefic/standard/actions/insert'
|
12
|
+
require 'gamefic/standard/actions/inventory'
|
13
|
+
require 'gamefic/standard/actions/leave'
|
14
|
+
require 'gamefic/standard/actions/look'
|
15
|
+
require 'gamefic/standard/actions/search'
|
16
|
+
require 'gamefic/standard/actions/place'
|
17
|
+
require 'gamefic/standard/actions/quit'
|
18
|
+
require 'gamefic/standard/actions/take'
|
19
|
+
require 'gamefic/standard/actions/move'
|
20
|
+
require 'gamefic/standard/actions/talk'
|
21
|
+
require 'gamefic/standard/actions/wait'
|
22
|
+
require 'gamefic/standard/actions/give'
|
23
|
+
require 'gamefic/standard/actions/repeat'
|
24
|
+
require 'gamefic/standard/actions/save-restore-undo'
|
25
|
+
require 'gamefic/standard/actions/pronouns'
|
26
|
+
|
27
|
+
module Gamefic
|
28
|
+
module Standard
|
29
|
+
module Actions
|
30
|
+
include Nil
|
31
|
+
include Attack
|
32
|
+
include Drop
|
33
|
+
include Enter
|
34
|
+
include Open
|
35
|
+
include Close
|
36
|
+
include Lock
|
37
|
+
include Unlock
|
38
|
+
include Go
|
39
|
+
include Insert
|
40
|
+
include Inventory
|
41
|
+
include Leave
|
42
|
+
include Look
|
43
|
+
include Search
|
44
|
+
include Place
|
45
|
+
include Quit
|
46
|
+
include Take
|
47
|
+
include Move
|
48
|
+
include Talk
|
49
|
+
include Wait
|
50
|
+
include Give
|
51
|
+
include Repeat
|
52
|
+
include SaveRestoreUndo
|
53
|
+
include Pronouns
|
54
|
+
include Gamefic::What
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
# Methods for adding definite and indefinite articles to entity names.
|
6
|
+
#
|
7
|
+
module Articles
|
8
|
+
extend Gamefic::Scriptable
|
9
|
+
|
10
|
+
# Get a name for the entity with an indefinite article (unless the entity
|
11
|
+
# has a proper name).
|
12
|
+
#
|
13
|
+
# @param entity [Gamefic::Entity]
|
14
|
+
# @return [String]
|
15
|
+
def a(entity)
|
16
|
+
entity.indefinitely
|
17
|
+
end
|
18
|
+
alias an a
|
19
|
+
|
20
|
+
# Get a name for the entity with a definite article (unless the entity has
|
21
|
+
# a proper name).
|
22
|
+
#
|
23
|
+
# @param entity [Gamefic::Entity]
|
24
|
+
# @return [String]
|
25
|
+
def the(entity)
|
26
|
+
entity.definitely
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get a capitalized name for the entity with an indefinite article (unless
|
30
|
+
# the entity has a proper name).
|
31
|
+
#
|
32
|
+
# @param entity [Gamefic::Entity]
|
33
|
+
# @return [String]
|
34
|
+
def a_(entity)
|
35
|
+
entity.indefinitely.cap_first
|
36
|
+
end
|
37
|
+
alias an_ a_
|
38
|
+
alias A a_
|
39
|
+
alias An a_
|
40
|
+
|
41
|
+
# Get a capitalized name for the entity with a definite article (unless
|
42
|
+
# the entity has a proper name).
|
43
|
+
#
|
44
|
+
# @param entity [Gamefic::Entity]
|
45
|
+
# @return [String]
|
46
|
+
def the_(entity)
|
47
|
+
entity.definitely.cap_first
|
48
|
+
end
|
49
|
+
alias The the_
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module Standard
|
5
|
+
# An openable and lockable receptacle.
|
6
|
+
#
|
7
|
+
class Container < Receptacle
|
8
|
+
include Gamefic::Standard::Openable
|
9
|
+
include Gamefic::Standard::Lockable
|
10
|
+
|
11
|
+
def accessible
|
12
|
+
open? ? super : []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|