From bdd7cae9d01b017c9881eee11660e2f390efbdfc Mon Sep 17 00:00:00 2001 From: Zachary Perlmutter Date: Wed, 27 Jan 2016 08:56:34 -0800 Subject: [PATCH 1/3] Modified lib/game.rb Note: You should probably test this before merging. I couldn't test it. * Renamed methods * `Game#occupied_check` --> `Game#occupied?` * `Game#numeric_check` --> `Game#numeric?` * removed unneeded `[]`s --- lib/game.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/game.rb b/lib/game.rb index 1a2a114..3546898 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -5,7 +5,7 @@ class Game attr_reader :board def initialize(player_1, player_2, board = Board.new) - @players = [player_1, player_2] + @players = player_1, player_2 @board = board @current_player_id = 0 end @@ -52,7 +52,7 @@ def valid_move?(move) occupied_check(x, y) end - def numeric_check(x, y) + def numeric?(x, y) return false unless x.is_a?(Numeric) && y.is_a?(Numeric) end @@ -60,7 +60,7 @@ def range_check(x, y) return false if x < 0 || y < 0 || x > 2 || y > 2 end - def occupied_check(x, y) + def occupied?(x, y) @board.cell_empty?(x, y) end end From 130743ec8e659af2f4c626417e79a22d721ea3c3 Mon Sep 17 00:00:00 2001 From: Zachary Perlmutter Date: Tue, 23 Feb 2016 09:55:29 -0800 Subject: [PATCH 2/3] Fixed what was failing the test --- lib/game.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/game.rb b/lib/game.rb index 3546898..266a340 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -47,16 +47,16 @@ def ask_a_valid_move(player) def valid_move?(move) x, y = move - numeric_check(x, y) - range_check(x, y) - occupied_check(x, y) + numeric?(x, y) + range?(x, y) + occupied?(x, y) end def numeric?(x, y) return false unless x.is_a?(Numeric) && y.is_a?(Numeric) end - def range_check(x, y) + def range?(x, y) return false if x < 0 || y < 0 || x > 2 || y > 2 end From e628332426f47e5899368c33635a273aa7802724 Mon Sep 17 00:00:00 2001 From: Zachary Perlmutter Date: Wed, 2 Mar 2016 09:13:06 -0800 Subject: [PATCH 3/3] Removed unneeded lines --- lib/game.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/game.rb b/lib/game.rb index 266a340..4853d9c 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -38,11 +38,8 @@ def swap_players def ask_a_valid_move(player) move = player.next_move?(@board) - if valid_move?(move) - move - else - ask_a_valid_move(player) - end + if valid_move?(move) then move + else ask_a_valid_move(player) end end def valid_move?(move)