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

SpacecraftRump::getEvadeChance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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\Table;
18
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...
19
use Stu\Component\Spacecraft\SpacecraftRumpEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Spacecraft\SpacecraftRumpEnum 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...
20
use Stu\Orm\Repository\SpacecraftRumpRepository;
21
22
#[Table(name: 'stu_rump')]
23
#[Index(name: 'rump_category_idx', columns: ['category_id'])]
24
#[Index(name: 'rump_role_idx', columns: ['role_id'])]
25
#[Entity(repositoryClass: SpacecraftRumpRepository::class)]
26
class SpacecraftRump implements SpacecraftRumpInterface
27
{
28
    #[Id]
29
    #[Column(type: 'integer')]
30
    #[GeneratedValue(strategy: 'IDENTITY')]
31
    private int $id;
32
33
    #[column(type: 'integer')]
34
    private int $category_id;
35
36
    #[column(type: 'integer', nullable: true)]
37
    private ?int $role_id = 0;
38
39
    #[column(type: 'smallint')]
40
    private int $evade_chance = 0;
41
42
    #[column(type: 'smallint')]
43
    private int $hit_chance = 0;
44
45
    #[column(type: 'smallint')]
46
    private int $module_level = 0;
47
48
    #[column(type: 'smallint')]
49
    private int $base_crew = 0;
50
51
    #[column(type: 'smallint')]
52
    private int $base_eps = 0;
53
54
    #[column(type: 'smallint')]
55
    private int $base_reactor = 0;
56
57
    #[column(type: 'integer')]
58
    private int $base_hull = 0;
59
60
    #[column(type: 'integer')]
61
    private int $base_shield = 0;
62
63
    #[column(type: 'smallint')]
64
    private int $base_damage = 0;
65
66
    #[column(type: 'smallint')]
67
    private int $base_sensor_range = 0;
68
69
    #[column(type: 'smallint')]
70
    private int $base_torpedo_storage = 0;
71
72
    #[column(type: 'smallint')]
73
    private int $phaser_volleys = 0;
74
75
    #[column(type: 'smallint')]
76
    private int $phaser_hull_damage_factor = 0;
77
78
    #[column(type: 'smallint')]
79
    private int $phaser_shield_damage_factor = 0;
80
81
    #[column(type: 'smallint')]
82
    private int $torpedo_level = 0;
83
84
    #[column(type: 'smallint')]
85
    private int $torpedo_volleys = 0;
86
87
    #[Column(type: 'string')]
88
    private string $name = '';
89
90
    #[Column(type: 'boolean')]
91
    private bool $is_buildable;
92
93
    #[Column(type: 'boolean')]
94
    private bool $is_npc;
95
96
    #[column(type: 'smallint')]
97
    private int $eps_cost = 0;
98
99
    #[column(type: 'integer')]
100
    private int $storage = 0;
101
102
    #[column(type: 'smallint')]
103
    private int $slots = 0;
104
105
    #[column(type: 'integer')]
106
    private int $buildtime = 0;
107
108
    #[column(type: 'smallint', nullable: true)]
109
    private ?int $needed_workbees = null;
110
111
    #[column(type: 'smallint')]
112
    private int $sort = 0;
113
114
    #[column(type: 'integer', nullable: true)]
115
    private ?int $database_id = 0;
116
117
    #[column(type: 'integer', nullable: true)]
118
    private ?int $commodity_id = 0;
119
120
    #[column(type: 'smallint')]
121
    private int $flight_ecost = 0;
122
123
    #[column(type: 'smallint')]
124
    private int $beam_factor = 0;
125
126
    #[column(type: 'smallint')]
127
    private int $special_slots = 0;
128
129
    #[column(type: 'smallint')]
130
    private int $shuttle_slots = 0;
131
132
    #[column(type: 'integer')]
133
    private int $tractor_mass = 1;
134
135
    #[column(type: 'integer')]
136
    private int $tractor_payload = 100;
137
138
    #[Column(type: 'integer')]
139
    private int $prestige;
140
141
    #[Column(type: 'integer')]
142
    private int $base_warpdrive = 0;
143
144
    #[Column(type: 'boolean', nullable: true)]
145
    private ?bool $npc_buildable = true;
146
147
    #[ManyToOne(targetEntity: 'ShipRumpRole')]
148
    #[JoinColumn(name: 'role_id', referencedColumnName: 'id')]
149
    private ?ShipRumpRoleInterface $shipRumpRole = null;
150
151
    /**
152
     * @var ArrayCollection<int, ShipRumpSpecialInterface>
153
     */
154
    #[OneToMany(targetEntity: 'ShipRumpSpecial', mappedBy: 'spacecraftRump', indexBy: 'special')]
155
    private Collection $specialAbilities;
156
157
    #[ManyToOne(targetEntity: 'ShipRumpCategory')]
158
    #[JoinColumn(name: 'category_id', referencedColumnName: 'id')]
159
    private ShipRumpCategoryInterface $shipRumpCategory;
160
161
    #[ManyToOne(targetEntity: 'Commodity')]
162
    #[JoinColumn(name: 'commodity_id', referencedColumnName: 'id')]
163
    private ?CommodityInterface $commodity = null;
164
165
    #[ManyToOne(targetEntity: 'DatabaseEntry')]
166
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
167
    private ?DatabaseEntryInterface $databaseEntry = null;
168
169
    /**
170
     * @var ArrayCollection<int, ShipRumpCostInterface>
171
     */
172
    #[OneToMany(targetEntity: 'ShipRumpCost', mappedBy: 'spacecraftRump')]
173
    private Collection $buildingCosts;
174
175
    /**
176
     * @var ArrayCollection<int, BuildplanHangarInterface>
177
     */
178
    #[OneToMany(targetEntity: 'BuildplanHangar', mappedBy: 'spacecraftRump')]
179
    private Collection $startHangar;
180
181
    public function __construct()
182
    {
183
        $this->buildingCosts = new ArrayCollection();
184
        $this->startHangar = new ArrayCollection();
185
        $this->specialAbilities = new ArrayCollection();
186
    }
187
188 39
    #[Override]
189
    public function getId(): int
190
    {
191 39
        return $this->id;
192
    }
193
194
    #[Override]
195
    public function setCategoryId(int $categoryId): SpacecraftRumpInterface
196
    {
197
        $this->category_id = $categoryId;
198
199
        return $this;
200
    }
201
202 17
    #[Override]
203
    public function getCategoryId(): int
204
    {
205 17
        return $this->category_id;
206
    }
207
208 19
    #[Override]
209
    public function getRoleId(): ?int
210
    {
211 19
        return $this->role_id;
212
    }
213
214
    #[Override]
215
    public function setRoleId(?int $roleId): SpacecraftRumpInterface
216
    {
217
        $this->role_id = $roleId;
218
        return $this;
219
    }
220
221 3
    #[Override]
222
    public function getEvadeChance(): int
223
    {
224 3
        return $this->evade_chance;
225
    }
226
227
    #[Override]
228
    public function setEvadeChance(int $evadeChance): SpacecraftRumpInterface
229
    {
230
        $this->evade_chance = $evadeChance;
231
        return $this;
232
    }
233
234 4
    #[Override]
235
    public function getHitChance(): int
236
    {
237 4
        return $this->hit_chance;
238
    }
239
240
    #[Override]
241
    public function setHitChance(int $hitChance): SpacecraftRumpInterface
242
    {
243
        $this->hit_chance = $hitChance;
244
        return $this;
245
    }
246
247 4
    #[Override]
248
    public function getModuleLevel(): int
249
    {
250 4
        return $this->module_level;
251
    }
252
253
    #[Override]
254
    public function setModuleLevel(int $moduleLevel): SpacecraftRumpInterface
255
    {
256
        $this->module_level = $moduleLevel;
257
        return $this;
258
    }
259
260 11
    #[Override]
261
    public function getBaseCrew(): int
262
    {
263 11
        return $this->base_crew;
264
    }
265
266
    #[Override]
267
    public function setBaseCrew(int $baseCrew): SpacecraftRumpInterface
268
    {
269
        $this->base_crew = $baseCrew;
270
        return $this;
271
    }
272
273 4
    #[Override]
274
    public function getBaseEps(): int
275
    {
276 4
        return $this->base_eps;
277
    }
278
279
    #[Override]
280
    public function setBaseEps(int $baseEps): SpacecraftRumpInterface
281
    {
282
        $this->base_eps = $baseEps;
283
        return $this;
284
    }
285
286 4
    #[Override]
287
    public function getBaseReactor(): int
288
    {
289 4
        return $this->base_reactor;
290
    }
291
292
    #[Override]
293
    public function setBaseReactor(int $baseReactor): SpacecraftRumpInterface
294
    {
295
        $this->base_reactor = $baseReactor;
296
        return $this;
297
    }
298
299 4
    #[Override]
300
    public function getBaseHull(): int
301
    {
302 4
        return $this->base_hull;
303
    }
304
305
    #[Override]
306
    public function setBaseHull(int $baseHull): SpacecraftRumpInterface
307
    {
308
        $this->base_hull = $baseHull;
309
        return $this;
310
    }
311
312 4
    #[Override]
313
    public function getBaseShield(): int
314
    {
315 4
        return $this->base_shield;
316
    }
317
318
    #[Override]
319
    public function setBaseShield(int $baseShield): SpacecraftRumpInterface
320
    {
321
        $this->base_shield = $baseShield;
322
        return $this;
323
    }
324
325 4
    #[Override]
326
    public function getBaseDamage(): int
327
    {
328 4
        return $this->base_damage;
329
    }
330
331 5
    #[Override]
332
    public function getBaseSensorRange(): int
333
    {
334 5
        return $this->base_sensor_range;
335
    }
336
337
    #[Override]
338
    public function setBaseSensorRange(int $baseSensorRange): SpacecraftRumpInterface
339
    {
340
        $this->base_sensor_range = $baseSensorRange;
341
        return $this;
342
    }
343
344 8
    #[Override]
345
    public function getBaseTorpedoStorage(): int
346
    {
347 8
        return $this->base_torpedo_storage;
348
    }
349
350
    #[Override]
351
    public function setBaseTorpedoStorage(int $baseTorpedoStorage): SpacecraftRumpInterface
352
    {
353
        $this->base_torpedo_storage = $baseTorpedoStorage;
354
        return $this;
355
    }
356
357 17
    #[Override]
358
    public function getBeamFactor(): int
359
    {
360 17
        return $this->beam_factor;
361
    }
362
363
    #[Override]
364
    public function setBeamFactor(int $beamFactor): SpacecraftRumpInterface
365
    {
366
        $this->beam_factor = $beamFactor;
367
        return $this;
368
    }
369
370 3
    #[Override]
371
    public function getSpecialSlots(): int
372
    {
373 3
        return $this->special_slots;
374
    }
375
376
    #[Override]
377
    public function setSpecialSlots(int $specialSlots): SpacecraftRumpInterface
378
    {
379
        $this->special_slots = $specialSlots;
380
        return $this;
381
    }
382
383 2
    #[Override]
384
    public function getShuttleSlots(): int
385
    {
386 2
        return $this->shuttle_slots;
387
    }
388
389
    #[Override]
390
    public function setShuttleSlots(int $shuttleSlots): SpacecraftRumpInterface
391
    {
392
        $this->shuttle_slots = $shuttleSlots;
393
        return $this;
394
    }
395
396 2
    #[Override]
397
    public function getTractorMass(): int
398
    {
399 2
        return $this->tractor_mass;
400
    }
401
402 2
    #[Override]
403
    public function getTractorPayload(): int
404
    {
405 2
        return $this->tractor_payload;
406
    }
407
408 3
    #[Override]
409
    public function getBaseWarpDrive(): int
410
    {
411 3
        return $this->base_warpdrive;
412
    }
413
414
    #[Override]
415
    public function setBaseWarpDrive(int $baseWarpDrive): SpacecraftRumpInterface
416
    {
417
        $this->base_warpdrive = $baseWarpDrive;
418
        return $this;
419
    }
420
421 6
    #[Override]
422
    public function getPhaserVolleys(): int
423
    {
424 6
        return $this->phaser_volleys;
425
    }
426
427
    #[Override]
428
    public function setPhaserVolleys(int $phaserVolleys): SpacecraftRumpInterface
429
    {
430
        $this->phaser_volleys = $phaserVolleys;
431
        return $this;
432
    }
433
434
    #[Override]
435
    public function getPhaserHullDamageFactor(): int
436
    {
437
        return $this->phaser_hull_damage_factor;
438
    }
439
440
    #[Override]
441
    public function setPhaserHullDamageFactor(int $phaserHullDamageFactor): SpacecraftRumpInterface
442
    {
443
        $this->phaser_hull_damage_factor = $phaserHullDamageFactor;
444
        return $this;
445
    }
446
447
    #[Override]
448
    public function getPhaserShieldDamageFactor(): int
449
    {
450
        return $this->phaser_shield_damage_factor;
451
    }
452
453
    #[Override]
454
    public function setPhaserShieldDamageFactor(int $phaserShieldDamageFactor): SpacecraftRumpInterface
455
    {
456
        $this->phaser_shield_damage_factor = $phaserShieldDamageFactor;
457
        return $this;
458
    }
459
460 6
    #[Override]
461
    public function getTorpedoLevel(): int
462
    {
463 6
        return $this->torpedo_level;
464
    }
465
466
    #[Override]
467
    public function setTorpedoLevel(int $torpedoLevel): SpacecraftRumpInterface
468
    {
469
        $this->torpedo_level = $torpedoLevel;
470
        return $this;
471
    }
472
473 6
    #[Override]
474
    public function getTorpedoVolleys(): int
475
    {
476 6
        return $this->torpedo_volleys;
477
    }
478
479
    #[Override]
480
    public function setTorpedoVolleys(int $torpedoVolleys): SpacecraftRumpInterface
481
    {
482
        $this->torpedo_volleys = $torpedoVolleys;
483
        return $this;
484
    }
485
486 26
    #[Override]
487
    public function getName(): string
488
    {
489 26
        return $this->name;
490
    }
491
492
    #[Override]
493
    public function setName(string $name): SpacecraftRumpInterface
494
    {
495
        $this->name = $name;
496
        return $this;
497
    }
498
499
    #[Override]
500
    public function getIsBuildable(): bool
501
    {
502
        return $this->is_buildable;
503
    }
504
505
    #[Override]
506
    public function setIsBuildable(bool $isBuildable): SpacecraftRumpInterface
507
    {
508
        $this->is_buildable = $isBuildable;
509
        return $this;
510
    }
511
512 1
    #[Override]
513
    public function getIsNpc(): bool
514
    {
515 1
        return $this->is_npc;
516
    }
517
518
    #[Override]
519
    public function setIsNpc(bool $isNpc): SpacecraftRumpInterface
520
    {
521
        $this->is_npc = $isNpc;
522
        return $this;
523
    }
524
525 4
    #[Override]
526
    public function getEpsCost(): int
527
    {
528 4
        return $this->eps_cost;
529
    }
530
531
    #[Override]
532
    public function setEpsCost(int $energyCosts): SpacecraftRumpInterface
533
    {
534
        $this->eps_cost = $energyCosts;
535
        return $this;
536
    }
537
538 19
    #[Override]
539
    public function getStorage(): int
540
    {
541 19
        return $this->storage;
542
    }
543
544
    #[Override]
545
    public function setStorage(int $storage): SpacecraftRumpInterface
546
    {
547
        $this->storage = $storage;
548
        return $this;
549
    }
550
551 2
    #[Override]
552
    public function getDockingSlots(): int
553
    {
554 2
        return $this->slots;
555
    }
556
557
    #[Override]
558
    public function setDockingSlots(int $slots): SpacecraftRumpInterface
559
    {
560
        $this->slots = $slots;
561
        return $this;
562
    }
563
564 4
    #[Override]
565
    public function getBuildtime(): int
566
    {
567 4
        return $this->buildtime;
568
    }
569
570
    #[Override]
571
    public function setBuildtime(int $buildtime): SpacecraftRumpInterface
572
    {
573
        $this->buildtime = $buildtime;
574
        return $this;
575
    }
576
577
    #[Override]
578
    public function getSort(): int
579
    {
580
        return $this->sort;
581
    }
582
583
    #[Override]
584
    public function setSort(int $sort): SpacecraftRumpInterface
585
    {
586
        $this->sort = $sort;
587
        return $this;
588
    }
589
590
    #[Override]
591
    public function getDatabaseId(): ?int
592
    {
593
        return $this->database_id;
594
    }
595
596
    #[Override]
597
    public function getCommodityId(): ?int
598
    {
599
        return $this->commodity_id;
600
    }
601
602
    #[Override]
603
    public function setCommodityId(?int $commodityId): SpacecraftRumpInterface
604
    {
605
        $this->commodity_id = $commodityId;
606
        return $this;
607
    }
608
609 8
    #[Override]
610
    public function getFlightEcost(): int
611
    {
612 8
        return $this->flight_ecost;
613
    }
614
615
    #[Override]
616
    public function setFlightEcost(int $flightEcost): SpacecraftRumpInterface
617
    {
618
        $this->flight_ecost = $flightEcost;
619
        return $this;
620
    }
621
622 5
    #[Override]
623
    public function getShipRumpRole(): ?ShipRumpRoleInterface
624
    {
625 5
        return $this->shipRumpRole;
626
    }
627
628
    #[Override]
629
    public function setShipRumpRole(?ShipRumpRoleInterface $shipRumpRole): SpacecraftRumpInterface
630
    {
631
        $this->shipRumpRole = $shipRumpRole;
632
        return $this;
633
    }
634
635 4
    #[Override]
636
    public function getShipRumpCategory(): ShipRumpCategoryInterface
637
    {
638 4
        return $this->shipRumpCategory;
639
    }
640
641
    #[Override]
642
    public function setShipRumpCategory(ShipRumpCategoryInterface $shipRumpCategory): SpacecraftRumpInterface
643
    {
644
        $this->shipRumpCategory = $shipRumpCategory;
645
        return $this;
646
    }
647
648
    #[Override]
649
    public function getCommodity(): ?CommodityInterface
650
    {
651
        return $this->commodity;
652
    }
653
654
    #[Override]
655
    public function setCommodity(?CommodityInterface $commodity): SpacecraftRumpInterface
656
    {
657
        $this->commodity = $commodity;
658
        return $this;
659
    }
660
661
    #[Override]
662
    public function getNeededWorkbees(): ?int
663
    {
664
        return $this->needed_workbees;
665
    }
666
667
    #[Override]
668
    public function getNeededRepairWorkbees(): ?int
669
    {
670
        return  $this->getNeededWorkbees() / 5;
671
    }
672
673
    #[Override]
674
    public function getDatabaseEntry(): ?DatabaseEntryInterface
675
    {
676
        return $this->databaseEntry;
677
    }
678
679
    #[Override]
680
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): SpacecraftRumpInterface
681
    {
682
        $this->databaseEntry = $databaseEntry;
683
        return $this;
684
    }
