Fibinger Ádám
2019-10-15 cc3ac843ada92f513339d893c8da534e3c5b9ae7
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;
   }
}