Class: Battle::Logic::MegaEvolve

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

Constructor Details

#initialize(scene) ⇒ MegaEvolve

Create the MegaEvolve checker

Parameters:



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

Parameters:

Returns:

  • (Boolean)


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

Parameters:



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

Parameters:

Returns:



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