Passed
Push — dev ( 98511f...00baf5 )
by Janko
15:17
created

Spacecraft   F

Complexity

Total Complexity 70

Size/Duplication

Total Lines 606
Duplicated Lines 0 %

Test Coverage

Coverage 50.27%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 288
c 1
b 0
f 0
dl 0
loc 606
ccs 93
cts 185
cp 0.5027
rs 2.8
wmc 70

61 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A __construct() 0 6 1
A setName() 0 5 1
A setLocation() 0 6 1
A getRumpName() 0 4 1
A setHoldingWeb() 0 6 1
A getAlertState() 0 4 1
A setIsInEmergency() 0 5 1
A getLogbook() 0 4 1
A setTakeoverPassive() 0 6 1
A getTakeoverActive() 0 4 1
A getModules() 0 17 4
A getUserName() 0 4 1
A getShield() 0 4 1
A getRump() 0 4 1
A getState() 0 4 1
A setTakeoverActive() 0 6 1
A setHitChance() 0 5 1
A isDisabled() 0 4 1
A setBuildplan() 0 5 1
A getRepairRate() 0 5 1
A isInEmergency() 0 4 1
A getTractoredShip() 0 4 1
A getStorage() 0 4 1
A setTractoredShip() 0 5 1
A setShield() 0 5 1
A getBuildplan() 0 4 1
A __toString() 0 18 2
A getFlightDirection() 0 4 1
A setHuell() 0 5 1
A getUser() 0 4 1
A getCrewAssignments() 0 4 1
A getTakeoverPassive() 0 4 1
A getRumpId() 0 4 1
A getId() 0 8 2
A getUserId() 0 4 1
A getLssMode() 0 4 1
A setIsDestroyed() 0 5 1
A setDisabled() 0 5 1
A setLssMode() 0 5 1
A setEvadeChance() 0 5 1
A getHull() 0 4 1
A getDatabaseId() 0 4 1
A getLocation() 0 11 3
A setMaxHuell() 0 5 1
A setTorpedoStorage() 0 5 1
A setUser() 0 5 1
A isDestroyed() 0 4 1
A setDatabaseId() 0 5 1
A getHref() 0 13 2
A setFlightDirection() 0 5 1
A getMaxHull() 0 4 1
A setAlertState() 0 5 1
A setState() 0 5 1
A setMaxShield() 0 5 1
A getBeamFactor() 0 4 1
A getTorpedoStorage() 0 4 1
A setRump() 0 5 1
A getTractorPayload() 0 9 2
A getHoldingWeb() 0 4 1
A getSystems() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Spacecraft often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Spacecraft, and based on these observations, apply Extract Interface, too.

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\DiscriminatorColumn;
11
use Doctrine\ORM\Mapping\DiscriminatorMap;
12
use Doctrine\ORM\Mapping\Entity;
13
use Doctrine\ORM\Mapping\GeneratedValue;
14
use Doctrine\ORM\Mapping\Id;
15
use Doctrine\ORM\Mapping\InheritanceType;
16
use Doctrine\ORM\Mapping\JoinColumn;
17
use Doctrine\ORM\Mapping\ManyToOne;
18
use Doctrine\ORM\Mapping\OneToMany;
19
use Doctrine\ORM\Mapping\OneToOne;
20
use Doctrine\ORM\Mapping\OrderBy;
21
use Doctrine\ORM\Mapping\Table;
22
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use RuntimeException;
24
use Stu\Component\Map\DirectionEnum;
25
use Stu\Component\Spacecraft\SpacecraftAlertStateEnum;
26
use Stu\Component\Spacecraft\SpacecraftModuleTypeEnum;
27
use Stu\Component\Spacecraft\SpacecraftStateEnum;
28
use Stu\Component\Spacecraft\SpacecraftLssModeEnum;
29
use Stu\Component\Spacecraft\SpacecraftTypeEnum;
30
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
31
use Stu\Component\Spacecraft\Trait\SpacecraftSystemExistenceTrait;
32
use Stu\Component\Spacecraft\Trait\SpacecrafCharacteristicsTrait;
33
use Stu\Component\Spacecraft\Trait\SpacecraftCrewTrait;
34
use Stu\Component\Spacecraft\Trait\SpacecraftEvadeChanceTrait;
35
use Stu\Component\Spacecraft\Trait\SpacecraftHitChanceTrait;
36
use Stu\Component\Spacecraft\Trait\SpacecraftHoldingWebTrait;
37
use Stu\Component\Spacecraft\Trait\SpacecraftHullColorStyleTrait;
38
use Stu\Component\Spacecraft\Trait\SpacecraftInteractionTrait;
39
use Stu\Component\Spacecraft\Trait\SpacecraftLocationTrait;
40
use Stu\Component\Spacecraft\Trait\SpacecraftShieldsTrait;
41
use Stu\Component\Spacecraft\Trait\SpacecraftStateTrait;
42
use Stu\Component\Spacecraft\Trait\SpacecraftStorageTrait;
43
use Stu\Component\Spacecraft\Trait\SpacecraftSystemHealthTrait;
44
use Stu\Component\Spacecraft\Trait\SpacecraftSystemStateTrait;
45
use Stu\Component\Spacecraft\Trait\SpacecraftTorpedoTrait;
46
use Stu\Orm\Repository\SpacecraftRepository;
47
48
#[Table(name: 'stu_spacecraft')]
49
#[Entity(repositoryClass: SpacecraftRepository::class)]
50
#[InheritanceType('JOINED')]
51
#[DiscriminatorColumn(name: 'type', type: 'string')]
52
#[DiscriminatorMap([
53
    SpacecraftTypeEnum::SHIP->value => Ship::class,
