/** * @param Game $game * * @return string */ public static function format(Game $game) { $msg = ":memo: Werewolf Kill Vote\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->getWerewolves() 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; }
/** * @param Game $game */ private function onFirstNight(Game $game) { $client = $this->client; foreach ($game->getLivingPlayers() as $player) { $client->getDMByUserId($player->getId())->then(function (DirectMessageChannel $dmc) use($client, $player, $game) { $client->send("Your role is {$player->role->getName()}", $dmc); if ($player->role->isWerewolfTeam()) { if (count($game->getWerewolves()) > 1) { $werewolves = PlayerListFormatter::format($game->getWerewolves()); $client->send("The werewolves are: {$werewolves}", $dmc); } else { $client->send("You are the only werewolf.", $dmc); } } if ($player->role->isRole(Role::SEER)) { $client->send("Seer, select a player by saying !see #channel @username.\r\nDO NOT DISCUSS WHAT YOU SEE DURING THE NIGHT, ONLY DISCUSS DURING THE DAY IF YOU ARE NOT DEAD!", $dmc); } if ($player->role->isRole(Role::BEHOLDER)) { $seers = $game->getPlayersOfRole(Role::SEER); $seers = PlayerListFormatter::format($seers); $client->send("The seer is: {$seers}", $dmc); } }); } $playerList = PlayerListFormatter::format($game->getLivingPlayers()); $roleList = RoleListFormatter::format($game->getLivingPlayers()); $msg = ":wolf: It is raining, and a new game of Werewolf is starting! For a tutorial, type !help.\r\n\r\n"; $msg .= "Players: {$playerList}\r\n"; $msg .= "Possible Roles: {$game->getRoleStrategy()->getRoleListMsg()}\r\n\r\n"; if ($this->optionsManager->getOptionValue(OptionName::role_seer)) { $msg .= ":moon: :rain_cloud: The rain comes down in torrents as the village sleeps, unaware of the horror the lurks outside in the wet. It is the middle of the night."; $msg .= " The game will begin when the Seer chooses someone."; } $this->sendMessageToChannel($game, $msg); if (!$this->optionsManager->getOptionValue(OptionName::role_seer)) { $this->changeGameState($game->getId(), GameState::NIGHT); } }