Class: DropGrappleAction
Instance Attribute Summary collapse
#action_type, #errors, #result, #session, #source
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #label, #name, #validate
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
119
120
121
|
# File 'lib/natural_20/actions/grapple_action.rb', line 119
def target
@target
end
|
Class Method Details
.apply!(_battle, item) ⇒ Object
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/natural_20/actions/grapple_action.rb', line 170
def self.apply!(_battle, item)
case item[:type]
when :drop_grapple
item[:target].escape_grapple_from!(item[:source])
Natural20::EventManager.received_event(event: :drop_grapple,
target: item[:target], source: item[:source],
source_roll: item[:source_roll],
target_roll: item[:target_roll])
end
end
|
.build(session, source) ⇒ Object
149
150
151
152
|
# File 'lib/natural_20/actions/grapple_action.rb', line 149
def self.build(session, source)
action = DropGrappleAction.new(session, source, :grapple)
action.build_map
end
|
.can?(entity, battle, _options = {}) ⇒ Boolean
121
122
123
|
# File 'lib/natural_20/actions/grapple_action.rb', line 121
def self.can?(entity, battle, _options = {})
battle.nil? || entity.grappling?
end
|
Instance Method Details
#build_map ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/natural_20/actions/grapple_action.rb', line 129
def build_map
OpenStruct.new({
action: self,
param: [
{
type: :select_target,
targets: @source.grappling_targets,
num: 1
}
],
next: lambda { |target|
self.target = target
OpenStruct.new({
param: nil,
next: -> { self }
})
}
})
end
|
#resolve(_session, _map, opts = {}) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/natural_20/actions/grapple_action.rb', line 158
def resolve(_session, _map, opts = {})
target = opts[:target] || @target
battle = opts[:battle]
@result =
[{
source: @source,
target: target,
type: :drop_grapple,
battle: battle
}]
end
|
#to_s ⇒ Object
125
126
127
|
# File 'lib/natural_20/actions/grapple_action.rb', line 125
def to_s
@action_type.to_s.humanize
end
|