Permalink
Browse files
Replace winning_player with winning_row
- Loading branch information...
Showing
with
2 additions
and
2 deletions.
-
+2
−2
tic-tac-toe/tic_tac_toe.rb
|
@@ -27,11 +27,11 @@ def winning_move?(square, player) |
|
|
|
|
|
|
|
def winner |
|
|
|
first_position_in_rows = [0, 3, 6] |
|
|
|
first_position_in_rows.each { |position| return mark_at(position) if winning_player(position) } |
|
|
|
first_position_in_rows.each { |position| return mark_at(position) if winning_row(position) } |
|
|
|
return '-' |
|
|
|
end |
|
|
|
|
|
|
|
def winning_player(position) |
|
|
|
def winning_row(position) |
|
|
|
position_occupied?(position) && |
|
|
|
mark_at(position) == mark_at(position.next) && |
|
|
|
mark_at(position.next) == mark_at(position.next.next) |
|
|
That's nice. I like this change because it replaces the concept of a winning PERSON (player) with a winning COMBINATION (row of Xs or Os)