getLivingPlayers() public method

An array containing all users that are still alive.
public getLivingPlayers ( ) : User[]
return Slack\User[] Users who are currently alive.
 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);
 }
Example #2
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: 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);
 }
Example #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: Что-то пошло не так. Кажется игра не началась.", $channel);
         });
         return;
     }
     // build list of players
     $playersList = PlayerListFormatter::format($this->game->getLivingPlayers());
     $this->gameManager->sendMessageToChannel($this->game, ":ok: Стойкие оловянные солдатики: " . $playersList);
 }
Example #4
0
 public static function format(Game $game)
 {
     $msg = ":memo: Town Ballot\r\n--------------------------------------------------------------\r\n";
     foreach ($game->getVotes() as $voteForId => $voters) {
         $voteForPlayer = $game->getPlayerById($voteForId);
         $numVoters = count($voters);
         if ($voteForId == 'noone') {
             $msg .= ":peace_symbol: No lynch\t\t | ({$numVoters}) | ";
         } else {
             $msg .= ":knife: Kill @{$voteForPlayer->getUsername()}\t\t | ({$numVoters}) | ";
         }
         $voterNames = [];
         foreach ($voters as $voter) {
             $voter = $game->getPlayerById($voter);
             $voterNames[] = '@' . $voter->getUsername();
         }
         $msg .= implode(', ', $voterNames) . "\r\n";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n:hourglass: Remaining Voters: ";
     $playerNames = [];
     foreach ($game->getLivingPlayers() as $player) {
         if (!$game->hasPlayerVoted($player->getId())) {
             $playerNames[] = '@' . $player->getUsername();
         }
     }
     if (count($playerNames) > 0) {
         $msg .= implode(', ', $playerNames);
     } else {
         $msg .= "None";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n";
     return $msg;
 }
 public static function format(Game $game)
 {
     $msg = ":memo: Votes des Villageois\r\n--------------------------------------------------------------\r\n";
     foreach ($game->getVotes() as $voteForId => $voters) {
         $voteForPlayer = $game->getPlayerById($voteForId);
         $numVoters = count($voters);
         if ($voteForId == 'noone') {
             $msg .= ":peace_symbol: Pas de lynchage\t\t | ({$numVoters}) | ";
         } else {
             $msg .= ":knife: Tuer @{$voteForPlayer->getUsername()}\t\t | ({$numVoters}) | ";
         }
         $voterNames = [];
         foreach ($voters as $voter) {
             $voter = $game->getPlayerById($voter);
             $voterNames[] = '@' . $voter->getUsername();
         }
         $msg .= implode(', ', $voterNames) . "\r\n";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n:hourglass: Personnes n'ayant pas encore voté: ";
     $playerNames = [];
     foreach ($game->getLivingPlayers() as $player) {
         if (!$game->hasPlayerVoted($player->getId())) {
             $playerNames[] = '@' . $player->getUsername();
         }
     }
     if (count($playerNames) > 0) {
         $msg .= implode(', ', $playerNames);
     } else {
         $msg .= "Aucune";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n";
     return $msg;
 }
 public static function format(Game $game)
 {
     $msg = ":memo: Вече\r\n--------------------------------------------------------------\r\n";
     foreach ($game->getVotes() as $voteForId => $voters) {
         $voteForPlayer = $game->getPlayerById($voteForId);
         $numVoters = count($voters);
         if ($voteForId == 'noone') {
             $msg .= ":peace_symbol: Пожалуй сегодня обойдемся без расчлененки и сжигания на костре\t\t | ({$numVoters}) | ";
         } else {
             $msg .= ":knife: Сжечь ведьму @{$voteForPlayer->getUsername()}\t\t | ({$numVoters}) | ";
         }
         $voterNames = [];
         foreach ($voters as $voter) {
             $voter = $game->getPlayerById($voter);
             $voterNames[] = '@' . $voter->getUsername();
         }
         $msg .= implode(', ', $voterNames) . "\r\n";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n:hourglass: Еще не опускали бюллетень в урну: ";
     $playerNames = [];
     foreach ($game->getLivingPlayers() as $player) {
         if (!$game->hasPlayerVoted($player->getId())) {
             $playerNames[] = '@' . $player->getUsername();
         }
     }
     if (count($playerNames) > 0) {
         $msg .= implode(', ', $playerNames);
     } else {
         $msg .= "Нет никого";
     }
     $msg .= "\r\n--------------------------------------------------------------\r\n";
     return $msg;
 }
Example #7
0
 public function fire()
 {
     $client = $this->client;
     foreach ($this->game->getLivingPlayers() as $player) {
         if (!strstr($this->chosenUserId, $player->getId())) {
             continue;
         }
         if ($player->role == Role::WEREWOLF || $player->role == Role::LYCAN) {
             $msg = "@{$player->getUsername()} is on the side of the Werewolves.";
         } else {
             $msg = "@{$player->getUsername()} is on the side of the Villagers.";
         }
         $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client, $msg) {
             $this->client->send($msg, $dmc);
         });
         $this->game->setSeerSeen(true);
         $this->gameManager->changeGameState($this->game->getId(), GameState::DAY);
         return;
     }
     $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client) {
         $this->client->send("Could not find the user you asked for.", $dmc);
     });
 }
Example #8
0
 public function fire()
 {
     $client = $this->client;
     foreach ($this->game->getLivingPlayers() as $player) {
         if (!strstr($this->chosenUserId, $player->getId())) {
             continue;
         }
         if ($player->role == Role::WEREWOLF || $player->role == Role::LYCAN) {
             $msg = "@{$player->getUsername()} на стороне Оборотней.";
         } else {
             $msg = "@{$player->getUsername()} на стороне Крестьян.";
         }
         $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client, $msg) {
             $this->client->send($msg, $dmc);
         });
         $this->game->setSeerSeen(true);
         $this->gameManager->changeGameState($this->game->getId(), GameState::DAY);
         return;
     }
     $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client) {
         $this->client->send("Не вижу такого чела, а он с какого района?", $dmc);
     });
 }
Example #9
0
 public function fire()
 {
     $client = $this->client;
     foreach ($this->game->getLivingPlayers() as $player) {
         if (!strstr($this->chosenUserId, $player->getId())) {
             continue;
         }
         if ($player->role == Role::WEREWOLF || $player->role == Role::LYCAN) {
             $msg = "@{$player->getUsername()} est dans le camp des Loups-Garous.";
         } else {
             $msg = "@{$player->getUsername()} est dans le camp des Villageois.";
         }
         $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client, $msg) {
             $this->client->send($msg, $dmc);
         });
         $this->game->setSeerSeen(true);
         $this->gameManager->changeGameState($this->game->getId(), GameState::DAY);
         return;
     }
     $this->client->getDMById($this->channel)->then(function (DirectMessageChannel $dmc) use($client) {
         $this->client->send("Impossible de trouver le joueur que vous avez demandé.", $dmc);
     });
 }
Example #10
0
 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);
 }
Example #11
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);
 }
Example #12
0
 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);
 }