コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function fire()
 {
     $this->game->removeLobbyPlayer($this->userId);
     $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers());
     if ($playersList) {
         $this->gameManager->sendMessageToChannel($this->game, "Current lobby: " . $playersList);
     } else {
         $this->gameManager->sendMessageToChannel($this->game, "Lobby is now empty");
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function fire()
 {
     if (!$this->gameManager->hasGame($this->channel)) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) {
             $this->client->send(":warning: No game in progress.", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getLivingPlayers());
     $this->gameManager->sendMessageToChannel($this->game, ":ok: Players still alive: " . $playersList);
 }
コード例 #3
0
 public function fire()
 {
     $client = $this->client;
     if (!$this->gameManager->hasGame($this->channel)) {
         $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) {
             $client->send(":warning: Aucun jeu en cours", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getLivingPlayers());
     $this->gameManager->sendMessageToChannel($this->game, ":ok: Joueurs encore vivants : " . $playersList);
 }
コード例 #4
0
ファイル: AliveCommand.php プロジェクト: EgorZhuk/slackwolf
 public function fire()
 {
     $client = $this->client;
     if (!$this->gameManager->hasGame($this->channel)) {
         $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) {
             $client->send(":warning: Что-то пошло не так. Кажется игра не началась.", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getLivingPlayers());
     $this->gameManager->sendMessageToChannel($this->game, ":ok: Стойкие оловянные солдатики: " . $playersList);
 }
コード例 #5
0
ファイル: JoinCommand.php プロジェクト: EgorZhuk/slackwolf
 public function fire()
 {
     $userId = $this->userId;
     $game = $this->game;
     $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
         return $channel->getMembers();
     })->then(function (array $users) use($userId, $game) {
         foreach ($users as $key => $user) {
             if ($user->getId() == $userId) {
                 $game->addLobbyPlayer($user);
             }
         }
     });
     $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers());
     $this->gameManager->sendMessageToChannel($this->game, "Список игроков: " . $playersList);
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function fire()
 {
     if (!$this->gameManager->hasGame($this->channel)) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) {
             $this->client->send(":warning: No game in progress.", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getDeadPlayers());
     if (empty($playersList)) {
         $this->gameManager->sendMessageToChannel($this->game, "No one has died yet.");
     } else {
         $this->gameManager->sendMessageToChannel($this->game, ":angel: Players who have died: " . $playersList);
     }
 }
コード例 #7
0
 public function fire()
 {
     $client = $this->client;
     if (!$this->gameManager->hasGame($this->channel)) {
         $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) {
             $client->send(":warning: Aucun jeu en cours", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getDeadPlayers());
     if (empty($playersList)) {
         $this->gameManager->sendMessageToChannel($this->game, "Personne n'est encore mort.");
     } else {
         $this->gameManager->sendMessageToChannel($this->game, ":angel: Joueurs morts: " . $playersList);
     }
 }
コード例 #8
0
ファイル: DeadCommand.php プロジェクト: EgorZhuk/slackwolf
 public function fire()
 {
     $client = $this->client;
     if (!$this->gameManager->hasGame($this->channel)) {
         $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) {
             $client->send(":warning: Что-то пошло не так. Кажется игра не началась.", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getDeadPlayers());
     if (empty($playersList)) {
         $this->gameManager->sendMessageToChannel($this->game, "Пока все живы.");
     } else {
         $this->gameManager->sendMessageToChannel($this->game, ":angel: Они ушли в лучший мир: " . $playersList);
     }
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function fire()
 {
     $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
         return $channel->getMembers();
     })->then(function (array $users) {
         foreach ($users as $key => $user) {
             /* @var $user \Slack\User */
             if ($user->getId() == $this->userId) {
                 if ($this->game->addLobbyPlayer($user)) {
                     $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers());
                     $this->gameManager->sendMessageToChannel($this->game, "Current lobby: " . $playersList);
                 } else {
                     $this->gameManager->sendMessageToChannel($this->game, "You've already joined, " . $user->getFirstName() . ". Quit trying to spam everyone.");
                 }
             }
         }
     });
 }
コード例 #10
0
 public function fire()
 {
     $client = $this->client;
     $gameManager = $this->gameManager;
     $message = $this->message;
     $loadPlayers = true;
     // Check to see that a game does not currently exist
     if ($this->gameManager->hasGame($this->channel)) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $gameManager) {
             $game = $gameManager->getGame($this->channel);
             if ($game->getState == GameState::LOBBY) {
                 $client->send('Un lobby est déjà créé. Tapez !join pour rejoindre la prochaine partie.', $channel);
             } else {
                 $client->send('Un jeu est déjà en cours.', $channel);
             }
         });
         return;
     }
     try {
         $gameManager->newGame($message->getChannel(), [], new RoleStrategy\Classic());
         $game = $gameManager->getGame($message->getChannel());
         $this->gameManager->sendMessageToChannel($game, "Un lobby a été créé. Tapez !join pour rejoindre la prochaine partie.");
         $userId = $this->userId;
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
             return $channel->getMembers();
         })->then(function (array $users) use($userId, $game) {
             foreach ($users as $key => $user) {
                 if ($user->getId() == $userId) {
                     $game->addLobbyPlayer($user);
                 }
             }
         });
         $playersList = PlayerListFormatter::format($game->getLobbyPlayers());
         $this->gameManager->sendMessageToChannel($game, "Lobby actuel : " . $playersList);
     } catch (Exception $e) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $e) {
             $client->send($e->getMessage(), $channel);
         });
     }
 }