54
    SpacecraftTypeEnum::STATION->value => Station::class,
55
    SpacecraftTypeEnum::THOLIAN_WEB->value => TholianWeb::class
56
])]
57
abstract class Spacecraft implements SpacecraftInterface
58
{
59
    use SpacecraftSystemStateTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...cecraftSystemStateTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
60
    use SpacecraftSystemExistenceTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...aftSystemExistenceTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
61
    use SpacecraftSystemHealthTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...ecraftSystemHealthTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
62
    use SpacecraftShieldsTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...\SpacecraftShieldsTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
63
    use SpacecraftHitChanceTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...pacecraftHitChanceTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
64
    use SpacecraftEvadeChanceTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...cecraftEvadeChanceTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
65
    use SpacecraftCrewTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft\Trait\SpacecraftCrewTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
66
    use SpacecraftLocationTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...SpacecraftLocationTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
67
    use SpacecraftStorageTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...\SpacecraftStorageTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
68
    use SpacecraftInteractionTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...cecraftInteractionTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
69
    use SpacecraftHoldingWebTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...acecraftHoldingWebTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
70
    use SpacecraftHullColorStyleTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...raftHullColorStyleTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
71
    use SpacecraftTorpedoTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...\SpacecraftTorpedoTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
72
    use SpacecrafCharacteristicsTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...rafCharacteristicsTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
73
    use SpacecraftStateTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...it\SpacecraftStateTrait requires the property $value which is not provided by Stu\Orm\Entity\Spacecraft.
Loading history...
74
75
    #[Id]
76
    #[Column(type: 'integer')]
77
    #[GeneratedValue(strategy: 'IDENTITY')]
78
    private ?int $id = null;
79
80
    #[Column(type: 'integer')]
81
    private int $user_id = 0;
82
83
    #[Column(type: 'integer')]
84
    private int $rump_id = 0;
0 ignored issues
show
introduced by
The private property $rump_id is not used, and could be removed.
Loading history...
85
86
    #[Column(type: 'integer', nullable: true)]
87
    private ?int $plan_id = null;
0 ignored issues
show
introduced by
The private property $plan_id is not used, and could be removed.
Loading history...
88
89
    #[Column(type: 'smallint', length: 1, enumType: DirectionEnum::class, nullable: true)]
90
    private ?DirectionEnum $direction = null;
91
92
    #[Column(type: 'string')]
93
    private string $name = '';
94
95
    #[Column(type: 'smallint', length: 1, enumType: SpacecraftAlertStateEnum::class)]
96
    private SpacecraftAlertStateEnum $alvl = SpacecraftAlertStateEnum::ALERT_GREEN;
97
98
    #[Column(type: 'smallint', length: 1, enumType: SpacecraftLssModeEnum::class)]
99
    private SpacecraftLssModeEnum $lss_mode = SpacecraftLssModeEnum::NORMAL;
100
101
    #[Column(type: 'integer', length: 6)]
102
    private int $huelle = 0;
103
104
    #[Column(type: 'integer', length: 6)]
105
    private int $max_huelle = 0;
106
107
    #[Column(type: 'integer', length: 6)]
108
    private int $schilde = 0;
109
110
    #[Column(type: 'integer', length: 6)]
111
    private int $max_schilde = 0;
112
113
    #[Column(type: 'integer', nullable: true)]
114
    private ?int $tractored_ship_id = null;
0 ignored issues
show
introduced by
The private property $tractored_ship_id is not used, and could be removed.
Loading history...
115
116
    #[Column(type: 'integer', nullable: true)]
117
    private ?int $holding_web_id = null;
0 ignored issues
show
introduced by
The private property $holding_web_id is not used, and could be removed.
Loading history...
118
119
    #[Column(type: 'integer', nullable: true)]
120
    private ?int $database_id = null;
121
122
    private bool $is_destroyed = false;
123
124
    #[Column(type: 'boolean')]
125
    private bool $disabled = false;
126
127
    #[Column(type: 'smallint', length: 3)]
128
    private int $hit_chance = 0;
129
130
    #[Column(type: 'smallint', length: 3)]
131
    private int $evade_chance = 0;
132
133
    #[Column(type: 'smallint', enumType: SpacecraftStateEnum::class)]
134
    private SpacecraftStateEnum $state = SpacecraftStateEnum::NONE;
135
136
    #[Column(type: 'integer')]
137
    private int $location_id = 0;
0 ignored issues
show
introduced by
The private property $location_id is not used, and could be removed.
Loading history...
138
139
    #[Column(type: 'boolean')]
140
    private bool $in_emergency = false;
141
142
    #[OneToOne(targetEntity: 'Ship')]
143
    #[JoinColumn(name: 'tractored_ship_id', referencedColumnName: 'id')]
144
    private ?ShipInterface $tractoredShip = null;
145
146
    #[ManyToOne(targetEntity: 'TholianWeb')]
147
    #[JoinColumn(name: 'holding_web_id', referencedColumnName: 'id')]
148
    private ?TholianWebInterface $holdingWeb = null;
149
150
    #[ManyToOne(targetEntity: 'User')]
151
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
152
    private UserInterface $user;
153
154
    /**
155
     * @var ArrayCollection<int, CrewAssignmentInterface>
156
     */
157
    #[OneToMany(targetEntity: 'CrewAssignment', mappedBy: 'spacecraft', indexBy: 'id')]
158
    #[OrderBy(['id' => 'ASC'])]
159
    private Collection $crew;
160
161
    #[OneToOne(targetEntity: 'TorpedoStorage', mappedBy: 'spacecraft')]
162
    private ?TorpedoStorageInterface $torpedoStorage = null;
163
164
    /**
165
     * @var ArrayCollection<int, SpacecraftSystemInterface>
166
     */
167
    #[OneToMany(targetEntity: 'SpacecraftSystem', mappedBy: 'spacecraft', indexBy: 'system_type')]
168
    #[OrderBy(['system_type' => 'ASC'])]
169
    private Collection $systems;
170
171
    #[ManyToOne(targetEntity: 'SpacecraftRump')]
172
    #[JoinColumn(name: 'rump_id', referencedColumnName: 'id')]
173
    private SpacecraftRumpInterface $rump;
174
175
    #[ManyToOne(targetEntity: 'SpacecraftBuildplan')]
176
    #[JoinColumn(name: 'plan_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
177
    private ?SpacecraftBuildplanInterface $buildplan = null;
178
179
    /**
180
     * @var ArrayCollection<int, StorageInterface>
181
     */
182
    #[OneToMany(targetEntity: 'Storage', mappedBy: 'spacecraft', indexBy: 'commodity_id')]
183
    #[OrderBy(['commodity_id' => 'ASC'])]
184
    private Collection $storage;
185
186
    #[ManyToOne(targetEntity: 'Location')]
187
    #[JoinColumn(name: 'location_id', referencedColumnName: 'id')]
188
    private LocationInterface $location;
189
190
    /**
191
     * @var ArrayCollection<int, ShipLogInterface>
192
     */
193
    #[OneToMany(targetEntity: 'ShipLog', mappedBy: 'spacecraft', fetch: 'EXTRA_LAZY')]
194
    #[OrderBy(['id' => 'DESC'])]
195
    private Collection $logbook;
196
197
    #[OneToOne(targetEntity: 'ShipTakeover', mappedBy: 'source')]
198
    private ?ShipTakeoverInterface $takeoverActive = null;
199
200
    #[OneToOne(targetEntity: 'ShipTakeover', mappedBy: 'target')]
201
    private ?ShipTakeoverInterface $takeoverPassive = null;
202
203 3
    public function __construct()
204
    {
205 3
        $this->crew = new ArrayCollection();
206 3
        $this->systems = new ArrayCollection();
207 3
        $this->storage = new ArrayCollection();
208 3
        $this->logbook = new ArrayCollection();
209
    }
210
211 43
    #[Override]
212
    public function getId(): int
213
    {
214 43
        if ($this->id === null) {
215
            throw new RuntimeException(sprintf('entity "%s" not yet persisted', $this->getName()));
216
        }
217
218 43
        return $this->id;
219
    }
220
221 1
    #[Override]
222
    public function getUserId(): int
223
    {
224 1
        return $this->user_id;
225
    }
226
227 7
    #[Override]
228
    public function getUserName(): string
229
    {
230 7
        return $this->getUser()->getName();
231
    }
232
233
    #[Override]
234
    public function getFlightDirection(): ?DirectionEnum
235
    {
236
        return $this->direction;
237
    }
238
239
    #[Override]
240
    public function setFlightDirection(DirectionEnum $direction): SpacecraftInterface
241
    {
242
        $this->direction = $direction;
243
        return $this;
244
    }
245
246 35
    #[Override]
247
    public function getName(): string
248
    {
249 35
        return $this->name;
250
    }
251
252
    #[Override]
253
    public function setName(string $name): SpacecraftInterface
254
    {
255
        $this->name = $name;
256
        return $this;
257
    }
258
259 2
    #[Override]
260
    public function getLssMode(): SpacecraftLssModeEnum
261
    {
262 2
        return $this->lss_mode;
263
    }
264
265
    #[Override]
266
    public function setLssMode(SpacecraftLssModeEnum $lssMode): SpacecraftInterface
267
    {
268
        $this->lss_mode = $lssMode;
269
        return $this;
270
    }
271
272 6
    #[Override]
273
    public function getAlertState(): SpacecraftAlertStateEnum
274
    {
275 6
        return $this->alvl;
276
    }
277
278
    #[Override]
279
    public function setAlertState(SpacecraftAlertStateEnum $state): SpacecraftInterface
280
    {
281
        $this->alvl = $state;
282
        return $this;
283
    }
284
285 15
    #[Override]
286
    public function getHull(): int
287
    {
288 15
        return $this->huelle;
289
    }
290
291
    #[Override]
292
    public function setHuell(int $hull): SpacecraftInterface
293
    {
294
        $this->huelle = $hull;
295
        return $this;
296
    }
297
298 15
    #[Override]
299
    public function getMaxHull(): int
300
    {
301 15
        return $this->max_huelle;
302
    }
303
304
    #[Override]
305
    public function setMaxHuell(int $maxHull): SpacecraftInterface
306
    {
307
        $this->max_huelle = $maxHull;
308
        return $this;
309
    }
310
311 9
    #[Override]
312
    public function getShield(): int
313
    {
314 9
        return $this->schilde;
315
    }
316
317
    #[Override]
318
    public function setShield(int $schilde): SpacecraftInterface
319
    {
320
        $this->schilde = $schilde;
321
        return $this;
322
    }
323
324
    #[Override]
325
    public function setMaxShield(int $maxShields): SpacecraftInterface
326
    {
327
        $this->max_schilde = $maxShields;
328
        return $this;
329
    }
330
331 1
    #[Override]
332
    public function getDatabaseId(): ?int
333
    {
334 1
        return $this->database_id;
335
    }
336
337
    #[Override]
338
    public function setDatabaseId(?int $databaseEntryId): SpacecraftInterface
339
    {
340
        $this->database_id = $databaseEntryId;
341
        return $this;
342
    }
343
344 2
    #[Override]
345
    public function isDestroyed(): bool
346
    {
347 2
        return $this->is_destroyed;
348
    }
349
350
    #[Override]
351
    public function setIsDestroyed(bool $isDestroyed): SpacecraftInterface
352
    {
353
        $this->is_destroyed = $isDestroyed;
354
        return $this;
355
    }
356
357
    #[Override]
358
    public function isDisabled(): bool
359
    {
360
        return $this->disabled;
361
    }
362
363
    #[Override]
364
    public function setDisabled(bool $isDisabled): SpacecraftInterface
365
    {
366
        $this->disabled = $isDisabled;
367
        return $this;
368
    }
369
370
    #[Override]
371
    public function setHitChance(int $hitChance): SpacecraftInterface
372
    {
373
        $this->hit_chance = $hitChance;
374
        return $this;
375
    }
376
377
    #[Override]
378
    public function setEvadeChance(int $evadeChance): SpacecraftInterface
379
    {
380
        $this->evade_chance = $evadeChance;
381
        return $this;
382
    }
383
384
    /**
385
     * proportional to tractor beam system status
386
     */
387 1
    #[Override]
388
    public function getTractorPayload(): int
389
    {
390 1
        if (!$this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)) {
391
            return 0;
392
        }
393
394 1
        return (int) (ceil($this->getRump()->getTractorPayload()
395 1
            * $this->getSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)->getStatus() / 100));
