diff --git a/src/Chrl/AppBundle/GameAction/NextAction.php b/src/Chrl/AppBundle/GameAction/NextAction.php index 7f4ffb9..e157c7f 100644 --- a/src/Chrl/AppBundle/GameAction/NextAction.php +++ b/src/Chrl/AppBundle/GameAction/NextAction.php @@ -8,13 +8,15 @@ public function run($message, $user) { $game = $this->gameService->findGame($message); - $this->botApi->sendMessage( - $game->chatId, - 'Ok, changing question.', - 'markdown' - ); - $this->gameService->em->persist($game); - $this->gameService->em->flush(); - $this->gameService->askQuestion($game); + if ($game->status == 1) { + $this->botApi->sendMessage( + $game->chatId, + 'Ok, changing question.', + 'markdown' + ); + $this->gameService->em->persist($game); + $this->gameService->em->flush(); + $this->gameService->askQuestion($game); + } } } diff --git a/src/Chrl/AppBundle/GameAction/StopAction.php b/src/Chrl/AppBundle/GameAction/StopAction.php new file mode 100644 index 0000000..e320824 --- /dev/null +++ b/src/Chrl/AppBundle/GameAction/StopAction.php @@ -0,0 +1,27 @@ +gameService->findGame($message); + + if ($game->status == 1) { + $game->status = 0; + + $this->gameService->em->persist($game); + $this->gameService->em->flush(); + $this->botApi->sendMessage($message['chat']['id'], 'The game has stopped!'); + } else { + $this->botApi->sendMessage( + $message['chat']['id'], + 'The game is not running...Use /start command to run game.' + ); + } + } +}