SenikTony tic_tac_toe #1

Merged
merged 1 commit into from Jun 26, 2012

Projects

None yet

3 participants

@SenikTony
Contributor

Заполнил методы: initialize;
turn(x, y);
can_turn?(x, y);
has_winner?;
finished?;
has_turns?;

@Locke23rus Locke23rus commented on the diff Jun 26, 2012
lib/tic_tac_toe/game.rb
end
def has_winner?
+ players.include?(winner)
end
def finished?
@Locke23rus
Locke23rus Jun 26, 2012 Member

Методы finished? и has_turns? можно сделать однострочными.

def finished?
  has_winner? || !has_turns?
end

def has_turns?
  turns_left > 0
end
@SenikTony
SenikTony Jun 26, 2012 Contributor

Оооо, теперь буду знать. Сенкью.

@Locke23rus
Locke23rus Jun 26, 2012 Member

Ждём еще один pull-request ;)

@shaliko
Member
shaliko commented Jun 26, 2012

@SenikTony Отличная работа!

@shaliko shaliko merged commit 5b9d61d into KubanRB:master Jun 26, 2012
@Locke23rus Locke23rus commented on the diff Jun 26, 2012
lib/tic_tac_toe/game.rb
end
def can_turn?(x, y)
+ !players.include?(turns[x][y])
@Locke23rus
Locke23rus Jun 26, 2012 Member

Как вариант можно заменить на

def can_turn?(x, y)
  turns[x][y].empty?
end
@SenikTony
SenikTony Jun 26, 2012 Contributor

Вот об этом я что-то и не подумал. Такая реализация can_turn? наверное даже более правильная.

@Locke23rus
Locke23rus Jun 26, 2012 Member

Только стоит проверить, я тесты не запускал :)

@SenikTony
SenikTony Jun 26, 2012 Contributor

При turns[x][y].empty? тесты не прошли.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment