Class: Battle::Logic::MegaEvolve
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00400 MegaEvolve.rb
Constant Summary collapse
- MEGA_EVOLVE_TOOLS =
List of tools that allow MEGA Evolution
%i[mega_ring mega_bracelet mega_pendant mega_glasses mega_anchor mega_stickpin mega_tiara mega_anklet mega_cuff]
Instance Method Summary collapse
-
#can_pokemon_mega_evolve?(pokemon) ⇒ Boolean
Test if a Pokemon can Mega Evolve.
-
#initialize(scene) ⇒ MegaEvolve
constructor
Create the MegaEvolve checker.
-
#mark_as_mega_evolved(pokemon)
Mark a Pokemon as mega evolved.
-
#mega_tool_name(pokemon) ⇒ String
Give the name of the mega tool used by the trainer.
Constructor Details
#initialize(scene) ⇒ MegaEvolve
Create the MegaEvolve checker
10 11 12 13 14 15 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00400 MegaEvolve.rb', line 10 def initialize(scene) @scene = scene # List of bags that already used the mega evolution # @type [Array<PFM::Bag>] @used_mega_tool_bags = [] end |
Instance Method Details
#can_pokemon_mega_evolve?(pokemon) ⇒ Boolean
Test if a Pokemon can Mega Evolve
20 21 22 23 24 25 26 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00400 MegaEvolve.rb', line 20 def can_pokemon_mega_evolve?(pokemon) bag = pokemon.bag return false unless MEGA_EVOLVE_TOOLS.any? { |item_db_symbol| bag.contain_item?(item_db_symbol) } return false if pokemon.from_party? && any_mega_player_action? return !@used_mega_tool_bags.include?(bag) && pokemon.can_mega_evolve? end |
#mark_as_mega_evolved(pokemon)
Mark a Pokemon as mega evolved
30 31 32 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00400 MegaEvolve.rb', line 30 def mark_as_mega_evolved(pokemon) @used_mega_tool_bags << pokemon.bag end |
#mega_tool_name(pokemon) ⇒ String
Give the name of the mega tool used by the trainer
37 38 39 40 41 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00400 MegaEvolve.rb', line 37 def mega_tool_name(pokemon) bag = pokemon.bag symbol = MEGA_EVOLVE_TOOLS.find { |item_db_symbol| bag.contain_item?(item_db_symbol) } return data_item(symbol || 0).name end |