class Goby::Escape
Allows an Entity
to try to escape from the opponent.
Constants
- FAILURE
Text for failed escape.
- SUCCESS
Text for successful escape.
Public Class Methods
new()
click to toggle source
Initializes the Escape
command.
Calls superclass method
Goby::BattleCommand::new
# File lib/goby/battle/escape.rb, line 14 def initialize super(name: "Escape") end
Public Instance Methods
run(user, enemy)
click to toggle source
Samples a probability to determine if the user will escape from battle.
@param [Entity] user the one who is trying to escape. @param [Entity] enemy the one from whom the user wants to escape.
# 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