1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\Common\Collections\Collection; |
9
|
|
|
use Doctrine\ORM\Mapping\Column; |
10
|
|
|
use Doctrine\ORM\Mapping\Entity; |
11
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
12
|
|
|
use Doctrine\ORM\Mapping\Id; |
13
|
|
|
use Doctrine\ORM\Mapping\Index; |
14
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
15
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
16
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
17
|
|
|
use Doctrine\ORM\Mapping\OneToOne; |
18
|
|
|
use Doctrine\ORM\Mapping\OrderBy; |
19
|
|
|
use Doctrine\ORM\Mapping\Table; |
20
|
|
|
use Override; |
|
|
|
|
21
|
|
|
use RuntimeException; |
22
|
|
|
use Stu\Component\Game\TimeConstants; |
|
|
|
|
23
|
|
|
use Stu\Component\Ship\ShipAlertStateEnum; |
24
|
|
|
use Stu\Component\Ship\ShipLSSModeEnum; |
|
|
|
|
25
|
|
|
use Stu\Component\Ship\ShipModuleTypeEnum; |
26
|
|
|
use Stu\Component\Ship\ShipRumpEnum; |
|
|
|
|
27
|
|
|
use Stu\Component\Ship\ShipStateEnum; |
28
|
|
|
use Stu\Component\Ship\SpacecraftTypeEnum; |
29
|
|
|
use Stu\Component\Ship\System\ShipSystemModeEnum; |
|
|
|
|
30
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
31
|
|
|
use Stu\Component\Ship\System\Type\TorpedoStorageShipSystem; |
|
|
|
|
32
|
|
|
use Stu\Component\Ship\System\Type\TractorBeamShipSystem; |
33
|
|
|
use Stu\Component\Station\StationUtility; |
34
|
|
|
use Stu\Module\Control\GameControllerInterface; |
35
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
36
|
|
|
use Stu\Module\Ship\Lib\Battle\FightLib; |
37
|
|
|
use Stu\Orm\Repository\ShipRepository; |
38
|
|
|
|
39
|
|
|
#[Table(name: 'stu_ships')] |
40
|
|
|
#[Index(name: 'ship_fleet_idx', columns: ['fleets_id'])] |
41
|
|
|
#[Index(name: 'ship_location_idx', columns: ['location_id'])] |
42
|
|
|
#[Index(name: 'ship_rump_idx', columns: ['rumps_id'])] |
43
|
|
|
#[Index(name: 'ship_web_idx', columns: ['holding_web_id'])] |
44
|
|
|
#[Index(name: 'ship_user_idx', columns: ['user_id'])] |
45
|
|
|
#[Index(name: 'ship_tractored_idx', columns: ['tractored_ship_id'])] |
46
|
|
|
#[Index(name: 'ship_influence_area_idx', columns: ['influence_area_id'])] |
47
|
|
|
#[Entity(repositoryClass: ShipRepository::class)] |
48
|
|
|
class Ship implements ShipInterface |
49
|
|
|
{ |
50
|
|
|
#[Id] |
51
|
|
|
#[Column(type: 'integer')] |
52
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
53
|
|
|
private ?int $id = null; |
54
|
|
|
|
55
|
|
|
#[Column(type: 'integer')] |
56
|
|
|
private int $user_id = 0; |
57
|
|
|
|
58
|
|
|
#[Column(type: 'integer')] |
59
|
|
|
private int $rumps_id = 0; |
|
|
|
|
60
|
|
|
|
61
|
|
|
#[Column(type: 'integer', nullable: true)] |
62
|
|
|
private ?int $plans_id = null; |
|
|
|
|
63
|
|
|
|
64
|
|
|
#[Column(type: 'integer', nullable: true)] |
65
|
|
|
private ?int $fleets_id = null; |
66
|
|
|
|
67
|
|
|
#[Column(type: 'smallint', length: 1)] |
68
|
|
|
private int $direction = 0; |
69
|
|
|
|
70
|
|
|
#[Column(type: 'string')] |
71
|
|
|
private string $name = ''; |
72
|
|
|
|
73
|
|
|
#[Column(type: 'smallint', length: 1, enumType: ShipAlertStateEnum::class)] |
74
|
|
|
private ShipAlertStateEnum $alvl = ShipAlertStateEnum::ALERT_GREEN; |
75
|
|
|
|
76
|
|
|
#[Column(type: 'smallint', length: 1)] |
77
|
|
|
private int $lss_mode = ShipLSSModeEnum::LSS_NORMAL; |
78
|
|
|
|
79
|
|
|
#[Column(type: 'integer', length: 6)] |
80
|
|
|
private int $huelle = 0; |
81
|
|
|
|
82
|
|
|
#[Column(type: 'integer', length: 6)] |
83
|
|
|
private int $max_huelle = 0; |
84
|
|
|
|
85
|
|
|
#[Column(type: 'integer', length: 6)] |
86
|
|
|
private int $schilde = 0; |
87
|
|
|
|
88
|
|
|
#[Column(type: 'integer', length: 6)] |
89
|
|
|
private int $max_schilde = 0; |
90
|
|
|
|
91
|
|
|
#[Column(type: 'integer', nullable: true)] |
92
|
|
|
private ?int $tractored_ship_id = null; |
93
|
|
|
|
94
|
|
|
#[Column(type: 'integer', nullable: true)] |
95
|
|
|
private ?int $holding_web_id = null; |
96
|
|
|
|
97
|
|
|
#[Column(type: 'integer', nullable: true)] |
98
|
|
|
private ?int $dock = null; |
99
|
|
|
|
100
|
|
|
#[Column(type: 'integer')] |
101
|
|
|
private int $former_rumps_id = 0; |
102
|
|
|
|
103
|
|
|
#[Column(type: 'smallint', length: 1, enumType: SpacecraftTypeEnum::class)] |
104
|
|
|
private SpacecraftTypeEnum $type = SpacecraftTypeEnum::SPACECRAFT_TYPE_SHIP; |
105
|
|
|
|
106
|
|
|
#[Column(type: 'integer', nullable: true)] |
107
|
|
|
private ?int $database_id = null; |
108
|
|
|
|
109
|
|
|
#[Column(type: 'boolean')] |
110
|
|
|
private bool $is_destroyed = false; |
111
|
|
|
|
112
|
|
|
#[Column(type: 'boolean')] |
113
|
|
|
private bool $disabled = false; |
114
|
|
|
|
115
|
|
|
#[Column(type: 'smallint', length: 3)] |
116
|
|
|
private int $hit_chance = 0; |
117
|
|
|
|
118
|
|
|
#[Column(type: 'smallint', length: 3)] |
119
|
|
|
private int $evade_chance = 0; |
120
|
|
|
|
121
|
|
|
#[Column(type: 'smallint', length: 4)] |
122
|
|
|
private int $base_damage = 0; |
123
|
|
|
|
124
|
|
|
#[Column(type: 'smallint', length: 3)] |
125
|
|
|
private int $sensor_range = 0; |
126
|
|
|
|
127
|
|
|
#[Column(type: 'integer')] |
128
|
|
|
private int $shield_regeneration_timer = 0; |
129
|
|
|
|
130
|
|
|
#[Column(type: 'smallint', enumType: ShipStateEnum::class)] |
131
|
|
|
private ShipStateEnum $state = ShipStateEnum::SHIP_STATE_NONE; |
132
|
|
|
|
133
|
|
|
#[Column(type: 'boolean')] |
134
|
|
|
private bool $is_fleet_leader = false; |
135
|
|
|
|
136
|
|
|
#[Column(type: 'integer')] |
137
|
|
|
private int $location_id = 0; |
|
|
|
|
138
|
|
|
|
139
|
|
|
#[Column(type: 'integer', nullable: true)] |
140
|
|
|
private ?int $influence_area_id = null; |
|
|
|
|
141
|
|
|
|
142
|
|
|
#[Column(type: 'boolean')] |
143
|
|
|
private bool $in_emergency = false; |
144
|
|
|
|
145
|
|
|
#[ManyToOne(targetEntity: 'Fleet', inversedBy: 'ships')] |
146
|
|
|
#[JoinColumn(name: 'fleets_id', referencedColumnName: 'id')] |
147
|
|
|
private ?FleetInterface $fleet = null; |
148
|
|
|
|
149
|
|
|
#[OneToOne(targetEntity: 'TradePost', mappedBy: 'ship')] |
150
|
|
|
private ?TradePostInterface $tradePost = null; |
151
|
|
|
|
152
|
|
|
#[ManyToOne(targetEntity: 'Ship', inversedBy: 'dockedShips')] |
153
|
|
|
#[JoinColumn(name: 'dock', referencedColumnName: 'id')] |
154
|
|
|
private ?ShipInterface $dockedTo = null; |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @var ArrayCollection<int, ShipInterface> |
158
|
|
|
*/ |
159
|
|
|
#[OneToMany(targetEntity: 'Ship', mappedBy: 'dockedTo', indexBy: 'id')] |
160
|
|
|
#[OrderBy(['fleets_id' => 'DESC', 'is_fleet_leader' => 'DESC'])] |
161
|
|
|
private Collection $dockedShips; |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @var ArrayCollection<int, DockingPrivilegeInterface> |
165
|
|
|
*/ |
166
|
|
|
#[OneToMany(targetEntity: 'DockingPrivilege', mappedBy: 'ship')] |
167
|
|
|
private Collection $dockingPrivileges; |
168
|
|
|
|
169
|
|
|
#[OneToOne(targetEntity: 'Ship')] |
170
|
|
|
#[JoinColumn(name: 'tractored_ship_id', referencedColumnName: 'id')] |
171
|
|
|
private ?ShipInterface $tractoredShip = null; |
172
|
|
|
|
173
|
|
|
#[OneToOne(targetEntity: 'Ship', mappedBy: 'tractoredShip')] |
174
|
|
|
private ?ShipInterface $tractoringShip = null; |
175
|
|
|
|
176
|
|
|
#[ManyToOne(targetEntity: 'TholianWeb')] |
177
|
|
|
#[JoinColumn(name: 'holding_web_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
178
|
|
|
private ?TholianWebInterface $holdingWeb = null; |
179
|
|
|
|
180
|
|
|
#[ManyToOne(targetEntity: 'User')] |
181
|
|
|
#[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
182
|
|
|
private UserInterface $user; |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @var ArrayCollection<int, ShipCrewInterface> |
186
|
|
|
*/ |
187
|
|
|
#[OneToMany(targetEntity: 'ShipCrew', mappedBy: 'ship', indexBy: 'id')] |
188
|
|
|
#[OrderBy(['id' => 'ASC'])] |
189
|
|
|
private Collection $crew; |
190
|
|
|
|
191
|
|
|
#[OneToOne(targetEntity: 'TorpedoStorage', mappedBy: 'ship')] |
192
|
|
|
private ?TorpedoStorageInterface $torpedoStorage = null; |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @var DatabaseEntryInterface|null |
196
|
|
|
*/ |
197
|
|
|
#[OneToOne(targetEntity: 'DatabaseEntry')] |
198
|
|
|
#[JoinColumn(name: 'database_id', referencedColumnName: 'id')] |
199
|
|
|
private ?DatabaseEntryInterface $databaseEntry; |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @var ArrayCollection<int, ShipSystemInterface> |
203
|
|
|
*/ |
204
|
|
|
#[OneToMany(targetEntity: 'ShipSystem', mappedBy: 'ship', indexBy: 'system_type')] |
205
|
|
|
#[OrderBy(['system_type' => 'ASC'])] |
206
|
|
|
private Collection $systems; |
207
|
|
|
|
208
|
|
|
#[ManyToOne(targetEntity: 'ShipRump')] |
209
|
|
|
#[JoinColumn(name: 'rumps_id', referencedColumnName: 'id')] |
210
|
|
|
private ShipRumpInterface $rump; |
211
|
|
|
|
212
|
|
|
#[ManyToOne(targetEntity: 'ShipBuildplan')] |
213
|
|
|
#[JoinColumn(name: 'plans_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
214
|
|
|
private ?ShipBuildplanInterface $buildplan = null; |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @var ArrayCollection<int, StorageInterface> |
218
|
|
|
*/ |
219
|
|
|
#[OneToMany(targetEntity: 'Storage', mappedBy: 'ship', indexBy: 'commodity_id')] |
220
|
|
|
#[OrderBy(['commodity_id' => 'ASC'])] |
221
|
|
|
private Collection $storage; |
222
|
|
|
|
223
|
|
|
#[ManyToOne(targetEntity: 'Location')] |
224
|
|
|
#[JoinColumn(name: 'location_id', referencedColumnName: 'id')] |
225
|
|
|
private LocationInterface $location; |
226
|
|
|
|
227
|
|
|
#[ManyToOne(targetEntity: 'StarSystem')] |
228
|
|
|
#[JoinColumn(name: 'influence_area_id', referencedColumnName: 'id')] |
229
|
|
|
private ?StarSystemInterface $influenceArea = null; |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @var ArrayCollection<int, ShipLogInterface> |
233
|
|
|
*/ |
234
|
|
|
#[OneToMany(targetEntity: 'ShipLog', mappedBy: 'ship', fetch: 'EXTRA_LAZY')] |
235
|
|
|
#[OrderBy(['id' => 'DESC'])] |
236
|
|
|
private Collection $logbook; |
237
|
|
|
|
238
|
|
|
#[OneToOne(targetEntity: 'ShipTakeover', mappedBy: 'source')] |
239
|
|
|
private ?ShipTakeoverInterface $takeoverActive = null; |
240
|
|
|
|
241
|
|
|
#[OneToOne(targetEntity: 'ShipTakeover', mappedBy: 'target')] |
242
|
|
|
private ?ShipTakeoverInterface $takeoverPassive = null; |
243
|
|
|
|
244
|
3 |
|
public function __construct() |
245
|
|
|
{ |
246
|
3 |
|
$this->dockedShips = new ArrayCollection(); |
247
|
3 |
|
$this->dockingPrivileges = new ArrayCollection(); |
248
|
3 |
|
$this->crew = new ArrayCollection(); |
249
|
3 |
|
$this->systems = new ArrayCollection(); |
250
|
3 |
|
$this->storage = new ArrayCollection(); |
251
|
3 |
|
$this->logbook = new ArrayCollection(); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
#[Override] |
255
|
|
|
public function getId(): int |
256
|
|
|
{ |
257
|
|
|
if ($this->id === null) { |
258
|
|
|
throw new RuntimeException('entity not yet persisted'); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
return $this->id; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
#[Override] |
265
|
|
|
public function getUserId(): int |
266
|
|
|
{ |
267
|
|
|
return $this->user_id; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
#[Override] |
271
|
|
|
public function getUserName(): string |
272
|
|
|
{ |
273
|
|
|
return $this->getUser()->getName(); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
#[Override] |
277
|
|
|
public function getFleetId(): ?int |
278
|
|
|
{ |
279
|
|
|
return $this->fleets_id; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
#[Override] |
283
|
|
|
public function setFleetId(?int $fleetId): ShipInterface |
284
|
|
|
{ |
285
|
|
|
$this->fleets_id = $fleetId; |
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
#[Override] |
290
|
|
|
public function getSystemsId(): ?int |
291
|
|
|
{ |
292
|
|
|
return $this->getSystem() !== null ? $this->getSystem()->getId() : null; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
#[Override] |
296
|
|
|
public function getLayer(): ?LayerInterface |
297
|
|
|
{ |
298
|
|
|
return $this->getLocation()->getLayer(); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
#[Override] |
302
|
|
|
public function getSx(): int |
303
|
|
|
{ |
304
|
|
|
return $this->getStarsystemMap()->getSx(); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
#[Override] |
308
|
|
|
public function getSy(): int |
309
|
|
|
{ |
310
|
|
|
return $this->getStarsystemMap()->getSy(); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
#[Override] |
314
|
|
|
public function getFlightDirection(): int |
315
|
|
|
{ |
316
|
|
|
return $this->direction; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
#[Override] |
320
|
|
|
public function setFlightDirection(int $direction): ShipInterface |
321
|
|
|
{ |
322
|
|
|
$this->direction = $direction; |
323
|
|
|
return $this; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
#[Override] |
327
|
|
|
public function getName(): string |
328
|
|
|
{ |
329
|
|
|
return $this->name; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
#[Override] |
333
|
|
|
public function setName(string $name): ShipInterface |
334
|
|
|
{ |
335
|
|
|
$this->name = $name; |
336
|
|
|
return $this; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
#[Override] |
340
|
|
|
public function getLSSmode(): int |
341
|
|
|
{ |
342
|
|
|
return $this->lss_mode; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
public function isLSSModeNormal(): bool |
346
|
|
|
{ |
347
|
|
|
return $this->getLSSMode() === ShipLSSModeEnum::LSS_NORMAL; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
public function isLSSModeBorder(): bool |
351
|
|
|
{ |
352
|
|
|
return $this->getLSSMode() === ShipLSSModeEnum::LSS_BORDER; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
#[Override] |
356
|
|
|
public function setLSSMode(int $lssMode): ShipInterface |
357
|
|
|
{ |
358
|
|
|
$this->lss_mode = $lssMode; |
359
|
|
|
return $this; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
#[Override] |
363
|
|
|
public function getAlertState(): ShipAlertStateEnum |
364
|
|
|
{ |
365
|
|
|
return $this->alvl; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
#[Override] |
369
|
|
|
public function setAlertState(ShipAlertStateEnum $state): ShipInterface |
370
|
|
|
{ |
371
|
|
|
$this->alvl = $state; |
372
|
|
|
return $this; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
#[Override] |
376
|
|
|
public function setAlertStateGreen(): ShipInterface |
377
|
|
|
{ |
378
|
|
|
return $this->setAlertState(ShipAlertStateEnum::ALERT_GREEN); |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
#[Override] |
382
|
|
|
public function isSystemHealthy(ShipSystemTypeEnum $type): bool |
383
|
|
|
{ |
384
|
|
|
if (!$this->hasShipSystem($type)) { |
385
|
|
|
return false; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
return $this->getShipSystem($type)->getStatus() > 0; |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
#[Override] |
392
|
|
|
public function getSystemState(ShipSystemTypeEnum $type): bool |
393
|
|
|
{ |
394
|
|
|
if (!$this->hasShipSystem($type)) { |
395
|
|
|
return false; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
return $this->getShipSystem($type)->getMode() === ShipSystemModeEnum::MODE_ON |
399
|
|
|
|| $this->getShipSystem($type)->getMode() === ShipSystemModeEnum::MODE_ALWAYS_ON; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
#[Override] |
403
|
|
|
public function getImpulseState(): bool |
404
|
|
|
{ |
405
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
#[Override] |
409
|
|
|
public function getWarpDriveState(): bool |
410
|
|
|
{ |
411
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_WARPDRIVE); |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
#[Override] |
415
|
|
|
public function isWarped(): bool |
416
|
|
|
{ |
417
|
|
|
$tractoringShip = $this->getTractoringShip(); |
418
|
|
|
|
419
|
|
|
if ($tractoringShip !== null) { |
420
|
|
|
return $tractoringShip->getWarpDriveState(); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
return $this->getWarpDriveState(); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
#[Override] |
427
|
|
|
public function getWebState(): bool |
428
|
|
|
{ |
429
|
|
|
return $this->getHoldingWeb() !== null; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
#[Override] |
433
|
|
|
public function getCloakState(): bool |
434
|
|
|
{ |
435
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_CLOAK); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
#[Override] |
439
|
|
|
public function getTachyonState(): bool |
440
|
|
|
{ |
441
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_TACHYON_SCANNER); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
#[Override] |
445
|
|
|
public function getSubspaceState(): bool |
446
|
|
|
{ |
447
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_SUBSPACE_SCANNER); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
#[Override] |
451
|
|
|
public function getAstroState(): bool |
452
|
|
|
{ |
453
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_ASTRO_LABORATORY); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
#[Override] |
457
|
|
|
public function getRPGModuleState(): bool |
458
|
|
|
{ |
459
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_RPG_MODULE); |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
#[Override] |
463
|
|
|
public function getConstructionHubState(): bool |
464
|
|
|
{ |
465
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_CONSTRUCTION_HUB); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
#[Override] |
469
|
|
|
public function getHull(): int |
470
|
|
|
{ |
471
|
|
|
return $this->huelle; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
#[Override] |
475
|
|
|
public function setHuell(int $hull): ShipInterface |
476
|
|
|
{ |
477
|
|
|
$this->huelle = $hull; |
478
|
|
|
return $this; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
#[Override] |
482
|
|
|
public function getMaxHull(): int |
483
|
|
|
{ |
484
|
|
|
return $this->max_huelle; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
#[Override] |
488
|
|
|
public function setMaxHuell(int $maxHull): ShipInterface |
489
|
|
|
{ |
490
|
|
|
$this->max_huelle = $maxHull; |
491
|
|
|
return $this; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
#[Override] |
495
|
|
|
public function getShield(): int |
496
|
|
|
{ |
497
|
|
|
return $this->schilde; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
#[Override] |
501
|
|
|
public function setShield(int $schilde): ShipInterface |
502
|
|
|
{ |
503
|
|
|
$this->schilde = $schilde; |
504
|
|
|
return $this; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* proportional to shield system status |
509
|
|
|
*/ |
510
|
|
|
#[Override] |
511
|
|
|
public function getMaxShield(bool $isTheoretical = false): int |
512
|
|
|
{ |
513
|
|
|
if ($isTheoretical || !$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_SHIELDS)) { |
514
|
|
|
return $this->max_schilde; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
return (int) (ceil($this->max_schilde |
518
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_SHIELDS)->getStatus() / 100)); |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
#[Override] |
522
|
|
|
public function setMaxShield(int $maxShields): ShipInterface |
523
|
|
|
{ |
524
|
|
|
$this->max_schilde = $maxShields; |
525
|
|
|
return $this; |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
#[Override] |
529
|
|
|
public function getHealthPercentage(): float |
530
|
|
|
{ |
531
|
|
|
return ($this->getHull() + $this->getShield()) |
532
|
|
|
/ ($this->getMaxHull() + $this->getMaxShield(true)) * 100; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
#[Override] |
536
|
|
|
public function getShieldState(): bool |
537
|
|
|
{ |
538
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_SHIELDS); |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
#[Override] |
542
|
|
|
public function getNbs(): bool |
543
|
|
|
{ |
544
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_NBS); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
#[Override] |
548
|
|
|
public function getLss(): bool |
549
|
|
|
{ |
550
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_LSS); |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
#[Override] |
554
|
|
|
public function getPhaserState(): bool |
555
|
|
|
{ |
556
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_PHASER); |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
#[Override] |
560
|
|
|
public function isAlertGreen(): bool |
561
|
|
|
{ |
562
|
|
|
return $this->getAlertState() === ShipAlertStateEnum::ALERT_GREEN; |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
#[Override] |
566
|
|
|
public function getTorpedoState(): bool |
567
|
|
|
{ |
568
|
|
|
return $this->getSystemState(ShipSystemTypeEnum::SYSTEM_TORPEDO); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
#[Override] |
572
|
|
|
public function getFormerRumpId(): int |
573
|
|
|
{ |
574
|
|
|
return $this->former_rumps_id; |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
#[Override] |
578
|
|
|
public function setFormerRumpId(int $formerShipRumpId): ShipInterface |
579
|
|
|
{ |
580
|
|
|
$this->former_rumps_id = $formerShipRumpId; |
581
|
|
|
return $this; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
#[Override] |
585
|
|
|
public function getTorpedoCount(): int |
586
|
|
|
{ |
587
|
|
|
if ($this->getTorpedoStorage() === null) { |
588
|
|
|
return 0; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
return $this->getTorpedoStorage()->getStorage()->getAmount(); |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
#[Override] |
595
|
|
|
public function isBase(): bool |
596
|
|
|
{ |
597
|
|
|
return $this->type === SpacecraftTypeEnum::SPACECRAFT_TYPE_STATION; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
#[Override] |
601
|
|
|
public function isTrumfield(): bool |
602
|
|
|
{ |
603
|
|
|
return $this->getRump()->isTrumfield(); |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
#[Override] |
607
|
|
|
public function isShuttle(): bool |
608
|
|
|
{ |
609
|
|
|
return $this->getRump()->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_SHUTTLE; |
610
|
|
|
} |
611
|
|
|
|
612
|
|
|
#[Override] |
613
|
|
|
public function isConstruction(): bool |
614
|
|
|
{ |
615
|
|
|
return $this->getRump()->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_CONSTRUCTION; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
#[Override] |
619
|
|
|
public function getSpacecraftType(): SpacecraftTypeEnum |
620
|
|
|
{ |
621
|
|
|
return $this->type; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
#[Override] |
625
|
|
|
public function setSpacecraftType(SpacecraftTypeEnum $type): ShipInterface |
626
|
|
|
{ |
627
|
|
|
$this->type = $type; |
628
|
|
|
return $this; |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
#[Override] |
632
|
|
|
public function getDatabaseId(): ?int |
633
|
|
|
{ |
634
|
|
|
return $this->database_id; |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
#[Override] |
638
|
|
|
public function setDatabaseEntry(DatabaseEntryInterface $entry): ShipInterface |
639
|
|
|
{ |
640
|
|
|
$this->databaseEntry = $entry; |
641
|
|
|
return $this; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
#[Override] |
645
|
|
|
public function isDestroyed(): bool |
646
|
|
|
{ |
647
|
|
|
return $this->is_destroyed; |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
#[Override] |
651
|
|
|
public function setIsDestroyed(bool $isDestroyed): ShipInterface |
652
|
|
|
{ |
653
|
|
|
$this->is_destroyed = $isDestroyed; |
654
|
|
|
return $this; |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
#[Override] |
658
|
|
|
public function isDisabled(): bool |
659
|
|
|
{ |
660
|
|
|
return $this->disabled; |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
#[Override] |
664
|
|
|
public function setDisabled(bool $isDisabled): ShipInterface |
665
|
|
|
{ |
666
|
|
|
$this->disabled = $isDisabled; |
667
|
|
|
return $this; |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
|
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* proportional to computer system status |
674
|
|
|
*/ |
675
|
|
|
#[Override] |
676
|
|
|
public function getHitChance(): int |
677
|
|
|
{ |
678
|
|
|
if (!$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_COMPUTER)) { |
679
|
|
|
return $this->hit_chance; |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
return (int) (ceil($this->hit_chance |
683
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_COMPUTER)->getStatus() / 100)); |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
#[Override] |
687
|
|
|
public function setHitChance(int $hitChance): ShipInterface |
688
|
|
|
{ |
689
|
|
|
$this->hit_chance = $hitChance; |
690
|
|
|
return $this; |
691
|
|
|
} |
692
|
|
|
|
693
|
|
|
/** |
694
|
|
|
* proportional to impulsedrive system status |
695
|
|
|
*/ |
696
|
|
|
#[Override] |
697
|
|
|
public function getEvadeChance(): int |
698
|
|
|
{ |
699
|
|
|
if (!$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE)) { |
700
|
|
|
return $this->evade_chance; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
return (int) (ceil($this->evade_chance |
704
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE)->getStatus() / 100)); |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
#[Override] |
708
|
|
|
public function setEvadeChance(int $evadeChance): ShipInterface |
709
|
|
|
{ |
710
|
|
|
$this->evade_chance = $evadeChance; |
711
|
|
|
return $this; |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* proportional to energy weapon system status |
716
|
|
|
*/ |
717
|
|
|
#[Override] |
718
|
|
|
public function getBaseDamage(): int |
719
|
|
|
{ |
720
|
|
|
if (!$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_PHASER)) { |
721
|
|
|
return $this->base_damage; |
722
|
|
|
} |
723
|
|
|
|
724
|
|
|
return (int) (ceil($this->base_damage |
725
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_PHASER)->getStatus() / 100)); |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
#[Override] |
729
|
|
|
public function setBaseDamage(int $baseDamage): ShipInterface |
730
|
|
|
{ |
731
|
|
|
$this->base_damage = $baseDamage; |
732
|
|
|
return $this; |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* proportional to sensor system status |
737
|
|
|
*/ |
738
|
|
|
#[Override] |
739
|
|
|
public function getSensorRange(): int |
740
|
|
|
{ |
741
|
|
|
if (!$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_LSS)) { |
742
|
|
|
return $this->sensor_range; |
743
|
|
|
} |
744
|
|
|
|
745
|
|
|
return (int) (ceil($this->sensor_range |
746
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_LSS)->getStatus() / 100)); |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
#[Override] |
750
|
|
|
public function setSensorRange(int $sensorRange): ShipInterface |
751
|
|
|
{ |
752
|
|
|
$this->sensor_range = $sensorRange; |
753
|
|
|
return $this; |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* proportional to tractor beam system status |
758
|
|
|
*/ |
759
|
|
|
#[Override] |
760
|
|
|
public function getTractorPayload(): int |
761
|
|
|
{ |
762
|
|
|
if (!$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_TRACTOR_BEAM)) { |
763
|
|
|
return 0; |
764
|
|
|
} |
765
|
|
|
|
766
|
|
|
return (int) (ceil($this->getRump()->getTractorPayload() |
767
|
|
|
* $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_TRACTOR_BEAM)->getStatus() / 100)); |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
#[Override] |
771
|
|
|
public function getShieldRegenerationTimer(): int |
772
|
|
|
{ |
773
|
|
|
return $this->shield_regeneration_timer; |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
#[Override] |
777
|
|
|
public function setShieldRegenerationTimer(int $shieldRegenerationTimer): ShipInterface |
778
|
|
|
{ |
779
|
|
|
$this->shield_regeneration_timer = $shieldRegenerationTimer; |
780
|
|
|
return $this; |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
#[Override] |
784
|
|
|
public function getState(): ShipStateEnum |
785
|
|
|
{ |
786
|
|
|
return $this->state; |
787
|
|
|
} |
788
|
|
|
|
789
|
|
|
#[Override] |
790
|
|
|
public function setState(ShipStateEnum $state): ShipInterface |
791
|
|
|
{ |
792
|
|
|
$this->state = $state; |
793
|
|
|
return $this; |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
#[Override] |
797
|
|
|
public function getIsInEmergency(): bool |
798
|
|
|
{ |
799
|
|
|
return $this->in_emergency; |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
#[Override] |
803
|
|
|
public function setIsInEmergency(bool $inEmergency): ShipInterface |
804
|
|
|
{ |
805
|
|
|
$this->in_emergency = $inEmergency; |
806
|
|
|
return $this; |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
#[Override] |
810
|
|
|
public function isUnderRepair(): bool |
811
|
|
|
{ |
812
|
|
|
return $this->getState() === ShipStateEnum::SHIP_STATE_REPAIR_ACTIVE |
813
|
|
|
|| $this->getState() === ShipStateEnum::SHIP_STATE_REPAIR_PASSIVE; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
#[Override] |
817
|
|
|
public function getIsFleetLeader(): bool |
818
|
|
|
{ |
819
|
|
|
return $this->getFleet() !== null && $this->is_fleet_leader; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
#[Override] |
823
|
|
|
public function setIsFleetLeader(bool $isFleetLeader): ShipInterface |
824
|
|
|
{ |
825
|
|
|
$this->is_fleet_leader = $isFleetLeader; |
826
|
|
|
return $this; |
827
|
|
|
} |
828
|
|
|
|
829
|
|
|
#[Override] |
830
|
|
|
public function getCrewAssignments(): Collection |
831
|
|
|
{ |
832
|
|
|
return $this->crew; |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
#[Override] |
836
|
|
|
public function getPosX(): int |
837
|
|
|
{ |
838
|
|
|
return $this->location->getX(); |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
#[Override] |
842
|
|
|
public function getPosY(): int |
843
|
|
|
{ |
844
|
|
|
return $this->location->getY(); |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
#[Override] |
848
|
|
|
public function getCrewCount(): int |
849
|
|
|
{ |
850
|
|
|
return $this->getCrewAssignments()->count(); |
851
|
|
|
} |
852
|
|
|
|
853
|
|
|
#[Override] |
854
|
|
|
public function getNeededCrewCount(): int |
855
|
|
|
{ |
856
|
|
|
$buildplan = $this->getBuildplan(); |
857
|
|
|
if ($buildplan === null) { |
858
|
|
|
return 0; |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
return $buildplan->getCrew(); |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
#[Override] |
865
|
|
|
public function getExcessCrewCount(): int |
866
|
|
|
{ |
867
|
|
|
return $this->getCrewCount() - $this->getNeededCrewCount(); |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
#[Override] |
871
|
|
|
public function hasEnoughCrew(?GameControllerInterface $game = null): bool |
872
|
|
|
{ |
873
|
|
|
$buildplan = $this->getBuildplan(); |
874
|
|
|
|
875
|
|
|
if ($buildplan === null) { |
876
|
|
|
if ($game !== null) { |
877
|
|
|
$game->addInformation(_("Keine Crew vorhanden")); |
878
|
|
|
} |
879
|
|
|
return false; |
880
|
|
|
} |
881
|
|
|
|
882
|
|
|
$result = $buildplan->getCrew() <= 0 |
883
|
|
|
|| $this->getCrewCount() >= $buildplan->getCrew(); |
884
|
|
|
|
885
|
|
|
if (!$result && $game !== null) { |
886
|
|
|
$game->addInformationf( |
887
|
|
|
_("Es werden %d Crewmitglieder benötigt"), |
888
|
|
|
$buildplan->getCrew() |
889
|
|
|
); |
890
|
|
|
} |
891
|
|
|
|
892
|
|
|
return $result; |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
#[Override] |
896
|
|
|
public function getFleet(): ?FleetInterface |
897
|
|
|
{ |
898
|
|
|
return $this->fleet; |
899
|
|
|
} |
900
|
|
|
|
901
|
|
|
#[Override] |
902
|
|
|
public function setFleet(?FleetInterface $fleet): ShipInterface |
903
|
|
|
{ |
904
|
|
|
$this->fleet = $fleet; |
905
|
|
|
return $this; |
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
#[Override] |
909
|
|
|
public function isFleetLeader(): bool |
910
|
|
|
{ |
911
|
|
|
return $this->getIsFleetLeader(); |
912
|
|
|
} |
913
|
|
|
|
914
|
|
|
#[Override] |
915
|
|
|
public function getUser(): UserInterface |
916
|
|
|
{ |
917
|
|
|
return $this->user; |
918
|
|
|
} |
919
|
|
|
|
920
|
|
|
#[Override] |
921
|
|
|
public function setUser(UserInterface $user): ShipInterface |
922
|
|
|
{ |
923
|
|
|
$this->user = $user; |
924
|
|
|
return $this; |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
#[Override] |
928
|
|
|
public function getSystem(): ?StarSystemInterface |
929
|
|
|
{ |
930
|
|
|
return $this->getStarsystemMap() !== null ? $this->getStarsystemMap()->getSystem() : null; |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
#[Override] |
934
|
|
|
public function getModules(): array |
935
|
|
|
{ |
936
|
|
|
$modules = []; |
937
|
|
|
|
938
|
|
|
$buildplan = $this->getBuildplan(); |
939
|
|
|
if ($buildplan === null) { |
940
|
|
|
return $modules; |
941
|
|
|
} |
942
|
|
|
|
943
|
|
|
foreach ($buildplan->getModules() as $obj) { |
944
|
|
|
$module = $obj->getModule(); |
945
|
|
|
$index = $module->getType() === ShipModuleTypeEnum::SPECIAL ? $module->getId() : $module->getType()->value; |
946
|
|
|
$modules[$index] = $module; |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
if ($this->isBase()) { |
950
|
|
|
foreach ($this->getSystems() as $system) { |
951
|
|
|
$module = $system->getModule(); |
952
|
|
|
|
953
|
|
|
if ($module !== null) { |
954
|
|
|
$index = $module->getType() === ShipModuleTypeEnum::SPECIAL ? $module->getId() : $module->getType()->value; |
955
|
|
|
$modules[$index] = $module; |
956
|
|
|
} |
957
|
|
|
} |
958
|
|
|
} |
959
|
|
|
|
960
|
|
|
return $modules; |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
#[Override] |
964
|
|
|
public function isDeflectorHealthy(): bool |
965
|
|
|
{ |
966
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_DEFLECTOR); |
967
|
|
|
} |
968
|
|
|
|
969
|
|
|
#[Override] |
970
|
|
|
public function isTroopQuartersHealthy(): bool |
971
|
|
|
{ |
972
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_TROOP_QUARTERS); |
973
|
|
|
} |
974
|
|
|
|
975
|
|
|
#[Override] |
976
|
|
|
public function isMatrixScannerHealthy(): bool |
977
|
|
|
{ |
978
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_MATRIX_SCANNER); |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
#[Override] |
982
|
|
|
public function isTorpedoStorageHealthy(): bool |
983
|
|
|
{ |
984
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_TORPEDO_STORAGE); |
985
|
|
|
} |
986
|
|
|
|
987
|
|
|
#[Override] |
988
|
|
|
public function isShuttleRampHealthy(): bool |
989
|
|
|
{ |
990
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_SHUTTLE_RAMP); |
991
|
|
|
} |
992
|
|
|
|
993
|
|
|
#[Override] |
994
|
|
|
public function isWebEmitterHealthy(): bool |
995
|
|
|
{ |
996
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_THOLIAN_WEB); |
997
|
|
|
} |
998
|
|
|
|
999
|
|
|
#[Override] |
1000
|
|
|
public function isWarpAble(): bool |
1001
|
|
|
{ |
1002
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_WARPDRIVE); |
1003
|
|
|
} |
1004
|
|
|
|
1005
|
|
|
#[Override] |
1006
|
|
|
public function isTractoring(): bool |
1007
|
|
|
{ |
1008
|
|
|
return $this->getTractoredShip() !== null; |
1009
|
|
|
} |
1010
|
|
|
|
1011
|
|
|
#[Override] |
1012
|
|
|
public function isTractored(): bool |
1013
|
|
|
{ |
1014
|
|
|
return $this->getTractoringShip() !== null; |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
#[Override] |
1018
|
|
|
public function isOverColony(): ?ColonyInterface |
1019
|
|
|
{ |
1020
|
|
|
return $this->getStarsystemMap() !== null ? $this->getStarsystemMap()->getColony() : null; |
1021
|
|
|
} |
1022
|
|
|
|
1023
|
|
|
#[Override] |
1024
|
|
|
public function isOverSystem(): ?StarSystemInterface |
1025
|
|
|
{ |
1026
|
|
|
if ($this->getSystem() !== null) { |
1027
|
|
|
return null; |
1028
|
|
|
} |
1029
|
|
|
|
1030
|
|
|
return $this->getMap()->getSystem(); |
1031
|
|
|
} |
1032
|
|
|
|
1033
|
|
|
#[Override] |
1034
|
|
|
public function isWarpPossible(): bool |
1035
|
|
|
{ |
1036
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_WARPDRIVE) && $this->getSystem() === null; |
1037
|
|
|
} |
1038
|
|
|
|
1039
|
|
|
#[Override] |
1040
|
|
|
public function getTorpedo(): ?TorpedoTypeInterface |
1041
|
|
|
{ |
1042
|
|
|
if ($this->getTorpedoStorage() === null) { |
1043
|
|
|
return null; |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
return $this->getTorpedoStorage()->getTorpedo(); |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
#[Override] |
1050
|
|
|
public function getTorpedoStorage(): ?TorpedoStorageInterface |
1051
|
|
|
{ |
1052
|
|
|
return $this->torpedoStorage; |
1053
|
|
|
} |
1054
|
|
|
|
1055
|
|
|
#[Override] |
1056
|
|
|
public function setTorpedoStorage(?TorpedoStorageInterface $torpedoStorage): ShipInterface |
1057
|
|
|
{ |
1058
|
|
|
$this->torpedoStorage = $torpedoStorage; |
1059
|
|
|
return $this; |
1060
|
|
|
} |
1061
|
|
|
|
1062
|
|
|
#[Override] |
1063
|
|
|
public function getStorage(): Collection |
1064
|
|
|
{ |
1065
|
|
|
return $this->storage; |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
#[Override] |
1069
|
|
|
public function getLogbook(): Collection |
1070
|
|
|
{ |
1071
|
|
|
return $this->logbook; |
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
#[Override] |
1075
|
|
|
public function getTakeoverActive(): ?ShipTakeoverInterface |
1076
|
|
|
{ |
1077
|
|
|
return $this->takeoverActive; |
1078
|
|
|
} |
1079
|
|
|
|
1080
|
|
|
#[Override] |
1081
|
|
|
public function setTakeoverActive(?ShipTakeoverInterface $takeover): ShipInterface |
1082
|
|
|
{ |
1083
|
|
|
$this->takeoverActive = $takeover; |
1084
|
|
|
|
1085
|
|
|
return $this; |
1086
|
|
|
} |
1087
|
|
|
|
1088
|
|
|
#[Override] |
1089
|
|
|
public function getTakeoverPassive(): ?ShipTakeoverInterface |
1090
|
|
|
{ |
1091
|
|
|
return $this->takeoverPassive; |
1092
|
|
|
} |
1093
|
|
|
|
1094
|
|
|
#[Override] |
1095
|
|
|
public function setTakeoverPassive(?ShipTakeoverInterface $takeover): ShipInterface |
1096
|
|
|
{ |
1097
|
|
|
$this->takeoverPassive = $takeover; |
1098
|
|
|
|
1099
|
|
|
return $this; |
1100
|
|
|
} |
1101
|
|
|
|
1102
|
|
|
#[Override] |
1103
|
|
|
public function getStorageSum(): int |
1104
|
|
|
{ |
1105
|
|
|
return array_reduce( |
1106
|
|
|
$this->getStorage()->getValues(), |
1107
|
|
|
fn(int $sum, StorageInterface $storage): int => $sum + $storage->getAmount(), |
1108
|
|
|
0 |
1109
|
|
|
); |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
#[Override] |
1113
|
|
|
public function getMaxStorage(): int |
1114
|
|
|
{ |
1115
|
|
|
return $this->getRump()->getStorage(); |
1116
|
|
|
} |
1117
|
|
|
|
1118
|
|
|
#[Override] |
1119
|
|
|
public function getBeamableStorage(): array |
1120
|
|
|
{ |
1121
|
|
|
return array_filter( |
1122
|
|
|
$this->getStorage()->getValues(), |
1123
|
|
|
fn(StorageInterface $storage): bool => $storage->getCommodity()->isBeamable() === true |
1124
|
|
|
); |
1125
|
|
|
} |
1126
|
|
|
|
1127
|
|
|
#[Override] |
1128
|
|
|
public function getTradePost(): ?TradePostInterface |
1129
|
|
|
{ |
1130
|
|
|
return $this->tradePost; |
1131
|
|
|
} |
1132
|
|
|
|
1133
|
|
|
#[Override] |
1134
|
|
|
public function setTradePost(?TradePostInterface $tradePost): ShipInterface |
1135
|
|
|
{ |
1136
|
|
|
$this->tradePost = $tradePost; |
1137
|
|
|
|
1138
|
|
|
return $this; |
1139
|
|
|
} |
1140
|
|
|
|
1141
|
3 |
|
#[Override] |
1142
|
|
|
public function getMap(): ?MapInterface |
1143
|
|
|
{ |
1144
|
3 |
|
if ($this->location instanceof MapInterface) { |
1145
|
1 |
|
return $this->location; |
|
|
|
|
1146
|
|
|
} |
1147
|
2 |
|
if ($this->location instanceof StarSystemMapInterface) { |
1148
|
2 |
|
return $this->location->getSystem()->getMap(); |
|
|
|
|
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
return null; |
1152
|
|
|
} |
1153
|
|
|
|
1154
|
|
|
#[Override] |
1155
|
|
|
public function getMapRegion(): ?MapRegionInterface |
1156
|
|
|
{ |
1157
|
|
|
$systemMap = $this->getStarsystemMap(); |
1158
|
|
|
if ($systemMap !== null) { |
1159
|
|
|
return null; |
1160
|
|
|
} |
1161
|
|
|
|
1162
|
|
|
$map = $this->getMap(); |
1163
|
|
|
if ($map === null) { |
1164
|
|
|
return null; |
1165
|
|
|
} |
1166
|
|
|
|
1167
|
|
|
return $map->getMapRegion(); |
1168
|
|
|
} |
1169
|
|
|
|
1170
|
3 |
|
#[Override] |
1171
|
|
|
public function setLocation(LocationInterface $location): ShipInterface |
1172
|
|
|
{ |
1173
|
3 |
|
$this->location = $location; |
1174
|
|
|
|
1175
|
3 |
|
return $this; |
1176
|
|
|
} |
1177
|
|
|
|
1178
|
3 |
|
#[Override] |
1179
|
|
|
public function getStarsystemMap(): ?StarSystemMapInterface |
1180
|
|
|
{ |
1181
|
3 |
|
if ($this->location instanceof StarSystemMapInterface) { |
1182
|
2 |
|
return $this->location; |
|
|
|
|
1183
|
|
|
} |
1184
|
|
|
|
1185
|
1 |
|
return null; |
1186
|
|
|
} |
1187
|
|
|
|
1188
|
|
|
#[Override] |
1189
|
|
|
public function getLocation(): LocationInterface |
1190
|
|
|
{ |
1191
|
|
|
return $this->location; |
1192
|
|
|
} |
1193
|
|
|
|
1194
|
|
|
#[Override] |
1195
|
|
|
public function getInfluenceArea(): ?StarSystemInterface |
1196
|
|
|
{ |
1197
|
|
|
return $this->influenceArea; |
1198
|
|
|
} |
1199
|
|
|
|
1200
|
|
|
#[Override] |
1201
|
|
|
public function setInfluenceArea(?StarSystemInterface $influenceArea): ShipInterface |
1202
|
|
|
{ |
1203
|
|
|
$this->influenceArea = $influenceArea; |
1204
|
|
|
return $this; |
1205
|
|
|
} |
1206
|
|
|
|
1207
|
|
|
#[Override] |
1208
|
|
|
public function getBeamFactor(): int |
1209
|
|
|
{ |
1210
|
|
|
return $this->getRump()->getBeamFactor(); |
1211
|
|
|
} |
1212
|
|
|
|
1213
|
|
|
#[Override] |
1214
|
|
|
public function getSectorString(): string |
1215
|
|
|
{ |
1216
|
|
|
return $this->getLocation()->getSectorString(); |
1217
|
|
|
} |
1218
|
|
|
|
1219
|
|
|
#[Override] |
1220
|
|
|
public function getBuildplan(): ?ShipBuildplanInterface |
1221
|
|
|
{ |
1222
|
|
|
return $this->buildplan; |
1223
|
|
|
} |
1224
|
|
|
|
1225
|
|
|
#[Override] |
1226
|
|
|
public function setBuildplan(?ShipBuildplanInterface $shipBuildplan): ShipInterface |
1227
|
|
|
{ |
1228
|
|
|
$this->buildplan = $shipBuildplan; |
1229
|
|
|
return $this; |
1230
|
|
|
} |
1231
|
|
|
|
1232
|
|
|
#[Override] |
1233
|
|
|
public function getSystems(): Collection |
1234
|
|
|
{ |
1235
|
|
|
return $this->systems; |
1236
|
|
|
} |
1237
|
|
|
|
1238
|
|
|
#[Override] |
1239
|
|
|
public function hasShipSystem(ShipSystemTypeEnum $type): bool |
1240
|
|
|
{ |
1241
|
|
|
return $this->getSystems()->containsKey($type->value); |
1242
|
|
|
} |
1243
|
|
|
|
1244
|
|
|
#[Override] |
1245
|
|
|
public function getShipSystem(ShipSystemTypeEnum $type): ShipSystemInterface |
1246
|
|
|
{ |
1247
|
|
|
$system = $this->getSystems()->get($type->value); |
1248
|
|
|
if ($system === null) { |
1249
|
|
|
throw new RuntimeException(sprintf('system type %d does not exist on ship', $type->value)); |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
return $system; |
1253
|
|
|
} |
1254
|
|
|
|
1255
|
|
|
#[Override] |
1256
|
|
|
public function getHealthySystems(): array |
1257
|
|
|
{ |
1258
|
|
|
$healthySystems = []; |
1259
|
|
|
foreach ($this->getSystems() as $system) { |
1260
|
|
|
if ($system->getStatus() > 0) { |
1261
|
|
|
$healthySystems[] = $system; |
1262
|
|
|
} |
1263
|
|
|
} |
1264
|
|
|
return $healthySystems; |
1265
|
|
|
} |
1266
|
|
|
|
1267
|
|
|
#[Override] |
1268
|
|
|
public function displayNbsActions(): bool |
1269
|
|
|
{ |
1270
|
|
|
return !$this->getCloakState() |
1271
|
|
|
&& !$this->isWarped(); |
1272
|
|
|
} |
1273
|
|
|
|
1274
|
|
|
#[Override] |
1275
|
|
|
public function isTractorbeamPossible(): bool |
1276
|
|
|
{ |
1277
|
|
|
return TractorBeamShipSystem::isTractorBeamPossible($this); |
1278
|
|
|
} |
1279
|
|
|
|
1280
|
|
|
#[Override] |
1281
|
|
|
public function isBoardingPossible(): bool |
1282
|
|
|
{ |
1283
|
|
|
return FightLib::isBoardingPossible($this); |
1284
|
|
|
} |
1285
|
|
|
|
1286
|
|
|
#[Override] |
1287
|
|
|
public function isInterceptable(): bool |
1288
|
|
|
{ |
1289
|
|
|
//TODO can tractored ships be intercepted?! |
1290
|
|
|
return $this->getWarpDriveState(); |
1291
|
|
|
} |
1292
|
|
|
|
1293
|
|
|
#[Override] |
1294
|
|
|
public function dockedOnTradePost(): bool |
1295
|
|
|
{ |
1296
|
|
|
return $this->getDockedTo() && $this->getDockedTo()->getTradePost() !== null; |
1297
|
|
|
} |
1298
|
|
|
|
1299
|
|
|
#[Override] |
1300
|
|
|
public function getDockPrivileges(): Collection |
1301
|
|
|
{ |
1302
|
|
|
return $this->dockingPrivileges; |
1303
|
|
|
} |
1304
|
|
|
|
1305
|
|
|
#[Override] |
1306
|
|
|
public function getDockingSlotCount(): int |
1307
|
|
|
{ |
1308
|
|
|
return ($this->getState() === ShipStateEnum::SHIP_STATE_UNDER_CONSTRUCTION) |
1309
|
|
|
|| ($this->getState() === ShipStateEnum::SHIP_STATE_UNDER_SCRAPPING) |
1310
|
|
|
? 50 : $this->getRump()->getDockingSlots(); |
1311
|
|
|
} |
1312
|
|
|
|
1313
|
|
|
#[Override] |
1314
|
|
|
public function hasFreeDockingSlots(): bool |
1315
|
|
|
{ |
1316
|
|
|
return $this->getDockingSlotCount() > $this->getDockedShipCount(); |
1317
|
|
|
} |
1318
|
|
|
|
1319
|
|
|
#[Override] |
1320
|
|
|
public function getFreeDockingSlotCount(): int |
1321
|
|
|
{ |
1322
|
|
|
return $this->getDockingSlotCount() - $this->getDockedShipCount(); |
1323
|
|
|
} |
1324
|
|
|
|
1325
|
|
|
#[Override] |
1326
|
|
|
public function getDockedShipCount(): int |
1327
|
|
|
{ |
1328
|
|
|
return $this->dockedShips->count(); |
1329
|
|
|
} |
1330
|
|
|
|
1331
|
|
|
#[Override] |
1332
|
|
|
public function getTractoredShip(): ?ShipInterface |
1333
|
|
|
{ |
1334
|
|
|
return $this->tractoredShip; |
1335
|
|
|
} |
1336
|
|
|
|
1337
|
|
|
#[Override] |
1338
|
|
|
public function setTractoredShip(?ShipInterface $ship): ShipInterface |
1339
|
|
|
{ |
1340
|
|
|
$this->tractoredShip = $ship; |
1341
|
|
|
return $this; |
1342
|
|
|
} |
1343
|
|
|
|
1344
|
|
|
#[Override] |
1345
|
|
|
public function setTractoredShipId(?int $shipId): ShipInterface |
1346
|
|
|
{ |
1347
|
|
|
$this->tractored_ship_id = $shipId; |
1348
|
|
|
return $this; |
1349
|
|
|
} |
1350
|
|
|
|
1351
|
|
|
#[Override] |
1352
|
|
|
public function getTractoringShip(): ?ShipInterface |
1353
|
|
|
{ |
1354
|
|
|
return $this->tractoringShip; |
1355
|
|
|
} |
1356
|
|
|
|
1357
|
|
|
#[Override] |
1358
|
|
|
public function setTractoringShip(?ShipInterface $ship): ShipInterface |
1359
|
|
|
{ |
1360
|
|
|
$this->tractoringShip = $ship; |
1361
|
|
|
return $this; |
1362
|
|
|
} |
1363
|
|
|
|
1364
|
|
|
#[Override] |
1365
|
|
|
public function getHoldingWeb(): ?TholianWebInterface |
1366
|
|
|
{ |
1367
|
|
|
return $this->holdingWeb; |
1368
|
|
|
} |
1369
|
|
|
|
1370
|
|
|
#[Override] |
1371
|
|
|
public function setHoldingWeb(?TholianWebInterface $web): ShipInterface |
1372
|
|
|
{ |
1373
|
|
|
$this->holdingWeb = $web; |
1374
|
|
|
|
1375
|
|
|
if ($web === null) { |
1376
|
|
|
$this->holding_web_id = null; |
1377
|
|
|
} |
1378
|
|
|
|
1379
|
|
|
return $this; |
1380
|
|
|
} |
1381
|
|
|
|
1382
|
|
|
#[Override] |
1383
|
|
|
public function getHoldingWebBackgroundStyle(): string |
1384
|
|
|
{ |
1385
|
|
|
if ($this->getHoldingWeb() === null) { |
1386
|
|
|
return ''; |
1387
|
|
|
} |
1388
|
|
|
|
1389
|
|
|
if ($this->getHoldingWeb()->isFinished()) { |
1390
|
|
|
$icon = 'web.png'; |
1391
|
|
|
} else { |
1392
|
|
|
$closeTofinish = $this->getHoldingWeb()->getFinishedTime() - time() < TimeConstants::ONE_HOUR_IN_SECONDS; |
1393
|
|
|
|
1394
|
|
|
$icon = $closeTofinish ? 'web_u.png' : 'web_u2.png'; |
1395
|
|
|
} |
1396
|
|
|
|
1397
|
|
|
return sprintf('src="assets/buttons/%s"; class="indexedGraphics" style="z-index: 5;"', $icon); |
1398
|
|
|
} |
1399
|
|
|
|
1400
|
|
|
public function getHoldingWebImageStyle(): string |
1401
|
|
|
{ |
1402
|
|
|
if ($this->getHoldingWeb() === null) { |
1403
|
|
|
return ''; |
1404
|
|
|
} |
1405
|
|
|
|
1406
|
|
|
if ($this->getHoldingWeb()->isFinished()) { |
1407
|
|
|
$icon = 'webfill.png'; |
1408
|
|
|
} else { |
1409
|
|
|
$closeTofinish = $this->getHoldingWeb()->getFinishedTime() - time() < TimeConstants::ONE_HOUR_IN_SECONDS; |
1410
|
|
|
|
1411
|
|
|
$icon = $closeTofinish ? 'web_ufill.png' : 'web_ufill2.png'; |
1412
|
|
|
} |
1413
|
|
|
|
1414
|
|
|
return $icon; |
1415
|
|
|
} |
1416
|
|
|
|
1417
|
|
|
private function getShieldRegenerationPercentage(): int |
1418
|
|
|
{ |
1419
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_SHIELDS) ? 10 : 0; |
1420
|
|
|
} |
1421
|
|
|
|
1422
|
|
|
#[Override] |
1423
|
|
|
public function getShieldRegenerationRate(): int |
1424
|
|
|
{ |
1425
|
|
|
return (int) ceil(($this->getMaxShield() / 100) * $this->getShieldRegenerationPercentage()); |
1426
|
|
|
} |
1427
|
|
|
|
1428
|
|
|
#[Override] |
1429
|
|
|
public function canIntercept(): bool |
1430
|
|
|
{ |
1431
|
|
|
return $this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_WARPDRIVE) |
1432
|
|
|
&& !$this->isTractored() && !$this->isTractoring(); |
1433
|
|
|
} |
1434
|
|
|
|
1435
|
|
|
#[Override] |
1436
|
|
|
public function canMove(): bool |
1437
|
|
|
{ |
1438
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_WARPDRIVE) |
1439
|
|
|
|| $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE); |
1440
|
|
|
} |
1441
|
|
|
|
1442
|
|
|
#[Override] |
1443
|
|
|
public function hasActiveWeapon(): bool |
1444
|
|
|
{ |
1445
|
|
|
return $this->getPhaserState() || $this->getTorpedoState(); |
1446
|
|
|
} |
1447
|
|
|
|
1448
|
|
|
#[Override] |
1449
|
|
|
public function hasEscapePods(): bool |
1450
|
|
|
{ |
1451
|
|
|
return $this->getRump()->isEscapePods() && $this->getCrewCount() > 0; |
1452
|
|
|
} |
1453
|
|
|
|
1454
|
|
|
#[Override] |
1455
|
|
|
public function getRepairRate(): int |
1456
|
|
|
{ |
1457
|
|
|
// @todo |
1458
|
|
|
return 100; |
1459
|
|
|
} |
1460
|
|
|
|
1461
|
|
|
#[Override] |
1462
|
|
|
public function getRump(): ShipRumpInterface |
1463
|
|
|
{ |
1464
|
|
|
return $this->rump; |
1465
|
|
|
} |
1466
|
|
|
|
1467
|
|
|
#[Override] |
1468
|
|
|
public function getRumpId(): int |
1469
|
|
|
{ |
1470
|
|
|
return $this->getRump()->getId(); |
1471
|
|
|
} |
1472
|
|
|
|
1473
|
|
|
#[Override] |
1474
|
|
|
public function getRumpName(): string |
1475
|
|
|
{ |
1476
|
|
|
return $this->getRump()->getName(); |
1477
|
|
|
} |
1478
|
|
|
|
1479
|
|
|
#[Override] |
1480
|
|
|
public function setRump(ShipRumpInterface $shipRump): ShipInterface |
1481
|
|
|
{ |
1482
|
|
|
$this->rump = $shipRump; |
1483
|
|
|
return $this; |
1484
|
|
|
} |
1485
|
|
|
|
1486
|
|
|
#[Override] |
1487
|
|
|
public function hasPhaser(): bool |
1488
|
|
|
{ |
1489
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_PHASER); |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
#[Override] |
1493
|
|
|
public function hasTorpedo(): bool |
1494
|
|
|
{ |
1495
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_TORPEDO); |
1496
|
|
|
} |
1497
|
|
|
|
1498
|
|
|
#[Override] |
1499
|
|
|
public function hasCloak(): bool |
1500
|
|
|
{ |
1501
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_CLOAK); |
1502
|
|
|
} |
1503
|
|
|
|
1504
|
|
|
#[Override] |
1505
|
|
|
public function hasTachyonScanner(): bool |
1506
|
|
|
{ |
1507
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_TACHYON_SCANNER); |
1508
|
|
|
} |
1509
|
|
|
|
1510
|
|
|
#[Override] |
1511
|
|
|
public function hasShuttleRamp(): bool |
1512
|
|
|
{ |
1513
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_SHUTTLE_RAMP); |
1514
|
|
|
} |
1515
|
|
|
|
1516
|
|
|
#[Override] |
1517
|
|
|
public function hasSubspaceScanner(): bool |
1518
|
|
|
{ |
1519
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_SUBSPACE_SCANNER); |
1520
|
|
|
} |
1521
|
|
|
|
1522
|
|
|
#[Override] |
1523
|
|
|
public function hasAstroLaboratory(): bool |
1524
|
|
|
{ |
1525
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_ASTRO_LABORATORY); |
1526
|
|
|
} |
1527
|
|
|
|
1528
|
|
|
#[Override] |
1529
|
|
|
public function hasWarpdrive(): bool |
1530
|
|
|
{ |
1531
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_WARPDRIVE); |
1532
|
|
|
} |
1533
|
|
|
|
1534
|
|
|
#[Override] |
1535
|
|
|
public function hasReactor(): bool |
1536
|
|
|
{ |
1537
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_WARPCORE) || |
1538
|
|
|
$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_FUSION_REACTOR) || |
1539
|
|
|
$this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_SINGULARITY_REACTOR); |
1540
|
|
|
} |
1541
|
|
|
|
1542
|
|
|
#[Override] |
1543
|
|
|
public function hasRPGModule(): bool |
1544
|
|
|
{ |
1545
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_RPG_MODULE); |
1546
|
|
|
} |
1547
|
|
|
|
1548
|
|
|
#[Override] |
1549
|
|
|
public function hasNbsLss(): bool |
1550
|
|
|
{ |
1551
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_LSS); |
1552
|
|
|
} |
1553
|
|
|
|
1554
|
|
|
#[Override] |
1555
|
|
|
public function hasUplink(): bool |
1556
|
|
|
{ |
1557
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_UPLINK); |
1558
|
|
|
} |
1559
|
|
|
|
1560
|
|
|
#[Override] |
1561
|
|
|
public function hasTranswarp(): bool |
1562
|
|
|
{ |
1563
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_TRANSWARP_COIL); |
1564
|
|
|
} |
1565
|
|
|
|
1566
|
|
|
#[Override] |
1567
|
|
|
public function getTranswarpCooldown(): ?int |
1568
|
|
|
{ |
1569
|
|
|
$cooldown = $this->getShipSystem(ShipSystemTypeEnum::SYSTEM_TRANSWARP_COIL)->getCooldown(); |
1570
|
|
|
|
1571
|
|
|
return $cooldown > time() ? $cooldown : null; |
1572
|
|
|
} |
1573
|
|
|
|
1574
|
|
|
#[Override] |
1575
|
|
|
public function getMaxTorpedos(): int |
1576
|
|
|
{ |
1577
|
|
|
return $this->getRump()->getBaseTorpedoStorage() |
1578
|
|
|
+ ($this->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_TORPEDO_STORAGE) |
1579
|
|
|
? TorpedoStorageShipSystem::TORPEDO_CAPACITY : 0); |
1580
|
|
|
} |
1581
|
|
|
|
1582
|
|
|
#[Override] |
1583
|
|
|
public function getDockedShips(): Collection |
1584
|
|
|
{ |
1585
|
|
|
return $this->dockedShips; |
1586
|
|
|
} |
1587
|
|
|
|
1588
|
|
|
#[Override] |
1589
|
|
|
public function getDockedTo(): ?ShipInterface |
1590
|
|
|
{ |
1591
|
|
|
return $this->dockedTo; |
1592
|
|
|
} |
1593
|
|
|
|
1594
|
|
|
#[Override] |
1595
|
|
|
public function setDockedTo(?ShipInterface $dockedTo): ShipInterface |
1596
|
|
|
{ |
1597
|
|
|
$this->dockedTo = $dockedTo; |
1598
|
|
|
return $this; |
1599
|
|
|
} |
1600
|
|
|
|
1601
|
|
|
#[Override] |
1602
|
|
|
public function setDockedToId(?int $dockedToId): ShipInterface |
1603
|
|
|
{ |
1604
|
|
|
$this->dock = $dockedToId; |
1605
|
|
|
return $this; |
1606
|
|
|
} |
1607
|
|
|
|
1608
|
|
|
#[Override] |
1609
|
|
|
public function hasFreeShuttleSpace(?LoggerUtilInterface $loggerUtil = null): bool |
1610
|
|
|
{ |
1611
|
|
|
if ($loggerUtil !== null) { |
1612
|
|
|
$loggerUtil->log(sprintf('rumpShuttleSlots: %d', $this->getRump()->getShuttleSlots())); |
1613
|
|
|
$loggerUtil->log(sprintf('storedShuttleCount: %d', $this->getStoredShuttleCount())); |
1614
|
|
|
} |
1615
|
|
|
return $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_SHUTTLE_RAMP) |
1616
|
|
|
&& $this->getRump()->getShuttleSlots() - $this->getStoredShuttleCount() > 0; |
1617
|
|
|
} |
1618
|
|
|
|
1619
|
|
|
#[Override] |
1620
|
|
|
public function getStoredShuttles(): array |
1621
|
|
|
{ |
1622
|
|
|
$shuttles = []; |
1623
|
|
|
|
1624
|
|
|
foreach ($this->getStorage() as $stor) { |
1625
|
|
|
if ($stor->getCommodity()->isShuttle()) { |
1626
|
|
|
$shuttles[] = $stor->getCommodity(); |
1627
|
|
|
} |
1628
|
|
|
} |
1629
|
|
|
|
1630
|
|
|
return $shuttles; |
1631
|
|
|
} |
1632
|
|
|
|
1633
|
|
|
#[Override] |
1634
|
|
|
public function getStoredShuttleCount(): int |
1635
|
|
|
{ |
1636
|
|
|
$count = 0; |
1637
|
|
|
|
1638
|
|
|
foreach ($this->getStorage() as $stor) { |
1639
|
|
|
if ($stor->getCommodity()->isShuttle()) { |
1640
|
|
|
$count += $stor->getAmount(); |
1641
|
|
|
} |
1642
|
|
|
} |
1643
|
|
|
|
1644
|
|
|
return $count; |
1645
|
|
|
} |
1646
|
|
|
|
1647
|
|
|
/** |
1648
|
|
|
* @return CommodityInterface[] |
1649
|
|
|
*/ |
1650
|
|
|
#[Override] |
1651
|
|
|
public function getStoredBuoy(): array |
1652
|
|
|
{ |
1653
|
|
|
$buoy = []; |
1654
|
|
|
|
1655
|
|
|
foreach ($this->getStorage() as $stor) { |
1656
|
|
|
if ($stor->getCommodity()->isBouy()) { |
1657
|
|
|
$buoy[] = $stor->getCommodity(); |
1658
|
|
|
} |
1659
|
|
|
} |
1660
|
|
|
|
1661
|
|
|
return $buoy; |
1662
|
|
|
} |
1663
|
|
|
|
1664
|
|
|
|
1665
|
|
|
#[Override] |
1666
|
|
|
public function hasStoredBuoy(): bool |
1667
|
|
|
{ |
1668
|
|
|
return $this->getStoredBuoy() !== []; |
1669
|
|
|
} |
1670
|
|
|
|
1671
|
|
|
|
1672
|
|
|
#[Override] |
1673
|
|
|
public function getDockedWorkbeeCount(): int |
1674
|
|
|
{ |
1675
|
|
|
$count = 0; |
1676
|
|
|
|
1677
|
|
|
foreach ($this->getDockedShips() as $ships) { |
1678
|
|
|
if ($ships->getRump()->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_SHUTTLE) { |
1679
|
|
|
$count += 1; |
1680
|
|
|
} |
1681
|
|
|
} |
1682
|
|
|
|
1683
|
|
|
return $count; |
1684
|
|
|
} |
1685
|
|
|
|
1686
|
|
|
#[Override] |
1687
|
|
|
public function canMan(): bool |
1688
|
|
|
{ |
1689
|
|
|
$buildplan = $this->getBuildplan(); |
1690
|
|
|
|
1691
|
|
|
return $buildplan !== null |
1692
|
|
|
&& $buildplan->getCrew() > 0 |
1693
|
|
|
&& $this->hasShipSystem(ShipSystemTypeEnum::SYSTEM_LIFE_SUPPORT); |
1694
|
|
|
} |
1695
|
|
|
|
1696
|
|
|
#[Override] |
1697
|
|
|
public function canBuildConstruction(): bool |
1698
|
|
|
{ |
1699
|
|
|
return StationUtility::canShipBuildConstruction($this); |
1700
|
|
|
} |
1701
|
|
|
|
1702
|
|
|
#[Override] |
1703
|
|
|
public function hasCrewmanOfUser(int $userId): bool |
1704
|
|
|
{ |
1705
|
|
|
foreach ($this->getCrewAssignments() as $shipCrew) { |
1706
|
|
|
if ($shipCrew->getCrew()->getUser()->getId() === $userId) { |
1707
|
|
|
return true; |
1708
|
|
|
} |
1709
|
|
|
} |
1710
|
|
|
|
1711
|
|
|
return false; |
1712
|
|
|
} |
1713
|
|
|
|
1714
|
|
|
#[Override] |
1715
|
|
|
public function __toString(): string |
1716
|
|
|
{ |
1717
|
|
|
if ($this->id !== null) { |
1718
|
|
|
return sprintf('id: %d, name: %s', $this->getId(), $this->getName()); |
1719
|
|
|
} |
1720
|
|
|
|
1721
|
|
|
return $this->getName(); |
1722
|
|
|
} |
1723
|
|
|
|
1724
|
|
|
#[Override] |
1725
|
|
|
public function getHullColorStyle(): string |
1726
|
|
|
{ |
1727
|
|
|
return $this->getColorStyle($this->getHull(), $this->getMaxHull()); |
1728
|
|
|
} |
1729
|
|
|
|
1730
|
|
|
private function getColorStyle(int $actual, int $max): string |
1731
|
|
|
{ |
1732
|
|
|
// full |
1733
|
|
|
if ($actual === $max) { |
1734
|
|
|
return ''; |
1735
|
|
|
} |
1736
|
|
|
|
1737
|
|
|
// less than 100% - green |
1738
|
|
|
if ($actual / $max > 0.75) { |
1739
|
|
|
return 'color: #19c100;'; |
1740
|
|
|
} |
1741
|
|
|
|
1742
|
|
|
// less than 75% - yellow |
1743
|
|
|
if ($actual / $max > 0.50) { |
1744
|
|
|
return 'color: #f4e932;'; |
1745
|
|
|
} |
1746
|
|
|
|
1747
|
|
|
// less than 50% - orange |
1748
|
|
|
if ($actual / $max > 0.25) { |
1749
|
|
|
return 'color: #f48b28;'; |
1750
|
|
|
} |
1751
|
|
|
|
1752
|
|
|
// less than 25% - red |
1753
|
|
|
return 'color: #ff3c3c;'; |
1754
|
|
|
} |
1755
|
|
|
} |
1756
|
|
|
|
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