/** * Main method for handling user input. If a letter hyperlink is pressed, the input is evaluated. * If the input is correct a guess is performed. Upon exception - an error message is generated by the * GameView. There is a check after each guess about the status of guesses. * @return void */ public function doPlay() { $userGuess = $this->view->getInput(); try { $this->game->doGuess($userGuess); } catch (InvalidArgumentException $iea) { $this->view->setMessageBadChar(); } catch (Exception $e) { $this->view->setMessageDublicate(); } if ($this->game->isOver()) { $this->view->setMessageLose(); } else { if ($this->game->isWon()) { $this->view->setMessageWin(); } } }