Slackwolf\Game\GameManager::onNight PHP Method

onNight() private method

private onNight ( Game $game )
$game Game
    private function onNight(Game $game)
    {
        $client = $this->client;
        $nightMsg = ":moon: :zzz: The sun sets, and the hard rain makes it difficult to hear anything outside. Villagers bar their doors, take long pulls of :beer:, and try not to think of what might lurk beyond the feeble candlelight. ";
        $this->sendMessageToChannel($game, $nightMsg);
        $wolves = $game->getWerewolves();
        $wolfMsg = ":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 = ":crystal_ball: 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 = ":shield: Bodyguard, you may guard someone once per with your grizzled ex-lawman skills. 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);
            });
        }
        $witches = $game->getPlayersOfRole(Role::WITCH);
        if (count($witches) > 0) {
            $witch_msg = ":wine_glass:  You may poison someone once for the entire game.  Type \"!poison #channel @user\" to poison someone \r\nor \"!poison #channel noone\" to do nothing.  \r\n:warning: Night will not end until you make a decision.";
            if ($game->getWitchPoisonPotion() > 0) {
                foreach ($witches as $witch) {
                    $this->client->getDMByUserId($witch->getId())->then(function (DirectMessageChannel $channel) use($client, $witch_msg) {
                        $client->send($witch_msg, $channel);
                    });
                }
            } else {
                $game->setWitchPoisoned(true);
            }
        }
    }