From cc3ac843ada92f513339d893c8da534e3c5b9ae7 Mon Sep 17 00:00:00 2001
From: Fibinger Ádám <adam.fibinger@wup.hu>
Date: Tue, 15 Oct 2019 16:47:12 +0200
Subject: [PATCH] Meccs történet alapok

---
 EOG/Models/Stripe.php |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/EOG/Models/Stripe.php b/EOG/Models/Stripe.php
index 0f91067..1531e3f 100644
--- a/EOG/Models/Stripe.php
+++ b/EOG/Models/Stripe.php
@@ -21,7 +21,7 @@
 			'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 = [];
@@ -157,7 +164,13 @@
 		return json_encode($this->state);
 	}
 
-	public function getOperators() {
+	public function getOperators()
+	{
 		return $this->allowedOperators;
 	}
+
+	public function getState()
+	{
+		return $this->state;
+	}
 }
\ No newline at end of file

--
Gitblit v1.8.0