gamefic-standard 3.2.4 → 4.0.0
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 +10 -0
- data/Rakefile +11 -5
- data/gamefic-standard.gemspec +15 -13
- data/lib/gamefic/standard/actions/attack.rb +32 -0
- data/lib/gamefic/standard/actions/close.rb +24 -0
- data/lib/gamefic/standard/actions/drop.rb +39 -0
- data/lib/gamefic/standard/actions/enter.rb +34 -0
- data/lib/gamefic/standard/actions/give.rb +38 -0
- data/lib/gamefic/standard/actions/go.rb +63 -0
- data/lib/gamefic/standard/actions/insert.rb +53 -0
- data/lib/gamefic/standard/actions/inventory.rb +20 -0
- data/lib/gamefic/standard/actions/leave.rb +57 -0
- data/lib/gamefic/standard/actions/lock.rb +31 -0
- data/lib/gamefic/standard/actions/look.rb +149 -0
- data/lib/gamefic/standard/actions/mount.rb +29 -0
- data/lib/gamefic/standard/actions/move.rb +28 -0
- data/lib/gamefic/standard/actions/nil.rb +37 -0
- data/lib/gamefic/standard/actions/open.rb +39 -0
- data/lib/gamefic/standard/actions/place.rb +39 -0
- data/lib/gamefic/standard/actions/pronouns.rb +34 -0
- data/lib/gamefic/standard/actions/quit.rb +24 -0
- data/lib/gamefic/standard/actions/repeat.rb +28 -0
- data/lib/gamefic/standard/actions/save-restore-undo.rb +26 -0
- data/lib/gamefic/standard/actions/search.rb +36 -0
- data/lib/gamefic/standard/actions/take.rb +54 -0
- data/lib/gamefic/standard/actions/talk.rb +51 -0
- data/lib/gamefic/standard/actions/unlock.rb +35 -0
- data/lib/gamefic/standard/actions/wait.rb +17 -0
- data/lib/gamefic/standard/actions.rb +57 -0
- data/lib/gamefic/standard/articles.rb +52 -0
- data/lib/gamefic/standard/enterable.rb +13 -0
- data/lib/gamefic/standard/entities/character.rb +14 -0
- data/lib/gamefic/standard/entities/container.rb +16 -0
- data/lib/gamefic/standard/entities/door.rb +46 -0
- data/lib/gamefic/standard/entities/fixture.rb +8 -0
- data/lib/gamefic/standard/entities/item.rb +11 -0
- data/lib/gamefic/standard/entities/portal.rb +50 -0
- data/lib/gamefic/standard/entities/receptacle.rb +9 -0
- data/lib/gamefic/standard/entities/room.rb +55 -0
- data/lib/gamefic/standard/entities/rubble.rb +16 -0
- data/lib/gamefic/standard/entities/scenery.rb +13 -0
- data/lib/gamefic/standard/entities/supporter.rb +9 -0
- data/lib/gamefic/standard/entities/thing.rb +9 -0
- data/lib/gamefic/standard/entities.rb +18 -0
- data/lib/gamefic/standard/introduction.rb +18 -0
- data/lib/gamefic/standard/lockable.rb +44 -0
- data/lib/gamefic/standard/openable.rb +33 -0
- data/lib/gamefic/standard/pathfinder.rb +82 -0
- data/lib/gamefic/standard/queries.rb +24 -0
- data/lib/gamefic/standard/standardized.rb +65 -0
- data/lib/{gamefic-standard → gamefic/standard}/version.rb +1 -1
- data/lib/gamefic/standard.rb +32 -0
- data/lib/gamefic-standard.rb +1 -27
- metadata +83 -58
- data/lib/gamefic-standard/actions/attack.rb +0 -28
- data/lib/gamefic-standard/actions/close.rb +0 -18
- data/lib/gamefic-standard/actions/drop.rb +0 -24
- data/lib/gamefic-standard/actions/enter.rb +0 -36
- data/lib/gamefic-standard/actions/go.rb +0 -59
- data/lib/gamefic-standard/actions/insert.rb +0 -39
- data/lib/gamefic-standard/actions/inventory.rb +0 -15
- data/lib/gamefic-standard/actions/leave.rb +0 -50
- data/lib/gamefic-standard/actions/lock.rb +0 -25
- data/lib/gamefic-standard/actions/look.rb +0 -133
- data/lib/gamefic-standard/actions/move.rb +0 -24
- data/lib/gamefic-standard/actions/nil.rb +0 -60
- data/lib/gamefic-standard/actions/open.rb +0 -29
- data/lib/gamefic-standard/actions/place.rb +0 -24
- data/lib/gamefic-standard/actions/pronouns.rb +0 -28
- data/lib/gamefic-standard/actions/quit.rb +0 -10
- data/lib/gamefic-standard/actions/repeat.rb +0 -14
- data/lib/gamefic-standard/actions/save-restore-undo.rb +0 -18
- data/lib/gamefic-standard/actions/search.rb +0 -26
- data/lib/gamefic-standard/actions/take.rb +0 -40
- data/lib/gamefic-standard/actions/talk.rb +0 -37
- data/lib/gamefic-standard/actions/unlock.rb +0 -25
- data/lib/gamefic-standard/actions/wait.rb +0 -7
- data/lib/gamefic-standard/actions.rb +0 -23
- data/lib/gamefic-standard/articles.rb +0 -42
- data/lib/gamefic-standard/entities/character.rb +0 -2
- data/lib/gamefic-standard/entities/container.rb +0 -8
- data/lib/gamefic-standard/entities/door.rb +0 -42
- data/lib/gamefic-standard/entities/fixture.rb +0 -4
- data/lib/gamefic-standard/entities/item.rb +0 -7
- data/lib/gamefic-standard/entities/portal.rb +0 -46
- data/lib/gamefic-standard/entities/receptacle.rb +0 -5
- data/lib/gamefic-standard/entities/room.rb +0 -46
- data/lib/gamefic-standard/entities/rubble.rb +0 -12
- data/lib/gamefic-standard/entities/scenery.rb +0 -9
- data/lib/gamefic-standard/entities/supporter.rb +0 -5
- data/lib/gamefic-standard/entities/thing.rb +0 -9
- data/lib/gamefic-standard/entities.rb +0 -12
- data/lib/gamefic-standard/give.rb +0 -21
- data/lib/gamefic-standard/grammar/attributes.rb +0 -37
- data/lib/gamefic-standard/grammar/pronoun.rb +0 -101
- data/lib/gamefic-standard/grammar.rb +0 -2
- data/lib/gamefic-standard/introduction.rb +0 -8
- data/lib/gamefic-standard/modules/enterable.rb +0 -9
- data/lib/gamefic-standard/modules/lockable.rb +0 -34
- data/lib/gamefic-standard/modules/openable.rb +0 -19
- data/lib/gamefic-standard/modules/standardized.rb +0 -57
- data/lib/gamefic-standard/modules.rb +0 -6
- data/lib/gamefic-standard/pathfinder.rb +0 -62
- data/lib/gamefic-standard/queries.rb +0 -12
- data/spec-opal/spec_helper.rb +0 -32
- /data/lib/{gamefic-standard → gamefic/standard}/direction.rb +0 -0
@@ -1,37 +0,0 @@
|
|
1
|
-
module Grammar
|
2
|
-
# A collection of attributes that enable grammar features for entities, such
|
3
|
-
# as selecting their correct pronouns.
|
4
|
-
#
|
5
|
-
module Attributes
|
6
|
-
# @see #gender
|
7
|
-
attr_writer :gender
|
8
|
-
|
9
|
-
# @see #plural?
|
10
|
-
attr_writer :plural
|
11
|
-
|
12
|
-
# The gender of the object. Supported values are :male, :female, :neutral,
|
13
|
-
# and :other. Use :neutral for objects that don't have a gender (i.e.,
|
14
|
-
# "it"). Use :other for people or characters that have an unspecified or
|
15
|
-
# non-binary gender (i.e., "they").
|
16
|
-
#
|
17
|
-
# @return [Symbol]
|
18
|
-
def gender
|
19
|
-
@gender ||= :neutral
|
20
|
-
end
|
21
|
-
|
22
|
-
# True if the object should be referred to in the plural, e.g., "they"
|
23
|
-
# instead of "it."
|
24
|
-
# @return [Boolean]
|
25
|
-
#
|
26
|
-
def plural?
|
27
|
-
@plural ||= false
|
28
|
-
end
|
29
|
-
|
30
|
-
# For now, the object's person is always assumed to be third
|
31
|
-
# (he/she/it/they). A future version of this library might support first
|
32
|
-
# (I/me) and second (you).
|
33
|
-
def person
|
34
|
-
3
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Grammar
|
4
|
-
# Functions to select pronouns based on an entity's attributes, such as
|
5
|
-
# gender.
|
6
|
-
#
|
7
|
-
module Pronoun
|
8
|
-
extend self
|
9
|
-
|
10
|
-
# @param entity [#person, #plural?, #gender]
|
11
|
-
# @return [String]
|
12
|
-
def subjective(entity)
|
13
|
-
map(entity)[:subjective]
|
14
|
-
end
|
15
|
-
alias they subjective
|
16
|
-
alias he subjective
|
17
|
-
alias she subjective
|
18
|
-
|
19
|
-
# @param entity [#person, #plural?, #gender]
|
20
|
-
# @return [String]
|
21
|
-
def subjective_(entity)
|
22
|
-
subjective(entity).cap_first
|
23
|
-
end
|
24
|
-
alias they_ subjective_
|
25
|
-
alias he_ subjective_
|
26
|
-
alias she_ subjective_
|
27
|
-
|
28
|
-
# @param entity [#person, #plural?, #gender]
|
29
|
-
# @return [String]
|
30
|
-
def objective(entity)
|
31
|
-
map(entity)[:objective]
|
32
|
-
end
|
33
|
-
alias them objective
|
34
|
-
|
35
|
-
# @param entity [#person, #plural?, #gender]
|
36
|
-
# @return [String]
|
37
|
-
def objective_(entity)
|
38
|
-
objective(entity).cap_first
|
39
|
-
end
|
40
|
-
alias them_ objective_
|
41
|
-
|
42
|
-
# @param entity [#person, #plural?, #gender]
|
43
|
-
# @return [String]
|
44
|
-
def possessive(entity)
|
45
|
-
map(entity)[:possessive]
|
46
|
-
end
|
47
|
-
alias their possessive
|
48
|
-
|
49
|
-
# @param entity [#person, #plural?, #gender]
|
50
|
-
# @return [String]
|
51
|
-
def possessive_(entity)
|
52
|
-
possessive(entity).cap_first
|
53
|
-
end
|
54
|
-
alias their_ possessive_
|
55
|
-
|
56
|
-
# @param entity [#person, #plural?, #gender]
|
57
|
-
# @return [String]
|
58
|
-
def reflexive(entity)
|
59
|
-
map(entity)[:reflexive]
|
60
|
-
end
|
61
|
-
alias themselves reflexive
|
62
|
-
alias themself reflexive
|
63
|
-
|
64
|
-
# @param entity [#person, #plural?, #gender]
|
65
|
-
# @return [String]
|
66
|
-
def reflexive_(entity)
|
67
|
-
reflexive(entity).cap_first
|
68
|
-
end
|
69
|
-
alias themselves_ reflexive_
|
70
|
-
alias themself_ reflexive_
|
71
|
-
|
72
|
-
# @param entity [#person, #plural?, #gender]
|
73
|
-
# @return [Hash]
|
74
|
-
def map(entity)
|
75
|
-
plurality = (entity.plural? ? :plural : :singular)
|
76
|
-
maps[[(entity.person || 3), plurality, entity.gender]] ||
|
77
|
-
maps[[(entity.person || 3), plurality]]
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def maps
|
83
|
-
@maps ||= {
|
84
|
-
[1, :singular] => Hash[map_keys.zip(%w[I me my myself])],
|
85
|
-
[2, :singular] => Hash[map_keys.zip(%w[you you your yourself])],
|
86
|
-
[3, :singular] => Hash[map_keys.zip(%w[it it its itself])],
|
87
|
-
[3, :singular, :male] => Hash[map_keys.zip(%w[he him his himself])],
|
88
|
-
[3, :singular, :female] => Hash[map_keys.zip(%w[she her her herself])],
|
89
|
-
[3, :singular, :other] => Hash[map_keys.zip(%w[they them their themselves])],
|
90
|
-
[3, :singular, :neutral] => Hash[map_keys.zip(%w[it it its itself])],
|
91
|
-
[1, :plural] => Hash[map_keys.zip(%w[we us our ourselves])],
|
92
|
-
[2, :plural] => Hash[map_keys.zip(%w[you you your yourselves])],
|
93
|
-
[3, :plural] => Hash[map_keys.zip(%w[they them their themselves])]
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
def map_keys
|
98
|
-
@map_keys ||= %i[subjective objective possessive reflexive]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,34 +0,0 @@
|
|
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
|
-
@open = false
|
12
|
-
end
|
13
|
-
@locked
|
14
|
-
end
|
15
|
-
|
16
|
-
def open=(bool)
|
17
|
-
@open = bool
|
18
|
-
@locked = false if @open == true
|
19
|
-
@open
|
20
|
-
end
|
21
|
-
|
22
|
-
def locked?
|
23
|
-
@locked ||= false
|
24
|
-
end
|
25
|
-
|
26
|
-
def unlocked?
|
27
|
-
!locked?
|
28
|
-
end
|
29
|
-
|
30
|
-
def lock_key?
|
31
|
-
!@lock_key.nil?
|
32
|
-
end
|
33
|
-
alias has_lock_key? lock_key?
|
34
|
-
end
|
@@ -1,57 +0,0 @@
|
|
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
|
-
ascendant = parent
|
54
|
-
ascendant = ascendant.parent until ascendant.is_a?(Room) || ascendant.nil?
|
55
|
-
ascendant
|
56
|
-
end
|
57
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# Pathfinders provide the shortest route between two locations. The
|
2
|
-
# destination needs to be accessible from the origin through portals. Note
|
3
|
-
# that Pathfinders do not take into account portals that characters should
|
4
|
-
# not be able to traverse, such as locked doors.
|
5
|
-
class Pathfinder
|
6
|
-
# @return [Room]
|
7
|
-
attr_reader :origin
|
8
|
-
|
9
|
-
# @return [Room]
|
10
|
-
attr_reader :destination
|
11
|
-
|
12
|
-
def initialize origin, destination
|
13
|
-
@origin = origin
|
14
|
-
@destination = destination
|
15
|
-
@path = nil
|
16
|
-
@paths = [[@origin]]
|
17
|
-
@visited = []
|
18
|
-
if @origin == @destination
|
19
|
-
@path = []
|
20
|
-
else
|
21
|
-
embark while @path.nil? && @paths.length > 0
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [Array<Room>]
|
26
|
-
def path
|
27
|
-
# @path is nil if the path is invalid, but #path should return an empty
|
28
|
-
# array instead.
|
29
|
-
@path || []
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Boolean]
|
33
|
-
def valid?
|
34
|
-
path.length > 0 || origin == destination
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def embark
|
40
|
-
new_paths = []
|
41
|
-
@paths.each { |path|
|
42
|
-
last = path.last
|
43
|
-
portals = last.children.that_are(Portal)
|
44
|
-
portals.each { |portal|
|
45
|
-
new_path = path.clone
|
46
|
-
if !@visited.include?(portal.destination)
|
47
|
-
new_path.push portal.destination
|
48
|
-
@visited.push portal.destination
|
49
|
-
if portal.destination == @destination
|
50
|
-
@path = new_path
|
51
|
-
@path.shift
|
52
|
-
break
|
53
|
-
end
|
54
|
-
new_paths.push new_path
|
55
|
-
end
|
56
|
-
}
|
57
|
-
path.push nil
|
58
|
-
}
|
59
|
-
@paths += new_paths
|
60
|
-
@paths.delete_if{|path| path.last.nil?}
|
61
|
-
end
|
62
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Gamefic::Scope::Room < Gamefic::Scope::Base
|
2
|
-
def matches
|
3
|
-
[context.room].compact
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
# @todo Monkey patch
|
8
|
-
module Gamefic::Scriptable::Queries
|
9
|
-
def room *args
|
10
|
-
Gamefic::Query::Scoped.new Gamefic::Scope::Room, *([Room] + args)
|
11
|
-
end
|
12
|
-
end
|
data/spec-opal/spec_helper.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'gamefic-standard'
|
4
|
-
|
5
|
-
class TestPlot < Gamefic::Plot
|
6
|
-
include Gamefic::Standard
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
# Run specs in random order to surface order dependencies. If you find an
|
11
|
-
# order dependency and want to debug it, you can fix the order by providing
|
12
|
-
# the seed, which is printed after each run.
|
13
|
-
# --seed 1234
|
14
|
-
config.order = :random
|
15
|
-
|
16
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
17
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
18
|
-
# test failures related to randomization by passing the same `--seed` value
|
19
|
-
# as the one that triggered the failure.
|
20
|
-
Kernel.srand config.seed
|
21
|
-
|
22
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
23
|
-
config.disable_monkey_patching!
|
24
|
-
|
25
|
-
config.expect_with :rspec do |c|
|
26
|
-
c.syntax = :expect
|
27
|
-
end
|
28
|
-
|
29
|
-
config.after :each do
|
30
|
-
TestPlot.blocks.clear
|
31
|
-
end
|
32
|
-
end
|
File without changes
|