Slackwolf\Game\Game::setLastGuardedUserId PHP Method

setLastGuardedUserId() public method

public setLastGuardedUserId ( $id )
$id
    public function setLastGuardedUserId($id)
    {
        $this->lastGuardedUserId = $id;
    }

Usage Example

Example #1
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);
         });
     }
 }
All Usage Examples Of Slackwolf\Game\Game::setLastGuardedUserId