|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Spacecraft\Repair\RepairUtilInterface; |
|
9
|
|
|
use Stu\Component\Spacecraft\SpacecraftAlertStateEnum; |
|
10
|
|
|
use Stu\Component\Spacecraft\System\Data\AstroLaboratorySystemData; |
|
11
|
|
|
use Stu\Component\Spacecraft\System\Data\BussardCollectorSystemData; |
|
12
|
|
|
use Stu\Component\Spacecraft\System\Data\TrackerSystemData; |
|
13
|
|
|
use Stu\Component\Spacecraft\System\Data\WebEmitterSystemData; |
|
14
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemManagerInterface; |
|
15
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
16
|
|
|
use Stu\Component\Spacecraft\System\SystemDataDeserializerInterface; |
|
17
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
|
18
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
19
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftStateChangerInterface; |
|
20
|
|
|
use Stu\Module\Spacecraft\Lib\Ui\StateIconAndTitle; |
|
21
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapper; |
|
22
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface; |
|
23
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
24
|
|
|
use Stu\Module\Station\Lib\StationWrapperInterface; |
|
25
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
26
|
|
|
use Stu\Orm\Repository\TorpedoTypeRepositoryInterface; |
|
27
|
|
|
|
|
28
|
|
|
//TODO increase coverage |
|
29
|
|
|
/** |
|
30
|
|
|
* @extends SpacecraftWrapper<ShipInterface> |
|
31
|
|
|
*/ |
|
32
|
|
|
final class ShipWrapper extends SpacecraftWrapper implements ShipWrapperInterface |
|
33
|
|
|
{ |
|
34
|
49 |
|
public function __construct( |
|
35
|
|
|
ShipInterface $ship, |
|
36
|
|
|
SpacecraftSystemManagerInterface $spacecraftSystemManager, |
|
37
|
|
|
SystemDataDeserializerInterface $systemDataDeserializer, |
|
38
|
|
|
TorpedoTypeRepositoryInterface $torpedoTypeRepository, |
|
39
|
|
|
GameControllerInterface $game, |
|
40
|
|
|
SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory, |
|
41
|
|
|
SpacecraftStateChangerInterface $spacecraftStateChanger, |
|
42
|
|
|
RepairUtilInterface $repairUtil, |
|
43
|
|
|
StateIconAndTitle $stateIconAndTitle, |
|
44
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory |
|
45
|
|
|
) { |
|
46
|
49 |
|
parent::__construct( |
|
47
|
49 |
|
$ship, |
|
48
|
49 |
|
$spacecraftSystemManager, |
|
49
|
49 |
|
$systemDataDeserializer, |
|
50
|
49 |
|
$torpedoTypeRepository, |
|
51
|
49 |
|
$game, |
|
52
|
49 |
|
$spacecraftWrapperFactory, |
|
53
|
49 |
|
$spacecraftStateChanger, |
|
54
|
49 |
|
$repairUtil, |
|
55
|
49 |
|
$stateIconAndTitle |
|
56
|
49 |
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
42 |
|
public function get(): ShipInterface |
|
60
|
|
|
{ |
|
61
|
42 |
|
return $this->spacecraft; |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
#[Override] |
|
65
|
|
|
public function getFleetWrapper(): ?FleetWrapperInterface |
|
66
|
|
|
{ |
|
67
|
|
|
$fleet = $this->get()->getFleet(); |
|
68
|
|
|
if ($fleet === null) { |
|
69
|
|
|
return null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return $this->spacecraftWrapperFactory->wrapFleet($fleet); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
7 |
|
#[Override] |
|
76
|
|
|
public function canLandOnCurrentColony(): bool |
|
77
|
|
|
{ |
|
78
|
7 |
|
if ($this->spacecraft->getRump()->getCommodity() === null) { |
|
79
|
1 |
|
return false; |
|
80
|
|
|
} |
|
81
|
6 |
|
if ($this->spacecraft->isShuttle()) { |
|
82
|
1 |
|
return false; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
5 |
|
$currentColony = $this->spacecraft->getStarsystemMap() !== null ? $this->spacecraft->getStarsystemMap()->getColony() : null; |
|
86
|
|
|
|
|
87
|
5 |
|
if ($currentColony === null) { |
|
88
|
2 |
|
return false; |
|
89
|
|
|
} |
|
90
|
3 |
|
if ($currentColony->getUser() !== $this->spacecraft->getUser()) { |
|
91
|
1 |
|
return false; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
2 |
|
return $this->colonyLibFactory |
|
95
|
2 |
|
->createColonySurface($currentColony) |
|
96
|
2 |
|
->hasAirfield(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
#[Override] |
|
100
|
|
|
public function canBeRetrofitted(): bool |
|
101
|
|
|
{ |
|
102
|
|
|
if ($this->spacecraft->getAlertState() !== SpacecraftAlertStateEnum::ALERT_GREEN) { |
|
103
|
|
|
return false; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
if ($this->spacecraft->getFleet()) { |
|
107
|
|
|
return false; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
if ($this->spacecraft->getShieldState()) { |
|
111
|
|
|
return false; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
if ($this->spacecraft->getCloakState()) { |
|
115
|
|
|
return false; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
if ($this->spacecraft->getUser() != $this->game->getUser()) { |
|
119
|
|
|
return false; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
if ( |
|
123
|
|
|
$this->spacecraft->getBuildplan() != null |
|
124
|
|
|
&& $this->spacecraft->getBuildplan()->getUser() != $this->game->getUser() |
|
125
|
|
|
) { |
|
126
|
|
|
return false; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
return true; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
#[Override] |
|
133
|
|
|
public function getTractoringSpacecraftWrapper(): ?SpacecraftWrapperInterface |
|
134
|
|
|
{ |
|
135
|
|
|
$tractoringSpacecraft = $this->spacecraft->getTractoringSpacecraft(); |
|
|
|
|
|
|
136
|
|
|
if ($tractoringSpacecraft === null) { |
|
137
|
|
|
return null; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
return $this->spacecraftWrapperFactory->wrapSpacecraft($tractoringSpacecraft); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
#[Override] |
|
144
|
|
|
public function getDockedToStationWrapper(): ?StationWrapperInterface |
|
145
|
|
|
{ |
|
146
|
|
|
$dockedTo = $this->spacecraft->getDockedTo(); |
|
|
|
|
|
|
147
|
|
|
if ($dockedTo === null) { |
|
148
|
|
|
return null; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
return $this->spacecraftWrapperFactory->wrapStation($dockedTo); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
1 |
|
#[Override] |
|
155
|
|
|
public function getTrackerSystemData(): ?TrackerSystemData |
|
156
|
|
|
{ |
|
157
|
1 |
|
return $this->getSpecificShipSystem( |
|
158
|
1 |
|
SpacecraftSystemTypeEnum::TRACKER, |
|
159
|
1 |
|
TrackerSystemData::class |
|
160
|
1 |
|
); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
1 |
|
#[Override] |
|
164
|
|
|
public function getBussardCollectorSystemData(): ?BussardCollectorSystemData |
|
165
|
|
|
{ |
|
166
|
1 |
|
return $this->getSpecificShipSystem( |
|
167
|
1 |
|
SpacecraftSystemTypeEnum::BUSSARD_COLLECTOR, |
|
168
|
1 |
|
BussardCollectorSystemData::class |
|
169
|
1 |
|
); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
1 |
|
#[Override] |
|
173
|
|
|
public function getWebEmitterSystemData(): ?WebEmitterSystemData |
|
174
|
|
|
{ |
|
175
|
1 |
|
return $this->getSpecificShipSystem( |
|
176
|
1 |
|
SpacecraftSystemTypeEnum::THOLIAN_WEB, |
|
177
|
1 |
|
WebEmitterSystemData::class |
|
178
|
1 |
|
); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
3 |
|
#[Override] |
|
182
|
|
|
public function getAstroLaboratorySystemData(): ?AstroLaboratorySystemData |
|
183
|
|
|
{ |
|
184
|
3 |
|
return $this->getSpecificShipSystem( |
|
185
|
3 |
|
SpacecraftSystemTypeEnum::ASTRO_LABORATORY, |
|
186
|
3 |
|
AstroLaboratorySystemData::class |
|
187
|
3 |
|
); |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
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