コード例 #11
0
ファイル: NewCommand.php プロジェクト: KingJ/slackwolf
 public function fire()
 {
     $client = $this->client;
     $gameManager = $this->gameManager;
     $message = $this->message;
     $loadPlayers = true;
     // Check to see that a game does not currently exist
     if ($this->gameManager->hasGame($this->channel)) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $gameManager) {
             $game = $gameManager->getGame($this->channel);
             if ($game->getState == GameState::LOBBY) {
                 $client->send('A game lobby is already open.  Type !join to play the next game.', $channel);
             } else {
                 $client->send('A game is already in progress.', $channel);
             }
         });
         return;
     }
     try {
         $gameManager->newGame($message->getChannel(), [], new RoleStrategy\Classic());
         $game = $gameManager->getGame($message->getChannel());
         $this->gameManager->sendMessageToChannel($game, "A new game lobby has been created.  Type !join to play the next game.");
         $userId = $this->userId;
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
             return $channel->getMembers();
         })->then(function (array $users) use($userId, $game) {
             foreach ($users as $key => $user) {
                 if ($user->getId() == $userId) {
                     $game->addLobbyPlayer($user);
                 }
             }
         });
         $playersList = PlayerListFormatter::format($game->getLobbyPlayers());
         $this->gameManager->sendMessageToChannel($game, "Current lobby: " . $playersList);
     } catch (Exception $e) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $e) {
             $client->send($e->getMessage(), $channel);
         });
     }
 }
コード例 #12
0
ファイル: NewCommand.php プロジェクト: EgorZhuk/slackwolf
 public function fire()
 {
     $client = $this->client;
     $gameManager = $this->gameManager;
     $message = $this->message;
     $loadPlayers = true;
     // Check to see that a game does not currently exist
     if ($this->gameManager->hasGame($this->channel)) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $gameManager) {
             $game = $gameManager->getGame($this->channel);
             if ($game->getState == GameState::LOBBY) {
                 $client->send('Уже объявлена регистрация на новую игру. Пиши !join чтобы сыграть в этой игре.', $channel);
             } else {
                 $client->send('Запись на рейс окончена.', $channel);
             }
         });
         return;
     }
     try {
         $gameManager->newGame($message->getChannel(), [], new RoleStrategy\Classic());
         $game = $gameManager->getGame($message->getChannel());
         $this->gameManager->sendMessageToChannel($game, "Объявлена регистрация на новую игру. Пиши !join чтобы сыграть в этой игре.");
         $userId = $this->userId;
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) {
             return $channel->getMembers();
         })->then(function (array $users) use($userId, $game) {
             foreach ($users as $key => $user) {
                 if ($user->getId() == $userId) {
                     $game->addLobbyPlayer($user);
                 }
             }
         });
         $playersList = PlayerListFormatter::format($game->getLobbyPlayers());
         $this->gameManager->sendMessageToChannel($game, "Список игроков: " . $playersList);
     } catch (Exception $e) {
         $this->client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client, $e) {
             $client->send($e->getMessage(), $channel);
         });
     }
 }
