Class: Battle::Logic::ItemChangeHandler

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

Overview

Handler responsive of answering properly item changes requests

Constant Summary collapse

PROTECTED_ITEMS =

List of item that cannot be knocked off

%i[exp_share lucky_egg amulet_coin oak_s_letter gram_1 gram_2 gram_3 prof_s_letter letter greet_mail favored_mail rsvp_mail thanks_mail inquiry_mail like_mail reply_mail bridge_mail_s bridge_mail_d bridge_mail_t bridge_mail_v bridge_mail_m]
PROTECTED_POKEMON_ITEMS =

TO DO : Add Z-Crystals to PROTECTED_ITEMS (7G) List of items that cannot be knocked off if the holder is a specific Pokemon

{giratina: %i[griseous_orb], arceus: %i[flame_plate splash_plate zap_plate meadow_plate icicle_plate fist_plate toxic_plate earth_plate sky_plate mind_plate insect_plate stone_plate spooky_plate draco_plate dread_plate iron_plate pixie_plate], genesect: %i[shock_drive burn_drive chill_drive douse_drive], silvally: %i[bug_memory dark_memory dragon_memory electry_memory fairy_memory fighting_memory fire_memory flying_memory ghost_memory grass_memory ground_memory ice_memory poison_memory psychic_memory rock_memory steel_memory water_memory], kyogre: %i[blue_orb], groudon: %i[red_orb], zacian: %i[rusted_sword], zamazenta: %i[rusted_shield], venusaur: %i[venusaurite], charizard: %i[charizardite_x charizardite_y], blatoise: %i[blastoisinite], alakazam: %i[alakazite], gengar: %i[gengarite], kangaskhan: %i[kangaskhanite], pinsir: %i[pinsirite], gyarados: %i[gyaradosite], aerodactyl: %i[aerodactylite], mewtwo: %i[mewtwonite_x mewtwonite_y], ampharos: %i[ampharosite], scizor: %i[scizorite], heracross: %i[heracronite], houndoom: %i[houndoominite], tyranitar: %i[tyranitarite], blaziken: %i[blazikenite], gardevoir: %i[gardevoirite], mawile: %i[mawilite], aggron: %i[aggronite], medicham: %i[medichamite], manectric: %i[manectite], banette: %i[banettite], absol: %i[absolite], latias: %i[latiasite], latios: %i[latiosite], garchomp: %i[garchompite], lucario: %i[lucarionite], abomasnow: %i[abomasite], beedril: %i[beedrillite], pidgeot: %i[pidgeotite], slowbro: %i[slowbronite], steelix: %i[steelixite], sceptile: %i[sceptilite], swamper: %i[swampertite], sableye: %i[sablenite], sharpedo: %i[sharpedoite], camerupt: %i[cameruptite], altaria: %i[altarianite], glalie: %i[glalitite], salamence: %i[salamencite], metagross: %i[metagrossite], lopunny: %i[lopunnite]}

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_post_item_change_hook(reason) {|handler, db_symbol, target, launcher, skill| ... }

Function that registers a post_item_change hook

Parameters:

  • reason (String)

    reason of the post_item_change registration

Yield Parameters:



925
926
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 925

def register_post_item_change_hook(reason)
end

.register_pre_item_change_hook(reason) {|handler, db_symbol, target, launcher, skill| ... }

Function that registers a pre_item_change hook

Parameters:

  • reason (String)

    reason of the pre_item_change registration

Yield Parameters:

Yield Returns:

  • (:prevent, nil)

    :prevent if the item change cannot be applied



916
917
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 916

def register_pre_item_change_hook(reason)
end

Instance Method Details

#can_give_item?(giver, target, launcher = giver) ⇒ Boolean

Function that checks if the Pokemon can give its item to a target

Parameters:

Returns:

  • (Boolean)


905
906
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 905

def can_give_item?(giver, target, launcher = giver)
end

#can_lose_item?(target, launcher = nil) ⇒ Boolean

Function that checks if the Pokemon can lose its item

Parameters:

Returns:

  • (Boolean)


898
899
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 898

def can_lose_item?(target, launcher = nil)
end

#change_item(db_symbol, overwrite, target, launcher = nil, skill = nil) ⇒ Boolean

Function that change the item held by a Pokemon

Parameters:

  • db_symbol (Symbol, :none)

    Symbol ID of the item

  • overwrite (Boolean)

    if the actual item held should be overwritten

  • 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

Returns:

  • (Boolean)

    if the operation was successful



892
893
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 892

def change_item(db_symbol, overwrite, target, launcher = nil, skill = nil)
end