Slackwolf\Game\Command\StartCommand::filterChosen PHP Method

filterChosen() private method

private filterChosen ( User[] &$users )
$users Slack\User[]
    private function filterChosen(&$users)
    {
        $chosenUsers = [];
        foreach ($this->args as $chosenUser) {
            $chosenUser = UserIdFormatter::format($chosenUser, $users);
            $chosenUsers[] = $chosenUser;
        }
        // Remove the bot from the player list
        foreach ($users as $key => $user) {
            if ($user->getUsername() == getenv('BOT_NAME')) {
                unset($users[$key]);
            }
        }
        // Remove players that weren't specified, if there were specified players
        if (count($chosenUsers) == 0 || $chosenUsers[0] != 'all') {
            foreach ($users as $key => $user) {
                $userFound = false;
                foreach ($chosenUsers as $chosenUser) {
                    if (strpos($chosenUser, $user->getId()) !== false) {
                        $userFound = true;
                    }
                }
                if (!$userFound) {
                    unset($users[$key]);
                }
            }
        }
    }