getVotes() public method

public getVotes ( ) : array
return array
Example #1
0
 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: 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;
 }
Example #3
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;
 }
Example #4
0
 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 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;
     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);
 }
Example #8
0
 private function onNightEnd(Game $game)
 {
     $client = $this->client;
     $votes = $game->getVotes();
     foreach ($votes as $lynch_id => $voters) {
         $player = $game->getPlayerById($lynch_id);
         if ($lynch_id == $game->getGuardedUserId()) {
             $killMsg = ":muscle: @{$player->getUsername()} was protected from being killed during the night.";
             $game->setLastGuardedUserId($game->getGuardedUserId());
             $game->setGuardedUserId(null);
         } else {
             $killMsg = ":skull_and_crossbones: @{$player->getUsername()} was killed during the night.";
             $game->removePlayer($lynch_id);
         }
         $client->getChannelGroupOrDMByID($game->getId())->then(function (Channel $channel) use($client, $killMsg) {
             $client->send($killMsg, $channel);
         });
     }
 }
Example #9
0
 private function onNightEnd(Game $game)
 {
     $votes = $game->getVotes();
     foreach ($votes as $lynch_id => $voters) {
         $player = $game->getPlayerById($lynch_id);
         if ($lynch_id == $game->getGuardedUserId()) {
             $killMsg = ":muscle: @{$player->getUsername()} was protected from being killed during the night.";
         } else {
             $killMsg = ":skull_and_crossbones: @{$player->getUsername()} ({$player->role}) was killed during the night.";
             $game->killPlayer($lynch_id);
         }
         $game->setLastGuardedUserId($game->getGuardedUserId());
         $game->setGuardedUserId(null);
         $this->sendMessageToChannel($game, $killMsg);
     }
 }
Example #10
0
 private function onNightEnd(Game $game)
 {
     $votes = $game->getVotes();
     foreach ($votes as $lynch_id => $voters) {
         $player = $game->getPlayerById($lynch_id);
         if ($lynch_id == $game->getGuardedUserId()) {
             $killMsg = ":muscle: @{$player->getUsername()} a été protégé par le Salvateur de l'attaque des Loups-Garous.";
         } else {
             $killMsg = ":skull_and_crossbones: @{$player->getUsername()} ({$player->role}) a été tué pendant la nuit.";
             $game->killPlayer($lynch_id);
         }
         $game->setLastGuardedUserId($game->getGuardedUserId());
         $game->setGuardedUserId(null);
         $this->sendMessageToChannel($game, $killMsg);
     }
 }
Example #11
0
 /**
  * @param Game $game
  */
 private function onNightEnd(Game $game)
 {
     $votes = $game->getVotes();
     $numKilled = 0;
     $hasGuarded = false;
     $hasHealed = false;
     $hasKilled = false;
     $hunterKilled = false;
     $hunterName = "";
     $killMsg = ":skull_and_crossbones: ";
     foreach ($votes as $lynch_id => $voters) {
         $player = $game->getPlayerById($lynch_id);
         if ($lynch_id == $game->getGuardedUserId()) {
             $hasGuarded = true;
         } elseif ($lynch_id == $game->getWitchHealedUserId()) {
             $hasHealed = true;
         } else {
             $killMsg .= " @{$player->getUsername()} ({$player->role->getName()})";
             if ($player->role->isRole(Role::HUNTER)) {
                 $hunterKilled = true;
                 $hunterName = $player->getUsername();
             }
             $game->killPlayer($lynch_id);
             $hasKilled = true;
             $numKilled++;
         }
     }
     // see if witch poisoned someone
     if ($game->getWitchPoisonedUserId()) {
         $poisoned_player_id = $game->getWitchPoisonedUserId();
         $poisoned_player = $game->getPlayerById($poisoned_player_id);
         $poisoned_player_name = $poisoned_player->getUsername();
         $poisoned_player_role = (string) $poisoned_player->role->getName();
         if ($numKilled > 0) {
             $killMsg .= " and";
         }
         $killMsg .= " @{$poisoned_player->getUsername()} ({$poisoned_player_role})";
         $game->killPlayer($poisoned_player_id);
         $hasKilled = true;
         $numKilled++;
         $game->setWitchPoisonedUserId(null);
         // if killed player was hunter
         if ($poisoned_player->role->isRole(Role::HUNTER)) {
             $hunterKilled = true;
             $hunterName = $poisoned_player_name;
         }
     }
     $wasOrWere = "was";
     if ($numKilled > 1) {
         $wasOrWere = "were";
     }
     $killMsg .= " {$wasOrWere} killed during the night.";
     $game->setLastGuardedUserId($game->getGuardedUserId());
     $game->setGuardedUserId(null);
     if ($hasKilled) {
         $this->sendMessageToChannel($game, $killMsg);
         // send shoot command to hunter if in game
         if ($hunterKilled) {
             $game->setHunterNeedsToShoot(true);
             $hunterMsg = ":bow_and_arrow: " . $hunterName . " you were killed.  The night isn't over, though, because as a hunter you can take one other player with you to your grave.  Type !shoot @playername, or !shoot noone.";
             $this->sendMessageToChannel($game, $hunterMsg);
         }
     }
     if ($numKilled == 0) {
         $this->sendMessageToChannel($game, "There was no deaths in the night!");
     }
     $game->setNightEnded(true);
 }
Example #12
0
 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);
 }
Example #13
0
 private function onNightEnd(Game $game)
 {
     $votes = $game->getVotes();
     foreach ($votes as $lynch_id => $voters) {
         $player = $game->getPlayerById($lynch_id);
         if ($lynch_id == $game->getGuardedUserId()) {
             $killMsg = ":muscle: @{$player->getUsername()} спасен благодаря тебе, мужик.";
         } else {
             $killMsg = ":skull_and_crossbones: @{$player->getUsername()} ({$player->role}) был беспощадно убит.";
             $game->killPlayer($lynch_id);
         }
         $game->setLastGuardedUserId($game->getGuardedUserId());
         $game->setGuardedUserId(null);
         $this->sendMessageToChannel($game, $killMsg);
     }
 }
Example #14
0
 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);
 }