Module: Battle::LogicMock
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb
Overview
Module responsive of mocking the battle logic so nothing happen on the reality
Note: super inside this script might call the original function
Instance Attribute Summary collapse
-
#env ⇒ PFM::Environnement
readonly
Get the env object.
Class Method Summary collapse
-
.extended(mod)
Method called when a visual gets mocked (through extend).
-
.mock_effect_handler(handler, battlers)
Mock the effect handler.
Instance Method Summary collapse
-
#fterrain_change_handler ⇒ Battle::Logic::WeatherChangeHandler
Get a new field terrain change handler.
-
#weather_change_handler ⇒ Battle::Logic::WeatherChangeHandler
Get a new weather change handler.
Instance Attribute Details
#env ⇒ PFM::Environnement (readonly)
Get the env object
74 75 76 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb', line 74 def env @env end |
Class Method Details
.extended(mod)
Method called when a visual gets mocked (through extend)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb', line 9 def extended(mod) mod.instance_variable_set(:@battle_info, mod.scene.battle_info) mod.instance_variable_set(:@messages, []) mod.instance_variable_set(:@actions, []) mod.instance_eval do @battlers.each do |battler_arr| battler_arr.map! do |battler| # @type [PFM::PokemonBattler] battler = battler.clone battler.instance_variable_set(:@scene, mod.scene) next battler end end end # @type [Array<PFM::PokemonBattler>] battlers = mod.instance_variable_get(:@battlers).flatten battlers.each do |battler| battler.instance_variable_set(:@effects, mock_effect_handler(battler.effects, battlers)) end mod.instance_variable_set(:@terrain_effects, mock_effect_handler(mod.terrain_effects, battlers)) mod.bank_effects.map { |effects| mock_effect_handler(effects, battlers) } mod.position_effects.each { |bank| bank&.map! { |effects| mock_effect_handler(effects, battlers) } } mod.instance_variable_set(:@evolve_request, []) mod.instance_variable_set(:@switch_request, []) mod.instance_variable_set(:@battle_result, -1) mod.instance_variable_set(:@env, Marshal.load(Marshal.dump($env))) end |
.mock_effect_handler(handler, battlers)
Mock the effect handler
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb', line 40 def mock_effect_handler(handler, battlers) handler = handler.clone # @type [Array<Object>] effects = handler.instance_variable_get(:@effects).clone effects.map! do |effect| effect = effect.clone effect.instance_variables.each do |iv| obj = effect.instance_variable_get(iv) next unless obj.is_a?(PFM::PokemonBattler) obj = battlers.find { |battler| battler.original == obj.original } effect.instance_variable_set(iv, obj) if obj end next effect end handler.instance_variable_set(:@effects, effects) return handler end |
Instance Method Details
#fterrain_change_handler ⇒ Battle::Logic::WeatherChangeHandler
Get a new field terrain change handler
68 69 70 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb', line 68 def fterrain_change_handler return Logic::FTerrainChangeHandler.new(self, @scene, @env) end |
#weather_change_handler ⇒ Battle::Logic::WeatherChangeHandler
Get a new weather change handler
62 63 64 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00003 BattleLogicMock.rb', line 62 def weather_change_handler return Logic::WeatherChangeHandler.new(self, @scene, @env) end |