gamefic-standard 3.3.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Rakefile +6 -3
- data/gamefic-standard.gemspec +4 -4
- data/lib/{gamefic-standard → gamefic/standard}/actions/drop.rb +2 -2
- data/lib/{gamefic-standard → gamefic/standard}/actions/enter.rb +0 -8
- data/lib/gamefic/standard/actions/give.rb +38 -0
- data/lib/{gamefic-standard → gamefic/standard}/actions/lock.rb +15 -3
- data/lib/gamefic/standard/actions/look.rb +149 -0
- data/lib/gamefic/standard/actions/mount.rb +29 -0
- data/lib/gamefic/standard/actions/nil.rb +37 -0
- data/lib/{gamefic-standard → gamefic/standard}/actions/place.rb +2 -2
- data/lib/{gamefic-standard → gamefic/standard}/actions/pronouns.rb +5 -7
- data/lib/gamefic/standard/actions/quit.rb +24 -0
- data/lib/gamefic/standard/actions/repeat.rb +28 -0
- data/lib/{gamefic-standard → gamefic/standard}/actions/search.rb +9 -9
- data/lib/{gamefic-standard → gamefic/standard}/actions/take.rb +2 -1
- data/lib/{gamefic-standard → gamefic/standard}/actions/talk.rb +2 -2
- data/lib/{gamefic-standard → gamefic/standard}/actions/unlock.rb +6 -2
- data/lib/gamefic/standard/actions.rb +57 -0
- data/lib/{gamefic-standard → gamefic/standard}/articles.rb +2 -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 +61 -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 → gamefic/standard}/lockable.rb +8 -0
- data/lib/{gamefic-standard → gamefic/standard}/openable.rb +2 -2
- data/lib/gamefic/standard/queries.rb +24 -0
- data/lib/{gamefic-standard → gamefic/standard}/version.rb +1 -1
- data/lib/gamefic/standard.rb +32 -0
- data/lib/gamefic-standard.rb +1 -34
- metadata +59 -57
- data/lib/gamefic-standard/actions/give.rb +0 -41
- data/lib/gamefic-standard/actions/look.rb +0 -152
- data/lib/gamefic-standard/actions/nil.rb +0 -70
- data/lib/gamefic-standard/actions/quit.rb +0 -20
- data/lib/gamefic-standard/actions/repeat.rb +0 -22
- data/lib/gamefic-standard/actions.rb +0 -56
- data/lib/gamefic-standard/entities/character.rb +0 -5
- 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 -61
- 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 -5
- data/lib/gamefic-standard/entities.rb +0 -12
- data/lib/gamefic-standard/queries.rb +0 -12
- /data/lib/{gamefic-standard → gamefic/standard}/actions/attack.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/close.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/go.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/insert.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/inventory.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/leave.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/move.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/open.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/save-restore-undo.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/actions/wait.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/direction.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/enterable.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/introduction.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/pathfinder.rb +0 -0
- /data/lib/{gamefic-standard → gamefic/standard}/standardized.rb +0 -0
@@ -1,152 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gamefic
|
4
|
-
module Standard
|
5
|
-
module Actions
|
6
|
-
module Look
|
7
|
-
extend Gamefic::Scriptable
|
8
|
-
|
9
|
-
respond :look do |actor|
|
10
|
-
actor.execute :look, actor.room
|
11
|
-
end
|
12
|
-
|
13
|
-
respond :look, myself do |actor, _|
|
14
|
-
actor.tell actor.description
|
15
|
-
actor.execute :inventory
|
16
|
-
end
|
17
|
-
|
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
|
24
|
-
|
25
|
-
respond :look, available(Supporter) do |actor, thing|
|
26
|
-
itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
|
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?
|
31
|
-
end
|
32
|
-
|
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?
|
37
|
-
|
38
|
-
itemized = thing.children.that_are_not(actor, proc(&:attached?)).that_are(proc(&:itemized?))
|
39
|
-
next if itemized.empty?
|
40
|
-
|
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
|
47
|
-
|
48
|
-
respond :look, parent(Supporter, proc(&:enterable?)) do |actor, supporter|
|
49
|
-
actor.proceed
|
50
|
-
actor.tell "You are currently on #{the supporter}."
|
51
|
-
end
|
52
|
-
|
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?
|
57
|
-
|
58
|
-
actor.tell "You see #{thing.children.join_and}."
|
59
|
-
end
|
60
|
-
|
61
|
-
respond :look, room do |actor, _room|
|
62
|
-
actor.execute :_describe_room
|
63
|
-
end
|
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
|
71
|
-
end
|
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
|
86
|
-
end
|
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
|
95
|
-
else
|
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(', ')}."
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
actor.execute :_look_parent_from_room
|
122
|
-
end
|
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
|
134
|
-
end
|
135
|
-
|
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
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,70 +0,0 @@
|
|
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
|
-
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
|
63
|
-
else
|
64
|
-
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gamefic
|
4
|
-
module Standard
|
5
|
-
module Actions
|
6
|
-
module Quit
|
7
|
-
extend Gamefic::Scriptable
|
8
|
-
|
9
|
-
yes_or_no :standard_confirm_quit do |actor, props|
|
10
|
-
actor.cue :default_conclusion if props.yes?
|
11
|
-
end
|
12
|
-
|
13
|
-
meta :quit do |actor|
|
14
|
-
actor.tell 'Are you sure you want to quit?'
|
15
|
-
actor.cue :standard_confirm_quit
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gamefic
|
4
|
-
module Standard
|
5
|
-
module Actions
|
6
|
-
module Repeat
|
7
|
-
extend Gamefic::Scriptable
|
8
|
-
|
9
|
-
meta :repeat do |actor|
|
10
|
-
if actor.last_input && !actor.last_input.empty?
|
11
|
-
actor.tell "Repeating <kbd>\"#{actor.last_input}\"</kbd>..."
|
12
|
-
actor.queue.push actor.last_input
|
13
|
-
else
|
14
|
-
actor.tell "You don't have a previous command to repeat right now."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
interpret 'again', 'repeat'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,56 +0,0 @@
|
|
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/open'
|
6
|
-
require 'gamefic-standard/actions/close'
|
7
|
-
require 'gamefic-standard/actions/lock'
|
8
|
-
require 'gamefic-standard/actions/unlock'
|
9
|
-
require 'gamefic-standard/actions/go'
|
10
|
-
require 'gamefic-standard/actions/insert'
|
11
|
-
require 'gamefic-standard/actions/inventory'
|
12
|
-
require 'gamefic-standard/actions/leave'
|
13
|
-
require 'gamefic-standard/actions/look'
|
14
|
-
require 'gamefic-standard/actions/search'
|
15
|
-
require 'gamefic-standard/actions/place'
|
16
|
-
require 'gamefic-standard/actions/quit'
|
17
|
-
require 'gamefic-standard/actions/take'
|
18
|
-
require 'gamefic-standard/actions/move'
|
19
|
-
require 'gamefic-standard/actions/talk'
|
20
|
-
require 'gamefic-standard/actions/wait'
|
21
|
-
require 'gamefic-standard/actions/give'
|
22
|
-
require 'gamefic-standard/actions/repeat'
|
23
|
-
require 'gamefic-standard/actions/save-restore-undo'
|
24
|
-
require 'gamefic-standard/actions/pronouns'
|
25
|
-
|
26
|
-
module Gamefic
|
27
|
-
module Standard
|
28
|
-
module Actions
|
29
|
-
include Nil
|
30
|
-
include Attack
|
31
|
-
include Drop
|
32
|
-
include Enter
|
33
|
-
include Open
|
34
|
-
include Close
|
35
|
-
include Lock
|
36
|
-
include Unlock
|
37
|
-
include Go
|
38
|
-
include Insert
|
39
|
-
include Inventory
|
40
|
-
include Leave
|
41
|
-
include Look
|
42
|
-
include Search
|
43
|
-
include Place
|
44
|
-
include Quit
|
45
|
-
include Take
|
46
|
-
include Move
|
47
|
-
include Talk
|
48
|
-
include Wait
|
49
|
-
include Give
|
50
|
-
include Repeat
|
51
|
-
include SaveRestoreUndo
|
52
|
-
include Pronouns
|
53
|
-
include Gamefic::What
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# An openable and lockable portal.
|
4
|
-
#
|
5
|
-
class Door < Portal
|
6
|
-
include Gamefic::Standard::Openable
|
7
|
-
include Gamefic::Standard::Lockable
|
8
|
-
|
9
|
-
def post_initialize
|
10
|
-
update_reverse_open
|
11
|
-
update_reverse_lock
|
12
|
-
end
|
13
|
-
|
14
|
-
def open=(bool)
|
15
|
-
super
|
16
|
-
reverse&.lock_key = lock_key
|
17
|
-
update_reverse_open
|
18
|
-
update_reverse_lock
|
19
|
-
end
|
20
|
-
|
21
|
-
def locked=(bool)
|
22
|
-
super
|
23
|
-
update_reverse_lock
|
24
|
-
end
|
25
|
-
|
26
|
-
def two_way_lock_key=(key)
|
27
|
-
self.lock_key = key
|
28
|
-
reverse&.lock_key = key
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def update_reverse_open
|
34
|
-
rev = find_reverse
|
35
|
-
rev&.open = open? unless rev&.open? == open?
|
36
|
-
end
|
37
|
-
|
38
|
-
def update_reverse_lock
|
39
|
-
rev = find_reverse
|
40
|
-
rev&.locked = locked? unless rev&.locked? == locked?
|
41
|
-
end
|
42
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# An entity that provides access from one room to another.
|
4
|
-
#
|
5
|
-
class Portal < Thing
|
6
|
-
# @return [Gamefic::Entity]
|
7
|
-
attr_accessor :destination
|
8
|
-
|
9
|
-
# Get the ordinal direction of this Portal
|
10
|
-
# Portals have distinct direction and name properties so games can display a
|
11
|
-
# bare compass direction for exits, e.g., "south" vs. "the southern door."
|
12
|
-
#
|
13
|
-
# A portal's destination can also be nil, in which case it can be referenced
|
14
|
-
# in commands by its destination, e.g., "go to the house."
|
15
|
-
#
|
16
|
-
# @return [Direction, nil]
|
17
|
-
attr_reader :direction
|
18
|
-
|
19
|
-
# Find the portal in the destination that returns to this portal's parent
|
20
|
-
#
|
21
|
-
# @return [Room, nil]
|
22
|
-
def reverse
|
23
|
-
return nil if destination.nil?
|
24
|
-
|
25
|
-
destination.children.that_are(Portal).find do |portal|
|
26
|
-
portal.destination == parent
|
27
|
-
end
|
28
|
-
end
|
29
|
-
alias find_reverse reverse
|
30
|
-
|
31
|
-
def direction=(dir)
|
32
|
-
@direction = Direction.find(dir)
|
33
|
-
end
|
34
|
-
|
35
|
-
def name
|
36
|
-
@name || direction&.name || destination.name
|
37
|
-
end
|
38
|
-
|
39
|
-
def instruction
|
40
|
-
direction || (destination ? "to #{destination.definitely}" : name)
|
41
|
-
end
|
42
|
-
|
43
|
-
def synonyms
|
44
|
-
"#{super} #{@destination} #{@direction} #{!direction.nil? ? direction.synonyms : ''}"
|
45
|
-
end
|
46
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Room < Thing
|
4
|
-
attr_writer :explicit_exits
|
5
|
-
|
6
|
-
set_default explicit_exits: true
|
7
|
-
|
8
|
-
def explicit_exits?
|
9
|
-
@explicit_exits
|
10
|
-
end
|
11
|
-
|
12
|
-
def tell(message)
|
13
|
-
children.each { |c| c.tell message }
|
14
|
-
end
|
15
|
-
|
16
|
-
# @return [Array<Portal>]
|
17
|
-
def portals
|
18
|
-
children.that_are(Portal)
|
19
|
-
end
|
20
|
-
|
21
|
-
# @param destination [Room]
|
22
|
-
# @param direction [Direction, String, nil]
|
23
|
-
# @param type [Class<Portal>]
|
24
|
-
# @param two_way [Boolean]
|
25
|
-
# @return [Portal, Array<Portal>]
|
26
|
-
def connect(destination, direction: nil, type: Portal, two_way: true, **opts)
|
27
|
-
direction = Direction.find(direction)
|
28
|
-
here = type.new parent: self, destination: destination, direction: Direction.find(direction), **opts
|
29
|
-
return here unless two_way
|
30
|
-
|
31
|
-
there = type.new parent: destination, destination: self, direction: direction&.reverse, **opts
|
32
|
-
[here, there]
|
33
|
-
end
|
34
|
-
|
35
|
-
class << self
|
36
|
-
def explicit_exits?
|
37
|
-
default_attributes[:explicit_exits]
|
38
|
-
end
|
39
|
-
|
40
|
-
def explicit_exits=(bool)
|
41
|
-
set_default explicit_exits: bool
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
protected
|
46
|
-
|
47
|
-
%w[north south west east northeast southeast southwest northwest up down].each do |direction|
|
48
|
-
define_method "#{direction}=" do |destination|
|
49
|
-
connect destination, direction: direction
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def connect=(destinations)
|
54
|
-
all = [destinations].flatten
|
55
|
-
until all.empty?
|
56
|
-
destination = all.shift
|
57
|
-
direction = (all.first.is_a?(String) ? all.shift : nil)
|
58
|
-
connect destination, direction: direction
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'gamefic-standard/entities/scenery'
|
4
|
-
|
5
|
-
# Rubble is Scenery with slightly modified action responses.
|
6
|
-
# Intended for things that might be portable but are useless.
|
7
|
-
# Rule of thumb: Scenery is something that can't be carried,
|
8
|
-
# like a table or the sky; and Rubble is something that might
|
9
|
-
# be portable but is otherwise useless, like trash or debris.
|
10
|
-
#
|
11
|
-
class Rubble < Scenery
|
12
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Scenery is an entity that is not itemized by default. They're typically used
|
4
|
-
# to provide a description for objects that can be observed but do not respond
|
5
|
-
# to any other interactions.
|
6
|
-
#
|
7
|
-
class Scenery < Thing
|
8
|
-
set_default itemized: false
|
9
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'gamefic-standard/entities/thing'
|
2
|
-
require 'gamefic-standard/entities/character'
|
3
|
-
require 'gamefic-standard/entities/fixture'
|
4
|
-
require 'gamefic-standard/entities/item'
|
5
|
-
require 'gamefic-standard/entities/portal'
|
6
|
-
require 'gamefic-standard/entities/door'
|
7
|
-
require 'gamefic-standard/entities/receptacle'
|
8
|
-
require 'gamefic-standard/entities/container'
|
9
|
-
require 'gamefic-standard/entities/room'
|
10
|
-
require 'gamefic-standard/entities/scenery'
|
11
|
-
require 'gamefic-standard/entities/rubble'
|
12
|
-
require 'gamefic-standard/entities/supporter'
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Gamefic::Scope::Room < Gamefic::Scope::Base
|
2
|
-
def matches
|
3
|
-
[context.room].compact
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
# @todo Monkey patch
|
8
|
-
module Gamefic::Scriptable::Queries
|
9
|
-
def room *args
|
10
|
-
Gamefic::Query::Scoped.new Gamefic::Scope::Room, *([Room] + args)
|
11
|
-
end
|
12
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|