Class: Battle::Logic::StatChangeHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
Defined in:
docs/5_Battle_04_Logic.rb

Overview

Handler responsive of answering properly statistic changes requests

Constant Summary collapse

TEXT_POS =

Position of text for Attack depending on the power

{atk: atk = [0, 27, 48, 69, 153, 174, 132, 111, 90], dfe: atk.map { |i| i + 3 }, ats: atk.map { |i| i + 6 }, dfs: atk.map { |i| i + 9 }, spd: atk.map { |i| i + 12 }, acc: atk.map { |i| i + 15 }, eva: atk.map { |i| i + 18 }}
ANIMATION =

ID of the animation depending on the stat

{atk: 478, dfe: 480, spd: 482, dfs: 486, ats: 484, eva: 488, acc: 490}
STAT_INDEX =

Index of the stages depending on the stat to change

Returns:

  • (Hash{ Symbol => Integer })
{atk: Configs.stats.atk_stage_index, dfe: Configs.stats.dfe_stage_index, ats: Configs.stats.ats_stage_index, dfs: Configs.stats.dfs_stage_index, spd: Configs.stats.spd_stage_index, acc: Configs.stats.acc_stage_index, eva: Configs.stats.eva_stage_index}
ALL_STATS =

Array containing all the possible stats

%i[atk dfe spd dfs ats eva acc]
ATTACK_STATS =

Array containing all the attack kind stat

%i[atk ats]
DEFENSE_STATS =

Array containing all the defense kind stat

%i[dfe dfs]
PHYSICAL_STATS =

Array containing the physical stats

%i[atk dfe]
SPECIAL_STATS =

Array containing the special stats

%i[ats dfs]

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_stat_change_hook(reason) {|handler, stat, power, target, launcher, skill| ... }

Function that register a stat_change hook

Parameters:

  • reason (String)

    reason of the stat_change registration

Yield Parameters:

Yield Returns:

  • (Integer, nil)

    if integer, it will change the power



843
844
# File 'docs/5_Battle_04_Logic.rb', line 843

def register_stat_change_hook(reason)
end

.register_stat_change_post_event_hook(reason) {|handler, stat, power, target, launcher, skill| ... }

Function that register a stat_change_post_event hook

Parameters:

  • reason (String)

    reason of the stat_change_post_event registration

Yield Parameters:



832
833
# File 'docs/5_Battle_04_Logic.rb', line 832

def register_stat_change_post_event_hook(reason)
end

.register_stat_decrease_prevention_hook(reason) {|handler, stat, target, launcher, skill| ... }

Function that registers a stat_decrease_prevention hook

Parameters:

  • reason (String)

    reason of the stat_decrease_prevention registration

Yield Parameters:

Yield Returns:

  • (:prevent, nil)

    :prevent if the stat decrease cannot apply



822
823
# File 'docs/5_Battle_04_Logic.rb', line 822

def register_stat_decrease_prevention_hook(reason)
end

.register_stat_increase_prevention_hook(reason) {|handler, stat, target, launcher, skill| ... }

Function that registers a stat_increase_prevention hook

Parameters:

  • reason (String)

    reason of the stat_increase_prevention registration

Yield Parameters:

Yield Returns:

  • (:prevent, nil)

    :prevent if the stat increase cannot apply



812
813
# File 'docs/5_Battle_04_Logic.rb', line 812

def register_stat_increase_prevention_hook(reason)
end

Instance Method Details

#stat_change(stat, power, target, launcher = nil, skill = nil, no_message: false)

Function that actually change a stat

Parameters:

  • stat (Symbol)

    :atk, :dfe, :spd, :ats, :dfs, :acc, :eva

  • power (Integer)

    power of the stat change

  • 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

  • no_message (Boolean) (defaults to: false)

    if the message about stat increase should be shown



771
772
# File 'docs/5_Battle_04_Logic.rb', line 771

def stat_change(stat, power, target, launcher = nil, skill = nil, no_message: false)
end

#stat_change_with_process(stat, power, target, launcher = nil, skill = nil, no_message: false)

Function that test if the change is possible and perform the change if so

Parameters:

  • stat (Symbol)

    :atk, :dfe, :spd, :ats, :dfs, :acc, :eva

  • power (Integer)

    power of the stat change

  • 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

  • no_message (Boolean) (defaults to: false)

    if the message about stat increase should be shown



780
781
# File 'docs/5_Battle_04_Logic.rb', line 780

def stat_change_with_process(stat, power, target, launcher = nil, skill = nil, no_message: false)
end

#stat_decreasable?(stat, target, launcher = nil, skill = nil) ⇒ Boolean

Note:

Thing that prevents the stat from decreasing should be defined using :stat_decrease_prevention Hook.

Function telling if a stat can be decreased

Parameters:

Returns:

  • (Boolean)


762
763
# File 'docs/5_Battle_04_Logic.rb', line 762

def stat_decreasable?(stat, target, launcher = nil, skill = nil)
end

#stat_increasable?(stat, target, launcher = nil, skill = nil) ⇒ Boolean

Note:

Thing that prevents the stat from increasoing should be defined using :stat_increase_prevention Hook.

Function telling if a stat can be increased

Parameters:

Returns:

  • (Boolean)


753
754
# File 'docs/5_Battle_04_Logic.rb', line 753

def stat_increasable?(stat, target, launcher = nil, skill = nil)
end

#stat_text_index(amount, power) ⇒ Integer

Get the text index in the TEXT_POS array depending on amount & power

Parameters:

  • amount (Integer)
  • power (Integer)

Returns:

  • (Integer)

    text pos



786
787
# File 'docs/5_Battle_04_Logic.rb', line 786

def stat_text_index(amount, power)
end