396
    }
397
398 5
    #[Override]
399
    public function getState(): SpacecraftStateEnum
400
    {
401 5
        return $this->state;
402
    }
403
404
    #[Override]
405
    public function setState(SpacecraftStateEnum $state): SpacecraftInterface
406
    {
407
        $this->state = $state;
408
        return $this;
409
    }
410
411 1
    #[Override]
412
    public function isInEmergency(): bool
413
    {
414 1
        return $this->in_emergency;
415
    }
416
417
    #[Override]
418
    public function setIsInEmergency(bool $inEmergency): SpacecraftInterface
419
    {
420
        $this->in_emergency = $inEmergency;
421
        return $this;
422
    }
423
424 13
    #[Override]
425
    public function getCrewAssignments(): Collection
426
    {
427 13
        return $this->crew;
428
    }
429
430 47
    #[Override]
431
    public function getUser(): UserInterface
432
    {
433 47
        return $this->user;
434
    }
435
436
    #[Override]
437
    public function setUser(UserInterface $user): SpacecraftInterface
438
    {
439
        $this->user = $user;
440
        return $this;
441
    }
442
443 2
    #[Override]
444
    public function getModules(): array
445
    {
446 2
        $modules = [];
447
448 2
        $buildplan = $this->getBuildplan();
449 2
        if ($buildplan === null) {
450
            return $modules;
451
        }
452
453 2
        foreach ($buildplan->getModulesOrdered() as $obj) {
454 2
            $module = $obj->getModule();
455 2
            $index = $module->getType() === SpacecraftModuleTypeEnum::SPECIAL ? $module->getId() : $module->getType()->value;
456 2
            $modules[$index] = $module;
457
        }
458
459 2
        return $modules;
460
    }
