class StandAction

typed: true

Attributes

as_bonus_action[RW]

Public Class Methods

build(session, source) click to toggle source
# 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) click to toggle source

@param entity [Natural20::Entity] @param battle [Natural20::Battle]

# 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) click to toggle source

required movement available to stand @param entity [Natural20::Entity]

# File lib/natural_20/actions/stand_action.rb, line 42
def self.required_movement(entity)
  (entity.speed / 2).floor
end

Public Instance Methods

apply!(battle, item) click to toggle source
# 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() click to toggle source
# File lib/natural_20/actions/stand_action.rb, line 11
def build_map
  OpenStruct.new({
                   param: nil,
                   next: -> { self }
                 })
end
resolve(_session, _map, opts = {}) click to toggle source
# 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