public function test_it_marks_board_field_with_current_player_mark_if_move_ok_when_moving_player() { $move = ["correct col", "correct row"]; $this->startingPlayer->shouldReceive("getMove")->with($this->game)->andReturn($move); $this->board->shouldReceive("isFieldEmpty")->withArgs($move)->andReturn(true); $this->board->shouldReceive("markField")->withArgs(["correct col", "correct row", self::STARTING_MARK])->andReturnNull(); $this->game->moveCurrentPlayer(); }
/** * @param Game $game */ private function moveCurrentPlayer(Game $game) { list($randomCol, $randomRow) = $game->getRandomBoardCoordinates(); $msg = sprintf("%s's [%s] move (e.g. %s %s): ", $game->getCurrentPlayerName(), $game->getCurrentPlayerMark(), $randomCol, $randomRow); $this->ioService->printMessageLine($msg); while (true) { try { $game->moveCurrentPlayer(); break; } catch (GameException $e) { $msg = sprintf("%s, try again: ", $e->getMessage()); $this->ioService->printMessage($msg); } } }