461
462 3
    #[Override]
463
    public function getTorpedoStorage(): ?TorpedoStorageInterface
464
    {
465 3
        return $this->torpedoStorage;
466
    }
467
468
    #[Override]
469
    public function setTorpedoStorage(?TorpedoStorageInterface $torpedoStorage): SpacecraftInterface
470
    {
471
        $this->torpedoStorage = $torpedoStorage;
472
        return $this;
473
    }
474
475 15
    #[Override]
476
    public function getStorage(): Collection
477
    {
478 15
        return $this->storage;
479
    }
480
481 39
    #[Override]
482
    public function getLocation(): MapInterface|StarSystemMapInterface
483
    {
484
        if (
485 39
            $this->location instanceof MapInterface
486 39
            || $this->location instanceof StarSystemMapInterface
487
        ) {
488 39
            return $this->location;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->location returns the type Stu\Orm\Entity\LocationInterface which includes types incompatible with the type-hinted return Stu\Orm\Entity\MapInterf...\StarSystemMapInterface.
Loading history...
489
        }
490
491
        throw new RuntimeException('unknown type');
492
    }
493
494 1
    #[Override]
495
    public function getLogbook(): Collection
496
    {
497 1
        return $this->logbook;
498
    }
499
500 4
    #[Override]
501
    public function getTakeoverActive(): ?ShipTakeoverInterface
