Class: Goby::Escape
- Inherits:
-
BattleCommand
- Object
- BattleCommand
- Goby::Escape
- Defined in:
- lib/goby/battle/escape.rb
Overview
Allows an Entity to try to escape from the opponent.
Constant Summary collapse
- SUCCESS =
Text for successful escape.
"Successful escape!\n\n"
- FAILURE =
Text for failed escape.
"Unable to escape!\n\n"
Constants inherited from BattleCommand
Instance Attribute Summary
Attributes inherited from BattleCommand
Instance Method Summary collapse
-
#initialize ⇒ Escape
constructor
Initializes the Escape command.
-
#run(user, enemy) ⇒ Object
Samples a probability to determine if the user will escape from battle.
Methods inherited from BattleCommand
Constructor Details
#initialize ⇒ Escape
Initializes the Escape command.
14 15 16 |
# File 'lib/goby/battle/escape.rb', line 14 def initialize super(name: "Escape") end |
Instance Method Details
#run(user, enemy) ⇒ Object
Samples a probability to determine if the user will escape from battle.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/goby/battle/escape.rb', line 22 def run(user, enemy) # Higher probability of escape when the enemy has low agility. if (user.sample_agilities(enemy)) user.escaped = true type(SUCCESS) return end # Should already be false. user.escaped = false type(FAILURE) end |