Class: MultiattackAction
- Inherits:
-
Natural20::Action
- Object
- Natural20::Action
- MultiattackAction
- Defined in:
- lib/natural_20/actions/multiattack_action.rb
Overview
typed: true
Instance Attribute Summary collapse
-
#as_bonus_action ⇒ Object
Returns the value of attribute as_bonus_action.
Attributes inherited from Natural20::Action
#action_type, #errors, #result, #session, #source
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Natural20::Action
#initialize, #label, #name, #to_s, #validate
Constructor Details
This class inherits a constructor from Natural20::Action
Instance Attribute Details
#as_bonus_action ⇒ Object
Returns the value of attribute as_bonus_action.
3 4 5 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 3 def as_bonus_action @as_bonus_action end |
Class Method Details
.apply!(battle, item) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 31 def self.apply!(battle, item) case (item[:type]) when :multiattack @total_attacks += 2 battle.consume!(:action, 1) end end |
.build(session, source) ⇒ Object
16 17 18 19 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 16 def self.build(session, source) action = MultiattackAction.new(session, source, :multiattack) action.build_map end |
.can?(entity, battle) ⇒ Boolean
5 6 7 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 5 def self.can?(entity, battle) battle && entity.total_actions(battle).positive? end |
Instance Method Details
#build_map ⇒ Object
9 10 11 12 13 14 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 9 def build_map OpenStruct.new({ param: nil, next: -> { self } }) end |
#resolve(_session, _map, opts = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/natural_20/actions/multiattack_action.rb', line 21 def resolve(_session, _map, opts = {}) @result = [{ source: @source, type: :multiattack, battle: opts[:battle] }] self end |