From ffa7c6f5c007dfc826aef0ca27d23bb69bbeed7e Mon Sep 17 00:00:00 2001
From: Fibinger Ádám <adam.fibinger@wup.hu>
Date: Thu, 04 Jun 2020 23:10:08 +0200
Subject: [PATCH] BO pöttyök + BestOf kupa típus

---
 EOG/Models/Stripe.php |   84 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 12 deletions(-)

diff --git a/EOG/Models/Stripe.php b/EOG/Models/Stripe.php
index 1531e3f..3250137 100644
--- a/EOG/Models/Stripe.php
+++ b/EOG/Models/Stripe.php
@@ -15,7 +15,7 @@
 		'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', 'iana', 'oryx', 'no-ban', 'no-ban2'];
 	protected $state = [
 		'stripe' => [
 			'class' => 'team',
@@ -23,21 +23,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 +72,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 +93,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,18 +143,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']))
 		{
-			$this->setCup($state['cup']['number'], $state['cup']['name']);
+			$cupNum = $state['cup']['number'] ?? '';
+			$cupName = $state['cup']['name'] ?? '';
+			$bestOf = (int) $state['cup']['bestof'] ?? 1;
+			$this->setCup($cupNum, $cupName, $bestOf);
 		}
 
 		if (!empty($state['team']))
@@ -173,4 +223,14 @@
 	{
 		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