class RailsGame

Public Instance Methods

choose_player_one(type) click to toggle source
# File lib/rails_game.rb, line 2
def choose_player_one(type)
  choose_player(type, 'x')
end
choose_player_two(type) click to toggle source
# File lib/rails_game.rb, line 6
def choose_player_two(type)
  choose_player(type, 'o')
end
print_board() click to toggle source
start() click to toggle source
# File lib/rails_game.rb, line 10
def start
  @game_state = GameState.new(@players[:one])
end
update(move) click to toggle source
# File lib/rails_game.rb, line 14
  def update(move)
#    switch_active_player if @game_state.update(move)
    switch_active_player if @game_state.perform_move(move)
  end

Private Instance Methods

choose_player(type, token) click to toggle source
# File lib/rails_game.rb, line 25
def choose_player(type, token)
  symbol = token == 'x' ? :one : :two
  
  if type == "Human"
    @players[symbol] = PlayerFactory.create_player(PlayerFactory::HUMAN, token)
  elsif type == "RandomCPU"
    @players[symbol] = PlayerFactory.create_player(PlayerFactory::RANDOM_CPU, token)
  elsif type == "PerfectCPU"
    @players[symbol] = PlayerFactory.create_player(PlayerFactory::PERFECT_CPU, token)
  end
end