gamefic-standard 2.2.0 → 2.3.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 +19 -2
- data/gamefic-standard.gemspec +1 -1
- data/lib/gamefic-standard/actions/close.rb +14 -0
- data/lib/gamefic-standard/actions/drop.rb +9 -6
- data/lib/gamefic-standard/actions/enter.rb +4 -0
- data/lib/gamefic-standard/actions/go.rb +20 -15
- data/lib/gamefic-standard/actions/insert.rb +8 -0
- data/lib/gamefic-standard/actions/leave.rb +15 -1
- data/lib/gamefic-standard/actions/lock.rb +21 -0
- data/lib/gamefic-standard/actions/look.rb +11 -10
- data/lib/gamefic-standard/actions/nil.rb +7 -10
- data/lib/gamefic-standard/actions/open.rb +29 -0
- data/lib/gamefic-standard/actions/place.rb +6 -18
- data/lib/gamefic-standard/actions/search.rb +26 -0
- data/lib/gamefic-standard/actions/take.rb +0 -4
- data/lib/gamefic-standard/actions/talk.rb +1 -5
- data/lib/gamefic-standard/actions/unlock.rb +21 -0
- data/lib/gamefic-standard/actions.rb +5 -0
- data/lib/gamefic-standard/entities/character.rb +2 -11
- data/lib/gamefic-standard/entities/container.rb +6 -0
- data/lib/gamefic-standard/{door.rb → entities/door.rb} +0 -9
- data/lib/gamefic-standard/entities/room.rb +1 -15
- data/lib/gamefic-standard/entities/thing.rb +5 -62
- data/lib/gamefic-standard/entities.rb +2 -0
- data/lib/gamefic-standard/give.rb +15 -18
- data/lib/gamefic-standard/modules/lockable.rb +32 -0
- data/lib/gamefic-standard/modules/openable.rb +19 -0
- data/lib/gamefic-standard/modules/standardized.rb +59 -0
- data/lib/gamefic-standard/modules.rb +3 -0
- data/lib/gamefic-standard/pathfinder.rb +0 -2
- data/lib/gamefic-standard/queries.rb +2 -2
- data/lib/gamefic-standard/test.rb +0 -2
- data/lib/gamefic-standard/version.rb +1 -1
- data/lib/gamefic-standard.rb +0 -2
- metadata +15 -30
- data/lib/gamefic-standard/clothing/actions/doff.rb +0 -14
- data/lib/gamefic-standard/clothing/actions/drop.rb +0 -10
- data/lib/gamefic-standard/clothing/actions/inventory.rb +0 -16
- data/lib/gamefic-standard/clothing/actions/wear.rb +0 -21
- data/lib/gamefic-standard/clothing/actions.rb +0 -4
- data/lib/gamefic-standard/clothing/entities/clothing.rb +0 -5
- data/lib/gamefic-standard/clothing/entities/coat.rb +0 -3
- data/lib/gamefic-standard/clothing/entities/gloves.rb +0 -3
- data/lib/gamefic-standard/clothing/entities/hat.rb +0 -3
- data/lib/gamefic-standard/clothing/entities/pants.rb +0 -3
- data/lib/gamefic-standard/clothing/entities/shirt.rb +0 -3
- data/lib/gamefic-standard/clothing/entities/shoes.rb +0 -3
- data/lib/gamefic-standard/clothing/entities.rb +0 -7
- data/lib/gamefic-standard/clothing.rb +0 -4
- data/lib/gamefic-standard/container.rb +0 -27
- data/lib/gamefic-standard/edible.rb +0 -23
- data/lib/gamefic-standard/lockable.rb +0 -98
- data/lib/gamefic-standard/openable.rb +0 -54
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc492bd7007da79a0370041571eda045f2d56c66987406001adb9609fa2272ff
|
|
4
|
+
data.tar.gz: 1f7d3bfaa885983d894b6eada5a752b629ca42183c96abcc22d7cf4f1f0c7a60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da8171873782d6fdea921d9a19981a581afb0e80913798ec969c2e9bd173ab73268ea3d1aff7e7d32f57dc969fa4d4ef3d386a36cb68a7a88220b7350082ad43
|
|
7
|
+
data.tar.gz: 3727672be7777bee08b33a79f3bee5fb2203e1cfe4ca140c6fa837b4b11d9cb4f2fadb35c7fb724bf7cae4a800382af6f240628141bede10bed053db184ae6c3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
## 2.3.1 - September 25, 2022
|
|
2
|
+
- Handle leave actions without parents
|
|
3
|
+
|
|
4
|
+
## 2.3.0 - September 4, 2021
|
|
5
|
+
- Use nil actions for untokenized arguments
|
|
6
|
+
- Fix response to closing closed entities
|
|
7
|
+
- Working give action
|
|
8
|
+
- Miscellaneous fixes for new specs
|
|
9
|
+
- Search action
|
|
10
|
+
- Separate actions from entities/modules
|
|
11
|
+
- Remove clothing
|
|
12
|
+
- Improve lockable behavior
|
|
13
|
+
- Remove edible
|
|
14
|
+
- Remove broken connect method
|
|
15
|
+
- Leave action opens entered containers
|
|
16
|
+
- Reduce entity inheritance
|
|
17
|
+
|
|
18
|
+
## 2.2.0 - June 21, 2021
|
|
2
19
|
- Insert, place, and wear try take first
|
|
3
20
|
- Improved verb recognition
|
|
4
21
|
- Openable doors
|
|
5
22
|
|
|
6
|
-
|
|
23
|
+
## 2.1.0 - March 7, 2021
|
|
7
24
|
- Remove sticky attribute
|
|
8
25
|
- Use set_player_class
|
data/gamefic-standard.gemspec
CHANGED
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
36
36
|
spec.require_paths = ["lib"]
|
|
37
37
|
|
|
38
|
-
spec.add_dependency 'gamefic', '~> 2.
|
|
38
|
+
spec.add_dependency 'gamefic', '~> 2.2'
|
|
39
39
|
|
|
40
40
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
41
41
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :close, Use.available do |actor, thing|
|
|
3
|
+
actor.tell "You can't close #{the thing}."
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
respond :close, Use.available(Openable) do |actor, thing|
|
|
7
|
+
if thing.open?
|
|
8
|
+
actor.tell "You close #{the thing}."
|
|
9
|
+
thing.open = false
|
|
10
|
+
else
|
|
11
|
+
actor.tell "#{The thing} is already closed."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
Gamefic.script do
|
|
2
|
-
respond :drop, Use.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
respond :drop, Use.available do |actor, thing|
|
|
3
|
+
actor.tell "You're not carrying #{the thing}."
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
respond :drop, Gamefic::Query::Descendants.new do |actor, thing|
|
|
7
|
+
actor.perform :take, thing
|
|
8
|
+
next unless thing.parent == actor
|
|
9
|
+
thing.parent = actor.parent
|
|
10
|
+
actor.tell "You drop #{the thing}."
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
respond :drop, Use.children do |actor, thing|
|
|
@@ -16,6 +16,10 @@ Gamefic.script do
|
|
|
16
16
|
actor.tell "You're inside #{the supporter} already."
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
respond :enter, Use.siblings(Container, :enterable?, :closed?) do |actor, container|
|
|
20
|
+
actor.tell "#{The container} is closed."
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
interpret "get on :thing", "enter :thing"
|
|
20
24
|
interpret "get in :thing", "enter :thing"
|
|
21
25
|
end
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
Gamefic.script do
|
|
2
2
|
respond :go, Use.siblings(Portal) do |actor, portal|
|
|
3
|
-
if
|
|
4
|
-
actor.
|
|
3
|
+
if portal.destination.nil?
|
|
4
|
+
actor.tell "That portal leads nowhere."
|
|
5
|
+
else
|
|
6
|
+
actor.parent = portal.destination
|
|
7
|
+
if !portal.direction.nil?
|
|
8
|
+
actor.tell "You go #{portal.direction}."
|
|
9
|
+
end
|
|
10
|
+
actor.perform :look
|
|
5
11
|
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
respond :go, Use.text do |actor, text|
|
|
6
15
|
if actor.parent == actor.room
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
actor.tell "I don't see any way to go \"#{text} from here."
|
|
17
|
+
else
|
|
18
|
+
actor.perform :leave
|
|
19
|
+
if actor.parent == actor.room
|
|
20
|
+
actor.perform "go #{text}"
|
|
9
21
|
else
|
|
10
|
-
actor.
|
|
11
|
-
if !portal.direction.nil?
|
|
12
|
-
actor.tell "You go #{portal.direction}."
|
|
13
|
-
end
|
|
14
|
-
actor.perform :look
|
|
22
|
+
actor.proceed
|
|
15
23
|
end
|
|
16
24
|
end
|
|
17
25
|
end
|
|
18
26
|
|
|
19
|
-
respond :go, Use.
|
|
20
|
-
actor.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
respond :go do |actor|
|
|
24
|
-
actor.tell "Where do you want to go?"
|
|
27
|
+
respond :go, Use.available(Door) do |actor, door|
|
|
28
|
+
actor.perform :open, door unless door.open?
|
|
29
|
+
actor.proceed if door.open?
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
interpret "north", "go north"
|
|
@@ -10,6 +10,14 @@ Gamefic.script do
|
|
|
10
10
|
actor.tell "You put #{the thing} in #{the receptacle}."
|
|
11
11
|
end
|
|
12
12
|
|
|
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
|
|
20
|
+
|
|
13
21
|
interpret "drop :item in :container", "insert :item :container"
|
|
14
22
|
interpret "put :item in :container", "insert :item :container"
|
|
15
23
|
interpret "place :item in :container", "insert :item :container"
|
|
@@ -8,6 +8,11 @@ Gamefic.script do
|
|
|
8
8
|
actor.parent = thing.parent
|
|
9
9
|
end
|
|
10
10
|
|
|
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
|
|
15
|
+
|
|
11
16
|
respond :leave, Use.room do |actor, room|
|
|
12
17
|
portals = room.children.that_are(Portal)
|
|
13
18
|
if portals.length == 0
|
|
@@ -20,7 +25,16 @@ Gamefic.script do
|
|
|
20
25
|
end
|
|
21
26
|
|
|
22
27
|
respond :leave do |actor|
|
|
23
|
-
|
|
28
|
+
if actor.parent
|
|
29
|
+
actor.perform :leave, actor.parent
|
|
30
|
+
else
|
|
31
|
+
actor.tell "You don't see any obvious exits."
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
|
|
36
|
+
actor.perform :open, container
|
|
37
|
+
actor.proceed if container.open?
|
|
24
38
|
end
|
|
25
39
|
|
|
26
40
|
interpret "exit", "leave"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :lock, Use.available do |actor, thing|
|
|
3
|
+
actor.tell "You can't lock #{the thing}."
|
|
4
|
+
end
|
|
5
|
+
|
|
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
|
|
14
|
+
|
|
15
|
+
respond :lock, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
|
|
16
|
+
actor.perform :take, key if key.parent != actor
|
|
17
|
+
actor.proceed if key.parent == actor
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
interpret "lock :container with :key", "lock :container :key"
|
|
21
|
+
end
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
Gamefic.script do
|
|
2
|
-
respond :look, Use.text do |actor, string|
|
|
3
|
-
actor.tell "You don't see any \"#{string}\" here."
|
|
4
|
-
end
|
|
5
|
-
|
|
6
2
|
respond :look, Use.text(/^here$/i) do |actor, _|
|
|
7
3
|
actor.perform :look, actor.room
|
|
8
4
|
end
|
|
@@ -14,9 +10,9 @@ Gamefic.script do
|
|
|
14
10
|
|
|
15
11
|
respond :look, Use.available(Thing) do |actor, thing|
|
|
16
12
|
actor.tell thing.description
|
|
17
|
-
thing.children.that_are(:attached?).that_are(:itemized?).each
|
|
13
|
+
thing.children.that_are(:attached?).that_are(:itemized?).each do |item|
|
|
18
14
|
actor.tell "#{An item} is attached to #{the thing}."
|
|
19
|
-
|
|
15
|
+
end
|
|
20
16
|
end
|
|
21
17
|
|
|
22
18
|
respond :look, Use.available(Supporter) do |actor, thing|
|
|
@@ -40,6 +36,11 @@ Gamefic.script do
|
|
|
40
36
|
actor.tell "You are currently on #{the supporter}."
|
|
41
37
|
end
|
|
42
38
|
|
|
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
|
|
43
|
+
|
|
43
44
|
respond :look, Use.room do |actor, room|
|
|
44
45
|
actor.tell "<strong>#{room.name.cap_first}</strong>"
|
|
45
46
|
actor.tell room.description if room.has_description?
|
|
@@ -52,13 +53,13 @@ Gamefic.script do
|
|
|
52
53
|
with_locales = []
|
|
53
54
|
chars = room.children.that_are(Character).that_are(:itemized?) - [actor]
|
|
54
55
|
charsum = []
|
|
55
|
-
chars.each
|
|
56
|
+
chars.each do |char|
|
|
56
57
|
if char.locale_description.nil?
|
|
57
58
|
charsum.push char
|
|
58
59
|
else
|
|
59
60
|
with_locales.push char
|
|
60
61
|
end
|
|
61
|
-
|
|
62
|
+
end
|
|
62
63
|
if charsum.length > 0
|
|
63
64
|
actor.tell "#{charsum.join_and.cap_first} #{charsum.length == 1 ? 'is' : 'are'} here."
|
|
64
65
|
end
|
|
@@ -85,9 +86,9 @@ Gamefic.script do
|
|
|
85
86
|
actor.tell "There is an exit #{p.instruction}."
|
|
86
87
|
else
|
|
87
88
|
dirs = []
|
|
88
|
-
portals.each
|
|
89
|
+
portals.each do |p|
|
|
89
90
|
dirs.push p.instruction
|
|
90
|
-
|
|
91
|
+
end
|
|
91
92
|
actor.tell "There are exits #{dirs.join_and(', ')}."
|
|
92
93
|
end
|
|
93
94
|
end
|
|
@@ -7,7 +7,13 @@ Gamefic.script do
|
|
|
7
7
|
if words.length > 1
|
|
8
8
|
found = Gamefic::Query::Available.new.resolve(actor, words[1..-1].join(' ')).objects
|
|
9
9
|
if found.empty?
|
|
10
|
-
|
|
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
|
|
11
17
|
elsif found.one?
|
|
12
18
|
actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
|
|
13
19
|
else
|
|
@@ -20,13 +26,4 @@ Gamefic.script do
|
|
|
20
26
|
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
|
21
27
|
end
|
|
22
28
|
end
|
|
23
|
-
|
|
24
|
-
meta nil, Gamefic::Query::Text.new(/^it$/) do |actor, string|
|
|
25
|
-
words = string.split_words
|
|
26
|
-
if verbs(to_s: true).include?(words[0])
|
|
27
|
-
actor.tell "I'm not sure what you mean by \"it.\""
|
|
28
|
-
else
|
|
29
|
-
actor.proceed
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
29
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :open, Use.available do |actor, thing|
|
|
3
|
+
actor.tell "You can't open #{the thing}."
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
respond :open, Use.available(Openable) do |actor, thing|
|
|
7
|
+
if thing.open?
|
|
8
|
+
actor.tell "#{The thing} is already open."
|
|
9
|
+
else
|
|
10
|
+
actor.tell "You open #{the thing}."
|
|
11
|
+
thing.open = true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
respond :open, Use.available(Lockable) do |actor, thing|
|
|
16
|
+
if thing.locked?
|
|
17
|
+
actor.tell "#{The thing} is locked."
|
|
18
|
+
else
|
|
19
|
+
actor.proceed
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
respond :open, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
|
|
24
|
+
actor.perform :unlock, thing, key
|
|
25
|
+
actor.perform :open, thing if thing.unlocked?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
interpret 'open :thing with :key', 'open :thing :key'
|
|
29
|
+
end
|
|
@@ -15,22 +15,10 @@ Gamefic.script do
|
|
|
15
15
|
actor.tell "You put #{the thing} on #{the supporter}."
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
respond :place, Use.text, Use.text do |actor, thing, supporter|
|
|
27
|
-
actor.tell "I don't know what you mean by \"#{thing}\" or \"#{supporter}.\""
|
|
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"
|
|
18
|
+
interpret 'put :thing on :supporter', 'place :thing :supporter'
|
|
19
|
+
interpret 'put :thing down on :supporter', 'place :thing :supporter'
|
|
20
|
+
interpret 'set :thing on :supporter', 'place :thing :supporter'
|
|
21
|
+
interpret 'set :thing down on :supporter', 'place :thing :supporter'
|
|
22
|
+
interpret 'drop :thing on :supporter', 'place :thing :supporter'
|
|
23
|
+
interpret 'place :thing on :supporter', 'place :thing :supporter'
|
|
36
24
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :search, Use.available(Thing) do |actor, thing|
|
|
3
|
+
actor.perform :look, thing
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
respond :search, Use.available(Receptacle) do |actor, thing|
|
|
7
|
+
if thing.accessible?
|
|
8
|
+
itemized = thing.children.that_are_not(:attached?).that_are(:itemized?)
|
|
9
|
+
if itemized.empty?
|
|
10
|
+
actor.tell "There's nothing inside #{the thing}."
|
|
11
|
+
else
|
|
12
|
+
actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
actor.tell "You can't see inside #{the thing}."
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
respond :search, Use.available(Container, :closed?) do |actor, container|
|
|
20
|
+
actor.perform :open, container
|
|
21
|
+
actor.proceed if container.open?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
interpret 'look inside :thing', 'search :thing'
|
|
25
|
+
interpret 'look in :thing', 'search :thing'
|
|
26
|
+
end
|
|
@@ -12,11 +12,7 @@ Gamefic.script do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
respond :talk, Use.available(Character) do |actor, character|
|
|
15
|
-
|
|
16
|
-
actor.perform :talk
|
|
17
|
-
else
|
|
18
|
-
actor.tell "#{The character} has nothing to say."
|
|
19
|
-
end
|
|
15
|
+
actor.tell "#{The character} has nothing to say."
|
|
20
16
|
end
|
|
21
17
|
|
|
22
18
|
interpret "talk to :character", "talk :character"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :unlock, Use.available do |actor, thing|
|
|
3
|
+
actor.tell "You can't unlock #{the thing}."
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
respond :unlock, Use.available(Lockable, :has_lock_key?), Use.children do |actor, thing, key|
|
|
7
|
+
if thing.lock_key == key
|
|
8
|
+
thing.locked = false
|
|
9
|
+
actor.tell "You unlock ##{the thing} with #{the key}."
|
|
10
|
+
else
|
|
11
|
+
actor.tell "You can't unlock #{the thing} with #{the key}."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
respond :unlock, Use.available(Lockable, :has_lock_key?), Use.available do |actor, _thing, key|
|
|
16
|
+
actor.perform :take, key if key.parent != actor
|
|
17
|
+
actor.proceed if key.parent == actor
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
interpret "unlock :container with :key", "unlock :container :key"
|
|
21
|
+
end
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
require 'gamefic-standard/actions/nil'
|
|
2
2
|
require 'gamefic-standard/actions/drop'
|
|
3
3
|
require 'gamefic-standard/actions/enter'
|
|
4
|
+
require 'gamefic-standard/actions/open'
|
|
5
|
+
require 'gamefic-standard/actions/close'
|
|
6
|
+
require 'gamefic-standard/actions/lock'
|
|
7
|
+
require 'gamefic-standard/actions/unlock'
|
|
4
8
|
require 'gamefic-standard/actions/go'
|
|
5
9
|
require 'gamefic-standard/actions/insert'
|
|
6
10
|
require 'gamefic-standard/actions/inventory'
|
|
7
11
|
require 'gamefic-standard/actions/leave'
|
|
8
12
|
require 'gamefic-standard/actions/look'
|
|
13
|
+
require 'gamefic-standard/actions/search'
|
|
9
14
|
require 'gamefic-standard/actions/place'
|
|
10
15
|
require 'gamefic-standard/actions/quit'
|
|
11
16
|
require 'gamefic-standard/actions/take'
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'gamefic-standard/openable'
|
|
2
|
-
|
|
3
1
|
# An openable portal.
|
|
4
2
|
#
|
|
5
3
|
class Door < Portal
|
|
@@ -40,10 +38,3 @@ class Door < Portal
|
|
|
40
38
|
rev.locked = locked?
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
|
-
|
|
44
|
-
Gamefic.script do
|
|
45
|
-
respond :go, Use.available(Door) do |actor, door|
|
|
46
|
-
actor.perform :open, door unless door.open?
|
|
47
|
-
actor.proceed if door.open?
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -8,9 +8,7 @@ class Room < Thing
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def tell(message)
|
|
11
|
-
children.each { |c|
|
|
12
|
-
c.tell message
|
|
13
|
-
}
|
|
11
|
+
children.each { |c| c.tell message }
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def find_portal(direction)
|
|
@@ -61,15 +59,3 @@ module Gamefic::World
|
|
|
61
59
|
portal
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
|
-
|
|
65
|
-
Room.module_exec self do |plot|
|
|
66
|
-
# Define the connect method dynamically so the plot is available
|
|
67
|
-
define_method :connect do |destination, direction = nil, type: Portal, two_way: true|
|
|
68
|
-
plot.connect self, destination, direction, type: Portal, two_way: true
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
class Room
|
|
72
|
-
# @!method connect destination, direction = nil, type: Portal, two_way: true
|
|
73
|
-
# Create a portal to connect this room to a destination.
|
|
74
|
-
# @return [Portal]
|
|
75
|
-
end
|
|
@@ -1,64 +1,7 @@
|
|
|
1
|
-
class
|
|
1
|
+
class Gamefic::Entity
|
|
2
2
|
include Grammar::Attributes
|
|
3
|
-
|
|
4
|
-
# @return [Boolean]
|
|
5
|
-
attr_writer :itemized
|
|
6
|
-
|
|
7
|
-
# @return [Boolean]
|
|
8
|
-
attr_writer :portable
|
|
9
|
-
|
|
10
|
-
# An optional description to use when itemizing entities in room
|
|
11
|
-
# descriptions. The locale_description will be used instead of adding
|
|
12
|
-
# the entity's name to a list.
|
|
13
|
-
#
|
|
14
|
-
# @return [String, nil]
|
|
15
|
-
attr_accessor :locale_description
|
|
16
|
-
|
|
17
|
-
set_default itemized: true
|
|
18
|
-
set_default portable: false
|
|
19
|
-
|
|
20
|
-
# Itemized entities are automatically listed in room descriptions.
|
|
21
|
-
#
|
|
22
|
-
# @return [Boolean]
|
|
23
|
-
def itemized?
|
|
24
|
-
@itemized
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Portable entities can be taken with TAKE actions.
|
|
28
|
-
#
|
|
29
|
-
# @return [Boolean]
|
|
30
|
-
def portable?
|
|
31
|
-
@portable
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# @return [Boolean]
|
|
35
|
-
def attached?
|
|
36
|
-
@attached ||= false
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @param bool [Boolean]
|
|
40
|
-
def attached= bool
|
|
41
|
-
@attached = if parent.nil?
|
|
42
|
-
# @todo Log attachment failure
|
|
43
|
-
false
|
|
44
|
-
else
|
|
45
|
-
bool
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def parent= new_parent
|
|
50
|
-
self.attached = false unless new_parent == parent
|
|
51
|
-
super
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# The entity's parent room (i.e., the closest ascendant that is a Room).
|
|
55
|
-
#
|
|
56
|
-
# @return [Room]
|
|
57
|
-
def room
|
|
58
|
-
p = parent
|
|
59
|
-
until p.is_a?(Room) or p.nil?
|
|
60
|
-
p = p.parent
|
|
61
|
-
end
|
|
62
|
-
p
|
|
63
|
-
end
|
|
3
|
+
include Standardized
|
|
64
4
|
end
|
|
5
|
+
|
|
6
|
+
Thing = Gamefic::Entity
|
|
7
|
+
Thing.set_default itemized: true, portable: false
|
|
@@ -3,7 +3,9 @@ require 'gamefic-standard/entities/character'
|
|
|
3
3
|
require 'gamefic-standard/entities/fixture'
|
|
4
4
|
require 'gamefic-standard/entities/item'
|
|
5
5
|
require 'gamefic-standard/entities/portal'
|
|
6
|
+
require 'gamefic-standard/entities/door'
|
|
6
7
|
require 'gamefic-standard/entities/receptacle'
|
|
8
|
+
require 'gamefic-standard/entities/container'
|
|
7
9
|
require 'gamefic-standard/entities/room'
|
|
8
10
|
require 'gamefic-standard/entities/scenery'
|
|
9
11
|
require 'gamefic-standard/entities/rubble'
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
end
|
|
1
|
+
Gamefic.script do
|
|
2
|
+
respond :give, Use.available, Gamefic::Query::Children.new do |actor, _character, _gift|
|
|
3
|
+
actor.tell 'Nothing happens.'
|
|
4
|
+
end
|
|
6
5
|
|
|
7
|
-
respond :give, Use.available(Character), Use.available do |actor, character, gift|
|
|
8
|
-
|
|
9
|
-
end
|
|
6
|
+
respond :give, Use.available(Character), Use.available do |actor, character, gift|
|
|
7
|
+
actor.tell "#{The character} doesn't want #{the gift}."
|
|
8
|
+
end
|
|
10
9
|
|
|
11
|
-
respond :give, Use.available(Character), Use.available do |actor, _character, gift|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
respond :give, Use.available(Character), Use.available do |actor, _character, gift|
|
|
11
|
+
if gift.parent != actor
|
|
12
|
+
actor.perform :take, gift
|
|
13
|
+
end
|
|
14
|
+
if gift.parent == actor
|
|
15
|
+
actor.proceed
|
|
16
|
+
end
|
|
16
17
|
end
|
|
17
|
-
end
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
actor.tell "You don't see any \"#{character}\" here."
|
|
19
|
+
interpret 'give :gift to :character', 'give :character :gift'
|
|
21
20
|
end
|
|
22
|
-
|
|
23
|
-
interpret "give :gift to :character", "give :character :gift"
|