685
686
    #[Override]
687
    public function getPrestige(): int
688
    {
689
        return $this->prestige;
690
    }
691
692
    #[Override]
693
    public function isEscapePods(): bool
694
    {
695
        return $this->getCategoryId() === SpacecraftRumpEnum::SHIP_CATEGORY_ESCAPE_PODS;
696
    }
697
698 1
    #[Override]
699
    public function isShipyard(): bool
700
    {
701 1
        return $this->getCategoryId() === SpacecraftRumpEnum::SHIP_CATEGORY_STATION
702 1
            && $this->getRoleId() === SpacecraftRumpEnum::SHIP_ROLE_SHIPYARD;
703
    }
704
705 1
    #[Override]
706
    public function isStation(): bool
707
    {
708 1
        return $this->getCategoryId() === SpacecraftRumpEnum::SHIP_CATEGORY_STATION;
709
    }
710
711
    #[Override]
712
    public function isWorkbee(): bool
713
    {
714
        $commodity = $this->getCommodity();
715
716
        return $commodity !== null && $commodity->isWorkbee();
717
    }
718
719
    #[Override]
720
    public function getStartHangar(): Collection
721
    {
722
        return $this->startHangar;
723
    }
724
725 4
    #[Override]
726
    public function getBuildingCosts(): Collection
727
    {
728 4
        return $this->buildingCosts;
729
    }
730
731
    #[Override]
732
    public function hasSpecialAbility(int $value): bool
733
    {
734
        return $this->specialAbilities->containsKey($value);
735
    }
736
737 1
    #[Override]
738
    public function getFractionId(): int
739
    {
740
        //last digit of id shows fraction id
741 1
        return $this->getId() % 10;
742
    }
743
744
    /**
745
     * @return Collection<int, ShipRumpSpecialInterface>
746
     */
747
    #[Override]
748
    public function getSpecialAbilities(): Collection
749
    {
750
        return $this->specialAbilities;
751
    }
752
753
    #[Override]
754
    public function getNpcBuildable(): ?bool
755
    {
756
        return $this->npc_buildable;
757
    }
758
759
    #[Override]
760
    public function setNpcBuildable(?bool $npcBuildable): SpacecraftRumpInterface
761
    {
762
        $this->npc_buildable = $npcBuildable;
763
        return $this;
764
    }
765
}
766