Module: Games::CyclicalTurn
- Included in:
- Chess::Game, Connect4::Game
- Defined in:
- lib/boardgame_engine/game_modules.rb
Overview
Module for games with a cyclical turn system
Instance Method Summary collapse
-
#change_turn ⇒ Object
Changes the turn to the next player.
Instance Method Details
#change_turn ⇒ Object
Changes the turn to the next player
8 9 10 11 |
# File 'lib/boardgame_engine/game_modules.rb', line 8 def change_turn idx = @players.find_index(@turn) @turn = @players[(idx + 1) % @players.length] end |