| | |
| | | 'glaz', 'goyo', 'gridlock', 'hibana', 'iq', 'jackal', 'jager', 'kaid', 'kapkan', |
| | | 'lesion', 'lion', 'maestro', 'maverick', 'mira', 'montagne', 'mozzie', 'mute', 'nokk', |
| | | 'nomad', 'pulse', 'rook', 'sledge', 'smoke', 'tachanka', 'thatcher', 'thermite', 'twitch', |
| | | 'valkyrie', 'vigil', 'warden', 'ying', 'zofia']; |
| | | 'valkyrie', 'vigil', 'warden', 'ying', 'zofia', 'wamai', 'kali']; |
| | | protected $state = [ |
| | | 'stripe' => [ |
| | | 'class' => 'team', |
| | | ], |
| | | 'cup' => [ |
| | | 'number' => '#75', |
| | | 'number' => '#76', |
| | | 'name' => '5on5 Open Cup', |
| | | ], |
| | | 'team' => [ |
| | |
| | | if (!in_array($class, $this->allowedStripeClasses)) |
| | | { |
| | | throw new \InvalidArgumentException("Given class " . $class . " not allowed. Allowed classes: " . implode(', ', $this->allowedStripeClasses)); |
| | | } |
| | | |
| | | if ($class === 'simple') |
| | | { |
| | | $this->setSimpleStripe(); |
| | | } |
| | | |
| | | $this->state['stripe']['class'] = $class; |
| | |
| | | //FIXME: védő és támadó operátorok külön |
| | | throw new \InvalidArgumentException("Given operator not allowed: " . $operator . " Allowed operators: " . implode(', ', $this->allowedOperators)); |
| | | } |
| | | |
| | | if (isset($this->state['team'][$team_color]['ban']) && count($this->state['team'][$team_color]['ban']) > 1) |
| | | { |
| | | throw new \InvalidArgumentException("Team " . $team_color . " already has 2 operators."); |
| | | } |
| | | |
| | | $this->state['team'][$team_color]['ban'][] = $operator; |
| | | } |
| | | |
| | | public function __get($name) |
| | |
| | | return isset($this->state[$name]); |
| | | } |
| | | |
| | | public function loadJson(string $json) |
| | | public function loadFromJson(string $json) |
| | | { |
| | | $state = json_decode($json); |
| | | $this->loadFromArray($state); |
| | | } |
| | | |
| | | public function loadFromArray(array $state) |
| | | { |
| | | |
| | | unset($this->state); |
| | | $this->state = []; |
| | |
| | | $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']); |
| | | $cupNum = $state['cup']['number'] ?? ''; |
| | | $cupName = $state['cup']['name'] ?? ''; |
| | | $this->setCup($cupNum, $cupName); |
| | | } |
| | | |
| | | if (!empty($state['team'])) |
| | |
| | | return json_encode($this->state); |
| | | } |
| | | |
| | | public function getOperators() { |
| | | public function getOperators() |
| | | { |
| | | return $this->allowedOperators; |
| | | } |
| | | |
| | | public function getState() |
| | | { |
| | | return $this->state; |
| | | } |
| | | |
| | | public function getType() |
| | | { |
| | | if (empty($this->state['stripe']['class'])) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | return $this->state['stripe']['class']; |
| | | } |
| | | } |