Class: Battle::Logic::StatChangeHandler

Inherits:
ChangeHandlerBase show all
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

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

#handle_stat_change_events(stat, power, target, launcher, skill) ⇒ Integer

Function that runs all the stat change event and returns the new power value

Parameters:

  • stat (Symbol) —

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

  • power (Integer) —

    power of the stat change

  • target (PFM::PokemonBattler)
  • launcher (PFM::PokemonBattler, nil) —

    Potential launcher of a move

  • skill (Battle::Move, nil) —

    Potential move used

Returns:

  • (Integer)


805
806
# File 'docs/5_Battle_04_Logic.rb', line 805

def handle_stat_change_events(stat, power, target, launcher, skill)
end

#handle_stat_change_post_events(stat, power, target, launcher, skill)

Function that runs all the stat change post event from all effect of the alive battlers

Parameters:

  • stat (Symbol) —

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

  • power (Integer) —

    power of the stat change

  • target (PFM::PokemonBattler)
  • launcher (PFM::PokemonBattler, nil) —

    Potential launcher of a move

  • skill (Battle::Move, nil) —

    Potential move used



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

def handle_stat_change_post_events(stat, power, target, launcher, skill)
end

#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



796
797
# File 'docs/5_Battle_04_Logic.rb', line 796

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



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

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)


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

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 increasing should be defined using :stat_increase_prevention Hook.

Function telling if a stat can be increased

Parameters:

Returns:

  • (Boolean)


778
779
# File 'docs/5_Battle_04_Logic.rb', line 778

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



828
829
# File 'docs/5_Battle_04_Logic.rb', line 828

def stat_text_index(amount, power)
end