gamefic-standard 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.vscode/launch.json +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gamefic-standard.gemspec +44 -0
- data/lib/gamefic-standard.rb +10 -0
- data/lib/gamefic-standard/actions.rb +13 -0
- data/lib/gamefic-standard/actions/drop.rb +21 -0
- data/lib/gamefic-standard/actions/enter.rb +21 -0
- data/lib/gamefic-standard/actions/go.rb +56 -0
- data/lib/gamefic-standard/actions/insert.rb +38 -0
- data/lib/gamefic-standard/actions/inventory.rb +11 -0
- data/lib/gamefic-standard/actions/leave.rb +32 -0
- data/lib/gamefic-standard/actions/look.rb +117 -0
- data/lib/gamefic-standard/actions/nil.rb +38 -0
- data/lib/gamefic-standard/actions/place.rb +43 -0
- data/lib/gamefic-standard/actions/quit.rb +14 -0
- data/lib/gamefic-standard/actions/take.rb +33 -0
- data/lib/gamefic-standard/actions/talk.rb +29 -0
- data/lib/gamefic-standard/actions/wait.rb +5 -0
- data/lib/gamefic-standard/articles.rb +50 -0
- data/lib/gamefic-standard/clothing.rb +4 -0
- data/lib/gamefic-standard/clothing/actions.rb +4 -0
- data/lib/gamefic-standard/clothing/actions/doff.rb +14 -0
- data/lib/gamefic-standard/clothing/actions/drop.rb +10 -0
- data/lib/gamefic-standard/clothing/actions/inventory.rb +16 -0
- data/lib/gamefic-standard/clothing/actions/wear.rb +22 -0
- data/lib/gamefic-standard/clothing/entities.rb +7 -0
- data/lib/gamefic-standard/clothing/entities/clothing.rb +5 -0
- data/lib/gamefic-standard/clothing/entities/coat.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/gloves.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/hat.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/pants.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/shirt.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/shoes.rb +3 -0
- data/lib/gamefic-standard/container.rb +27 -0
- data/lib/gamefic-standard/direction.rb +55 -0
- data/lib/gamefic-standard/edible.rb +23 -0
- data/lib/gamefic-standard/entities.rb +10 -0
- data/lib/gamefic-standard/entities/character.rb +11 -0
- data/lib/gamefic-standard/entities/fixture.rb +3 -0
- data/lib/gamefic-standard/entities/item.rb +5 -0
- data/lib/gamefic-standard/entities/portal.rb +44 -0
- data/lib/gamefic-standard/entities/receptacle.rb +3 -0
- data/lib/gamefic-standard/entities/room.rb +79 -0
- data/lib/gamefic-standard/entities/rubble.rb +11 -0
- data/lib/gamefic-standard/entities/scenery.rb +7 -0
- data/lib/gamefic-standard/entities/supporter.rb +7 -0
- data/lib/gamefic-standard/entities/thing.rb +72 -0
- data/lib/gamefic-standard/give.rb +27 -0
- data/lib/gamefic-standard/grammar.rb +2 -0
- data/lib/gamefic-standard/grammar/attributes.rb +37 -0
- data/lib/gamefic-standard/grammar/pronoun.rb +101 -0
- data/lib/gamefic-standard/lockable.rb +93 -0
- data/lib/gamefic-standard/modules.rb +7 -0
- data/lib/gamefic-standard/modules/enterable.rb +19 -0
- data/lib/gamefic-standard/modules/use.rb +45 -0
- data/lib/gamefic-standard/openable.rb +49 -0
- data/lib/gamefic-standard/pathfinder.rb +65 -0
- data/lib/gamefic-standard/queries.rb +25 -0
- data/lib/gamefic-standard/test.rb +36 -0
- data/lib/gamefic-standard/version.rb +5 -0
- metadata +182 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
# The StandardMethods module provides a namespace to define additional methods
|
2
|
+
# for plots and subplots. Examples include the `connect` method for creating
|
3
|
+
# portals between rooms.
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'gamefic-standard/modules/use'
|
7
|
+
require 'gamefic-standard/modules/enterable'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Enterable
|
2
|
+
attr_writer :enterable, :leave_verb, :enter_verb, :inside_verb
|
3
|
+
|
4
|
+
def enterable?
|
5
|
+
@enterable ||= false
|
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
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Use
|
2
|
+
def self.children *args
|
3
|
+
Gamefic::Query::Children.new *args
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.family *args
|
7
|
+
Gamefic::Query::Family.new *args
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parent *args
|
11
|
+
Gamefic::Query::Parent.new *args
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.siblings *args
|
15
|
+
Gamefic::Query::Siblings.new *args
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.text *args
|
19
|
+
Gamefic::Query::Text.new *args
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.available *args
|
23
|
+
Gamefic::Query::Available.new *args
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.reachable *args
|
27
|
+
available *args
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.visible *args
|
31
|
+
available *args
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.room *args
|
35
|
+
Gamefic::Query::Room.new *args
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.itself *args
|
39
|
+
Gamefic::Query::Room.new *args
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.from objects, *args
|
43
|
+
Gamefic::Query::External.new objects, *args
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +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
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# @gamefic.script standard/pathfinder
|
2
|
+
# Pathfinders provide the shortest route between two locations. The
|
3
|
+
# destination needs to be accessible from the origin through portals. Note
|
4
|
+
# that Pathfinders do not take into account portals that characters should
|
5
|
+
# not be able to traverse, such as locked doors.
|
6
|
+
|
7
|
+
class Pathfinder
|
8
|
+
# @return [Room]
|
9
|
+
attr_reader :origin
|
10
|
+
# @return [Room]
|
11
|
+
attr_reader :destination
|
12
|
+
|
13
|
+
def initialize origin, destination
|
14
|
+
@origin = origin
|
15
|
+
@destination = destination
|
16
|
+
@path = nil
|
17
|
+
@paths = [[@origin]]
|
18
|
+
@visited = []
|
19
|
+
if @origin == @destination
|
20
|
+
@path = []
|
21
|
+
else
|
22
|
+
while @path.nil? and @paths.length > 0
|
23
|
+
embark
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Array<Room>]
|
29
|
+
def path
|
30
|
+
# @path is nil if the path is invalid, but #path should return an empty
|
31
|
+
# array instead.
|
32
|
+
@path || []
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Boolean]
|
36
|
+
def valid?
|
37
|
+
path.length > 0 or origin == destination
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def embark
|
43
|
+
new_paths = []
|
44
|
+
@paths.each { |path|
|
45
|
+
last = path.last
|
46
|
+
portals = last.children.that_are(Portal)
|
47
|
+
portals.each { |portal|
|
48
|
+
new_path = path.clone
|
49
|
+
if !@visited.include?(portal.destination)
|
50
|
+
new_path.push portal.destination
|
51
|
+
@visited.push portal.destination
|
52
|
+
if portal.destination == @destination
|
53
|
+
@path = new_path
|
54
|
+
@path.shift
|
55
|
+
break
|
56
|
+
end
|
57
|
+
new_paths.push new_path
|
58
|
+
end
|
59
|
+
}
|
60
|
+
path.push nil
|
61
|
+
}
|
62
|
+
@paths += new_paths
|
63
|
+
@paths.delete_if{|path| path.last.nil?}
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Gamefic::Query::Available < Gamefic::Query::Base
|
2
|
+
def context_from(subject)
|
3
|
+
result = []
|
4
|
+
top = subject.room || subject.parent
|
5
|
+
unless top.nil?
|
6
|
+
result.concat subquery_accessible(top)
|
7
|
+
end
|
8
|
+
result.delete subject
|
9
|
+
subject.children.each { |c|
|
10
|
+
result.push c
|
11
|
+
result.concat subquery_accessible(c)
|
12
|
+
}
|
13
|
+
result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Gamefic::Query::Room < Gamefic::Query::Base
|
18
|
+
def context_from(subject)
|
19
|
+
subject.room ? [subject.room] : []
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Gamefic.script do
|
24
|
+
set_default_query Gamefic::Query::Available
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# @gamefic.script standard/test
|
2
|
+
|
3
|
+
module Tester
|
4
|
+
def test_procs
|
5
|
+
@test_procs ||= Hash.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def on_test name = :me, &block
|
9
|
+
test_procs[name] = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_test name, actor
|
13
|
+
queue = []
|
14
|
+
test_procs[name].call(actor, queue)
|
15
|
+
actor.queue.concat queue
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Gamefic::Plot
|
20
|
+
include Tester
|
21
|
+
end
|
22
|
+
|
23
|
+
class Gamefic::Subplot
|
24
|
+
include Tester
|
25
|
+
end
|
26
|
+
|
27
|
+
Gamefic.script do
|
28
|
+
meta :test, Gamefic::Query::Text.new do |actor, name|
|
29
|
+
sym = name.to_sym
|
30
|
+
if test_procs[sym].nil?
|
31
|
+
actor.tell "There's no test named '#{name}' in this game."
|
32
|
+
else
|
33
|
+
run_test sym, actor
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gamefic-standard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fred Snyder
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gamefic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.14'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.14'
|
83
|
+
description: A collection of components for building games and interactive fiction
|
84
|
+
in Gamefic.
|
85
|
+
email:
|
86
|
+
- fsnyder@castwide.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- ".vscode/launch.json"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- gamefic-standard.gemspec
|
102
|
+
- lib/gamefic-standard.rb
|
103
|
+
- lib/gamefic-standard/actions.rb
|
104
|
+
- lib/gamefic-standard/actions/drop.rb
|
105
|
+
- lib/gamefic-standard/actions/enter.rb
|
106
|
+
- lib/gamefic-standard/actions/go.rb
|
107
|
+
- lib/gamefic-standard/actions/insert.rb
|
108
|
+
- lib/gamefic-standard/actions/inventory.rb
|
109
|
+
- lib/gamefic-standard/actions/leave.rb
|
110
|
+
- lib/gamefic-standard/actions/look.rb
|
111
|
+
- lib/gamefic-standard/actions/nil.rb
|
112
|
+
- lib/gamefic-standard/actions/place.rb
|
113
|
+
- lib/gamefic-standard/actions/quit.rb
|
114
|
+
- lib/gamefic-standard/actions/take.rb
|
115
|
+
- lib/gamefic-standard/actions/talk.rb
|
116
|
+
- lib/gamefic-standard/actions/wait.rb
|
117
|
+
- lib/gamefic-standard/articles.rb
|
118
|
+
- lib/gamefic-standard/clothing.rb
|
119
|
+
- lib/gamefic-standard/clothing/actions.rb
|
120
|
+
- lib/gamefic-standard/clothing/actions/doff.rb
|
121
|
+
- lib/gamefic-standard/clothing/actions/drop.rb
|
122
|
+
- lib/gamefic-standard/clothing/actions/inventory.rb
|
123
|
+
- lib/gamefic-standard/clothing/actions/wear.rb
|
124
|
+
- lib/gamefic-standard/clothing/entities.rb
|
125
|
+
- lib/gamefic-standard/clothing/entities/clothing.rb
|
126
|
+
- lib/gamefic-standard/clothing/entities/coat.rb
|
127
|
+
- lib/gamefic-standard/clothing/entities/gloves.rb
|
128
|
+
- lib/gamefic-standard/clothing/entities/hat.rb
|
129
|
+
- lib/gamefic-standard/clothing/entities/pants.rb
|
130
|
+
- lib/gamefic-standard/clothing/entities/shirt.rb
|
131
|
+
- lib/gamefic-standard/clothing/entities/shoes.rb
|
132
|
+
- lib/gamefic-standard/container.rb
|
133
|
+
- lib/gamefic-standard/direction.rb
|
134
|
+
- lib/gamefic-standard/edible.rb
|
135
|
+
- lib/gamefic-standard/entities.rb
|
136
|
+
- lib/gamefic-standard/entities/character.rb
|
137
|
+
- lib/gamefic-standard/entities/fixture.rb
|
138
|
+
- lib/gamefic-standard/entities/item.rb
|
139
|
+
- lib/gamefic-standard/entities/portal.rb
|
140
|
+
- lib/gamefic-standard/entities/receptacle.rb
|
141
|
+
- lib/gamefic-standard/entities/room.rb
|
142
|
+
- lib/gamefic-standard/entities/rubble.rb
|
143
|
+
- lib/gamefic-standard/entities/scenery.rb
|
144
|
+
- lib/gamefic-standard/entities/supporter.rb
|
145
|
+
- lib/gamefic-standard/entities/thing.rb
|
146
|
+
- lib/gamefic-standard/give.rb
|
147
|
+
- lib/gamefic-standard/grammar.rb
|
148
|
+
- lib/gamefic-standard/grammar/attributes.rb
|
149
|
+
- lib/gamefic-standard/grammar/pronoun.rb
|
150
|
+
- lib/gamefic-standard/lockable.rb
|
151
|
+
- lib/gamefic-standard/modules.rb
|
152
|
+
- lib/gamefic-standard/modules/enterable.rb
|
153
|
+
- lib/gamefic-standard/modules/use.rb
|
154
|
+
- lib/gamefic-standard/openable.rb
|
155
|
+
- lib/gamefic-standard/pathfinder.rb
|
156
|
+
- lib/gamefic-standard/queries.rb
|
157
|
+
- lib/gamefic-standard/test.rb
|
158
|
+
- lib/gamefic-standard/version.rb
|
159
|
+
homepage: http://gamefic.com
|
160
|
+
licenses:
|
161
|
+
- MIT
|
162
|
+
metadata: {}
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubygems_version: 3.0.3
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: The Gamefic standard script library.
|
182
|
+
test_files: []
|