Class: Battle::Logic::ChangeHandlerBase
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb
Overview
Class responsive of describing the minimum functionality of change handlers
Direct Known Subclasses
AbilityChangeHandler, BattleEndHandler, CatchHandler, DamageHandler, FTerrainChangeHandler, FleeHandler, ItemChangeHandler, StatChangeHandler, StatusChangeHandler, SwitchHandler, TransformHandler, WeatherChangeHandler
Instance Attribute Summary collapse
-
#logic ⇒ Battle::Logic
readonly
Get the logic.
-
#scene ⇒ Battle::Scene
readonly
Get the scene.
Instance Method Summary collapse
-
#initialize(logic, scene) ⇒ ChangeHandlerBase
constructor
Create a new ChangeHandler.
-
#prevent_change(&reason) ⇒ :prevent
Function that register a reason why the change is not possible.
-
#process_prevention_reason
Process the reason a change could not be done.
-
#reset_prevention_reason
Reset the reason why change cannot be done.
Constructor Details
#initialize(logic, scene) ⇒ ChangeHandlerBase
Create a new ChangeHandler
14 15 16 17 18 19 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 14 def initialize(logic, scene) @logic = logic @scene = scene # @type [Proc] @reason = nil end |
Instance Attribute Details
#logic ⇒ Battle::Logic (readonly)
Get the logic
7 8 9 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 7 def logic @logic end |
#scene ⇒ Battle::Scene (readonly)
Get the scene
10 11 12 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 10 def scene @scene end |
Instance Method Details
#prevent_change(&reason) ⇒ :prevent
Function that register a reason why the change is not possible
34 35 36 37 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 34 def prevent_change(&reason) @reason = reason return :prevent end |
#process_prevention_reason
Process the reason a change could not be done
22 23 24 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 22 def process_prevention_reason @reason&.call end |
#reset_prevention_reason
Reset the reason why change cannot be done
27 28 29 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01000 ChangeHandler.rb', line 27 def reset_prevention_reason @reason = nil end |