class Oakdex::Battle::StatusConditions::Sleep

Represents Sleep status condition

Public Class Methods

new(pokemon) click to toggle source
# File lib/oakdex/battle/status_conditions/sleep.rb, line 6
def initialize(pokemon)
  super
  @turn_count = 0
  @max_turn_count = rand(1..3)
end

Public Instance Methods

after_turn(turn) click to toggle source
# File lib/oakdex/battle/status_conditions/sleep.rb, line 12
def after_turn(turn)
  wake_up(turn.battle) if @turn_count >= @max_turn_count
  @turn_count += 1
end
prevents_move?(move_execution) click to toggle source
# File lib/oakdex/battle/status_conditions/sleep.rb, line 17
def prevents_move?(move_execution)
  move_execution
    .battle
    .add_to_log('sleeping',
                pokemon.trainer.name,
                pokemon.name)
  true
end

Private Instance Methods

wake_up(battle) click to toggle source
# File lib/oakdex/battle/status_conditions/sleep.rb, line 28
def wake_up(battle)
  pokemon.remove_status_condition(self)
  battle.add_to_log('wake_up',
                    pokemon.trainer.name,
                    pokemon.name)
end