| | |
| | | const TEAM_ORANGE = 'orange'; |
| | | |
| | | private $allowedColors = [self::TEAM_BLUE, self::TEAM_ORANGE]; |
| | | private $allowedStripeClasses = ['team', 'simple']; |
| | | private $allowedStripeClasses = ['team', 'simple', 'team-ban']; |
| | | private $allowedOperators = [ |
| | | 'alibi', 'amaru', 'ash', 'bandit', 'blackbeard', 'blitz', 'buck', 'capitao', 'castle', |
| | | 'caveira', 'clash', 'doc', 'dokkaebi', 'echo', 'ela', 'finka', 'frost', 'fuze', |
| | |
| | | |
| | | public function setClass(string $class): self |
| | | { |
| | | if (!in_array($class, $this->allowedStripeClasses)) { |
| | | if (!in_array($class, $this->allowedStripeClasses)) |
| | | { |
| | | throw new \InvalidArgumentException("Given class " . $class . " not allowed. Allowed classes: " . implode(', ', $this->allowedStripeClasses)); |
| | | } |
| | | |
| | | if ($class === 'simple') { |
| | | if ($class === 'simple') |
| | | { |
| | | $this->setSimpleStripe(); |
| | | } |
| | | |
| | |
| | | */ |
| | | private function testColor(string $color) |
| | | { |
| | | if (!in_array($color, $this->allowedColors)) { |
| | | if (!in_array($color, $this->allowedColors)) |
| | | { |
| | | throw new \InvalidArgumentException("Given colour " . $team_color . " not allowed. Allowed colours: " . implode(', ', $this->allowedColors)); |
| | | } |
| | | } |
| | |
| | | public function addTeamBan(string $team_color = self::TEAM_BLUE, $operator) |
| | | { |
| | | $this->testColor($team_color); |
| | | if (!in_array($operator, $this->allowedOperators)) { |
| | | if (!in_array($operator, $this->allowedOperators)) |
| | | { |
| | | //FIXME: védő és támadó operátorok külön |
| | | throw new \InvalidArgumentException("Given operator not allowed: " . $operator . " Allowed operators: " . implode(', ', $this->allowedOperators)); |
| | | } |
| | |
| | | |
| | | public function __get($name) |
| | | { |
| | | if ($this->__isset($name)) { |
| | | if ($this->__isset($name)) |
| | | { |
| | | return $this->state[$name]; |
| | | } |
| | | |
| | |
| | | { |
| | | $state = json_decode($json); |
| | | |
| | | if (!empty($state['stripe']["class"])) { |
| | | unset($this->state); |
| | | $this->state = []; |
| | | |
| | | if (!empty($state['stripe']["class"])) |
| | | { |
| | | $this->setClass($state['stripe']["class"]); |
| | | } |
| | | |
| | | if (!empty($state['cup']['name']) && !empty($state['cup']['number'])) { |
| | | if (!empty($state['cup']['name']) && !empty($state['cup']['number'])) |
| | | { |
| | | $this->setCup($state['cup']['number'], $state['cup']['name']); |
| | | } |
| | | |
| | | if (!empty($state['team'])) |
| | | { |
| | | foreach ([self::TEAM_BLUE, self::TEAM_ORANGE] as $color) |
| | | { |
| | | if (!empty($state['team'][$color]['name'])) |
| | | { |
| | | $this->setTeamName($color, $state['team'][$color]['name']); |
| | | } |
| | | |
| | | if (!empty($state['team'][$color]['ban']) && is_array($state['team'][$color]['ban'])) |
| | | { |
| | | foreach ($state['team'][$color]['ban'] as $operator) |
| | | { |
| | | $this->addTeamBan($color, $operator); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public function getJson() |
| | | { |
| | | return json_encode($this->state); |
| | | } |
| | | |
| | | public function getOperators() { |
| | | return $this->allowedOperators; |
| | | } |
| | | } |