Module: Battle::Move::Mechanics::Counter
- Included in:
- Counter, Battle::Move::MetalBurst, Battle::Move::MirrorCoat
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/04150 Battle_Move/00001 Mechanics/00050 Counter.rb
Overview
Preset used for counter attacks Should be included only in a Battle::Move class or a class with the same interface The includer must overwrite the following methods:
-
counter_fails?(attacker, user, targets)
Instance Method Summary collapse
-
#damages(user, target) ⇒ Integer
(also: #counter_damages)
Method calculating the damages done by counter.
-
#move_usable_by_user(user, targets) ⇒ Boolean
(also: #counter_move_usable_by_user)
Function that tests if the user is able to use the move.
Instance Method Details
#damages(user, target) ⇒ Integer Also known as: counter_damages
Method calculating the damages done by counter
26 27 28 29 30 31 32 33 |
# File 'scripts/01600 Alpha 25 Battle Engine/04150 Battle_Move/00001 Mechanics/00050 Counter.rb', line 26 def damages(user, target) @effectiveness = 1 @critical = false return 1 unless (attacker = last_attacker(user)) log_data("damages = #{(attacker.move_history.last.move.damage_dealt * damage_multiplier).floor.clamp(1, Float::INFINITY)} # after counter") return (attacker.move_history.last.move.damage_dealt * damage_multiplier).floor.clamp(1, Float::INFINITY) end |
#move_usable_by_user(user, targets) ⇒ Boolean Also known as: counter_move_usable_by_user
Note:
Thing that prevents the move from being used should be defined by :move_prevention_user Hook
Function that tests if the user is able to use the move
14 15 16 17 18 19 |
# File 'scripts/01600 Alpha 25 Battle Engine/04150 Battle_Move/00001 Mechanics/00050 Counter.rb', line 14 def move_usable_by_user(user, targets) return false unless super return show_usage_failure(user) && false if counter_fails?(last_attacker(user), user, targets) return true end |