コード例 #13
0
ファイル: GameManager.php プロジェクト: EgorZhuk/slackwolf
 private function onDay(Game $game)
 {
     $remainingPlayers = PlayerListFormatter::format($game->getLivingPlayers());
     $dayBreakMsg = ":sunrise: Прокричал петух, пора вставать, у тебя свиньи не кормлены.\r\n";
     $dayBreakMsg .= "Перепись населения: {$remainingPlayers}\r\n\r\n";
     $dayBreakMsg .= "Крестьяне, пора снимать с Оборотней шкуры! Пиши !vote @username чтобы посадить плохиша на вилы.";
     if ($this->optionsManager->getOptionValue(OptionName::changevote)) {
         $dayBreakMsg .= "\r\nМожно поменять решение пока голосование не завершилось. Пиши !vote clear если у тебя ветренная натура.";
     }
     if ($this->optionsManager->getOptionValue(OptionName::no_lynch)) {
         $dayBreakMsg .= "\r\nПиши !vote noone если устал от кровопролития и не хочешь никого сегодня убивать.";
     }
     $this->sendMessageToChannel($game, $dayBreakMsg);
 }
コード例 #14
0
ファイル: LeaveCommand.php プロジェクト: EgorZhuk/slackwolf
 public function fire()
 {
     $this->game->removeLobbyPlayer($this->userId);
     $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers());
     $this->gameManager->sendMessageToChannel($this->game, "Список игроков: " . $playersList);
 }
コード例 #15
0
ファイル: GameManager.php プロジェクト: b-lawrence/slackwolf
 private function onDay(Game $game)
 {
     $client = $this->client;
     $remainingPlayers = PlayerListFormatter::format($game->getPlayers());
     $dayBreakMsg = ":sunrise: The sun rises from the horizon and the villagers awake.\r\n";
     $dayBreakMsg .= "Remaining Players: {$remainingPlayers}\r\n\r\n";
     $dayBreakMsg .= "Villagers, find the Werewolves! Type !vote @username to vote to lynch a player.";
     $this->client->getChannelGroupOrDMByID($game->getId())->then(function (Channel $channel) use($client, $dayBreakMsg) {
         $client->send($dayBreakMsg, $channel);
     });
 }
コード例 #16
0
ファイル: GameManager.php プロジェクト: KingJ/slackwolf
 private function onDay(Game $game)
 {
     $remainingPlayers = PlayerListFormatter::format($game->getLivingPlayers());
     $dayBreakMsg = ":sunrise: The sun rises and the villagers awake.\r\n";
     $dayBreakMsg .= "Remaining Players: {$remainingPlayers}\r\n\r\n";
     $dayBreakMsg .= "Villagers, find the Werewolves! Type !vote @username to vote to lynch a player.";
     if ($this->optionsManager->getOptionValue(OptionName::changevote)) {
         $dayBreakMsg .= "\r\nYou may change your vote at any time before voting closes. Type !vote clear to remove your vote.";
     }
     if ($this->optionsManager->getOptionValue(OptionName::no_lynch)) {
         $dayBreakMsg .= "\r\nType !vote noone to vote to not lynch anybody today.";
     }
     $this->sendMessageToChannel($game, $dayBreakMsg);
 }
コード例 #17
0
 private function onDay(Game $game)
 {
     $remainingPlayers = PlayerListFormatter::format($game->getLivingPlayers());
     $dayBreakMsg = ":sunrise: C'est le jour, les villageois se réveillent.\r\n";
     $dayBreakMsg .= "Joueurs restant : {$remainingPlayers}\r\n\r\n";
     $dayBreakMsg .= "Villageois, trouvez les Loups-Garous ! Tapez !vote @joueur pour votez le joueur à lyncher.";
     if ($this->optionsManager->getOptionValue(OptionName::changevote)) {
         $dayBreakMsg .= "\r\nVous pouvez changer votre vote tant que le vote n'est pas fini. Tapez !vote clear pour retirer votre vote.";
     }
     if ($this->optionsManager->getOptionValue(OptionName::no_lynch)) {
         $dayBreakMsg .= "\r\\Tapez !vote noone pour voter pour que personne ne meure.";
     }
     $this->sendMessageToChannel($game, $dayBreakMsg);
 }