|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Component\Spacecraft\Nbs; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Lib\SessionInterface; |
|
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
10
|
|
|
use Stu\Module\Ship\Lib\Fleet\FleetNfsIterator; |
|
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftNfsIterator; |
|
12
|
|
|
use Stu\Orm\Entity\MapInterface; |
|
13
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
14
|
|
|
use Stu\Orm\Entity\StarSystemMapInterface; |
|
15
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
|
16
|
|
|
use Stu\Orm\Repository\SpacecraftRepositoryInterface; |
|
17
|
|
|
use Stu\Orm\Repository\StationRepositoryInterface; |
|
18
|
|
|
use Stu\Orm\Repository\TachyonScanRepositoryInterface; |
|
19
|
|
|
|
|
20
|
|
|
final class NbsUtility implements NbsUtilityInterface |
|
21
|
|
|
{ |
|
22
|
1 |
|
public function __construct( |
|
23
|
|
|
private TachyonScanRepositoryInterface $tachyonScanRepository, |
|
24
|
|
|
private SpacecraftRepositoryInterface $spacecraftRepository, |
|
25
|
|
|
private ShipRepositoryInterface $shipRepository, |
|
26
|
|
|
private StationRepositoryInterface $stationRepository |
|
27
|
1 |
|
) {} |
|
28
|
|
|
|
|
29
|
2 |
|
#[Override] |
|
30
|
|
|
public function isTachyonActive(SpacecraftInterface $spacecraft): bool |
|
31
|
|
|
{ |
|
32
|
2 |
|
return $this->tachyonScanRepository->isTachyonScanActiveByShipLocationAndOwner($spacecraft); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
2 |
|
#[Override] |
|
36
|
|
|
public function setNbsTemplateVars( |
|
37
|
|
|
SpacecraftInterface $spacecraft, |
|
38
|
|
|
GameControllerInterface $game, |
|
39
|
|
|
?SessionInterface $session, |
|
40
|
|
|
bool $tachyonActive, |
|
41
|
|
|
MapInterface|StarSystemMapInterface|null $field = null |
|
42
|
|
|
): void { |
|
43
|
2 |
|
if ($spacecraft->getNbs() || $field !== null) { |
|
44
|
1 |
|
$stationNbs = new SpacecraftNfsIterator($this->stationRepository->getStationScannerResults( |
|
45
|
1 |
|
$spacecraft, |
|
46
|
1 |
|
$tachyonActive, |
|
47
|
1 |
|
$field |
|
48
|
1 |
|
), $game->getUser()->getId()); |
|
49
|
|
|
|
|
50
|
1 |
|
$singleSpacecraftsNbs = new SpacecraftNfsIterator($this->spacecraftRepository->getSingleSpacecraftScannerResults( |
|
51
|
1 |
|
$spacecraft, |
|
52
|
1 |
|
$tachyonActive, |
|
53
|
1 |
|
$field |
|
54
|
1 |
|
), $game->getUser()->getId()); |
|
55
|
|
|
|
|
56
|
1 |
|
$fleetNbs = new FleetNfsIterator( |
|
57
|
1 |
|
$this->shipRepository->getFleetShipsScannerResults( |
|
58
|
1 |
|
$spacecraft, |
|
59
|
1 |
|
$tachyonActive, |
|
60
|
1 |
|
$field |
|
61
|
1 |
|
), |
|
62
|
1 |
|
$spacecraft, |
|
63
|
1 |
|
$session, |
|
64
|
1 |
|
$game->getUser()->getId() |
|
65
|
1 |
|
); |
|
66
|
|
|
|
|
67
|
1 |
|
$trumfieldNbs = $field !== null |
|
68
|
|
|
? $field->getTrumfields()->toArray() |
|
69
|
1 |
|
: $spacecraft->getLocation()->getTrumfields()->toArray(); |
|
70
|
|
|
|
|
71
|
1 |
|
$game->setTemplateVar( |
|
72
|
1 |
|
'HAS_NBS', |
|
73
|
1 |
|
$fleetNbs->count() > 0 || $stationNbs->count() > 0 || $singleSpacecraftsNbs->count() > 0 || count($trumfieldNbs) > 0 |
|
74
|
1 |
|
); |
|
75
|
|
|
|
|
76
|
1 |
|
$game->setTemplateVar('CLOAK_NBS', $this->showCloakedShipInfo($spacecraft, $tachyonActive)); |
|
77
|
1 |
|
$game->setTemplateVar('FLEET_NBS', $fleetNbs); |
|
78
|
1 |
|
$game->setTemplateVar('STATION_NBS', $stationNbs->count() > 0 ? $stationNbs : null); |
|
79
|
1 |
|
$game->setTemplateVar('SPACECRAFT_NBS', $singleSpacecraftsNbs->count() > 0 ? $singleSpacecraftsNbs : null); |
|
80
|
1 |
|
$game->setTemplateVar('TRUMFIELD_NBS', $trumfieldNbs); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
1 |
|
private function showCloakedShipInfo(SpacecraftInterface $spacecraft, bool $tachyonActive): bool |
|
85
|
|
|
{ |
|
86
|
1 |
|
return !$tachyonActive |
|
87
|
1 |
|
&& $spacecraft->getTachyonState() |
|
88
|
1 |
|
&& $this->spacecraftRepository->isCloakedSpacecraftAtLocation($spacecraft); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
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