gamefic-standard 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/gamefic-standard.gemspec +44 -44
- data/lib/gamefic-standard.rb +1 -0
- data/lib/gamefic-standard/actions/drop.rb +2 -6
- data/lib/gamefic-standard/actions/go.rb +1 -7
- data/lib/gamefic-standard/actions/insert.rb +2 -6
- data/lib/gamefic-standard/actions/look.rb +21 -27
- data/lib/gamefic-standard/actions/nil.rb +11 -18
- data/lib/gamefic-standard/actions/place.rb +2 -6
- data/lib/gamefic-standard/clothing/actions/inventory.rb +16 -16
- data/lib/gamefic-standard/clothing/actions/wear.rb +22 -22
- data/lib/gamefic-standard/container.rb +27 -27
- data/lib/gamefic-standard/direction.rb +5 -0
- data/lib/gamefic-standard/entities/character.rb +1 -1
- data/lib/gamefic-standard/entities/portal.rb +16 -20
- data/lib/gamefic-standard/entities/room.rb +0 -4
- data/lib/gamefic-standard/entities/supporter.rb +0 -4
- data/lib/gamefic-standard/entities/thing.rb +9 -20
- data/lib/gamefic-standard/give.rb +1 -5
- data/lib/gamefic-standard/modules/enterable.rb +1 -13
- data/lib/gamefic-standard/modules/use.rb +1 -1
- data/lib/gamefic-standard/openable.rb +49 -49
- data/lib/gamefic-standard/version.rb +1 -1
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8449554314b654b07a264e2d7726bbedac25212a65cc0feba5aea75c32e120c4
|
4
|
+
data.tar.gz: 2d1bedb7f9f780db43afc42994676e22625fc434bf46dfa16ccf7f6340217266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2bba15cb8c073bc68182f773fcc6b5b6b658ff4556d8995588c6ee2950598494e941d3e260693103e1f17f903d84ba5ea29cac36f75e65de6bf7e3fb3201a0c
|
7
|
+
data.tar.gz: e0c0999196d96e5a44f855fa76f3310b58acca624de2fc3d51bc95b8d74f1e6e6600c7b83f742ec79590e70aa5dbdfb92478deaa4d9dc3231092b5781963bd0e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/gamefic-standard.gemspec
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'gamefic-standard/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "gamefic-standard"
|
7
|
-
spec.version = Gamefic::Standard::VERSION
|
8
|
-
spec.authors = ["Fred Snyder"]
|
9
|
-
spec.email = ["fsnyder@castwide.com"]
|
10
|
-
|
11
|
-
spec.summary = %q{The Gamefic standard script library.}
|
12
|
-
spec.description = %q{A collection of components for building games and interactive fiction in Gamefic.}
|
13
|
-
spec.homepage = "http://gamefic.com"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
# if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
|
21
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
22
|
-
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
23
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
-
# else
|
25
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
-
# "public gem pushes."
|
27
|
-
# end
|
28
|
-
|
29
|
-
# Specify which files should be added to the gem when it is released.
|
30
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
-
end
|
34
|
-
spec.bindir = "exe"
|
35
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = ["lib"]
|
37
|
-
|
38
|
-
spec.add_dependency 'gamefic', '~> 2.0'
|
39
|
-
|
40
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
41
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
42
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
-
spec.add_development_dependency 'simplecov', '~> 0.14'
|
44
|
-
end
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'gamefic-standard/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gamefic-standard"
|
7
|
+
spec.version = Gamefic::Standard::VERSION
|
8
|
+
spec.authors = ["Fred Snyder"]
|
9
|
+
spec.email = ["fsnyder@castwide.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{The Gamefic standard script library.}
|
12
|
+
spec.description = %q{A collection of components for building games and interactive fiction in Gamefic.}
|
13
|
+
spec.homepage = "http://gamefic.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
|
21
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
23
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
+
# else
|
25
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
# "public gem pushes."
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_dependency 'gamefic', '~> 2.0', '>= 2.0.3'
|
39
|
+
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
41
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
+
spec.add_development_dependency 'simplecov', '~> 0.14'
|
44
|
+
end
|
data/lib/gamefic-standard.rb
CHANGED
@@ -8,12 +8,8 @@ Gamefic.script do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
respond :drop, Use.children do |actor, thing|
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
thing.parent = actor.parent
|
15
|
-
actor.tell "You drop #{the thing}."
|
16
|
-
end
|
11
|
+
thing.parent = actor.parent
|
12
|
+
actor.tell "You drop #{the thing}."
|
17
13
|
end
|
18
14
|
|
19
15
|
interpret "put down :thing", "drop :thing"
|
@@ -11,17 +11,11 @@ Gamefic.script do
|
|
11
11
|
if !portal.direction.nil?
|
12
12
|
actor.tell "You go #{portal.direction}."
|
13
13
|
end
|
14
|
-
actor.
|
15
|
-
actor.execute :_describe_destination
|
16
|
-
actor.execute :_itemize_room
|
14
|
+
actor.perform :look
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
|
-
meta :_describe_destination do |actor|
|
22
|
-
actor.tell actor.room.description if actor.room.has_description?
|
23
|
-
end
|
24
|
-
|
25
19
|
respond :go, Use.text do |actor, string|
|
26
20
|
actor.tell "You don't see any exit \"#{string}\" from here."
|
27
21
|
end
|
@@ -5,12 +5,8 @@ Gamefic.script do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
respond :insert, Use.children, Use.available(Receptacle) do |actor, thing, receptacle|
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
actor.tell "You put #{the thing} in #{the receptacle}."
|
12
|
-
thing.parent = receptacle
|
13
|
-
end
|
8
|
+
actor.tell "You put #{the thing} in #{the receptacle}."
|
9
|
+
thing.parent = receptacle
|
14
10
|
end
|
15
11
|
|
16
12
|
respond :insert, Use.available, Use.available(Receptacle) do |actor, thing, receptacle|
|
@@ -1,16 +1,13 @@
|
|
1
1
|
Gamefic.script do
|
2
2
|
respond :look, Use.text do |actor, string|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
else
|
9
|
-
actor.tell "You don't see any \"#{string}\" here."
|
10
|
-
end
|
3
|
+
actor.tell "You don't see any \"#{string}\" here."
|
4
|
+
end
|
5
|
+
|
6
|
+
respond :look, Use.text(/^here$/i) do |actor, _|
|
7
|
+
actor.perform :look, actor.room
|
11
8
|
end
|
12
9
|
|
13
|
-
respond :look, Use.itself do |actor,
|
10
|
+
respond :look, Use.itself do |actor, _|
|
14
11
|
actor.tell actor.description
|
15
12
|
actor.perform :inventory
|
16
13
|
end
|
@@ -23,15 +20,11 @@ Gamefic.script do
|
|
23
20
|
end
|
24
21
|
|
25
22
|
respond :look, Use.available(Supporter) do |actor, thing|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
actor.tell "You see #{itemized.join_and} on #{the thing}." unless itemized.empty?
|
32
|
-
else
|
33
|
-
actor.proceed
|
34
|
-
end
|
23
|
+
itemized = thing.children.that_are_not(:attached?).that_are(:itemized?)
|
24
|
+
# If the supporter does not have a description but it does contain
|
25
|
+
# itemized things, avoid saying there's nothing special about it.
|
26
|
+
actor.proceed if thing.has_description? || itemized.empty?
|
27
|
+
actor.tell "You see #{itemized.join_and} on #{the thing}." unless itemized.empty?
|
35
28
|
end
|
36
29
|
|
37
30
|
respond :look, Use.available(Receptacle) do |actor, thing|
|
@@ -71,13 +64,13 @@ Gamefic.script do
|
|
71
64
|
end
|
72
65
|
items = room.children.that_are(:itemized?) - [actor] - room.children.that_are(Character) - room.children.that_are(Portal)
|
73
66
|
itemsum = []
|
74
|
-
items.each
|
67
|
+
items.each do |item|
|
75
68
|
if item.locale_description.nil?
|
76
69
|
itemsum.push item
|
77
70
|
else
|
78
71
|
with_locales.push item
|
79
72
|
end
|
80
|
-
|
73
|
+
end
|
81
74
|
if itemsum.length > 0
|
82
75
|
actor.tell "You see #{itemsum.join_and}."
|
83
76
|
end
|
@@ -99,7 +92,7 @@ Gamefic.script do
|
|
99
92
|
end
|
100
93
|
end
|
101
94
|
end
|
102
|
-
if actor.parent.
|
95
|
+
if actor.parent.is_a?(Supporter)
|
103
96
|
actor.tell "You are on #{the actor.parent}."
|
104
97
|
actor.parent.children.that_are_not(actor).each { |s|
|
105
98
|
actor.tell "#{A s} is on #{the actor.parent}."
|
@@ -107,11 +100,12 @@ Gamefic.script do
|
|
107
100
|
end
|
108
101
|
end
|
109
102
|
|
110
|
-
interpret
|
111
|
-
interpret
|
103
|
+
interpret 'look around', 'look here'
|
104
|
+
interpret 'look', 'look here'
|
105
|
+
interpret 'l', 'look here'
|
112
106
|
|
113
|
-
interpret
|
114
|
-
interpret
|
115
|
-
interpret
|
116
|
-
interpret
|
107
|
+
interpret 'look at :thing', 'look :thing'
|
108
|
+
interpret 'l :thing', 'look :thing'
|
109
|
+
interpret 'examine :thing', 'look :thing'
|
110
|
+
interpret 'x :thing', 'look :thing'
|
117
111
|
end
|
@@ -1,29 +1,22 @@
|
|
1
1
|
Gamefic.script do
|
2
|
-
meta nil, Gamefic::Query::Text.new
|
2
|
+
meta nil, Gamefic::Query::Text.new do |actor, string|
|
3
3
|
words = string.split_words
|
4
4
|
list = verbs
|
5
5
|
if list.include?(words[0])
|
6
6
|
if words.length > 1
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
next if c.include?('_')
|
15
|
-
if c.length > words[0].length and c.start_with?(words[0])
|
16
|
-
found.push c
|
7
|
+
found = Gamefic::Query::Available.new.resolve(actor, words[1..-1].join(' ')).objects
|
8
|
+
if found.empty?
|
9
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but could not understand the rest of your sentence.)
|
10
|
+
elsif found.one?
|
11
|
+
actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
|
12
|
+
else
|
13
|
+
actor.tell %(I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
|
17
14
|
end
|
18
|
-
}
|
19
|
-
if found.length == 1
|
20
|
-
words[0] = found[0]
|
21
|
-
actor.perform words.join(' ')
|
22
|
-
elsif found.length > 1 and words[0].length > 2
|
23
|
-
actor.tell "I'm not sure if #{words[0]} means #{found.join_and(', ', ' or ')}."
|
24
15
|
else
|
25
|
-
actor.tell
|
16
|
+
actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
|
26
17
|
end
|
18
|
+
else
|
19
|
+
actor.tell %(I don't recognize "#{words[0]}" as a verb.)
|
27
20
|
end
|
28
21
|
end
|
29
22
|
|
@@ -14,12 +14,8 @@ Gamefic.script do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
respond :place, Use.children, Use.reachable(Supporter) do |actor, thing, supporter|
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
thing.parent = supporter
|
21
|
-
actor.tell "You put #{the thing} on #{the supporter}."
|
22
|
-
end
|
17
|
+
thing.parent = supporter
|
18
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
23
19
|
end
|
24
20
|
|
25
21
|
respond :place, Use.visible, Use.text do |actor, thing, supporter|
|
@@ -1,16 +1,16 @@
|
|
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
|
+
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,22 +1,22 @@
|
|
1
|
-
Gamefic.script do
|
2
|
-
respond :wear, Use.available(Clothing) do |actor, clothing|
|
3
|
-
if clothing.parent != actor
|
4
|
-
actor.tell "You don't have #{the clothing}."
|
5
|
-
end
|
6
|
-
if clothing.attached?
|
7
|
-
actor.tell "You're already wearing #{the clothing}."
|
8
|
-
else
|
9
|
-
already = actor.children.that_are(clothing.class).that_are(:attached?)
|
10
|
-
if already.length == 0
|
11
|
-
clothing.attached = true
|
12
|
-
actor.tell "You put on #{the clothing}."
|
13
|
-
else
|
14
|
-
actor.tell "You're already wearing #{an already[0]}."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
xlate "put on :clothing", "wear :clothing"
|
20
|
-
xlate "put :clothing on", "wear :clothing"
|
21
|
-
xlate "don :clothing", "wear :clothing"
|
22
|
-
end
|
1
|
+
Gamefic.script do
|
2
|
+
respond :wear, Use.available(Clothing) do |actor, clothing|
|
3
|
+
if clothing.parent != actor
|
4
|
+
actor.tell "You don't have #{the clothing}."
|
5
|
+
end
|
6
|
+
if clothing.attached?
|
7
|
+
actor.tell "You're already wearing #{the clothing}."
|
8
|
+
else
|
9
|
+
already = actor.children.that_are(clothing.class).that_are(:attached?)
|
10
|
+
if already.length == 0
|
11
|
+
clothing.attached = true
|
12
|
+
actor.tell "You put on #{the clothing}."
|
13
|
+
else
|
14
|
+
actor.tell "You're already wearing #{an already[0]}."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
xlate "put on :clothing", "wear :clothing"
|
20
|
+
xlate "put :clothing on", "wear :clothing"
|
21
|
+
xlate "don :clothing", "wear :clothing"
|
22
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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,
|
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
|
+
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,4 +1,6 @@
|
|
1
1
|
class Direction
|
2
|
+
include Gamefic::Serialize
|
3
|
+
|
2
4
|
attr_accessor :name, :adjective, :adverb, :reverse
|
3
5
|
|
4
6
|
def initialize args = {}
|
@@ -48,7 +50,10 @@ class Direction
|
|
48
50
|
@compass
|
49
51
|
end
|
50
52
|
|
53
|
+
# @param dir [Direction, string]
|
54
|
+
# @return [Direction, nil]
|
51
55
|
def find(dir)
|
56
|
+
return dir if dir.is_a?(Direction)
|
52
57
|
compass[dir.to_s.downcase.to_sym]
|
53
58
|
end
|
54
59
|
end
|
@@ -1,33 +1,29 @@
|
|
1
1
|
class Portal < Thing
|
2
|
+
# @return [Gamefic::Entity]
|
2
3
|
attr_accessor :destination
|
3
4
|
|
5
|
+
# Get the ordinal direction of this Portal
|
6
|
+
# Portals have distinct direction and name properties so games can display a
|
7
|
+
# bare compass direction for exits, e.g., "south" vs. "the southern door."
|
8
|
+
#
|
9
|
+
# A portal's destination can also be nil, in which case it can be referenced
|
10
|
+
# in commands by its destination, e.g., "go to the house."
|
11
|
+
#
|
12
|
+
# @return [Direction, nil]
|
13
|
+
attr_reader :direction
|
14
|
+
|
4
15
|
# Find the portal in the destination that returns to this portal's parent
|
5
16
|
#
|
6
|
-
# @return [Room]
|
17
|
+
# @return [Room, nil]
|
7
18
|
def find_reverse
|
8
19
|
return nil if destination.nil?
|
9
|
-
|
10
|
-
|
11
|
-
destination.children.that_are(Portal).each { |c|
|
12
|
-
if c.direction == rev
|
13
|
-
return c
|
14
|
-
end
|
15
|
-
}
|
20
|
+
destination.children.that_are(Portal).find do |portal|
|
21
|
+
portal.destination == parent
|
16
22
|
end
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
|
20
|
-
# Get the ordinal direction of this Portal
|
21
|
-
# Portals have distinct direction and name properties so games can display a
|
22
|
-
# bare compass direction for exits, e.g., "south" vs. "the southern door."
|
23
|
-
#
|
24
|
-
# @return [Direction]
|
25
|
-
def direction
|
26
|
-
@direction
|
27
23
|
end
|
28
24
|
|
29
|
-
def direction=
|
30
|
-
@direction = Direction.find(
|
25
|
+
def direction= dir
|
26
|
+
@direction = Direction.find(dir)
|
31
27
|
end
|
32
28
|
|
33
29
|
def name
|
@@ -3,8 +3,6 @@ class Thing < Gamefic::Entity
|
|
3
3
|
|
4
4
|
attr_writer :itemized
|
5
5
|
|
6
|
-
attr_writer :sticky
|
7
|
-
|
8
6
|
attr_writer :portable
|
9
7
|
|
10
8
|
# An optional description to use when itemizing entities in room
|
@@ -13,13 +11,7 @@ class Thing < Gamefic::Entity
|
|
13
11
|
#
|
14
12
|
attr_accessor :locale_description
|
15
13
|
|
16
|
-
# A message to be displayed in response to DROP actions when the entity is
|
17
|
-
# sticky.
|
18
|
-
#
|
19
|
-
attr_accessor :sticky_message
|
20
|
-
|
21
14
|
set_default itemized: true
|
22
|
-
set_default sticky: false
|
23
15
|
set_default portable: false
|
24
16
|
|
25
17
|
# Itemized entities are automatically listed in room descriptions.
|
@@ -29,13 +21,6 @@ class Thing < Gamefic::Entity
|
|
29
21
|
@itemized
|
30
22
|
end
|
31
23
|
|
32
|
-
# Sticky entities cannot be dropped with DROP actions
|
33
|
-
#
|
34
|
-
# @return [Boolean]
|
35
|
-
def sticky?
|
36
|
-
@sticky
|
37
|
-
end
|
38
|
-
|
39
24
|
# Portable entities can be taken with TAKE actions.
|
40
25
|
#
|
41
26
|
# @return [Boolean]
|
@@ -48,14 +33,18 @@ class Thing < Gamefic::Entity
|
|
48
33
|
@attached ||= false
|
49
34
|
end
|
50
35
|
|
51
|
-
# @param [Boolean]
|
36
|
+
# @param bool [Boolean]
|
52
37
|
def attached= bool
|
53
|
-
|
54
|
-
|
38
|
+
@attached = if parent.nil?
|
39
|
+
# @todo Log attachment failure
|
40
|
+
false
|
41
|
+
else
|
42
|
+
bool
|
43
|
+
end
|
55
44
|
end
|
56
45
|
|
57
|
-
def parent=
|
58
|
-
self.attached = false unless
|
46
|
+
def parent= new_parent
|
47
|
+
self.attached = false unless new_parent == parent
|
59
48
|
super
|
60
49
|
end
|
61
50
|
|
@@ -5,11 +5,7 @@ respond :give, Use.available, Gamefic::Query::Children.new do |actor, _character
|
|
5
5
|
end
|
6
6
|
|
7
7
|
respond :give, Use.available(Character), Use.available do |actor, character, gift|
|
8
|
-
|
9
|
-
actor.tell gift.sticky_message || "You need to keep #{the gift} for now."
|
10
|
-
else
|
11
|
-
actor.tell "#{The character} doesn't want #{the gift}."
|
12
|
-
end
|
8
|
+
actor.tell "#{The character} doesn't want #{the gift}."
|
13
9
|
end
|
14
10
|
|
15
11
|
respond :give, Use.available(Character), Use.available do |actor, _character, gift|
|
@@ -1,19 +1,7 @@
|
|
1
1
|
module Enterable
|
2
|
-
attr_writer :enterable
|
2
|
+
attr_writer :enterable
|
3
3
|
|
4
4
|
def enterable?
|
5
5
|
@enterable ||= false
|
6
6
|
end
|
7
|
-
|
8
|
-
def inside_verb
|
9
|
-
@inside_verb ||= "be in"
|
10
|
-
end
|
11
|
-
|
12
|
-
def enter_verb
|
13
|
-
@enter_verb ||= "enter"
|
14
|
-
end
|
15
|
-
|
16
|
-
def leave_verb
|
17
|
-
@leave_verb ||= "leave"
|
18
|
-
end
|
19
7
|
end
|
@@ -1,49 +1,49 @@
|
|
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
|
-
end
|
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
|
+
end
|
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.1.0
|
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: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gamefic
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.3
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.3
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +98,7 @@ files:
|
|
92
98
|
- ".rspec"
|
93
99
|
- ".travis.yml"
|
94
100
|
- ".vscode/launch.json"
|
101
|
+
- CHANGELOG.md
|
95
102
|
- Gemfile
|
96
103
|
- LICENSE.txt
|
97
104
|
- README.md
|
@@ -175,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
182
|
- !ruby/object:Gem::Version
|
176
183
|
version: '0'
|
177
184
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.1.2
|
179
186
|
signing_key:
|
180
187
|
specification_version: 4
|
181
188
|
summary: The Gamefic standard script library.
|