Class: Battle::Logic::DamageHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
Defined in:
docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb

Overview

Handler responsive of defining how damage should be dealt (if possible)

Instance Attribute Summary

Attributes inherited from ChangeHandlerBase

#logic, #pre_checked_effects, #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

.register_damage_prevention_hook(reason) {|handler, hp, target, launcher, skill| ... }

Function that registers a damage_prevention hook

Parameters:

  • reason (String)

    reason of the damage_prevention registration

Yield Parameters:

Yield Returns:

  • (:prevent, Integer)

    :prevent if the damage cannot be applied, Integer if the hp variable should be updated



1154
1155
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1154

def register_damage_prevention_hook(reason)
end

.register_post_damage_death_hook(reason) {|handler, hp, target, launcher, skill| ... }

Function that registers a post_damage_death hook (when target is KO)

Parameters:

  • reason (String)

    reason of the post_damage_death registration

Yield Parameters:



1172
1173
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1172

def register_post_damage_death_hook(reason)
end

.register_post_damage_hook(reason) {|handler, hp, target, launcher, skill| ... }

Function that registers a post_damage hook (when target is still alive)

Parameters:

  • reason (String)

    reason of the post_damage registration

Yield Parameters:



1163
1164
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1163

def register_post_damage_hook(reason)
end

Instance Method Details

#damage_appliable(hp, target, launcher = nil, skill = nil) ⇒ Integer, false

Note:

Thing that prevents the damage from being applied should be defined using :damage_prevention Hook.

Function telling if a damage can be applied and how much

Parameters:

Returns:

  • (Integer, false)


1096
1097
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1096

def damage_appliable(hp, target, launcher = nil, skill = nil)
end

#damage_change(hp, target, launcher = nil, skill = nil, &messages)

Function that actually deal the damage

Parameters:

  • hp (Integer)

    number of hp (damage) dealt

  • target (PFM::PokemonBattler)
  • launcher (PFM::PokemonBattler, nil) (defaults to: nil)

    Potential launcher of a move

  • skill (Battle::Move, nil) (defaults to: nil)

    Potential move used

  • messages (Proc)

    messages shown right before the post processing



1104
1105
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1104

def damage_change(hp, target, launcher = nil, skill = nil, &messages)
end

#damage_change_with_process(hp, target, launcher = nil, skill = nil, &messages)

Function that test if the damage can be dealt and deal the damage if so

Parameters:

  • hp (Integer)

    number of hp (damage) dealt

  • target (PFM::PokemonBattler)
  • launcher (PFM::PokemonBattler, nil) (defaults to: nil)

    Potential launcher of a move

  • skill (Battle::Move, nil) (defaults to: nil)

    Potential move used

  • messages (Proc)

    messages shown right before the post processing



1112
1113
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1112

def damage_change_with_process(hp, target, launcher = nil, skill = nil, &messages)
end

#drain(hp_factor, target, launcher, skill = nil, hp_overwrite: nil, drain_factor: 1, &messages)

Function that drains a certain quantity of HP from the target and give it to the user

Parameters:

  • hp_factor (Integer)

    the division factor of HP to drain

  • target (PFM::PokemonBattler)

    target that get HP drained

  • launcher (PFM::PokemonBattler)

    launcher of a draining move/effect

  • skill (Battle::Move, nil) (defaults to: nil)

    Potential move used

  • hp_overwrite (Integer, nil) (defaults to: nil)

    for the number of hp drained by the move

  • drain_factor (Integer) (defaults to: 1)

    the division factor of HP drained

  • messages (Proc)

    messages shown right before the post processing



1133
1134
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1133

def drain(hp_factor, target, launcher, skill = nil, hp_overwrite: nil, drain_factor: 1, &messages)
end

#drain_with_process(hp_factor, target, launcher, skill = nil, hp_overwrite: nil, drain_factor: 1, &messages)

Function that test if the drain damages can be dealt and perform the drain if so

Parameters:

  • hp_factor (Integer)

    the division factor of HP to drain

  • target (PFM::PokemonBattler)
  • launcher (PFM::PokemonBattler)

    Potential launcher of a move

  • skill (Battle::Move, nil) (defaults to: nil)

    Potential move used

  • hp_overwrite (Integer, nil) (defaults to: nil)

    for the number of hp drained by the move

  • drain_factor (Integer) (defaults to: 1)

    the division factor of HP drained

  • messages (Proc)

    messages shown right before the post processing



1143
1144
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1143

def drain_with_process(hp_factor, target, launcher, skill = nil, hp_overwrite: nil, drain_factor: 1, &messages)
end

#heal(target, hp, test_heal_block: true, animation_id: nil) {|hp| ... } ⇒ Boolean

Note:

this method yields a block in order to show the message after the animation

Note:

this shows the default message if no block has been given

Function that proceed the heal of a Pokemon

Parameters:

  • target (PFM::PokemonBattler)
  • hp (Integer)

    number of HP to heal

  • test_heal_block (Boolean) (defaults to: true)
  • animation_id (Symbol, Integer) (defaults to: nil)

    animation to use instead of the original one

Yield Parameters:

  • hp (Integer)

    the actual hp healed

Returns:

  • (Boolean)

    if the heal was successful or not



1123
1124
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1123

def heal(target, hp, test_heal_block: true, animation_id: nil)
end