Class: Oakdex::Battle::Turn
- Inherits:
-
Object
- Object
- Oakdex::Battle::Turn
- Extended by:
- Forwardable
- Defined in:
- lib/oakdex/battle/turn.rb
Overview
Represents one Turn within the battle
Instance Attribute Summary collapse
-
#battle ⇒ Object
readonly
Returns the value of attribute battle.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(battle, actions) ⇒ Turn
constructor
A new instance of Turn.
Constructor Details
#initialize(battle, actions) ⇒ Turn
Returns a new instance of Turn.
12 13 14 15 |
# File 'lib/oakdex/battle/turn.rb', line 12 def initialize(battle, actions) @battle = battle @actions = actions end |
Instance Attribute Details
#battle ⇒ Object (readonly)
Returns the value of attribute battle.
10 11 12 |
# File 'lib/oakdex/battle/turn.rb', line 10 def battle @battle end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/oakdex/battle/turn.rb', line 17 def execute execute_status_conditions(:before_turn) @actions.each { |a| a.turn = self } ordered_actions.each do |action| next unless valid_target?(action) next if action.pokemon && action.pokemon.fainted? action.execute end execute_status_conditions(:after_turn) end |