Class: Battle::Logic::CatchHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
Defined in:
scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01009 CatchHandler.rb

Overview

Handler responsive of answering properly Pokemon catching requests

Constant Summary collapse

STATUS_MODIFIER =

Modifier applied to the formula depending of the Status

Returns:

{
  poison: 1.5,
  paralysis: 1.5,
  burn: 1.5,
  sleep: 2.5,
  freeze: 2.5,
  toxic: 1.5
}
BALL_RATE_CALCULATION =
{}
TEXT_CATCH =

ID of the catching text in the text database

Returns:

[[18, 63], [18, 64], [18, 65], [18, 66], [18, 67], [18, 68]]
ULTRA_BEAST =

DB_Symbol of each Ultra-Beast

Returns:

  • (Array<Symbol>)
%i[nihilego buzzwole pheromosa xurkitree celesteela kartana guzzlord poipole naganadel stakataka blacephalon]

Instance Attribute Summary

Attributes inherited from ChangeHandlerBase

#logic, #scene

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#exec_hooks, #force_return, included, register, remove, remove_without_name

Methods inherited from ChangeHandlerBase

#initialize, #prevent_change, #process_prevention_reason, #reset_prevention_reason

Constructor Details

This class inherits a constructor from Battle::Logic::ChangeHandlerBase

Class Method Details

.add_ball_rate_calculation(ball_name) {|target, pkm_ally| ... }

Define a new ball rate calculation in BALL_RATE_CALCULATION

Parameters:

  • ball_name (Symbol)

    the DB_symbol of the ball

Yield Parameters:

Yield Returns:



54
55
56
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01009 CatchHandler.rb', line 54

def add_ball_rate_calculation(ball_name, &block)
  BALL_RATE_CALCULATION[ball_name] = block if block
end

Instance Method Details

#caught?Boolean

Tells if the Pokemon is caught

Returns:

  • (Boolean)


44
45
46
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01009 CatchHandler.rb', line 44

def caught?
  return @bounces == 3 || @critical_capture
end

#try_to_catch_pokemon(target, pkm_ally, ball)

Function that try to catch the targeted Pokemon

Parameters:



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01009 CatchHandler.rb', line 28

def try_to_catch_pokemon(target, pkm_ally, ball)
  log_data("# FR: try_to_catch_pokemon(#{target}, #{pkm_ally}, #{ball})")
  @bounces = -1
  @scene.message_window.blocking = true
  @scene.message_window.wait_input = true
  exec_hooks(Battle::Logic::CatchHandler, :ball_blocked, binding)
  catching_procedure(target, pkm_ally, ball)
  show_message_and_animation(target, ball, @bounces, caught?)
  return caught?
rescue Hooks::ForceReturn => e
  log_data("# FR: try_to_catch_pokemon #{e.data} from #{e.hook_name} (#{e.reason})")
  return e.data
end