Passed
Push — dev ( 857b11...ce9e84 )
by Janko
16:15
created

Colony::getTwilightZone()   B

Complexity

Conditions 8
Paths 33

Size

Total Lines 37
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 11.8345

Importance

Changes 0
Metric Value
cc 8
eloc 24
nc 33
nop 1
dl 0
loc 37
ccs 14
cts 23
cp 0.6087
crap 11.8345
rs 8.4444
c 0
b 0
f 0
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;
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...
21
use Stu\Component\Colony\ColonyMenuEnum;
22
use Stu\Component\Game\ModuleEnum;
23
use Stu\Component\Game\TimeConstants;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Game\TimeConstants 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...
24
use Stu\Lib\Colony\PlanetFieldHostTypeEnum;
25
use Stu\Lib\Transfer\CommodityTransfer;
26
use Stu\Lib\Transfer\TransferEntityTypeEnum;
27
use Stu\Module\Colony\View\ShowColony\ShowColony;
28
use Stu\Module\PlayerSetting\Lib\UserEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Module\PlayerSetting\Lib\UserEnum 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...
29
use Stu\Orm\Repository\ColonyRepository;
30
31
#[Table(name: 'stu_colonies')]
32
#[Index(name: 'colony_user_idx', columns: ['user_id'])]
33
#[Index(name: 'colony_classes_idx', columns: ['colonies_classes_id'])]
34
#[Index(name: 'colony_sys_map_idx', columns: ['starsystem_map_id'])]
35
#[Entity(repositoryClass: ColonyRepository::class)]
36
class Colony implements ColonyInterface
37
{
38
    #[Id]
39
    #[Column(type: 'integer')]
40
    #[GeneratedValue(strategy: 'IDENTITY')]
41
    private int $id;
42
43
    #[Column(type: 'integer')]
44
    private int $colonies_classes_id = 0;
45
46
    #[Column(type: 'integer')]
47
    private int $user_id = 0;
48
49
    #[Column(type: 'integer')]
50
    private int $starsystem_map_id = 0;
0 ignored issues
show
introduced by
The private property $starsystem_map_id is not used, and could be removed.
Loading history...
51
52
    #[Column(type: 'string')]
53
    private string $name = '';
54
55
    #[Column(type: 'string', length: 100)]
56
    private string $planet_name = '';
57
58
    #[Column(type: 'integer', length: 5)]
59
    private int $bev_work = 0;
60
61
    #[Column(type: 'integer', length: 5)]
62
    private int $bev_free = 0;
63
64
    #[Column(type: 'integer', length: 5)]
65
    private int $bev_max = 0;
66
67
    #[Column(type: 'integer', length: 5)]
68
    private int $eps = 0;
69
70
    #[Column(type: 'integer', length: 5)]
71
    private int $max_eps = 0;
72
73
    #[Column(type: 'integer', length: 5)]
74
    private int $max_storage = 0;
75
76
    #[Column(type: 'text', nullable: true)]
77
    private ?string $mask = null;
78
79
    #[Column(type: 'integer', nullable: true)]
80
    private ?int $database_id = null;
81
82
    #[Column(type: 'integer', length: 5)]
83
    private int $populationlimit = 0;
84
85
    #[Column(type: 'boolean')]
86
    private bool $immigrationstate = true;
87
88
    #[Column(type: 'integer', length: 6, nullable: true)]
89
    private ?int $shields = 0;
90
91
    #[Column(type: 'integer', length: 6, nullable: true)]
92
    private ?int $shield_frequency = 0;
93
94
    #[Column(type: 'integer', length: 3, nullable: true)]
95
    private ?int $torpedo_type = null;
0 ignored issues
show
introduced by
The private property $torpedo_type is not used, and could be removed.
Loading history...
96
97
    #[Column(type: 'integer', length: 3)]
98
    private int $rotation_factor = 1;
99
100
    #[Column(type: 'integer', length: 2)]
101
    private int $surface_width = 0;
102
103
    #[ManyToOne(targetEntity: 'ColonyClass')]
104
    #[JoinColumn(name: 'colonies_classes_id', referencedColumnName: 'id')]
105
    private ColonyClassInterface $colonyClass;
106
107
    #[OneToOne(targetEntity: 'StarSystemMap', inversedBy: 'colony')]
108
    #[JoinColumn(name: 'starsystem_map_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
109
    private StarSystemMapInterface $starsystem_map;
110
111
    #[ManyToOne(targetEntity: 'User')]
112
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id')]
113
    private UserInterface $user;
114
115
    /**
116
     * @var ArrayCollection<int, PlanetFieldInterface>
117
     */
118
    #[OneToMany(targetEntity: 'PlanetField', mappedBy: 'colony', indexBy: 'field_id', fetch: 'EXTRA_LAZY')]
119
    #[OrderBy(['field_id' => 'ASC'])]
120
    private Collection $planetFields;
121
122
    /**
123
     * @var ArrayCollection<int, StorageInterface>
124
     */
125
    #[OneToMany(targetEntity: 'Storage', mappedBy: 'colony', indexBy: 'commodity_id')]
126
    #[OrderBy(['commodity_id' => 'ASC'])]
127
    private Collection $storage;
128
129
    #[ManyToOne(targetEntity: 'TorpedoType')]
130
    #[JoinColumn(name: 'torpedo_type', referencedColumnName: 'id')]
131
    private ?TorpedoTypeInterface $torpedo = null;
132
133
    #[OneToOne(targetEntity: 'DatabaseEntry')]
134
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
135
    private ?DatabaseEntryInterface $databaseEntry;
136
137
    /**
138
     * @var ArrayCollection<int, FleetInterface>
139
     */
140
    #[OneToMany(targetEntity: 'Fleet', mappedBy: 'defendedColony')]
141
    private Collection $defenders;
142
143
    /**
144
     * @var ArrayCollection<int, FleetInterface>
145
     */
146
    #[OneToMany(targetEntity: 'Fleet', mappedBy: 'blockedColony')]
147
    private Collection $blockers;
148
149
    /**
150
     * @var ArrayCollection<int, CrewAssignmentInterface>
151
     */
152
    #[OneToMany(targetEntity: 'CrewAssignment', mappedBy: 'colony')]
153
    private Collection $crewAssignments;
154
155
    /**
156
     * @var ArrayCollection<int, CrewAssignmentInterface>
157
     */
158
    #[OneToMany(targetEntity: 'CrewTraining', mappedBy: 'colony')]
159
    private Collection $crewTrainings;
160
161
    /**
162
     * @var ArrayCollection<int, ColonyDepositMiningInterface>
163
     */
164
    #[OneToMany(targetEntity: 'ColonyDepositMining', mappedBy: 'colony')]
165
    #[OrderBy(['commodity_id' => 'ASC'])]
166
    private Collection $depositMinings;
167
168
    /** @var array<int, int> */
169
    private array $twilightZones = [];
170
171
    public function __construct()
172
    {
173
        $this->planetFields = new ArrayCollection();
174
        $this->storage = new ArrayCollection();
175
        $this->defenders = new ArrayCollection();
176
        $this->blockers = new ArrayCollection();
177
        $this->crewAssignments = new ArrayCollection();
178
        $this->crewTrainings = new ArrayCollection();
179
        $this->depositMinings = new ArrayCollection();
180
    }
181
182 45
    #[Override]
183
    public function getId(): int
184
    {
185 45
        return $this->id;
186
    }
187
188 9
    #[Override]
189
    public function getColonyClassId(): int
190
    {
191 9
        return $this->colonies_classes_id;
192
    }
193
194 39
    #[Override]
195
    public function getUserId(): int
196
    {
197 39
        return $this->user_id;
198
    }
199
200 10
    #[Override]
201
    public function getSx(): int
202
    {
203 10
        return $this->getStarsystemMap()->getSx();
204
    }
205
206 10
    #[Override]
207
    public function getSy(): int
208
    {
209 10
        return $this->getStarsystemMap()->getSy();
210
    }
211
212
    #[Override]
213
    public function getSystemsId(): int
214
    {
215
        return $this->getSystem()->getId();
216
    }
217
218 19
    #[Override]
219
    public function getName(): string
220
    {
221 19
        return $this->name;
222
    }
223
224 2
    #[Override]
225
    public function getNameAndSectorString(): string
226
    {
227 2
        return sprintf(
228 2
            '%s %s',
229 2
            $this->getName(),
230 2
            $this->getSectorString()
231 2
        );
232
    }
233
234 4
    #[Override]
235
    public function getSystemString(): string
236
    {
237 4
        return sprintf('%s-System (%s|%s)', $this->getSystem()->getName(), $this->getSystem()->getCx(), $this->getSystem()->getCy());
238
    }
239
240
    #[Override]
241
    public function setName(string $name): ColonyInterface
242
    {
243
        $this->name = $name;
244
        return $this;
245
    }
246
247 4
    #[Override]
248
    public function getPlanetName(): string
249
    {
250 4
        return $this->planet_name;
251
    }
252
253
    #[Override]
254
    public function setPlanetName(string $planet_name): ColonyInterface
255
    {
256
        $this->planet_name = $planet_name;
257
        return $this;
258
    }
259
260 10
    #[Override]
261
    public function getWorkers(): int
262
    {
263 10
        return $this->bev_work;
264
    }
265
266
    #[Override]
267
    public function setWorkers(int $bev_work): ColonyInterface
268
    {
269
        $this->bev_work = $bev_work;
270
        return $this;
271
    }
272
273 10
    #[Override]
274
    public function getWorkless(): int
275
    {
276 10
        return $this->bev_free;
277
    }
278
279
    #[Override]
280
    public function setWorkless(int $bev_free): ColonyInterface
281
    {
282
        $this->bev_free = $bev_free;
283
        return $this;
284
    }
285
286 5
    #[Override]
287
    public function getMaxBev(): int
288
    {
289 5
        return $this->bev_max;
290
    }
291
292
    #[Override]
293
    public function setMaxBev(int $bev_max): ColonyInterface
294
    {
295
        $this->bev_max = $bev_max;
296
        return $this;
297
    }
298
299 11
    #[Override]
300
    public function getEps(): int
301
    {
302 11
        return $this->eps;
303
    }
304
305
    #[Override]
306
    public function setEps(int $eps): ColonyInterface
307
    {
308
        $this->eps = $eps;
309
        return $this;
310
    }
311
312 9
    #[Override]
313
    public function getMaxEps(): int
314
    {
315 9
        return $this->max_eps;
316
    }
317
318
    #[Override]
319
    public function setMaxEps(int $max_eps): ColonyInterface
320
    {
321
        $this->max_eps = $max_eps;
322
        return $this;
323
    }
324
325 13
    #[Override]
326
    public function getMaxStorage(): int
327
    {
328 13
        return $this->max_storage;
329
    }
330
331
    #[Override]
332
    public function setMaxStorage(int $max_storage): ColonyInterface
333
    {
334
        $this->max_storage = $max_storage;
335
        return $this;
336
    }
337
338
    #[Override]
339
    public function getMask(): ?string
340
    {
341
        return $this->mask;
342
    }
343
344
    #[Override]
345
    public function setMask(?string $mask): ColonyInterface
346
    {
347
        $this->mask = $mask;
348
        return $this;
349
    }
350
351
    #[Override]
352
    public function getDatabaseId(): ?int
353
    {
354
        return $this->database_id;
355
    }
356
357
    #[Override]
358
    public function setDatabaseEntry(?DatabaseEntryInterface $entry): ColonyInterface
359
    {
360
        $this->databaseEntry = $entry;
361
        return $this;
362
    }
363
364 6
    #[Override]
365
    public function getPopulationlimit(): int
366
    {
367 6
        return $this->populationlimit;
368
    }
369
370
    #[Override]
371
    public function setPopulationlimit(int $populationlimit): ColonyInterface
372
    {
373
        $this->populationlimit = $populationlimit;
374
        return $this;
375
    }
376
377 6
    #[Override]
378
    public function getImmigrationstate(): bool
379
    {
380 6
        return $this->immigrationstate;
381
    }
382
383
    #[Override]
384
    public function setImmigrationstate(bool $immigrationstate): ColonyInterface
385
    {
386
        $this->immigrationstate = $immigrationstate;
387
        return $this;
388
    }
389
390
    #[Override]
391
    public function getShields(): ?int
392
    {
393
        return $this->shields;
394
    }
395
396
    #[Override]
397
    public function setShields(?int $shields): ColonyInterface
398
    {
399
        $this->shields = $shields;
400
        return $this;
401
    }
402
403 6
    #[Override]
404
    public function getTwilightZone(int $timestamp): int
405
    {
406 6
        if (array_key_exists($timestamp, $this->twilightZones)) {
407 6
            return $this->twilightZones[$timestamp];
408
        }
409
410 1
        $twilightZone = 0;
411
412 1
        $width = $this->getSurfaceWidth();
413 1
        $rotationTime = $this->getRotationTime();
414 1
        $colonyTimeSeconds = $this->getColonyTimeSeconds($timestamp);
415
416 1
        if ($this->getDayTimePrefix($timestamp) == 1) {
417
            $scaled = floor((((100 / ($rotationTime * 0.125)) * ($colonyTimeSeconds - $rotationTime * 0.25)) / 100) * $width);
418
            if ($scaled == 0) {
419
                $twilightZone = - (($width) - 1);
420
            } elseif ((int) - (($width) - ceil($scaled)) == 0) {
421
                $twilightZone = -1;
422
            } else {
423
                $twilightZone = (int) - (($width) - $scaled);
424
            }
425
        }
426 1
        if ($this->getDayTimePrefix($timestamp) == 2) {
427 1
            $twilightZone = $width;
428
        }
429 1
        if ($this->getDayTimePrefix($timestamp) == 3) {
430
            $scaled = floor((((100 / ($rotationTime * 0.125)) * ($colonyTimeSeconds - $rotationTime * 0.75)) / 100) * $width);
431
            $twilightZone = (int) ($width - $scaled);
432
        }
433 1
        if ($this->getDayTimePrefix($timestamp) == 4) {
434
            $twilightZone = 0;
435
        }
436
437 1
        $this->twilightZones[$timestamp] = $twilightZone;
438
439 1
        return $twilightZone;
440
    }
441
442
    #[Override]
443
    public function getShieldFrequency(): ?int
444
    {
445
        return $this->shield_frequency;
446
    }
447
448
    #[Override]
449
    public function setShieldFrequency(?int $shieldFrequency): ColonyInterface
450
    {
451
        $this->shield_frequency = $shieldFrequency;
452
        return $this;
453
    }
454
455
    #[Override]
456
    public function getTorpedo(): ?TorpedoTypeInterface
457
    {
458
        return $this->torpedo;
459
    }
460
461
    #[Override]
462
    public function setTorpedo(?TorpedoTypeInterface $torpedoType): ColonyInterface
463
    {
464
        $this->torpedo = $torpedoType;
465
        return $this;
466
    }
467
468 4
    #[Override]
469
    public function getRotationFactor(): int
470
    {
471 4
        return $this->rotation_factor;
472
    }
473
474
    #[Override]
475
    public function setRotationFactor(int $rotationFactor): ColonyInterface
476
    {
477
        $this->rotation_factor = $rotationFactor;
478
479
        return $this;
480
    }
481
482 4
    #[Override]
483
    public function getRotationTime(): int
484
    {
485 4
        return (int) (TimeConstants::ONE_DAY_IN_SECONDS * $this->getRotationFactor() / 100);
486
    }
487
488 4
    public function getColonyTimeSeconds(int $timestamp): int
489
    {
490 4
        return $timestamp % $this->getRotationTime();
491
    }
492
493 4
    #[Override]
494
    public function getColonyTimeHour(int $timestamp): ?string
495
    {
496 4
        $rotationTime = $this->getRotationTime();
497
498 4
        return sprintf("%02d", (int) floor(($rotationTime / 3600) * ($this->getColonyTimeSeconds($timestamp) / $rotationTime)));
499
    }
500
501 4
    #[Override]
502
    public function getColonyTimeMinute(int $timestamp): ?string
503
    {
504 4
        $rotationTime = $this->getRotationTime();
505
506 4
        return sprintf("%02d", (int) floor(60 * (($rotationTime / 3600) * ($this->getColonyTimeSeconds($timestamp) / $rotationTime) - ((int) $this->getColonyTimeHour($timestamp)))));
507
    }
508
509 4
    #[Override]
510
    public function getDayTimePrefix(int $timestamp): ?int
511
    {
512 4
        $daytimeprefix = null;
513 4
        $daypercent = (int) (($this->getColonyTimeSeconds($timestamp) / $this->getRotationTime()) * 100);
514 4
        if ($daypercent > 25 && $daypercent <= 37.5) {
515
            $daytimeprefix = 1; //Sonnenaufgang
516
        }
517 4
        if ($daypercent > 37.5 && $daypercent <= 75) {
518 4
            $daytimeprefix = 2; //Tag
519
        }
520 4
        if ($daypercent > 75 && $daypercent <= 87.5) {
521
            $daytimeprefix = 3; //Sonnenuntergang
522
        }
523 4
        if ($daypercent > 87.5 || $daypercent <= 25) {
524
            $daytimeprefix = 4; //Nacht
525
        }
526 4
        return $daytimeprefix;
527
    }
528
529 4
    #[Override]
530
    public function getDayTimeName(int $timestamp): ?string
531
    {
532 4
        $daytimename = null;
533 4
        if ($this->getDayTimePrefix($timestamp) == 1) {
534
            $daytimename = 'Morgen';
535
        }
536
537 4
        if ($this->getDayTimePrefix($timestamp) == 2) {
538 4
            $daytimename = 'Tag';
539
        }
540
541 4
        if ($this->getDayTimePrefix($timestamp) == 3) {
542
            $daytimename = 'Abend';
543
        }
544
545 4
        if ($this->getDayTimePrefix($timestamp) == 4) {
546
            $daytimename = 'Nacht';
547
        }
548 4
        return $daytimename;
549
    }
550
551 6
    #[Override]
552
    public function getSurfaceWidth(): int
553
    {
554 6
        return $this->surface_width;
555
    }
556
557
    #[Override]
558
    public function setSurfaceWidth(int $surfaceWidth): ColonyInterface
559
    {
560
        $this->surface_width = $surfaceWidth;
561
        return $this;
562
    }
563
564 22
    #[Override]
565
    public function getColonyClass(): ColonyClassInterface
566
    {
567 22
        return $this->colonyClass;
568
    }
569
570
    #[Override]
571
    public function setColonyClass(ColonyClassInterface $colonyClass): ColonyInterface
572
    {
573
        $this->colonyClass = $colonyClass;
574
        return $this;
575
    }
576
577 13
    #[Override]
578
    public function getStorageSum(): int
579
    {
580 13
        return array_reduce(
581 13
            $this->getStorage()->getValues(),
582 13
            fn(int $sum, StorageInterface $storage): int => $sum + $storage->getAmount(),
583 13
            0
584 13
        );
585
    }
586
587
    #[Override]
588
    public function storagePlaceLeft(): bool
589
    {
590
        return $this->getMaxStorage() > $this->getStorageSum();
591
    }
592
593 19
    #[Override]
594
    public function getStarsystemMap(): StarSystemMapInterface
595
    {
596 19
        return $this->starsystem_map;
597
    }
598
599 10
    #[Override]
600
    public function getLocation(): MapInterface|StarSystemMapInterface
601
    {
602 10
        return $this->getStarsystemMap();
603
    }
604
605
    #[Override]
606
    public function setStarsystemMap(StarSystemMapInterface $systemMap): ColonyInterface
607
    {
608
        $this->starsystem_map = $systemMap;
609
610
        return $this;
611
    }
612
613 10
    #[Override]
614
    public function getSystem(): StarSystemInterface
615
    {
616 10
        return $this->getStarsystemMap()->getSystem();
617
    }
618
619 2
    #[Override]
620
    public function getBeamFactor(): int
621
    {
622 2
        return 10;
623
    }
624
625 5
    #[Override]
626
    public function getPlanetFields(): Collection
627
    {
628 5
        return $this->planetFields;
629
    }
630
631 2
    #[Override]
632
    public function getBeamableStorage(): Collection
633
    {
634 2
        return CommodityTransfer::excludeNonBeamable($this->storage);
635
    }
636
637 20
    #[Override]
638
    public function getStorage(): Collection
639
    {
640 20
        return $this->storage;
641
    }
642
643 1
    #[Override]
644
    public function isDefended(): bool
645
    {
646 1
        return !$this->getDefenders()->isEmpty();
647
    }
648
649 1
    #[Override]
650
    public function getDefenders(): Collection
651
    {
652 1
        return $this->defenders;
653
    }
654
655 1
    #[Override]
656
    public function isBlocked(): bool
657
    {
658 1
        return !$this->getBlockers()->isEmpty();
659
    }
660
661 1
    #[Override]
662
    public function getBlockers(): Collection
663
    {
664 1
        return $this->blockers;
665
    }
666
667
    #[Override]
668
    public function getCrewAssignments(): Collection
669
    {
670
        return $this->crewAssignments;
671
    }
672
673 3
    #[Override]
674
    public function getCrewAssignmentAmount(): int
675
    {
676 3
        return $this->crewAssignments->count();
677
    }
678
679 1
    #[Override]
680
    public function getCrewTrainingAmount(): int
681
    {
682 1
        return $this->crewTrainings->count();
683
    }
684
685 5
    #[Override]
686
    public function getUserDepositMinings(): array
687
    {
688 5
        $result = [];
689
690 5
        foreach ($this->depositMinings as $deposit) {
691
            if ($deposit->getUser() === $this->getUser()) {
692
                $result[$deposit->getCommodity()->getId()] = $deposit;
693
            }
694
        }
695
696 5
        return $result;
697
    }
698
699 5
    #[Override]
700
    public function isFree(): bool
701
    {
702 5
        return $this->getUserId() === UserEnum::USER_NOONE;
703
    }
704
705 15
    #[Override]
706
    public function getUser(): UserInterface
707
    {
708 15
        return $this->user;
709
    }
710
711
    #[Override]
712
    public function setUser(UserInterface $user): ColonyInterface
713
    {
714
        $this->user = $user;
715
        return $this;
716
    }
717
718 10
    #[Override]
719
    public function getPopulation(): int
720
    {
721 10
        return $this->getWorkers() + $this->getWorkless();
722
    }
723
724 4
    #[Override]
725
    public function getFreeHousing(): int
726
    {
727 4
        return $this->getMaxBev() - $this->getPopulation();
728
    }
729
730
    #[Override]
731
    public function lowerEps(int $value): void
732
    {
733
        $this->setEps($this->getEps() - $value);
734
    }
735
736
    #[Override]
737
    public function upperEps(int $value): void
738
    {
739
        $this->setEps($this->getEps() + $value);
740
    }
741
742 2
    #[Override]
743
    public function getSectorString(): string
744
    {
745 2
        return $this->getStarsystemMap()->getSectorString();
746
    }
747
748 4
    #[Override]
749
    public function getDepositMinings(): Collection
750
    {
751 4
        return $this->depositMinings;
752
    }
753
754 12
    #[Override]
755
    public function getPlanetFieldHostIdentifier(): string
756
    {
757 12
        return 'colony';
758
    }
759
760 15
    #[Override]
761
    public function getPlanetFieldHostColumnIdentifier(): string
762
    {
763 15
        return 'colonies_id';
764
    }
765
766
    #[Override]
767
    public function isColony(): bool
768
    {
769
        return true;
770
    }
771
772 20
    #[Override]
773
    public function getHostType(): PlanetFieldHostTypeEnum
774
    {
775 20
        return PlanetFieldHostTypeEnum::COLONY;
776
    }
777
778
    #[Override]
779
    public function getDefaultViewIdentifier(): string
780
    {
781
        return ShowColony::VIEW_IDENTIFIER;
782
    }
783
784
    #[Override]
785
    public function isMenuAllowed(ColonyMenuEnum $menu): bool
786
    {
787
        return true;
788
    }
789
790 4
    #[Override]
791
    public function getTransferEntityType(): TransferEntityTypeEnum
792
    {
793 4
        return TransferEntityTypeEnum::COLONY;
794
    }
795
796
    #[Override]
797
    public function getHref(): string
798
    {
799
        return sprintf(
800
            '%s?%s=1&id=%d',
801
            ModuleEnum::COLONY->getPhpPage(),
802
            ShowColony::VIEW_IDENTIFIER,
803
            $this->getId()
804
        );
805
    }
806
807
    #[Override]
808
    public function getComponentParameters(): string
809
    {
810
        return sprintf(
811
            '&hosttype=%d&id=%d',
812
            $this->getHostType()->value,
813
            $this->getId()
814
        );
815
    }
816
}
817