caster = $caster; $this->friendTeam = $friendTeam; $this->enemyTeam = $enemyTeam; $this->targetType = $targetType; $this->icon = $icon; $this->name = $name; } protected function getTarget(): array { $targets = []; $allExceptCaster = array_merge($this->friendTeam, $this->enemyTeam); switch ($this->targetType) { case self::TAGRET_SELF: $targets[] = $this->caster; break; case self::TARGET_RANDOM_ENEMY: shuffle($this->enemyTeam); $targets[] = end($this->enemyTeam); break; case self::TARGET_RANDOM_FRIEND: shuffle($this->friendTeam); $targets[] = end($this->friendTeam); break; case self::TARGET_RANDOM: shuffle($allExceptCaster); $targets[] = end($allExceptCaster); break; case self::TARGET_RANDOM_ENEMIES: for ($i = 1; $i <= count($this->enemyTeam); $i++) { if ($i > 1 && mt_rand(1,2) === 1) { continue; } shuffle($this->enemyTeam); $targets[] = array_shift($this->enemyTeam); } break; case self::TARGET_RANDOM_FRIENDS: for ($i = 1; $i <= count($this->friendTeam); $i++) { if ($i > 1 && mt_rand(1,2) === 1) { continue; } shuffle($this->friendTeam); $targets[] = array_shift($this->friendTeam); } break; case self::TARGET_RANDOMS: for ($i = 1; $i <= count($allExceptCaster); $i++) { if ($i > 1 && mt_rand(1,2) === 1) { continue; } shuffle($allExceptCaster); $targets[] = array_shift($allExceptCaster); } break; case self::TARGET_ALL_ENEMIES: $targets = $this->enemyTeam; break; case self::TARGET_ALL_FRIENDS: $targets = $this->friendTeam; break; case self::TARGET_ALL: $targets = $allExceptCaster; $targets[] = $this->caster; break; } return $targets; } /** * Возвращает иконку приёма. В текущей реализации у каждого приёма должна быть иконка. * @return string */ abstract public function getIcon(): string; }