Class: Battle::Logic::WeatherChangeHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
Defined in:
docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb

Overview

Handler responsive of answering properly weather changes requests

Constant Summary collapse

WEATHER_SYM_TO_MSG =

Mapping between weather symbol & message_id

{none: 97, rain: 88, sunny: 87, sandstorm: 89, hail: 90, fog: 91, hardsun: 271, hardrain: 269, strong_winds: 273}

Instance Attribute Summary

Attributes inherited from ChangeHandlerBase

#logic, #pre_checked_effects, #scene

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#exec_hooks, #force_return, included, register, remove, remove_without_name

Methods inherited from ChangeHandlerBase

#prevent_change, #process_prevention_reason, #reset_prevention_reason

Constructor Details

#initialize(logic, scene, env = $env) ⇒ WeatherChangeHandler

Create a new Weather Change Handler

Parameters:



1398
1399
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1398

def initialize(logic, scene, env = $env)
end

Class Method Details

.register_post_weather_change_hook(reason) {|handler, weather_type, last_weather| ... }

Function that registers a on_post_weather_change hook

Parameters:

  • reason (String)

    reason of the on_post_weather_change registration

Yield Parameters:

  • handler (WeatherChangeHandler)
  • weather_type (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

  • last_weather (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain



1435
1436
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1435

def register_post_weather_change_hook(reason)
end

.register_weather_prevention_hook(reason) {|handler, weather_type, last_weather| ... }

Function that registers a weather_prevention hook

Parameters:

  • reason (String)

    reason of the weather_prevention registration

Yield Parameters:

  • handler (WeatherChangeHandler)
  • weather_type (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

  • last_weather (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

Yield Returns:

  • (:prevent, nil)

    :prevent if the status cannot be applied



1428
1429
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1428

def register_weather_prevention_hook(reason)
end

Instance Method Details

#weather_appliable?(weather_type) ⇒ Boolean

Function telling if a weather can be applyied

Parameters:

  • weather_type (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

Returns:

  • (Boolean)


1403
1404
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1403

def weather_appliable?(weather_type)
end

#weather_change(weather_type, nb_turn)

Function that actually change the weather

Parameters:

  • weather_type (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

  • nb_turn (Integer, nil)

    Number of turn, use nil for Infinity



1408
1409
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1408

def weather_change(weather_type, nb_turn)
end

#weather_change_with_process(weather_type, nb_turn)

Function that test if the change is possible and perform the change if so

Parameters:

  • weather_type (Symbol)

    :none, :rain, :sunny, :sandstorm, :hail, :fog, :hardsun, :hardrain

  • nb_turn (Integer, nil)

    Number of turn, use nil for Infinity



1413
1414
# File 'docs/01600_Alpha_25_Battle_Engine_00200_Battle_Logic.rb', line 1413

def weather_change_with_process(weather_type, nb_turn)
end