public function run(\IQU\DataSource\HttpRequest $request) { $letter = $request->getParameter('letter'); $return = ['illegalLetter' => 0, 'isFinish' => 0, 'isWin' => 0, 'word' => $this->hangmanService->getWord(), 'triesLeft' => $this->hangmanService->getCountOfTries()]; if (!$this->validationHangmanService->isAcceptableLetter($letter)) { $return['illegalLetter'] = 1; return $return; } if (!$this->hangmanService->openLetter($letter)) { $this->hangmanService->decreaseCountOfTries(); } return ['illegalLetter' => 0, 'isFinish' => $this->hangmanService->isEndOfTheGame(), 'isWin' => $this->hangmanService->isWordFound(), 'word' => $this->hangmanService->getWord(), 'triesLeft' => $this->hangmanService->getCountOfTries()]; }
public function run(\IQU\DataSource\HttpRequest $request) { $this->hangmanService->reset(); return ['word' => $this->hangmanService->getWord(), 'triesLeft' => $this->hangmanService->getCountOfTries()]; }