Slackwolf\Game\Command\ShootCommand::__construct PHP Method

__construct() public method

Constructs a new Shoot command.
public __construct ( RealTimeClient $client, GameManager $gameManager, Message $message, array $args = null )
$client Slack\RealTimeClient
$gameManager Slackwolf\Game\GameManager
$message Slackwolf\Message\Message
$args array
    public function __construct(RealTimeClient $client, GameManager $gameManager, Message $message, array $args = null)
    {
        parent::__construct($client, $gameManager, $message, $args);
        $client = $this->client;
        if (!$this->game) {
            throw new Exception("No game in progress.");
        }
        if (!$this->game->hunterNeedsToShoot) {
            $this->gameManager->sendMessageToChannel($this->game, ":warning: Invalid !shoot command.");
            throw new Exception("Hunter cant shoot yet.");
        }
        if ($this->channel[0] == 'D') {
            $this->gameManager->sendMessageToChannel($this->game, "Please !shoot in the public channel.");
            throw new Exception("You may not !shoot privately.");
        }
        if (count($this->args) < 1) {
            $this->gameManager->sendMessageToChannel($this->game, "Please target a player using !shoot @player");
            throw new InvalidArgumentException("Must specify a player");
        }
        $this->args[0] = UserIdFormatter::format($this->args[0], $this->game->getOriginalPlayers());
    }