Class: Battle::Logic::DamageHandler

Inherits:
ChangeHandlerBase show all
Defined in:
docs/5_Battle_04_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

Instance Method Summary collapse

Methods inherited from ChangeHandlerBase

#initialize, #pass_change, #prevent_change, #process_reason, #reset_reason

Constructor Details

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

Instance Method Details

#can_heal?(target, test_heal_block: true) ⇒ Boolean

Whether a battler can be healed

Parameters:

Returns:

  • (Boolean)


1053
1054
# File 'docs/5_Battle_04_Logic.rb', line 1053

def can_heal?(target, test_heal_block: true)
end

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

Function telling if a damage can be applied and how much

Parameters:

Returns:

  • (Integer, false)


1031
1032
# File 'docs/5_Battle_04_Logic.rb', line 1031

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



1039
1040
# File 'docs/5_Battle_04_Logic.rb', line 1039

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



1047
1048
# File 'docs/5_Battle_04_Logic.rb', line 1047

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



1083
1084
# File 'docs/5_Battle_04_Logic.rb', line 1083

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



1093
1094
# File 'docs/5_Battle_04_Logic.rb', line 1093

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, &block) {|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

  • block (Proc) —

    block to show messages after the animation

Yield Parameters:

  • hp (Integer) —

    the actual hp healed

Returns:

  • (Boolean) —

    if the heal was successful or not



1073
1074
# File 'docs/5_Battle_04_Logic.rb', line 1073

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

#heal_change(target, hp, animation_id: nil) {|hp| ... }

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 actually performs the heal

Parameters:

Yield Parameters:

  • hp (Integer) —

    The actual HP healed



1061
1062
# File 'docs/5_Battle_04_Logic.rb', line 1061

def heal_change(target, hp, animation_id: nil)
end