Class: Battle::Logic::WeatherChangeHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
Defined in:
docs/5_Battle_04_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, snow: 287}

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:



1432
1433
# File 'docs/5_Battle_04_Logic.rb', line 1432

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



1469
1470
# File 'docs/5_Battle_04_Logic.rb', line 1469

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



1462
1463
# File 'docs/5_Battle_04_Logic.rb', line 1462

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)


1437
1438
# File 'docs/5_Battle_04_Logic.rb', line 1437

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



1442
1443
# File 'docs/5_Battle_04_Logic.rb', line 1442

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



1447
1448
# File 'docs/5_Battle_04_Logic.rb', line 1447

def weather_change_with_process(weather_type, nb_turn)
end