Class: Oakdex::Battle::MoveExecution
- Inherits:
-
Object
- Object
- Oakdex::Battle::MoveExecution
- Extended by:
- Forwardable
- Defined in:
- lib/oakdex/battle/move_execution.rb
Overview
Represents one Action. One turn has many actions.
Constant Summary collapse
- RECALL_PRIORITY =
6
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #execute ⇒ Object
- #hitting? ⇒ Boolean
- #hitting_probability ⇒ Object
-
#initialize(action, target) ⇒ MoveExecution
constructor
A new instance of MoveExecution.
Constructor Details
#initialize(action, target) ⇒ MoveExecution
Returns a new instance of MoveExecution.
16 17 18 19 |
# File 'lib/oakdex/battle/move_execution.rb', line 16 def initialize(action, target) @action = action @target = target end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
14 15 16 |
# File 'lib/oakdex/battle/move_execution.rb', line 14 def action @action end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
14 15 16 |
# File 'lib/oakdex/battle/move_execution.rb', line 14 def target @target end |
Instance Method Details
#execute ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oakdex/battle/move_execution.rb', line 30 def execute return if prevented_by_status_condition? pokemon.change_pp_by(move.name, -1) if hitting? add_uses_move_log execute_damage execute_stat_modifiers execute_status_conditions execute_status_condition_callbacks else add_move_does_not_hit_log end battle.remove_fainted end |
#hitting? ⇒ Boolean
25 26 27 28 |
# File 'lib/oakdex/battle/move_execution.rb', line 25 def hitting? @hitting = rand(1..1000) <= hitting_probability ? 1 : 0 @hitting == 1 end |
#hitting_probability ⇒ Object
21 22 23 |
# File 'lib/oakdex/battle/move_execution.rb', line 21 def hitting_probability ((move.accuracy / 100.0) * (pokemon.accuracy / target.evasion)) * 1000 end |