Class: Battle::Logic::TransformHandler
- Inherits:
-
ChangeHandlerBase
- Object
- ChangeHandlerBase
- Battle::Logic::TransformHandler
- Includes:
- Hooks
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01013 TransformHandler.rb
Overview
Handler responsive of answering properly transform requests
Instance Attribute Summary
Attributes inherited from ChangeHandlerBase
Class Method Summary collapse
-
.register_on_initialize_transform(reason) {|handler, target| ... }
Function that registers a on_initialize_transform hook.
Instance Method Summary collapse
-
#can_copy?(copied) ⇒ Boolean
Function that tells if the pokemon can copy another pokemon.
-
#can_transform?(target) ⇒ Boolean
Function that tells if the Pokemon can transform or not.
-
#initialize_transform_attempt(target)
Function responsive of transforming a Pokemon when initialized.
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_on_initialize_transform(reason) {|handler, target| ... }
Function that registers a on_initialize_transform hook
35 36 37 38 39 40 41 42 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01013 TransformHandler.rb', line 35 def register_on_initialize_transform(reason) Hooks.register(TransformHandler, :on_initialize_transform, reason) do |hook_binding| yield( self, hook_binding.local_variable_get(:target) ) end end |
Instance Method Details
#can_copy?(copied) ⇒ Boolean
Function that tells if the pokemon can copy another pokemon
22 23 24 25 26 27 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01013 TransformHandler.rb', line 22 def can_copy?(copied) return false if copied&.effects&.has?(:substitute) return false if copied.has_ability?(:illusion) && !can_transform?(copied) return true end |
#can_transform?(target) ⇒ Boolean
Function that tells if the Pokemon can transform or not
15 16 17 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01013 TransformHandler.rb', line 15 def can_transform?(target) return !target.transform end |
#initialize_transform_attempt(target)
Function responsive of transforming a Pokemon when initialized
8 9 10 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01013 TransformHandler.rb', line 8 def initialize_transform_attempt(target) exec_hooks(TransformHandler, :on_initialize_transform, binding) end |