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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# A module for entities that are both openable and lockable.
|
|
2
|
+
#
|
|
3
|
+
module Lockable
|
|
4
|
+
include Openable
|
|
5
|
+
|
|
6
|
+
attr_accessor :lock_key
|
|
7
|
+
|
|
8
|
+
def locked=(bool)
|
|
9
|
+
@locked = bool
|
|
10
|
+
if @locked == true
|
|
11
|
+
self.open = false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def open=(bool)
|
|
16
|
+
@open = bool
|
|
17
|
+
@locked = false if @open == true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def locked?
|
|
21
|
+
@locked ||= false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def unlocked?
|
|
25
|
+
!locked?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def lock_key?
|
|
29
|
+
!@lock_key.nil?
|
|
30
|
+
end
|
|
31
|
+
alias has_lock_key? lock_key?
|
|
32
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Standardized
|
|
2
|
+
# @return [Boolean]
|
|
3
|
+
attr_writer :itemized
|
|
4
|
+
|
|
5
|
+
# @return [Boolean]
|
|
6
|
+
attr_writer :portable
|
|
7
|
+
|
|
8
|
+
# An optional description to use when itemizing entities in room
|
|
9
|
+
# descriptions. The locale_description will be used instead of adding
|
|
10
|
+
# the entity's name to a list.
|
|
11
|
+
#
|
|
12
|
+
# @return [String, nil]
|
|
13
|
+
attr_accessor :locale_description
|
|
14
|
+
|
|
15
|
+
# Itemized entities are automatically listed in room descriptions.
|
|
16
|
+
#
|
|
17
|
+
# @return [Boolean]
|
|
18
|
+
def itemized?
|
|
19
|
+
@itemized
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Portable entities can be taken with TAKE actions.
|
|
23
|
+
#
|
|
24
|
+
# @return [Boolean]
|
|
25
|
+
def portable?
|
|
26
|
+
@portable
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
def attached?
|
|
31
|
+
@attached ||= false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @param bool [Boolean]
|
|
35
|
+
def attached= bool
|
|
36
|
+
@attached = if parent.nil?
|
|
37
|
+
# @todo Log attachment failure
|
|
38
|
+
false
|
|
39
|
+
else
|
|
40
|
+
bool
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def parent= new_parent
|
|
45
|
+
self.attached = false unless new_parent == parent
|
|
46
|
+
super
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The entity's parent room (i.e., the closest ascendant that is a Room).
|
|
50
|
+
#
|
|
51
|
+
# @return [Room]
|
|
52
|
+
def room
|
|
53
|
+
p = parent
|
|
54
|
+
until p.is_a?(Room) or p.nil?
|
|
55
|
+
p = p.parent
|
|
56
|
+
end
|
|
57
|
+
p
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
# @gamefic.script standard/pathfinder
|
|
2
1
|
# Pathfinders provide the shortest route between two locations. The
|
|
3
2
|
# destination needs to be accessible from the origin through portals. Note
|
|
4
3
|
# that Pathfinders do not take into account portals that characters should
|
|
5
4
|
# not be able to traverse, such as locked doors.
|
|
6
|
-
|
|
7
5
|
class Pathfinder
|
|
8
6
|
# @return [Room]
|
|
9
7
|
attr_reader :origin
|
|
@@ -6,10 +6,10 @@ class Gamefic::Query::Available < Gamefic::Query::Base
|
|
|
6
6
|
result.concat subquery_accessible(top)
|
|
7
7
|
end
|
|
8
8
|
result.delete subject
|
|
9
|
-
subject.children.each
|
|
9
|
+
subject.children.each do |c|
|
|
10
10
|
result.push c
|
|
11
11
|
result.concat subquery_accessible(c)
|
|
12
|
-
|
|
12
|
+
end
|
|
13
13
|
result
|
|
14
14
|
end
|
|
15
15
|
end
|
data/lib/gamefic-standard.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gamefic-standard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gamefic
|
|
@@ -16,20 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
20
|
-
- - ">="
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: 2.0.3
|
|
19
|
+
version: '2.2'
|
|
23
20
|
type: :runtime
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
23
|
requirements:
|
|
27
24
|
- - "~>"
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '2.
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.0.3
|
|
26
|
+
version: '2.2'
|
|
33
27
|
- !ruby/object:Gem::Dependency
|
|
34
28
|
name: bundler
|
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -108,40 +102,30 @@ files:
|
|
|
108
102
|
- gamefic-standard.gemspec
|
|
109
103
|
- lib/gamefic-standard.rb
|
|
110
104
|
- lib/gamefic-standard/actions.rb
|
|
105
|
+
- lib/gamefic-standard/actions/close.rb
|
|
111
106
|
- lib/gamefic-standard/actions/drop.rb
|
|
112
107
|
- lib/gamefic-standard/actions/enter.rb
|
|
113
108
|
- lib/gamefic-standard/actions/go.rb
|
|
114
109
|
- lib/gamefic-standard/actions/insert.rb
|
|
115
110
|
- lib/gamefic-standard/actions/inventory.rb
|
|
116
111
|
- lib/gamefic-standard/actions/leave.rb
|
|
112
|
+
- lib/gamefic-standard/actions/lock.rb
|
|
117
113
|
- lib/gamefic-standard/actions/look.rb
|
|
118
114
|
- lib/gamefic-standard/actions/nil.rb
|
|
115
|
+
- lib/gamefic-standard/actions/open.rb
|
|
119
116
|
- lib/gamefic-standard/actions/place.rb
|
|
120
117
|
- lib/gamefic-standard/actions/quit.rb
|
|
118
|
+
- lib/gamefic-standard/actions/search.rb
|
|
121
119
|
- lib/gamefic-standard/actions/take.rb
|
|
122
120
|
- lib/gamefic-standard/actions/talk.rb
|
|
121
|
+
- lib/gamefic-standard/actions/unlock.rb
|
|
123
122
|
- lib/gamefic-standard/actions/wait.rb
|
|
124
123
|
- lib/gamefic-standard/articles.rb
|
|
125
|
-
- lib/gamefic-standard/clothing.rb
|
|
126
|
-
- lib/gamefic-standard/clothing/actions.rb
|
|
127
|
-
- lib/gamefic-standard/clothing/actions/doff.rb
|
|
128
|
-
- lib/gamefic-standard/clothing/actions/drop.rb
|
|
129
|
-
- lib/gamefic-standard/clothing/actions/inventory.rb
|
|
130
|
-
- lib/gamefic-standard/clothing/actions/wear.rb
|
|
131
|
-
- lib/gamefic-standard/clothing/entities.rb
|
|
132
|
-
- lib/gamefic-standard/clothing/entities/clothing.rb
|
|
133
|
-
- lib/gamefic-standard/clothing/entities/coat.rb
|
|
134
|
-
- lib/gamefic-standard/clothing/entities/gloves.rb
|
|
135
|
-
- lib/gamefic-standard/clothing/entities/hat.rb
|
|
136
|
-
- lib/gamefic-standard/clothing/entities/pants.rb
|
|
137
|
-
- lib/gamefic-standard/clothing/entities/shirt.rb
|
|
138
|
-
- lib/gamefic-standard/clothing/entities/shoes.rb
|
|
139
|
-
- lib/gamefic-standard/container.rb
|
|
140
124
|
- lib/gamefic-standard/direction.rb
|
|
141
|
-
- lib/gamefic-standard/door.rb
|
|
142
|
-
- lib/gamefic-standard/edible.rb
|
|
143
125
|
- lib/gamefic-standard/entities.rb
|
|
144
126
|
- lib/gamefic-standard/entities/character.rb
|
|
127
|
+
- lib/gamefic-standard/entities/container.rb
|
|
128
|
+
- lib/gamefic-standard/entities/door.rb
|
|
145
129
|
- lib/gamefic-standard/entities/fixture.rb
|
|
146
130
|
- lib/gamefic-standard/entities/item.rb
|
|
147
131
|
- lib/gamefic-standard/entities/portal.rb
|
|
@@ -155,11 +139,12 @@ files:
|
|
|
155
139
|
- lib/gamefic-standard/grammar.rb
|
|
156
140
|
- lib/gamefic-standard/grammar/attributes.rb
|
|
157
141
|
- lib/gamefic-standard/grammar/pronoun.rb
|
|
158
|
-
- lib/gamefic-standard/lockable.rb
|
|
159
142
|
- lib/gamefic-standard/modules.rb
|
|
160
143
|
- lib/gamefic-standard/modules/enterable.rb
|
|
144
|
+
- lib/gamefic-standard/modules/lockable.rb
|
|
145
|
+
- lib/gamefic-standard/modules/openable.rb
|
|
146
|
+
- lib/gamefic-standard/modules/standardized.rb
|
|
161
147
|
- lib/gamefic-standard/modules/use.rb
|
|
162
|
-
- lib/gamefic-standard/openable.rb
|
|
163
148
|
- lib/gamefic-standard/pathfinder.rb
|
|
164
149
|
- lib/gamefic-standard/queries.rb
|
|
165
150
|
- lib/gamefic-standard/test.rb
|
|
@@ -183,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
168
|
- !ruby/object:Gem::Version
|
|
184
169
|
version: '0'
|
|
185
170
|
requirements: []
|
|
186
|
-
rubygems_version: 3.
|
|
171
|
+
rubygems_version: 3.3.7
|
|
187
172
|
signing_key:
|
|
188
173
|
specification_version: 4
|
|
189
174
|
summary: The Gamefic standard script library.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Gamefic.script do
|
|
2
|
-
respond :doff, Gamefic::Query::Children.new(Clothing) do |actor, clothing|
|
|
3
|
-
if !clothing.attached?
|
|
4
|
-
actor.tell "You're not wearing #{the clothing}."
|
|
5
|
-
else
|
|
6
|
-
clothing.attached = false
|
|
7
|
-
actor.tell "You take off #{the clothing}."
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
interpret "remove :clothing", "doff :clothing"
|
|
12
|
-
interpret "take off :clothing", "doff :clothing"
|
|
13
|
-
interpret "take :clothing off", "doff :clothing"
|
|
14
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Gamefic.script do
|
|
2
|
-
respond :inventory do |actor|
|
|
3
|
-
if actor.children.length > 0
|
|
4
|
-
carried = actor.children.that_are_not(:attached?)
|
|
5
|
-
worn = actor.children.that_are(:attached?)
|
|
6
|
-
if carried.length > 0
|
|
7
|
-
actor.tell "You are carrying #{carried.join_and}."
|
|
8
|
-
end
|
|
9
|
-
if worn.length > 0
|
|
10
|
-
actor.tell "You are wearing #{worn.join_and}."
|
|
11
|
-
end
|
|
12
|
-
else
|
|
13
|
-
actor.tell "You aren't carrying anything."
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Gamefic.script do
|
|
2
|
-
respond :wear, Use.available(Clothing) do |actor, clothing|
|
|
3
|
-
actor.perform :take, clothing unless clothing.parent == actor
|
|
4
|
-
next unless clothing.parent == actor
|
|
5
|
-
if clothing.attached?
|
|
6
|
-
actor.tell "You're already wearing #{the clothing}."
|
|
7
|
-
else
|
|
8
|
-
already = actor.children.that_are(clothing.class).that_are(:attached?)
|
|
9
|
-
if already.length == 0
|
|
10
|
-
clothing.attached = true
|
|
11
|
-
actor.tell "You put on #{the clothing}."
|
|
12
|
-
else
|
|
13
|
-
actor.tell "You're already wearing #{an already[0]}."
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
interpret "put on :clothing", "wear :clothing"
|
|
19
|
-
interpret "put :clothing on", "wear :clothing"
|
|
20
|
-
interpret "don :clothing", "wear :clothing"
|
|
21
|
-
end
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
require 'gamefic-standard/clothing/entities/clothing'
|
|
2
|
-
require 'gamefic-standard/clothing/entities/coat'
|
|
3
|
-
require 'gamefic-standard/clothing/entities/gloves'
|
|
4
|
-
require 'gamefic-standard/clothing/entities/hat'
|
|
5
|
-
require 'gamefic-standard/clothing/entities/pants'
|
|
6
|
-
require 'gamefic-standard/clothing/entities/shirt'
|
|
7
|
-
require 'gamefic-standard/clothing/entities/shoes'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'gamefic-standard/openable'
|
|
2
|
-
require 'gamefic-standard/lockable'
|
|
3
|
-
|
|
4
|
-
# An openable and lockable receptacle.
|
|
5
|
-
#
|
|
6
|
-
class Container < Receptacle
|
|
7
|
-
include Openable
|
|
8
|
-
include Lockable
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
Gamefic.script do
|
|
12
|
-
respond :insert, Use.available, Use.available(Container) do |actor, _thing, container|
|
|
13
|
-
if container.open?
|
|
14
|
-
actor.proceed
|
|
15
|
-
else
|
|
16
|
-
actor.tell "#{The container} is closed."
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
|
|
21
|
-
actor.tell "#{The container} is closed."
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
respond :enter, Use.siblings(Container, :enterable?, :closed?) do |actor, container|
|
|
25
|
-
actor.tell "#{The container} is closed."
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# @gamefic.script standard/edible
|
|
2
|
-
|
|
3
|
-
module Edibility
|
|
4
|
-
attr_writer :edible
|
|
5
|
-
def edible?
|
|
6
|
-
@edible ||= false
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class Thing
|
|
11
|
-
include Edibility
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
Gamefic.script do
|
|
15
|
-
respond :eat, Use.available do |actor, item|
|
|
16
|
-
actor.tell "You can't eat #{the item}."
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
respond :eat, Use.available(:edible?) do |actor, item|
|
|
20
|
-
actor.tell "You eat #{the item}."
|
|
21
|
-
destroy item
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# @gamefic.script standard/lockable
|
|
2
|
-
|
|
3
|
-
require 'gamefic-standard/openable'
|
|
4
|
-
|
|
5
|
-
# A module for entities that are both openable and lockable.
|
|
6
|
-
#
|
|
7
|
-
module Lockable
|
|
8
|
-
include Openable
|
|
9
|
-
|
|
10
|
-
attr_accessor :lock_key
|
|
11
|
-
|
|
12
|
-
def locked=(bool)
|
|
13
|
-
@locked = bool
|
|
14
|
-
if @locked == true
|
|
15
|
-
self.open = false
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def open=(bool)
|
|
20
|
-
@open = bool
|
|
21
|
-
@locked = false if @open == true
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def locked?
|
|
25
|
-
@locked ||= false
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def unlocked?
|
|
29
|
-
!locked?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def lock_key?
|
|
33
|
-
!@lock_key.nil?
|
|
34
|
-
end
|
|
35
|
-
alias has_lock_key? lock_key?
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
Gamefic.script do
|
|
39
|
-
respond :lock, Use.available do |actor, thing|
|
|
40
|
-
actor.tell "You can't lock #{the thing}."
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
respond :_toggle_lock, Use.available(Lockable, :has_lock_key?) do |actor, thing|
|
|
44
|
-
verb = thing.locked? ? 'unlock' : 'lock'
|
|
45
|
-
key = nil
|
|
46
|
-
if thing.lock_key.parent == actor
|
|
47
|
-
key = thing.lock_key
|
|
48
|
-
end
|
|
49
|
-
if key.nil?
|
|
50
|
-
actor.tell "You don't have any way to #{verb} #{the thing}."
|
|
51
|
-
else
|
|
52
|
-
actor.tell "You #{verb} #{the thing} with #{the key}."
|
|
53
|
-
thing.locked = !thing.locked?
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
respond :lock, Use.available(Lockable, :has_lock_key?), Use.children do |actor, thing, key|
|
|
58
|
-
if thing.lock_key == key
|
|
59
|
-
actor.perform :_toggle_lock, thing
|
|
60
|
-
else
|
|
61
|
-
actor.tell "You can't unlock #{the thing} with #{the key}."
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
respond :lock, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
|
|
66
|
-
actor.perform :take, key if key.parent != actor
|
|
67
|
-
actor.proceed if key.parent == actor
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
respond :unlock, Use.available do |actor, thing|
|
|
71
|
-
actor.tell "You can't unlock #{the thing}."
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
respond :unlock, Use.available(Lockable, :has_lock_key?), Use.children do |actor, thing, key|
|
|
75
|
-
if thing.lock_key == key
|
|
76
|
-
actor.perform :_toggle_lock, thing
|
|
77
|
-
else
|
|
78
|
-
actor.tell "You can't unlock #{the thing} with #{the key}."
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
respond :unlock, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
|
|
83
|
-
actor.perform :take, key if key.parent != actor
|
|
84
|
-
actor.proceed if key.parent == actor
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
respond :open, Use.available(Lockable) do |actor, thing|
|
|
88
|
-
if thing.locked?
|
|
89
|
-
actor.tell "#{The thing} is locked."
|
|
90
|
-
else
|
|
91
|
-
actor.proceed
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
interpret "lock :container with :key", "lock :container :key"
|
|
96
|
-
interpret "unlock :container with :key", "unlock :container :key"
|
|
97
|
-
interpret "open :container with :key", "unlock :container :key"
|
|
98
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# @gamefic.script standard/openable
|
|
2
|
-
|
|
3
|
-
# A module for entities that are openable.
|
|
4
|
-
#
|
|
5
|
-
module Openable
|
|
6
|
-
def open= bool
|
|
7
|
-
@open = bool
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def open?
|
|
11
|
-
@open ||= false
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def closed?
|
|
15
|
-
!open?
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def accessible?
|
|
19
|
-
open?
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Gamefic.script do
|
|
24
|
-
respond :open, Use.available do |actor, thing|
|
|
25
|
-
actor.tell "You can't open #{the thing}."
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
respond :open, Use.available(Openable) do |actor, thing|
|
|
29
|
-
if thing.open?
|
|
30
|
-
actor.tell "#{The thing} is already open."
|
|
31
|
-
else
|
|
32
|
-
actor.tell "You open #{the thing}."
|
|
33
|
-
thing.open = true
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
respond :close, Use.available do |actor, thing|
|
|
38
|
-
actor.tell "You can't close #{the thing}."
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
respond :close, Use.available(Openable) do |actor, thing|
|
|
42
|
-
if thing.open?
|
|
43
|
-
actor.tell "You close #{the thing}."
|
|
44
|
-
thing.open = false
|
|
45
|
-
else
|
|
46
|
-
actor.tell "#{The thing} is already open."
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
respond :look, Use.available(Thing, Openable) do |actor, thing|
|
|
51
|
-
actor.proceed
|
|
52
|
-
actor.tell "#{The thing} is #{thing.open? ? 'open' : 'closed'}."
|
|
53
|
-
end
|
|
54
|
-
end
|