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