gamefic 2.2.3 → 2.3.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 +5 -0
- data/lib/gamefic/action.rb +40 -4
- data/lib/gamefic/active.rb +44 -37
- data/lib/gamefic/core_ext/array.rb +15 -12
- data/lib/gamefic/dispatcher.rb +3 -12
- data/lib/gamefic/plot.rb +4 -0
- data/lib/gamefic/query/base.rb +10 -6
- data/lib/gamefic/query/external.rb +26 -5
- data/lib/gamefic/subplot.rb +4 -1
- data/lib/gamefic/version.rb +1 -1
- data/lib/gamefic/world/commands.rb +12 -4
- data/lib/gamefic/world/playbook.rb +24 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8d74d06ad87105050c1ca487acd976d293f4ca52fa6cc760061ccdbb3a14e7
|
4
|
+
data.tar.gz: f791519291a168cf31045d6bc2f136d4829f5ddce2fa7c370d6c4887f83f560e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8abcf0f9ca24db9b8bc3f61be5d0d28dcd86c24f047e420eb117bd09411b70d5f3ae7e9c2c5d2277062c4c72a970d2c9144eb0990a46872eb80b7a7bd75369e
|
7
|
+
data.tar.gz: 2bdec46fe7d946a05c3d9bf258314db25c61f32459993f03f1c2096dd31b0056917332fcd5c05ee011e3c352e373a1dcaa74f670d069398e481334ff64c07f1d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
## 2.3.0 - January 25, 2023
|
2
|
+
- Remove unused Active#actions method
|
3
|
+
- Add before_action and after_action hooks
|
4
|
+
|
1
5
|
## 2.2.3 - July 9, 2022
|
2
6
|
- Fix Ruby version incompatibilities
|
7
|
+
- Fix private attr_accessor call
|
3
8
|
|
4
9
|
## 2.2.2 - September 6, 2021
|
5
10
|
- Darkroom indexes non-static elements
|
data/lib/gamefic/action.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Gamefic
|
2
2
|
class Action
|
3
|
+
# @return [Gamefic::Actor]
|
4
|
+
attr_reader :actor
|
5
|
+
|
3
6
|
# An array of objects on which the action will operate, e.g., an entity
|
4
7
|
# that is a direct object of a command.
|
5
8
|
#
|
@@ -7,17 +10,31 @@ module Gamefic
|
|
7
10
|
attr_reader :arguments
|
8
11
|
alias parameters arguments
|
9
12
|
|
10
|
-
|
13
|
+
# @param actor [Gamefic::Actor]
|
14
|
+
# @param arguments [Array<Object>]
|
15
|
+
def initialize actor, arguments, with_callbacks = false
|
11
16
|
@actor = actor
|
12
17
|
@arguments = arguments
|
13
18
|
@executed = false
|
19
|
+
@with_callbacks = with_callbacks
|
14
20
|
end
|
15
21
|
|
16
22
|
# Perform the action.
|
17
23
|
#
|
18
24
|
def execute
|
19
|
-
|
25
|
+
return if @cancelled
|
26
|
+
run_before_actions
|
27
|
+
return if @cancelled
|
20
28
|
self.class.executor.call(@actor, *arguments) unless self.class.executor.nil?
|
29
|
+
@executed = true
|
30
|
+
run_after_actions
|
31
|
+
end
|
32
|
+
|
33
|
+
# Cancel an action. This method can be called in a before_action hook to
|
34
|
+
# prevent subsequent hooks and the action itself from being executed.
|
35
|
+
#
|
36
|
+
def cancel
|
37
|
+
@cancelled = true
|
21
38
|
end
|
22
39
|
|
23
40
|
# True if the #execute method has been called for this action.
|
@@ -68,6 +85,25 @@ module Gamefic
|
|
68
85
|
act
|
69
86
|
end
|
70
87
|
|
88
|
+
private
|
89
|
+
|
90
|
+
def run_before_actions
|
91
|
+
return unless @with_callbacks
|
92
|
+
@actor.playbooks
|
93
|
+
.flat_map(&:before_actions)
|
94
|
+
.each do |block|
|
95
|
+
block.call(self)
|
96
|
+
break if @cancelled
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def run_after_actions
|
101
|
+
return unless @with_callbacks
|
102
|
+
@actor.playbooks
|
103
|
+
.flat_map(&:after_actions)
|
104
|
+
.each { |block| block.call(self) }
|
105
|
+
end
|
106
|
+
|
71
107
|
class << self
|
72
108
|
attr_reader :verb
|
73
109
|
|
@@ -135,7 +171,7 @@ module Gamefic
|
|
135
171
|
# @param action [Gamefic::Entity]
|
136
172
|
# @param command [Command]
|
137
173
|
# @return [self, nil]
|
138
|
-
def attempt actor, command
|
174
|
+
def attempt actor, command, with_callbacks = false
|
139
175
|
return nil if command.verb != verb
|
140
176
|
tokens = command.arguments
|
141
177
|
result = []
|
@@ -153,7 +189,7 @@ module Gamefic
|
|
153
189
|
result.push accepted.first
|
154
190
|
end
|
155
191
|
end
|
156
|
-
new(actor, result)
|
192
|
+
new(actor, result, with_callbacks)
|
157
193
|
end
|
158
194
|
|
159
195
|
protected
|
data/lib/gamefic/active.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Gamefic
|
2
4
|
class NotConclusionError < RuntimeError; end
|
3
5
|
|
@@ -37,7 +39,7 @@ module Gamefic
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def syntaxes
|
40
|
-
playbooks.
|
42
|
+
playbooks.flat_map(&:syntaxes)
|
41
43
|
end
|
42
44
|
|
43
45
|
# An array of actions waiting to be performed.
|
@@ -84,28 +86,18 @@ module Gamefic
|
|
84
86
|
end
|
85
87
|
|
86
88
|
# Perform a command.
|
87
|
-
# The command can be specified as a String or a verb with a list of
|
88
|
-
# parameters. Either form should yield the same result, but the
|
89
|
-
# verb/parameter form can yield better performance since it bypasses the
|
90
|
-
# parser.
|
91
89
|
#
|
92
|
-
# The command will be executed immediately regardless of the
|
93
|
-
# state.
|
90
|
+
# The command's action will be executed immediately regardless of the
|
91
|
+
# entity's state.
|
94
92
|
#
|
95
93
|
# @example Send a command as a string
|
96
94
|
# character.perform "take the key"
|
97
95
|
#
|
98
|
-
# @
|
99
|
-
# character.perform :take, @key
|
100
|
-
#
|
101
|
-
# @todo Modify this method so it only accepts a single command.
|
102
|
-
# Verbs with parameters should use Active#execute instead.
|
103
|
-
# It might be necessary to support command splats with a deprecation
|
104
|
-
# warning until version 3.
|
105
|
-
#
|
96
|
+
# @param command [String, Symbol]
|
106
97
|
# @return [Gamefic::Action]
|
107
98
|
def perform(*command)
|
108
99
|
if command.length > 1
|
100
|
+
STDERR.puts "[WARN] #{caller[0]}: Passing a verb and arguments to #perform is deprecated. Use #execute instead."
|
109
101
|
execute command.first, *command[1..-1]
|
110
102
|
else
|
111
103
|
dispatchers.push Dispatcher.dispatch(self, command.first.to_s)
|
@@ -118,16 +110,18 @@ module Gamefic
|
|
118
110
|
# This method executes the command exactly as #perform does, except it
|
119
111
|
# buffers the resulting output instead of sending it to the user.
|
120
112
|
#
|
121
|
-
# @
|
122
|
-
# See Active#perform for more information.
|
123
|
-
#
|
113
|
+
# @param command [String, Symbol]
|
124
114
|
# @return [String] The output that resulted from performing the command.
|
125
115
|
def quietly(*command)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
116
|
+
if command.length > 1
|
117
|
+
STDERR.puts "#{caller[0]}: Passing a verb and arguments to #quietly is deprecated. Use #execute instead"
|
118
|
+
execute command.first, *command[1..-1], quietly: true
|
119
|
+
else
|
120
|
+
dispatchers.push Dispatcher.dispatch(self, command.first.to_s)
|
121
|
+
result = proceed quietly: true
|
122
|
+
dispatchers.pop
|
123
|
+
result
|
124
|
+
end
|
131
125
|
end
|
132
126
|
|
133
127
|
# Perform an action.
|
@@ -141,6 +135,9 @@ module Gamefic
|
|
141
135
|
# @example
|
142
136
|
# character.execute :take, @key
|
143
137
|
#
|
138
|
+
# @param verb [Symbol]
|
139
|
+
# @param params [Array]
|
140
|
+
# @params quietly [Boolean]
|
144
141
|
# @return [Gamefic::Action]
|
145
142
|
def execute(verb, *params, quietly: false)
|
146
143
|
dispatchers.push Dispatcher.dispatch_from_params(self, verb, params)
|
@@ -171,21 +168,15 @@ module Gamefic
|
|
171
168
|
# end
|
172
169
|
# end
|
173
170
|
#
|
171
|
+
# @param quietly [Boolean] If true, return the action's output instead of appending it to #messages
|
172
|
+
# @return [String, nil]
|
174
173
|
def proceed quietly: false
|
175
174
|
return if dispatchers.empty?
|
176
175
|
a = dispatchers.last.next
|
177
176
|
return if a.nil?
|
178
|
-
|
179
|
-
if buffer_stack == 0
|
180
|
-
@buffer = ""
|
181
|
-
end
|
182
|
-
set_buffer_stack(buffer_stack + 1)
|
183
|
-
end
|
177
|
+
prepare_buffer quietly
|
184
178
|
a.execute
|
185
|
-
|
186
|
-
set_buffer_stack(buffer_stack - 1)
|
187
|
-
@buffer
|
188
|
-
end
|
179
|
+
flush_buffer quietly
|
189
180
|
end
|
190
181
|
|
191
182
|
# Immediately start a new scene for the character.
|
@@ -251,8 +242,8 @@ module Gamefic
|
|
251
242
|
# Track the entity's performance of a scene.
|
252
243
|
#
|
253
244
|
def entered scene
|
254
|
-
klass = (scene.
|
255
|
-
entered_scenes.
|
245
|
+
klass = (scene.is_a?(Gamefic::Scene::Base) ? scene.class : scene)
|
246
|
+
entered_scenes.add klass
|
256
247
|
end
|
257
248
|
|
258
249
|
# Determine whether the entity has performed the specified scene.
|
@@ -265,9 +256,25 @@ module Gamefic
|
|
265
256
|
|
266
257
|
private
|
267
258
|
|
268
|
-
|
259
|
+
def prepare_buffer quietly
|
260
|
+
if quietly
|
261
|
+
if buffer_stack == 0
|
262
|
+
@buffer = ""
|
263
|
+
end
|
264
|
+
set_buffer_stack(buffer_stack + 1)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def flush_buffer quietly
|
269
|
+
if quietly
|
270
|
+
set_buffer_stack(buffer_stack - 1)
|
271
|
+
@buffer
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
# @return [Set<Gamefic::Scene::Base>]
|
269
276
|
def entered_scenes
|
270
|
-
@entered_scenes ||=
|
277
|
+
@entered_scenes ||= Set.new
|
271
278
|
end
|
272
279
|
|
273
280
|
def buffer_stack
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Array
|
2
4
|
# Get a subset of the array that matches the arguments.
|
3
5
|
# If the argument is a Class or Module, the elements must be of the type.
|
@@ -12,7 +14,7 @@ class Array
|
|
12
14
|
#
|
13
15
|
# @return [Array]
|
14
16
|
def that_are(*cls)
|
15
|
-
result =
|
17
|
+
result = clone
|
16
18
|
cls.each do |c|
|
17
19
|
_keep result, c, true
|
18
20
|
end
|
@@ -24,7 +26,7 @@ class Array
|
|
24
26
|
#
|
25
27
|
# @return [Array]
|
26
28
|
def that_are_not(*cls)
|
27
|
-
result =
|
29
|
+
result = clone
|
28
30
|
cls.each do |c|
|
29
31
|
_keep result, c, false
|
30
32
|
end
|
@@ -34,7 +36,7 @@ class Array
|
|
34
36
|
# Pop a random element from the array.
|
35
37
|
#
|
36
38
|
def pop_sample
|
37
|
-
delete_at(rand(
|
39
|
+
delete_at(rand(length))
|
38
40
|
end
|
39
41
|
|
40
42
|
# Get a string representation of the array that separates elements with
|
@@ -48,31 +50,32 @@ class Array
|
|
48
50
|
# @param andSep [String] The separator for the last element
|
49
51
|
# @param serial [Boolean] Use serial separators (e.g., serial commas)
|
50
52
|
# @return [String]
|
51
|
-
def join_and(sep = ', ',
|
52
|
-
if
|
53
|
-
|
53
|
+
def join_and(sep = ', ', and_sep = ' and ', serial = true)
|
54
|
+
if length < 3
|
55
|
+
join(and_sep)
|
54
56
|
else
|
55
57
|
start = self[0..-2]
|
56
|
-
start.join(sep) + "#{serial ? sep.strip : ''}#{
|
58
|
+
start.join(sep) + "#{serial ? sep.strip : ''}#{and_sep}#{last}"
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
62
|
# @see Array#join_and
|
61
63
|
#
|
62
64
|
# @return [String]
|
63
|
-
def join_or(sep = ', ',
|
64
|
-
join_and(sep,
|
65
|
+
def join_or(sep = ', ', or_sep = ' or ', serial = true)
|
66
|
+
join_and(sep, or_sep, serial)
|
65
67
|
end
|
66
68
|
|
67
69
|
private
|
68
70
|
|
69
71
|
def _keep(arr, cls, bool)
|
70
|
-
|
72
|
+
case cls
|
73
|
+
when Class, Module
|
71
74
|
arr.keep_if { |i| i.is_a?(cls) == bool }
|
72
|
-
|
75
|
+
when Symbol
|
73
76
|
arr.keep_if { |i| i.send(cls) == bool }
|
74
77
|
else
|
75
|
-
arr.keep_if {|i| (i == cls) == bool}
|
78
|
+
arr.keep_if { |i| (i == cls) == bool }
|
76
79
|
end
|
77
80
|
end
|
78
81
|
end
|
data/lib/gamefic/dispatcher.rb
CHANGED
@@ -9,6 +9,7 @@ module Gamefic
|
|
9
9
|
@actor = actor
|
10
10
|
@commands = commands
|
11
11
|
@actions = actions
|
12
|
+
@started = false
|
12
13
|
end
|
13
14
|
|
14
15
|
def merge dispatcher
|
@@ -21,13 +22,9 @@ module Gamefic
|
|
21
22
|
while instance.nil? && !@actions.empty?
|
22
23
|
action = actions.shift
|
23
24
|
commands.each do |cmd|
|
24
|
-
instance = action.attempt(actor, cmd)
|
25
|
+
instance = action.attempt(actor, cmd, !@started)
|
25
26
|
if instance
|
26
|
-
|
27
|
-
actor.playbooks.reverse.each do |playbook|
|
28
|
-
return nil unless validate_playbook(playbook, instance)
|
29
|
-
end
|
30
|
-
end
|
27
|
+
@started = true
|
31
28
|
break
|
32
29
|
end
|
33
30
|
end
|
@@ -66,11 +63,5 @@ module Gamefic
|
|
66
63
|
|
67
64
|
# @return [Array<Action>]
|
68
65
|
attr_reader :actions
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def validate_playbook playbook, action
|
73
|
-
playbook.validators.all? { |v| v.call(actor, action.verb, action.parameters) != false }
|
74
|
-
end
|
75
66
|
end
|
76
67
|
end
|
data/lib/gamefic/plot.rb
CHANGED
data/lib/gamefic/query/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Gamefic
|
2
2
|
module Query
|
3
3
|
class Base
|
4
|
-
NEST_REGEXP = / in | on | of | from | inside /
|
4
|
+
NEST_REGEXP = / in | on | of | from | inside | from inside /
|
5
5
|
|
6
6
|
attr_reader :arguments
|
7
7
|
|
@@ -31,6 +31,9 @@ module Gamefic
|
|
31
31
|
# Get a collection of objects that exist in the subject's context and
|
32
32
|
# match the provided token. The result is provided as a Matches object.
|
33
33
|
#
|
34
|
+
# @param subject [Entity]
|
35
|
+
# @param token [String]
|
36
|
+
# @param continued [Boolean]
|
34
37
|
# @return [Gamefic::Query::Matches]
|
35
38
|
def resolve(subject, token, continued: false)
|
36
39
|
available = context_from(subject)
|
@@ -38,14 +41,13 @@ module Gamefic
|
|
38
41
|
if continued
|
39
42
|
return Matches.execute(available, token, continued: continued)
|
40
43
|
elsif nested?(token)
|
41
|
-
drill = denest(available, token)
|
42
|
-
drill.keep_if{ |e| accept?(e) }
|
44
|
+
drill = denest(available, token).select { |e| accept?(e) }
|
43
45
|
return Matches.new(drill, token, '') unless drill.length != 1
|
44
46
|
return Matches.new([], '', token)
|
45
47
|
end
|
46
|
-
result = available.select{ |e| e.specified?(token) }
|
47
|
-
result = available.select{ |e| e.specified?(token, fuzzy: true) } if result.empty?
|
48
|
-
result.keep_if{ |e| accept? e }
|
48
|
+
result = available.select { |e| e.specified?(token) }
|
49
|
+
result = available.select { |e| e.specified?(token, fuzzy: true) } if result.empty?
|
50
|
+
result.keep_if { |e| accept? e }
|
49
51
|
Matches.new(result, (result.empty? ? '' : token), (result.empty? ? token : ''))
|
50
52
|
end
|
51
53
|
|
@@ -82,6 +84,7 @@ module Gamefic
|
|
82
84
|
|
83
85
|
# Determine whether the specified entity passes the query's arguments.
|
84
86
|
#
|
87
|
+
# @param [Entity]
|
85
88
|
# @return [Boolean]
|
86
89
|
def accept?(entity)
|
87
90
|
result = true
|
@@ -106,6 +109,7 @@ module Gamefic
|
|
106
109
|
# recursively append its children.
|
107
110
|
# The result will NOT include the original entity itself.
|
108
111
|
#
|
112
|
+
# @param [Entity]
|
109
113
|
# @return [Array<Object>]
|
110
114
|
def subquery_accessible entity
|
111
115
|
return [] if entity.nil?
|
@@ -1,17 +1,38 @@
|
|
1
1
|
module Gamefic
|
2
2
|
module Query
|
3
3
|
class External < Base
|
4
|
-
|
4
|
+
# @param container [Plot, Subplot, Array]
|
5
|
+
def initialize container, *args
|
5
6
|
super(*args)
|
6
|
-
@
|
7
|
+
@container = container
|
7
8
|
end
|
8
9
|
|
9
10
|
def context_from subject
|
10
|
-
|
11
|
+
Set.new
|
12
|
+
.merge(container_entities)
|
13
|
+
.merge(container_subplots_for(@container, subject))
|
14
|
+
.to_a
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
# @return [Array<Entity>]
|
20
|
+
def container_entities
|
21
|
+
if @container.is_a?(World::Entities)
|
22
|
+
@container.entities
|
23
|
+
elsif @container.is_a?(Enumerable)
|
24
|
+
@container
|
25
|
+
else
|
26
|
+
raise ArgumentError, "Unable to derive entities from #{@container}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Array<Entity>]
|
31
|
+
def container_subplots_for container, subject
|
32
|
+
return [] unless container.is_a?(Plot::Host)
|
33
|
+
container.subplots_featuring(subject).flat_map do |subplot|
|
34
|
+
subplot.entities + container_subplots_for(subplot, subject)
|
35
|
+
end
|
15
36
|
end
|
16
37
|
end
|
17
38
|
end
|
data/lib/gamefic/subplot.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'gamefic/plot'
|
2
2
|
|
3
3
|
module Gamefic
|
4
|
-
|
4
|
+
# Subplots are disposable plots that run inside a parent plot. They can be
|
5
|
+
# started and concluded at any time during the parent plot's execution.
|
6
|
+
#
|
7
|
+
class Subplot
|
5
8
|
include World
|
6
9
|
include Scriptable
|
7
10
|
include Gamefic::Serialize
|
data/lib/gamefic/version.rb
CHANGED
@@ -95,11 +95,19 @@ module Gamefic
|
|
95
95
|
playbook.meta command, *queries, &proc
|
96
96
|
end
|
97
97
|
|
98
|
-
#
|
98
|
+
# Add a proc to be evaluated before a character executes an action.
|
99
99
|
#
|
100
|
-
# @yieldparam [Gamefic::
|
101
|
-
def
|
102
|
-
playbook.
|
100
|
+
# @yieldparam [Gamefic::Action]
|
101
|
+
def before_action &block
|
102
|
+
playbook.before_actions.push block
|
103
|
+
end
|
104
|
+
alias validate before_action
|
105
|
+
|
106
|
+
# Add a proc to be evaluated after a character executes an action.
|
107
|
+
#
|
108
|
+
# @yieldparam [Gamefic::Action]
|
109
|
+
def after_action &block
|
110
|
+
playbook.after_actions.push block
|
103
111
|
end
|
104
112
|
|
105
113
|
# Create an alternate Syntax for an Action.
|
@@ -10,19 +10,26 @@ module Gamefic
|
|
10
10
|
# @return [Array<Gamefic::Syntax>]
|
11
11
|
attr_reader :syntaxes
|
12
12
|
|
13
|
-
# An array of
|
13
|
+
# An array of blocks to execute before actions.
|
14
14
|
#
|
15
15
|
# @return [Array<Proc>]
|
16
|
-
attr_reader :
|
16
|
+
attr_reader :before_actions
|
17
|
+
|
18
|
+
# An array of blocks to execute after actions.
|
19
|
+
#
|
20
|
+
# @return [Array<Proc>]
|
21
|
+
attr_reader :after_actions
|
17
22
|
|
18
23
|
# @param commands [Hash]
|
19
24
|
# @param syntaxes [Array<Syntax>, Set<Syntax>]
|
20
|
-
# @param
|
21
|
-
|
25
|
+
# @param before_actions [Array]
|
26
|
+
# @param after_actions [Array]
|
27
|
+
def initialize commands: {}, syntaxes: [], before_actions: [], after_actions: []
|
22
28
|
@commands = commands
|
23
29
|
@syntax_set = syntaxes.to_set
|
24
30
|
sort_syntaxes
|
25
|
-
@
|
31
|
+
@before_actions = before_actions
|
32
|
+
@after_actions = after_actions
|
26
33
|
end
|
27
34
|
|
28
35
|
# An array of available actions.
|
@@ -39,10 +46,19 @@ module Gamefic
|
|
39
46
|
@commands.keys
|
40
47
|
end
|
41
48
|
|
42
|
-
# Add a
|
49
|
+
# Add a proc to be evaluated before a character executes an action.
|
50
|
+
#
|
51
|
+
# @yieldparam [Gamefic::Action]
|
52
|
+
def before_action &block
|
53
|
+
@before_actions.push block
|
54
|
+
end
|
55
|
+
alias validate before_action
|
56
|
+
|
57
|
+
# Add a proc to be evaluated after a character executes an action.
|
43
58
|
#
|
44
|
-
|
45
|
-
|
59
|
+
# @yieldparam [Gamefic::Action]
|
60
|
+
def after_action &block
|
61
|
+
@after_actions.push block
|
46
62
|
end
|
47
63
|
|
48
64
|
# Get an Array of all Actions associated with the specified verb.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|