|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Battle\Party; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\Common\Collections\Collection; |
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
10
|
|
|
|
|
11
|
|
|
class AttackedBattleParty extends AbstractBattleParty |
|
12
|
|
|
{ |
|
13
|
9 |
|
#[Override] |
|
14
|
|
|
protected function initMembers(): Collection |
|
15
|
|
|
{ |
|
16
|
9 |
|
$fleetWrapper = $this->leader->getFleetWrapper(); |
|
17
|
|
|
|
|
18
|
9 |
|
if ($fleetWrapper !== null) { |
|
19
|
|
|
|
|
20
|
|
|
// only uncloaked defenders fight |
|
21
|
3 |
|
$uncloakedDefenders = $fleetWrapper->getShipWrappers() |
|
22
|
3 |
|
->filter(fn(SpacecraftWrapperInterface $wrapper): bool => !$wrapper->get()->isCloaked()) |
|
23
|
3 |
|
->toArray(); |
|
24
|
|
|
|
|
25
|
3 |
|
$allDefenders = $this->addDockedTo($uncloakedDefenders); |
|
26
|
|
|
|
|
27
|
|
|
// if all defenders were cloaked, they obviously were scanned and enter the fight as a whole fleet |
|
28
|
3 |
|
return $allDefenders->isEmpty() |
|
29
|
1 |
|
? $fleetWrapper->getShipWrappers() |
|
30
|
3 |
|
: $allDefenders; |
|
31
|
|
|
} else { |
|
32
|
|
|
|
|
33
|
6 |
|
return $this->addDockedTo([$this->leader->get()->getId() => $this->leader]); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param array<int, covariant SpacecraftWrapperInterface> $spacecrafts |
|
|
|
|
|
|
39
|
|
|
* |
|
40
|
|
|
* @return Collection<int, SpacecraftWrapperInterface> |
|
41
|
|
|
*/ |
|
42
|
9 |
|
private function addDockedTo(array $spacecrafts): Collection |
|
43
|
|
|
{ |
|
44
|
9 |
|
$dockedToWrappers = []; |
|
45
|
|
|
|
|
46
|
9 |
|
foreach ($spacecrafts as $wrapper) { |
|
47
|
8 |
|
$dockedToWrapper = $wrapper instanceof ShipWrapperInterface ? $wrapper->getDockedToStationWrapper() : null; |
|
48
|
|
|
if ( |
|
49
|
8 |
|
$dockedToWrapper === null |
|
50
|
8 |
|
|| $dockedToWrapper->get()->getUser()->isNpc() |
|
51
|
|
|
) { |
|
52
|
6 |
|
continue; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
3 |
|
$dockedToWrappers[$dockedToWrapper->get()->getId()] = $dockedToWrapper; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
9 |
|
return new ArrayCollection($spacecrafts + $dockedToWrappers); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths