From 1045038fc4c542164017a42eb39b532266073a6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 16 Nov 2008 13:28:00 +0700 Subject: [PATCH] added current_user and other_user --- app/controllers/game_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 8800830..d37cb86 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -7,17 +7,25 @@ class GameController < ApplicationController @last_check = @board.checks.last end + def current_user + @board.turn > 0 ? @board.player1 : @board.player2 + end + + def other_user + @board.turn > 0 ? @board.player2 : @board.player1 + end + def index redirect_to :action => :list end def play - player = @board.turn > 0 ? @board.player1 : @board.player2; + player = current_user end def check - player = @board.turn > 0 ? @board.player1 : @board.player2; + player = current_user raise "Not your turn" unless session[@board.id] == player x = params[:x].to_i y = params[:y].to_i -- 2.11.4.GIT