Slackwolf\Game\OptionsManager::getOptionValue PHP Method

getOptionValue() public method

public getOptionValue ( $optionName ) : null
$optionName
return null
    public function getOptionValue($optionName)
    {
        /** @var Option $option */
        $option = null;
        foreach ($this->options as $searchOption) {
            /** @var Option $searchOption */
            if ($searchOption->name == $optionName) {
                $option = $searchOption;
                break;
            }
        }
        return $option == null ? null : $option->value;
    }

Usage Example

Example #1
0
 /**
  * @param Game $game
  */
 private function onDay(Game $game)
 {
     $remainingPlayers = PlayerListFormatter::format($game->getLivingPlayers());
     $dayBreakMsg = ":sunrise: The sun rises and the villagers awake. It is still raining, but it slows somewhat, allowing momentary respite from the cold, wet hell that we all live in.\r\n";
     $dayBreakMsg .= "Remaining Players: {$remainingPlayers}\r\n\r\n";
     $dayBreakMsg .= "Villagers, find the Werewolves! Type !vote @username to vote to lynch a player.";
     if ($this->optionsManager->getOptionValue(OptionName::changevote)) {
         $dayBreakMsg .= "\r\nYou may change your vote at any time before voting closes. Type !vote clear to remove your vote.";
     }
     if ($this->optionsManager->getOptionValue(OptionName::no_lynch)) {
         $dayBreakMsg .= "\r\nType !vote noone to vote to not lynch anybody today.";
     }
     $this->sendMessageToChannel($game, $dayBreakMsg);
 }