gamefic-standard 3.2.3 → 3.3.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 +10 -0
- data/Rakefile +5 -2
- data/gamefic-standard.gemspec +13 -11
- data/lib/gamefic-standard/actions/attack.rb +23 -19
- data/lib/gamefic-standard/actions/close.rb +16 -10
- data/lib/gamefic-standard/actions/drop.rb +31 -16
- data/lib/gamefic-standard/actions/enter.rb +32 -26
- data/lib/gamefic-standard/actions/give.rb +41 -0
- data/lib/gamefic-standard/actions/go.rb +47 -43
- data/lib/gamefic-standard/actions/insert.rb +42 -28
- data/lib/gamefic-standard/actions/inventory.rb +13 -8
- data/lib/gamefic-standard/actions/leave.rb +44 -37
- data/lib/gamefic-standard/actions/lock.rb +22 -16
- data/lib/gamefic-standard/actions/look.rb +123 -104
- data/lib/gamefic-standard/actions/move.rb +18 -14
- data/lib/gamefic-standard/actions/nil.rb +62 -52
- data/lib/gamefic-standard/actions/open.rb +34 -24
- data/lib/gamefic-standard/actions/place.rb +35 -20
- data/lib/gamefic-standard/actions/pronouns.rb +26 -18
- data/lib/gamefic-standard/actions/quit.rb +17 -7
- data/lib/gamefic-standard/actions/repeat.rb +17 -9
- data/lib/gamefic-standard/actions/save-restore-undo.rb +19 -11
- data/lib/gamefic-standard/actions/search.rb +31 -21
- data/lib/gamefic-standard/actions/take.rb +47 -34
- data/lib/gamefic-standard/actions/talk.rb +45 -31
- data/lib/gamefic-standard/actions/unlock.rb +31 -21
- data/lib/gamefic-standard/actions/wait.rb +15 -5
- data/lib/gamefic-standard/actions.rb +33 -0
- data/lib/gamefic-standard/articles.rb +45 -40
- data/lib/gamefic-standard/enterable.rb +13 -0
- data/lib/gamefic-standard/entities/character.rb +3 -0
- data/lib/gamefic-standard/entities/container.rb +2 -2
- data/lib/gamefic-standard/entities/door.rb +13 -13
- data/lib/gamefic-standard/entities/portal.rb +1 -1
- data/lib/gamefic-standard/entities/receptacle.rb +1 -1
- data/lib/gamefic-standard/entities/room.rb +20 -5
- data/lib/gamefic-standard/entities/supporter.rb +1 -1
- data/lib/gamefic-standard/entities/thing.rb +1 -5
- data/lib/gamefic-standard/introduction.rb +14 -4
- data/lib/gamefic-standard/lockable.rb +36 -0
- data/lib/gamefic-standard/openable.rb +33 -0
- data/lib/gamefic-standard/pathfinder.rb +75 -55
- data/lib/gamefic-standard/standardized.rb +65 -0
- data/lib/gamefic-standard/version.rb +1 -1
- data/lib/gamefic-standard.rb +12 -3
- metadata +36 -13
- 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/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/spec-opal/spec_helper.rb +0 -32
@@ -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
|
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
|