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);
         $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->getPlayers() 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;
 }
Esempio n. 2
0
 public function fire()
 {
     $client = $this->client;
     foreach ($this->game->getPlayers() 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);
     });
 }
Esempio n. 3
0
 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);
     });
 }