From 42082209d5dc6921afebea67196958e370b737c1 Mon Sep 17 00:00:00 2001 From: Fibinger Ádám <adam.fibinger@wup.hu> Date: Fri, 19 Jun 2020 19:18:45 +0200 Subject: [PATCH] Ace + Melusi --- EOG/Models/Stripe.php | 74 +++++++++++++++++++++++++++++++------ 1 files changed, 62 insertions(+), 12 deletions(-) diff --git a/EOG/Models/Stripe.php b/EOG/Models/Stripe.php index 2a84d3a..32e5baa 100644 --- a/EOG/Models/Stripe.php +++ b/EOG/Models/Stripe.php @@ -15,7 +15,9 @@ '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', 'wamai', 'kali']; + 'valkyrie', 'vigil', 'warden', 'ying', 'zofia', 'wamai', 'kali', 'iana', 'oryx', 'no-ban', 'no-ban2', + 'ace', 'melusi' + ]; protected $state = [ 'stripe' => [ 'class' => 'team', @@ -23,21 +25,33 @@ 'cup' => [ 'number' => '#76', 'name' => '5on5 Open Cup', + 'bestof' => '5', ], 'team' => [ 'orange' => [ - 'name' => 'Narancs Csapat', - 'ban' => [ + 'name' => 'Narancs Csapat', + 'ban' => [ 'mira', 'jackal' + ], + 'score' => [ + true, + true, + true ] + ], 'blue' => [ - 'name' => 'Kék csapat', - 'ban' => [ + 'name' => 'Kék csapat', + 'ban' => [ 'rook', 'blitz' + ], + 'score' => [ + true, + true, + true ] ] ] @@ -60,10 +74,16 @@ unset($this->state['team']); } - public function setCup(string $number, string $name) + public function setScore(string $team, int $number, bool $score) + { + $this->state['team'][$team]['score'][$number] = $score; + } + + public function setCup(string $number, string $name, int $bestOf = 1) { $this->state['cup']['number'] = $number; $this->state['cup']['name'] = $name; + $this->state['cup']['bestof'] = $bestOf; } /** @@ -75,17 +95,17 @@ { if (!in_array($color, $this->allowedColors)) { - throw new \InvalidArgumentException("Given colour " . $team_color . " not allowed. Allowed colours: " . implode(', ', $this->allowedColors)); + throw new \InvalidArgumentException("Given colour " . $color . " not allowed. Allowed colours: " . implode(', ', $this->allowedColors)); } } - public function setTeamName(string $team_color = self::TEAM_BLUE, $name) + public function setTeamName(string $team_color = self::TEAM_BLUE, $name = '') { $this->testColor($team_color); $this->state['team'][$team_color]['name'] = $name; } - public function addTeamBan(string $team_color = self::TEAM_BLUE, $operator) + public function addTeamBan(string $team_color = self::TEAM_BLUE, $operator = '') { $this->testColor($team_color); if (!in_array($operator, $this->allowedOperators)) @@ -125,20 +145,50 @@ public function loadFromArray(array $state) { - unset($this->state); $this->state = []; + + if (!empty($state['team']['orange']['score'][0])) + { + $this->setScore('orange', 0, true); + } + + if (!empty($state['team']['orange']['score'][1])) + { + $this->setScore('orange', 1, true); + } + + if (!empty($state['team']['orange']['score'][2])) + { + $this->setScore('orange', 2, true); + } + + if (!empty($state['team']['blue']['score'][0])) + { + $this->setScore('blue', 0, true); + } + + if (!empty($state['team']['blue']['score'][1])) + { + $this->setScore('blue', 1, true); + } + + if (!empty($state['team']['blue']['score'][2])) + { + $this->setScore('blue', 2, true); + } 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']) || !empty($state['cup']['bestof'])) { $cupNum = $state['cup']['number'] ?? ''; $cupName = $state['cup']['name'] ?? ''; - $this->setCup($cupNum, $cupName); + $bestOf = (int) $state['cup']['bestof'] ?? 1; + $this->setCup($cupNum, $cupName, $bestOf); } if (!empty($state['team'])) -- Gitblit v1.8.0