Class: Model::GameState
- Inherits:
-
Object
- Object
- Model::GameState
- Defined in:
- lib/tic_tac_toe/model/game_state.rb
Instance Method Summary collapse
Instance Method Details
#rating(board, team) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/tic_tac_toe/model/game_state.rb', line 9 def (board, team) winner = winner(board) return 0 unless winner winner.name == team.name ? 1 : -1 end |
#winner(board) ⇒ Object
3 4 5 6 7 |
# File 'lib/tic_tac_toe/model/game_state.rb', line 3 def winner(board) tile_collection = board.tile_collection rows(tile_collection) || cols(tile_collection) || diags(tile_collection) end |