private function post($view, GameAction $action, $char = null) { $content = $this->twig->render("::" . $view . ".text.twig", array('game' => $action->getGame(), 'action' => $action, 'char' => $char)); $payload = new ChatPostMessagePayload(); $payload->setChannel("#" . $action->getChannelName()); $payload->setText($content); $payload->setUsername("Hangbot"); $response = $this->slack->send($payload); return $response; }
public function abort(GameAction $action) { $game = $action->getGame(); if (!$game) { throw new \InvalidArgumentException("No game in progress"); } if ($game->getUserStarted() !== $action->getPlayerId()) { throw new \InvalidArgumentException("You are not the game master!"); } $game->abort(); $this->slack->postAbort($action); $this->em->flush(); }