Passed
Push — dev ( ef4569...47421a )
by Nico
06:55
created

ShipRump::setRoleId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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