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->getPlayersOfRole(Role::WEREWOLF) 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: Самые честные в мире итоги голосования Оборотней\r\n-----------------------------------------\r\n"; foreach ($game->getVotes() as $voteForId => $voters) { $voteForPlayer = $game->getPlayerById($voteForId); $numVoters = count($voters); $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->getPlayersOfRole(Role::WEREWOLF) 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; }
public static function format(Game $game) { $msg = ":memo: Votes des Loups-Garous\r\n-----------------------------------------\r\n"; foreach ($game->getVotes() as $voteForId => $voters) { $voteForPlayer = $game->getPlayerById($voteForId); $numVoters = count($voters); $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: Votes restants: "; $playerNames = []; foreach ($game->getPlayersOfRole(Role::WEREWOLF) as $player) { if (!$game->hasPlayerVoted($player->getId())) { $playerNames[] = '@' . $player->getUsername(); } } if (count($playerNames) > 0) { $msg .= implode(', ', $playerNames); } else { $msg .= "Aucun"; } $msg .= "\r\n--------------------------------------------------------------\r\n"; return $msg; }
public function fire() { $client = $this->client; if ($this->game->getState() != GameState::NIGHT) { $client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) use($client) { $client->send(":warning: You can only kill at night.", $channel); }); throw new Exception("Killing occurs only during the night."); } // Voter should be alive if (!$this->game->hasPlayer($this->userId)) { $client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) use($client) { $client->send(":warning: You aren't alive in the specified channel.", $channel); }); throw new Exception("Can't kill if dead."); } // Person player is voting for should also be alive if (!$this->game->hasPlayer($this->args[0])) { $client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) use($client) { $client->send(":warning: Could not find that player.", $channel); }); throw new Exception("Voted player not found in game."); } // Person should be werewolf $player = $this->game->getPlayerById($this->userId); if ($player->role != Role::WEREWOLF) { $client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) use($client) { $client->send(":warning: YOu have to be a werewolf to kill.", $channel); }); throw new Exception("Only werewolves can kill."); } if ($this->game->hasPlayerVoted($this->userId)) { $client->getChannelGroupOrDMByID($this->channel)->then(function (Channel $channel) use($client) { $client->send(":warning: You have already voted.", $channel); }); throw new Exception("You have already voted."); } $this->game->vote($this->userId, $this->args[1]); $msg = KillFormatter::format($this->game); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client, $msg) { $client->send($msg, $channel); }); } foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { if (!$this->game->hasPlayerVoted($player->getId())) { return; } } $votes = $this->game->getVotes(); if (count($votes) > 1) { $this->game->clearVotes(); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client) { $client->send(":warning: The werewolves did not unanimously vote on a member of the town. Vote again.", $channel); }); } return; } $this->game->setWolvesVoted(true); $this->gameManager->changeGameState($this->game->getId(), GameState::DAY); }
private function onNight(Game $game) { $client = $this->client; $nightMsg = ":crescent_moon: :zzz: The sun sets and the villagers go to sleep."; $this->client->getChannelGroupOrDMByID($game->getId())->then(function (Channel $channel) use($client, $nightMsg) { $client->send($nightMsg, $channel); }); $wolves = $game->getPlayersOfRole(Role::WEREWOLF); $wolfMsg = ":crescent_moon: It is night and it is time to hunt. Type !kill #channel @player to make your choice. "; foreach ($wolves as $wolf) { $this->client->getDMByUserId($wolf->getId())->then(function (DirectMessageChannel $channel) use($client, $wolfMsg) { $client->send($wolfMsg, $channel); }); } $seerMsg = ":mag_right: Seer, select a player by saying !see #channel @username."; $seers = $game->getPlayersOfRole(Role::SEER); foreach ($seers as $seer) { $this->client->getDMByUserId($seer->getId())->then(function (DirectMessageChannel $channel) use($client, $seerMsg) { $client->send($seerMsg, $channel); }); } $bodyGuardMsg = ":muscle: Bodyguard, you may guard someone once per night. That player cannot be eliminated. Type !guard #channel @user"; $bodyguards = $game->getPlayersOfRole(Role::BODYGUARD); foreach ($bodyguards as $bodyguard) { $this->client->getDMByUserId($bodyguard->getId())->then(function (DirectMessageChannel $channel) use($client, $bodyGuardMsg) { $client->send($bodyGuardMsg, $channel); }); } }
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}", $dmc); if ($player->role == Role::WEREWOLF) { if ($game->getNumRole(Role::WEREWOLF) > 1) { $werewolves = PlayerListFormatter::format($game->getPlayersOfRole(Role::WEREWOLF)); $client->send("The werewolves are: {$werewolves}", $dmc); } else { $client->send("You are the only werewolf.", $dmc); } } if ($player->role == 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 == 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: 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 .= ":crescent_moon: :zzz: It is the middle of the night and the village is sleeping."; $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); } }
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("Vous êtes {$player->role}", $dmc); if ($player->role == Role::WEREWOLF) { if ($game->getNumRole(Role::WEREWOLF) > 1) { $werewolves = PlayerListFormatter::format($game->getPlayersOfRole(Role::WEREWOLF)); $client->send("Les Loups-Garous sont : {$werewolves}", $dmc); } else { $client->send("Vous êtes le seul Loup-Garou.", $dmc); } } if ($player->role == Role::SEER) { $client->send("C'est à votre tour ! Espionnez un joueur en tapant !see #channel @joueur.\r\nNE DITES PAS PENDANT LA NUIT CE QUE VOUS AVEZ VU, PARLEZ UNIQUEMENT PENDANT LE JOUR ET SI VOUS N'ÊTES PAS MORT(E) !", $dmc); } if ($player->role == Role::BEHOLDER) { $seers = $game->getPlayersOfRole(Role::SEER); $seers = PlayerListFormatter::format($seers); $client->send("La Voyante est: {$seers}", $dmc); } }); } $playerList = PlayerListFormatter::format($game->getLivingPlayers()); $roleList = RoleListFormatter::format($game->getLivingPlayers()); $msg = ":wolf: Une nouvelle partie de Loups-Garous a commencé ! Pour un tutoriel, tapez !help.\r\n\r\n"; $msg .= "Joueurs: {$playerList}\r\n"; $msg .= "Rôles possibles: {$game->getRoleStrategy()->getRoleListMsg()}\r\n\r\n"; if ($this->optionsManager->getOptionValue(OptionName::role_seer)) { $msg .= ":crescent_moon: :zzz: C'est la nuit, le village dort."; $msg .= " La partie commencera quand la Voyante aura sondé quelqu'un."; } $this->sendMessageToChannel($game, $msg); if (!$this->optionsManager->getOptionValue(OptionName::role_seer)) { $this->changeGameState($game->getId(), GameState::NIGHT); } }
public function fire() { $client = $this->client; if ($this->game->getWolvesVoted()) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Волки уже свое отвыли.", $channel); }); throw new Exception("Волки уже свое отвыли."); } if ($this->game->getState() != GameState::NIGHT) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Ночь утра мудренее. Дождись заката.", $channel); }); throw new Exception("Ночь утра мудренее. Дождись заката."); } // Voter should be alive if (!$this->game->isPlayerAlive($this->userId)) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Кажется тебя уже выпилили, наберись терпения и жди следующей игры.", $channel); }); throw new Exception("Кажется тебя уже выпилили, наберись терпения и жди следующей игры."); } // Person player is voting for should also be alive if (!$this->game->isPlayerAlive($this->args[1])) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Не вижу такого чела, а он с какого района?", $channel); }); throw new Exception("Не вижу такого чела, а он с какого района?"); } // Person should be werewolf $player = $this->game->getPlayerById($this->userId); if ($player->role != Role::WEREWOLF) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: А справка, что ты оборотень у тебя есть?", $channel); }); throw new Exception("А справка, что ты оборотень у тебя есть?"); } if ($this->game->hasPlayerVoted($this->userId)) { //If changeVote is not enabled and player has already voted, do not allow another vote if (!$this->gameManager->optionsManager->getOptionValue(OptionName::changevote)) { throw new Exception("Ой, все! Нельзя быть таким непостоянным."); } $this->game->clearPlayerVote($this->userId); } $this->game->vote($this->userId, $this->args[1]); $msg = KillFormatter::format($this->game); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client, $msg) { $client->send($msg, $channel); }); } foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { if (!$this->game->hasPlayerVoted($player->getId())) { return; } } $votes = $this->game->getVotes(); if (count($votes) > 1) { $this->game->clearVotes(); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client) { $client->send(":warning: Никого не убили. Вы уж там между собой разберитесь и проголосуйте снова.", $channel); }); } return; } $this->game->setWolvesVoted(true); $this->gameManager->changeGameState($this->game->getId(), GameState::DAY); }
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("Ты у нас будешь {$player->role}", $dmc); if ($player->role == Role::WEREWOLF) { if ($game->getNumRole(Role::WEREWOLF) > 1) { $werewolves = PlayerListFormatter::format($game->getPlayersOfRole(Role::WEREWOLF)); $client->send("В этой игре Оборотни: {$werewolves}", $dmc); } else { $client->send("В этой игре ты единственный Оборотень.", $dmc); } } if ($player->role == Role::SEER) { $client->send("Смотритель, выбери игрока !see #channel @username.\r\nВНИМАНИЕ! ДЕРЖИ ЯЗЫК ЗА ЗУБАМИ ДО УТРА, А ЕСЛИ УМЕР ЛУЧШЕ ВООБЩЕ ПОМОЛЧИ!1111", $dmc); } if ($player->role == Role::BEHOLDER) { $seers = $game->getPlayersOfRole(Role::SEER); $seers = PlayerListFormatter::format($seers); $client->send("Смотрители: {$seers}", $dmc); } }); } $playerList = PlayerListFormatter::format($game->getLivingPlayers()); $roleList = RoleListFormatter::format($game->getLivingPlayers()); $msg = ":wolf: Новая игра в Оборотня начинается! Если не знаешь правил пиши !help.\r\n\r\n"; $msg .= "ВАЖНО! Главное разобраться какие сообщения писать в общий чат, а какие в личку боту.\r\n\r\n"; $msg .= "Если кратко: все действия, связанные с ролями идут в личку. Голосование днем и обсуждение - в общий чат. \r\n\r\n"; $msg .= "Игроки: {$playerList}\r\n"; $msg .= "Возможные роли: {$game->getRoleStrategy()->getRoleListMsg()}\r\n\r\n"; if ($this->optionsManager->getOptionValue(OptionName::role_seer)) { $msg .= ":crescent_moon: :zzz: Наступает ночь, крестьяне выпили чарку, съели шкварку и идут спать. "; $msg .= "Игра начнется как только Смотритель выберет кого-то."; } $this->sendMessageToChannel($game, $msg); if (!$this->optionsManager->getOptionValue(OptionName::role_seer)) { $this->changeGameState($game->getId(), GameState::NIGHT); } }
public function fire() { $client = $this->client; if ($this->game->getWolvesVoted()) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Les Loups-Garous ont déjà voté.", $channel); }); throw new Exception("Les Loups-Garous ne peuvent pas voter après la fin du vote."); } if ($this->game->getState() != GameState::NIGHT) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Vous pouvez tuer uniquement pendant la nuit.", $channel); }); throw new Exception("Impossible de tuer en dehors de la nuit."); } // Voter should be alive if (!$this->game->isPlayerAlive($this->userId)) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Vous n'êtes pas vivant dans le channel spécifié.", $channel); }); throw new Exception("Impossible de tuer en étant mort."); } // Person player is voting for should also be alive if (!$this->game->isPlayerAlive($this->args[1])) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Impossible de trouver ce joueur.", $channel); }); throw new Exception("Joueur voté pas dans la partie."); } // Person should be werewolf $player = $this->game->getPlayerById($this->userId); if ($player->role != Role::WEREWOLF) { $client->getChannelGroupOrDMByID($this->channel)->then(function (ChannelInterface $channel) use($client) { $client->send(":warning: Vous devez être un Loup-Garou pour tuer.", $channel); }); throw new Exception("Seulement les Loups-Garous peuvent tuer"); } if ($this->game->hasPlayerVoted($this->userId)) { //If changeVote is not enabled and player has already voted, do not allow another vote if (!$this->gameManager->optionsManager->getOptionValue(OptionName::changevote)) { throw new Exception("Changement de vote non autorisé."); } $this->game->clearPlayerVote($this->userId); } $this->game->vote($this->userId, $this->args[1]); $msg = KillFormatter::format($this->game); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client, $msg) { $client->send($msg, $channel); }); } foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { if (!$this->game->hasPlayerVoted($player->getId())) { return; } } $votes = $this->game->getVotes(); if (count($votes) > 1) { $this->game->clearVotes(); foreach ($this->game->getPlayersOfRole(Role::WEREWOLF) as $player) { $client->getDMByUserID($player->getId())->then(function (DirectMessageChannel $channel) use($client) { $client->send(":warning: Les Loups-Garous n'ont pas voté à l'unanimité sur un Villageois. Merci de voter à nouveau.", $channel); }); } return; } $this->game->setWolvesVoted(true); $this->gameManager->changeGameState($this->game->getId(), GameState::DAY); }