예제 #1
0
파일: NewTry.php 프로젝트: rootree/IQU
 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()];
 }
예제 #2
0
파일: StartGame.php 프로젝트: rootree/IQU
 public function run(\IQU\DataSource\HttpRequest $request)
 {
     $this->hangmanService->reset();
     return ['word' => $this->hangmanService->getWord(), 'triesLeft' => $this->hangmanService->getCountOfTries()];
 }