502
    {
503 4
        return $this->takeoverActive;
504
    }
505
506
    #[Override]
507
    public function setTakeoverActive(?ShipTakeoverInterface $takeover): SpacecraftInterface
508
    {
509
        $this->takeoverActive = $takeover;
510
511
        return $this;
512
    }
513
514 4
    #[Override]
515
    public function getTakeoverPassive(): ?ShipTakeoverInterface
516
    {
517 4
        return $this->takeoverPassive;
518
    }
519
520
    #[Override]
521
    public function setTakeoverPassive(?ShipTakeoverInterface $takeover): SpacecraftInterface
522
    {
523
        $this->takeoverPassive = $takeover;
524
525
        return $this;
526
    }
527
528 3
    #[Override]
529
    public function setLocation(LocationInterface $location): SpacecraftInterface
530
    {
531 3
        $this->location = $location;
532
533 3
        return $this;
534
    }
535
536 11
    #[Override]
537
    public function getBeamFactor(): int
538
    {
539 11
        return $this->getRump()->getBeamFactor();
540
    }
541
542 13
    #[Override]
543
    public function getBuildplan(): ?SpacecraftBuildplanInterface
544
    {
545 13
        return $this->buildplan;
546
    }
547
548
    #[Override]
549
    public function setBuildplan(?SpacecraftBuildplanInterface $spacecraftBuildplan): SpacecraftInterface
