Skip to content

Commit

Permalink
Replaced #player_settings occurrences with #player_methods and remove…
Browse files Browse the repository at this point in the history
…d game#switch_turn from controller
  • Loading branch information
lisahamm committed Mar 11, 2015
1 parent 72454bf commit 513a476
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ source 'https://rubygems.org'

gem 'sinatra', require: 'sinatra/base'
gem 'rspec'
gem 'tic_tac_toe', :github => 'lisahamm/ruby_ttt'
# gem 'tic_tac_toe', :github => 'lisahamm/ruby_ttt'
gem 'tic_tac_toe', :path => '/Users/lisahamm/Desktop/Projects/apprenticeship/tic_tac_toe/ruby_ttt'

gem 'rack-test'
gem 'rack-flash3'
5 changes: 2 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
GIT
remote: git://github.com/lisahamm/ruby_ttt.git
revision: 68400f7aeac4dcfe44107469cbc798b13e8594f8
PATH
remote: /Users/lisahamm/Desktop/Projects/apprenticeship/tic_tac_toe/ruby_ttt
specs:
tic_tac_toe (0.0.1)

Expand Down
8 changes: 3 additions & 5 deletions tic_tac_toe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class TicTacToeController < Sinatra::Base

if computer_opponent(params) == "player1"
game.take_turn(game.generate_ai_move)
game.switch_turn
end

session[:computer_opponent] = computer_opponent(params)
session[:player_settings] = player_settings(params)
session[:player1_mark] = player_marks(params)[0]
session[:player2_mark] = player_marks(params)[1]
session[:current_player_mark] = game.current_player_mark
session[:moves] = game.board_to_array
redirect to('/game')
Expand All @@ -43,11 +43,10 @@ class TicTacToeController < Sinatra::Base

post '/make_move' do
board = array_to_board(session[:moves])
game = TicTacToe::Game.new(board, session[:player_settings], session[:current_player_mark])
game = TicTacToe::Game.new(session[:player1_mark], session[:player2_mark], session[:current_player_mark], board)

move = params[:move].to_i
game.take_turn(move)
game.switch_turn

if !game.in_progress?
session[:moves] = game.board_to_array
Expand All @@ -56,7 +55,6 @@ class TicTacToeController < Sinatra::Base

if session[:computer_opponent] != nil
game.take_turn(game.generate_ai_move)
game.switch_turn
end

session[:moves] = game.board_to_array
Expand Down

0 comments on commit 513a476

Please sign in to comment.