public function join() { try { $user = $this->event->getRequest()->getSendingUser(); $channel = $this->event->getRequest()->getSource(); if (!$this->current_game) { throw new \Exception('There\'s no game in progress.'); } $this->current_game->addPlayer($user); $this->event->addResponse(Response::notice($channel, "@{$user} has joined the game.")); } catch (\Exception $e) { $this->event->addResponse(Response::msg($user, $e->getMessage())); } }
/** * @expectedException \Exception */ public function testCantKeepIfGameHasntStarted() { $game = new Game('creating_player_name'); $game->addPlayer('new_player_one'); $game->addPlayer('new_player_two'); $game->keep(); }