550
    {
551
        $this->buildplan = $spacecraftBuildplan;
552
        return $this;
553
    }
554
555 39
    #[Override]
556
    public function getSystems(): Collection
557
    {
558 39
        return $this->systems;
559
    }
560
561 2
    #[Override]
562
    public function getTractoredShip(): ?ShipInterface
563
    {
564 2
        return $this->tractoredShip;
565
    }
566
567
    #[Override]
568
    public function setTractoredShip(?ShipInterface $ship): SpacecraftInterface
569
    {
570
        $this->tractoredShip = $ship;
571
        return $this;
572
    }
573
574 8
    #[Override]
575
    public function getHoldingWeb(): ?TholianWebInterface
576
    {
577 8
        return $this->holdingWeb;
578
    }
579
580
    #[Override]
581
    public function setHoldingWeb(?TholianWebInterface $web): SpacecraftInterface
582
    {
583
        $this->holdingWeb = $web;
584
585
        return $this;
586
    }
587
588 1
    #[Override]
589
    public function getRepairRate(): int
590
    {
591
        // @todo
592 1
        return 100;
593
    }
594
595 36
    #[Override]
596
    public function getRump(): SpacecraftRumpInterface
597
    {
598 36
        return $this->rump;
599
    }
600
601 19
    #[Override]
602
    public function getRumpId(): int
603
    {
604 19
        return $this->getRump()->getId();
605
    }
606
607 19
    #[Override]
608
    public function getRumpName(): string
609
    {
610 19
        return $this->getRump()->getName();
611
    }
612
613
    #[Override]
614
    public function setRump(SpacecraftRumpInterface $shipRump): SpacecraftInterface
615
    {
616
        $this->rump = $shipRump;
617
        return $this;
618
    }
619
620 2
    #[Override]
621
    public function getHref(): string
622
    {
623 2
        $moduleView = $this->getType()->getModuleView();
624 2
        if ($moduleView === null) {
625
            return '';
626
        }
627
628 2
        return sprintf(
629 2
            '%s?%s=1&id=%d',
630 2
            $moduleView->getPhpPage(),
631 2
            $this->getType()->getViewIdentifier(),
632 2
            $this->getId()
633 2
        );
634
    }
635
636
    #[Override]
637
    public function __toString(): string
638
    {
639
        if ($this->id !== null) {
640
            return sprintf(
641
                "id: %d, name: %s,\nhull: %d/%d, shields %d/%d,\nevadeChance: %d, hitChance: %d",
642
                $this->getId(),
643
                $this->getName(),
644
                $this->huelle,
645
                $this->max_huelle,
646
                $this->schilde,
647
                $this->max_schilde,
648
                $this->evade_chance,
649
                $this->hit_chance
650
            );
651
        }
652
653
        return $this->getName();
654
    }
655
}
656