Class: StandAction
- Inherits:
-
Natural20::Action
- Object
- Natural20::Action
- StandAction
- Defined in:
- lib/natural_20/actions/stand_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
- .build(session, source) ⇒ Object
- .can?(entity, battle) ⇒ Boolean
-
.required_movement(entity) ⇒ Object
required movement available to stand.
Instance Method Summary collapse
Methods inherited from Natural20::Action
apply!, #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/stand_action.rb', line 3 def as_bonus_action @as_bonus_action end |
Class Method Details
.build(session, source) ⇒ Object
18 19 20 21 |
# File 'lib/natural_20/actions/stand_action.rb', line 18 def self.build(session, source) action = StandAction.new(session, source, :attack) action.build_map end |
.can?(entity, battle) ⇒ Boolean
7 8 9 |
# File 'lib/natural_20/actions/stand_action.rb', line 7 def self.can?(entity, battle) battle && entity.prone? && entity.speed.positive? && entity.available_movement(battle) >= required_movement(entity) end |
.required_movement(entity) ⇒ Object
required movement available to stand
42 43 44 |
# File 'lib/natural_20/actions/stand_action.rb', line 42 def self.required_movement(entity) (entity.speed / 2).floor end |
Instance Method Details
#apply!(battle, item) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/natural_20/actions/stand_action.rb', line 32 def apply!(battle, item) case (item[:type]) when :stand item[:source].stand! battle.consume(item[:source], :movement, (item[:source].speed / 2).floor) end end |
#build_map ⇒ Object
11 12 13 14 15 16 |
# File 'lib/natural_20/actions/stand_action.rb', line 11 def build_map OpenStruct.new({ param: nil, next: -> { self } }) end |
#resolve(_session, _map, opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/natural_20/actions/stand_action.rb', line 23 def resolve(_session, _map, opts = {}) @result = [{ source: @source, type: :stand, battle: opts[:battle] }] self end |