From cffd2c46efe5875ad1eb86a566a9b41bdb461861 Mon Sep 17 00:00:00 2001 From: Fibinger Ádám <adam.fibinger@wup.hu> Date: Thu, 09 Jan 2020 16:31:43 +0100 Subject: [PATCH] Kali, Wamai és egyéb módosítások --- EOG/Models/Stripe.php | 47 ++++++++++++++++++++++++++++++++++++----------- 1 files changed, 36 insertions(+), 11 deletions(-) diff --git a/EOG/Models/Stripe.php b/EOG/Models/Stripe.php index 0f91067..2a84d3a 100644 --- a/EOG/Models/Stripe.php +++ b/EOG/Models/Stripe.php @@ -15,13 +15,13 @@ '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' => [ @@ -48,11 +48,6 @@ 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; @@ -98,6 +93,13 @@ //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) @@ -115,9 +117,14 @@ 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 = []; @@ -127,9 +134,11 @@ $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'])) @@ -157,7 +166,23 @@ 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']; + } } \ No newline at end of file -- Gitblit v1.8.0