gamefic-standard 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/gamefic-standard.rb +1 -0
- data/lib/gamefic-standard/actions/go.rb +20 -20
- data/lib/gamefic-standard/actions/insert.rb +4 -11
- data/lib/gamefic-standard/actions/nil.rb +2 -1
- data/lib/gamefic-standard/actions/place.rb +12 -15
- data/lib/gamefic-standard/clothing/actions/doff.rb +3 -3
- data/lib/gamefic-standard/clothing/actions/wear.rb +5 -6
- data/lib/gamefic-standard/direction.rb +24 -23
- data/lib/gamefic-standard/door.rb +49 -0
- data/lib/gamefic-standard/edible.rb +23 -23
- data/lib/gamefic-standard/entities/portal.rb +2 -1
- data/lib/gamefic-standard/entities/thing.rb +3 -0
- data/lib/gamefic-standard/lockable.rb +6 -1
- data/lib/gamefic-standard/openable.rb +5 -0
- data/lib/gamefic-standard/pathfinder.rb +4 -5
- data/lib/gamefic-standard/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 755a0c99a63ecce4d48bbbf7381e744c0b7bba4afe57d63c77a8d7febbeba51c
|
4
|
+
data.tar.gz: dcd68b55305fa872123273e76bec293bacf3b396608249291f483d3f01627bf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c17e7ae751826ef14a8533b406b2d9d978fbaad606949aebd2547f34a4a6ee7a901613e4d128694c784e8a8cf993b3c60d8cb6ba050de46a80e70455e0ff55
|
7
|
+
data.tar.gz: f10f11412b6128ec91057c060ef418fd54789cd9d616c24178b4e2c070f00cf5c4c478f56e49fe07eea029d29114c11df14566c1826d00bb962f7e581702cb13
|
data/CHANGELOG.md
CHANGED
data/lib/gamefic-standard.rb
CHANGED
@@ -24,27 +24,27 @@ Gamefic.script do
|
|
24
24
|
actor.tell "Where do you want to go?"
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
interpret "north", "go north"
|
28
|
+
interpret "south", "go south"
|
29
|
+
interpret "west", "go west"
|
30
|
+
interpret "east", "go east"
|
31
|
+
interpret "up", "go up"
|
32
|
+
interpret "down", "go down"
|
33
|
+
interpret "northwest", "go northwest"
|
34
|
+
interpret "northeast", "go northeast"
|
35
|
+
interpret "southwest", "go southwest"
|
36
|
+
interpret "southeast", "go southeast"
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
interpret "n", "go north"
|
39
|
+
interpret "s", "go south"
|
40
|
+
interpret "w", "go west"
|
41
|
+
interpret "e", "go east"
|
42
|
+
interpret "u", "go up"
|
43
|
+
interpret "d", "go down"
|
44
|
+
interpret "nw", "go northwest"
|
45
|
+
interpret "ne", "go northeast"
|
46
|
+
interpret "sw", "go southwest"
|
47
|
+
interpret "se", "go southeast"
|
48
48
|
|
49
49
|
interpret "go to :place", "go :place"
|
50
50
|
end
|
@@ -1,20 +1,13 @@
|
|
1
|
-
# script 'standard'
|
2
1
|
Gamefic.script do
|
3
2
|
respond :insert, Use.available, Use.available do |actor, thing, target|
|
4
3
|
actor.tell "You can't put #{the thing} inside #{the target}."
|
5
4
|
end
|
6
5
|
|
7
|
-
respond :insert, Use.children, Use.available(Receptacle) do |actor, thing, receptacle|
|
8
|
-
actor.tell "You put #{the thing} in #{the receptacle}."
|
9
|
-
thing.parent = receptacle
|
10
|
-
end
|
11
|
-
|
12
6
|
respond :insert, Use.available, Use.available(Receptacle) do |actor, thing, receptacle|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
7
|
+
actor.perform :take, thing unless thing.parent == actor
|
8
|
+
next unless thing.parent == actor
|
9
|
+
thing.parent = receptacle
|
10
|
+
actor.tell "You put #{the thing} in #{the receptacle}."
|
18
11
|
end
|
19
12
|
|
20
13
|
interpret "drop :item in :container", "insert :item :container"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
Gamefic.script do
|
2
2
|
meta nil, Gamefic::Query::Text.new do |actor, string|
|
3
3
|
words = string.split_words
|
4
|
-
|
4
|
+
# @todo There should probably be an Active#verbs or Active#command_words method
|
5
|
+
list = actor.playbooks.flat_map(&:syntaxes).flat_map(&:first_word)
|
5
6
|
if list.include?(words[0])
|
6
7
|
if words.length > 1
|
7
8
|
found = Gamefic::Query::Available.new.resolve(actor, words[1..-1].join(' ')).objects
|
@@ -3,14 +3,11 @@ Gamefic.script do
|
|
3
3
|
actor.tell "You can't put #{the thing} on #{the supporter}."
|
4
4
|
end
|
5
5
|
|
6
|
-
respond :place, Use.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
thing.parent = supporter
|
12
|
-
actor.tell "You put #{the thing} on #{the supporter}."
|
13
|
-
end
|
6
|
+
respond :place, Use.available, Use.available(Supporter) do |actor, thing, supporter|
|
7
|
+
actor.perform :take, thing unless thing.parent == actor
|
8
|
+
next unless thing.parent == actor
|
9
|
+
thing.parent = supporter
|
10
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
14
11
|
end
|
15
12
|
|
16
13
|
respond :place, Use.children, Use.reachable(Supporter) do |actor, thing, supporter|
|
@@ -18,7 +15,7 @@ Gamefic.script do
|
|
18
15
|
actor.tell "You put #{the thing} on #{the supporter}."
|
19
16
|
end
|
20
17
|
|
21
|
-
respond :place, Use.visible, Use.text do |actor,
|
18
|
+
respond :place, Use.visible, Use.text do |actor, _thing, supporter|
|
22
19
|
actor.tell "You don't see anything called \"#{supporter}\" here."
|
23
20
|
end
|
24
21
|
|
@@ -30,10 +27,10 @@ Gamefic.script do
|
|
30
27
|
actor.tell "I don't know what you mean by \"#{thing}\" or \"#{supporter}.\""
|
31
28
|
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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"
|
39
36
|
end
|
@@ -8,7 +8,7 @@ Gamefic.script do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
interpret "remove :clothing", "doff :clothing"
|
12
|
+
interpret "take off :clothing", "doff :clothing"
|
13
|
+
interpret "take :clothing off", "doff :clothing"
|
14
14
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
Gamefic.script do
|
2
2
|
respond :wear, Use.available(Clothing) do |actor, clothing|
|
3
|
-
|
4
|
-
|
5
|
-
end
|
3
|
+
actor.perform :take, clothing unless clothing.parent == actor
|
4
|
+
next unless clothing.parent == actor
|
6
5
|
if clothing.attached?
|
7
6
|
actor.tell "You're already wearing #{the clothing}."
|
8
7
|
else
|
@@ -16,7 +15,7 @@ Gamefic.script do
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
interpret "put on :clothing", "wear :clothing"
|
19
|
+
interpret "put :clothing on", "wear :clothing"
|
20
|
+
interpret "don :clothing", "wear :clothing"
|
22
21
|
end
|
@@ -1,53 +1,54 @@
|
|
1
1
|
class Direction
|
2
2
|
include Gamefic::Serialize
|
3
3
|
|
4
|
-
|
4
|
+
attr_writer :adjective, :adverb, :reverse
|
5
5
|
|
6
|
-
|
6
|
+
# @return [String]
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
def initialize **args
|
7
10
|
args.each { |key, value|
|
8
11
|
send "#{key}=", value
|
9
12
|
}
|
10
|
-
if !reverse.nil?
|
11
|
-
reverse.reverse = self
|
12
|
-
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# @return [String]
|
15
16
|
def adjective
|
16
17
|
@adjective || @name
|
17
18
|
end
|
18
19
|
|
20
|
+
# @return [String]
|
19
21
|
def adverb
|
20
22
|
@adverb || @name
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
@reverse = dir
|
25
|
-
end
|
26
|
-
|
25
|
+
# @return [String]
|
27
26
|
def synonyms
|
28
27
|
"#{adjective} #{adverb}"
|
29
28
|
end
|
30
29
|
|
30
|
+
def reverse
|
31
|
+
Direction.find @reverse
|
32
|
+
end
|
33
|
+
|
31
34
|
def to_s
|
32
35
|
@name
|
33
36
|
end
|
34
37
|
|
35
38
|
class << self
|
36
39
|
def compass
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
@compass
|
40
|
+
@compass ||= {
|
41
|
+
north: Direction.new(name: 'north', adjective: 'northern', reverse: :south),
|
42
|
+
south: Direction.new(name: 'south', adjective: 'southern', reverse: :north),
|
43
|
+
west: Direction.new(name: 'west', adjective: 'western', reverse: :east),
|
44
|
+
east: Direction.new(name: 'east', adjective: 'eastern', reverse: :west),
|
45
|
+
northwest: Direction.new(name: 'northwest', adjective: 'northwestern', reverse: :southeast),
|
46
|
+
southeast: Direction.new(name: 'southeast', adjective: 'southeastern', reverse: :northwest),
|
47
|
+
northeast: Direction.new(name: 'northeast', adjective: 'northeastern', reverse: :southwest),
|
48
|
+
southwest: Direction.new(name: 'southwest', adjective: 'southwestern', reverse: :northeast),
|
49
|
+
up: Direction.new(name: 'up', adjective: 'upwards', reverse: :down),
|
50
|
+
down: Direction.new(name: 'down', adjective: 'downwards', reverse: :up)
|
51
|
+
}
|
51
52
|
end
|
52
53
|
|
53
54
|
# @param dir [Direction, string]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'gamefic-standard/openable'
|
2
|
+
|
3
|
+
# An openable portal.
|
4
|
+
#
|
5
|
+
class Door < Portal
|
6
|
+
include Openable
|
7
|
+
include Lockable
|
8
|
+
|
9
|
+
def post_initialize
|
10
|
+
update_reverse_open
|
11
|
+
end
|
12
|
+
|
13
|
+
def open= bool
|
14
|
+
super
|
15
|
+
update_reverse_open
|
16
|
+
end
|
17
|
+
|
18
|
+
def locked= bool
|
19
|
+
super
|
20
|
+
update_reverse_lock
|
21
|
+
end
|
22
|
+
|
23
|
+
def two_way_lock_key= key
|
24
|
+
lock_key = key
|
25
|
+
return if reverse.nil?
|
26
|
+
reverse.lock_key = key
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def update_reverse_open
|
32
|
+
rev = find_reverse
|
33
|
+
return if rev.nil? || rev.open? == open?
|
34
|
+
rev.open = open?
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_reverse_lock
|
38
|
+
rev = find_reverse
|
39
|
+
return if rev.nil? || rev.locked? == locked?
|
40
|
+
rev.locked = locked?
|
41
|
+
end
|
42
|
+
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
|
@@ -1,23 +1,23 @@
|
|
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
|
+
# @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
|
@@ -15,12 +15,13 @@ class Portal < Thing
|
|
15
15
|
# Find the portal in the destination that returns to this portal's parent
|
16
16
|
#
|
17
17
|
# @return [Room, nil]
|
18
|
-
def
|
18
|
+
def reverse
|
19
19
|
return nil if destination.nil?
|
20
20
|
destination.children.that_are(Portal).find do |portal|
|
21
21
|
portal.destination == parent
|
22
22
|
end
|
23
23
|
end
|
24
|
+
alias find_reverse reverse
|
24
25
|
|
25
26
|
def direction= dir
|
26
27
|
@direction = Direction.find(dir)
|
@@ -1,14 +1,17 @@
|
|
1
1
|
class Thing < Gamefic::Entity
|
2
2
|
include Grammar::Attributes
|
3
3
|
|
4
|
+
# @return [Boolean]
|
4
5
|
attr_writer :itemized
|
5
6
|
|
7
|
+
# @return [Boolean]
|
6
8
|
attr_writer :portable
|
7
9
|
|
8
10
|
# An optional description to use when itemizing entities in room
|
9
11
|
# descriptions. The locale_description will be used instead of adding
|
10
12
|
# the entity's name to a list.
|
11
13
|
#
|
14
|
+
# @return [String, nil]
|
12
15
|
attr_accessor :locale_description
|
13
16
|
|
14
17
|
set_default itemized: true
|
@@ -7,9 +7,10 @@
|
|
7
7
|
class Pathfinder
|
8
8
|
# @return [Room]
|
9
9
|
attr_reader :origin
|
10
|
+
|
10
11
|
# @return [Room]
|
11
12
|
attr_reader :destination
|
12
|
-
|
13
|
+
|
13
14
|
def initialize origin, destination
|
14
15
|
@origin = origin
|
15
16
|
@destination = destination
|
@@ -19,9 +20,7 @@ class Pathfinder
|
|
19
20
|
if @origin == @destination
|
20
21
|
@path = []
|
21
22
|
else
|
22
|
-
while @path.nil?
|
23
|
-
embark
|
24
|
-
end
|
23
|
+
embark while @path.nil? && @paths.length > 0
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -34,7 +33,7 @@ class Pathfinder
|
|
34
33
|
|
35
34
|
# @return [Boolean]
|
36
35
|
def valid?
|
37
|
-
path.length > 0
|
36
|
+
path.length > 0 || origin == destination
|
38
37
|
end
|
39
38
|
|
40
39
|
private
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gamefic
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/gamefic-standard/clothing/entities/shoes.rb
|
139
139
|
- lib/gamefic-standard/container.rb
|
140
140
|
- lib/gamefic-standard/direction.rb
|
141
|
+
- lib/gamefic-standard/door.rb
|
141
142
|
- lib/gamefic-standard/edible.rb
|
142
143
|
- lib/gamefic-standard/entities.rb
|
143
144
|
- lib/gamefic-standard/entities/character.rb
|
@@ -167,7 +168,7 @@ homepage: http://gamefic.com
|
|
167
168
|
licenses:
|
168
169
|
- MIT
|
169
170
|
metadata: {}
|
170
|
-
post_install_message:
|
171
|
+
post_install_message:
|
171
172
|
rdoc_options: []
|
172
173
|
require_paths:
|
173
174
|
- lib
|
@@ -182,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
- !ruby/object:Gem::Version
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
|
-
rubygems_version: 3.1.
|
186
|
-
signing_key:
|
186
|
+
rubygems_version: 3.1.6
|
187
|
+
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: The Gamefic standard script library.
|
189
190
|
test_files: []
|