class Game

Attributes

board[R]
current_player[R]
player_o[R]
player_x[R]

Public Class Methods

new(board, player_x, player_o) click to toggle source
# File lib/game.rb, line 5
def initialize(board, player_x, player_o)
  @board = board
  @player_x = player_x
  @player_o = player_o
  @current_player = player_x
end

Public Instance Methods

change_turns() click to toggle source
# File lib/game.rb, line 17
def change_turns
  @current_player = @board.current_player_marker == "X" ? @player_x : @player_o
end
game_over?() click to toggle source
# File lib/game.rb, line 21
def game_over?
  @board.game_over?
end
take_turn() click to toggle source
# File lib/game.rb, line 12
def take_turn
  @board = @board.place_marker(@current_player.choose_space(@board))
  change_turns
end