Passed
Push — dev ( 205f61...d7fd40 )
by Nico
08:56
created

ShipRump::setBaseWarpDrive()   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 = null;
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
     * @Column(type="integer")
258
     *
259
     */
260
    private int $base_warpdrive = 0;
261
262
    /**
263
     *
264
     * @ManyToOne(targetEntity="ShipRumpRole")
265
     * @JoinColumn(name="role_id", referencedColumnName="id")
266
     */
267
    private ?ShipRumpRoleInterface $shipRumpRole = null;
268
269
    /**
270
     * @var Collection<int, ShipRumpSpecialInterface>
271
     *
272
     * @OneToMany(targetEntity="ShipRumpSpecial", mappedBy="shipRump", indexBy="special")
273
     */
274
    private Collection $specialAbilities;
275
276
    /**
277
     *
278
     * @ManyToOne(targetEntity="ShipRumpCategory")
279
     * @JoinColumn(name="category_id", referencedColumnName="id")
280
     */
281
    private ShipRumpCategoryInterface $shipRumpCategory;
282
283
    /**
284
     *
285
     * @ManyToOne(targetEntity="Commodity")
286
     * @JoinColumn(name="commodity_id", referencedColumnName="id")
287
     */
288
    private ?CommodityInterface $commodity = null;
289
290
    /**
291
     *
292
     * @ManyToOne(targetEntity="DatabaseEntry")
293
     * @JoinColumn(name="database_id", referencedColumnName="id")
294
     */
295
    private ?DatabaseEntryInterface $databaseEntry = null;
296
297
    /**
298
     * @var ArrayCollection<int, ShipRumpCostInterface>
299
     *
300
     * @OneToMany(targetEntity="ShipRumpCost", mappedBy="shipRump")
301
     */
302
    private Collection $buildingCosts;
303
304
    /**
305
     * @var ArrayCollection<int, BuildplanHangarInterface>
306
     *
307
     * @OneToMany(targetEntity="BuildplanHangar", mappedBy="shipRump")
308
     */
309
    private Collection $startHangar;
310
311
    public function __construct()
312
    {
313
        $this->buildingCosts = new ArrayCollection();
314
        $this->startHangar = new ArrayCollection();
315
        $this->specialAbilities = new ArrayCollection();
316
    }
317
318
    public function getId(): int
319
    {
320
        return $this->id;
321
    }
322
323
    public function setCategoryId(int $categoryId): ShipRumpInterface
324
    {
325
        $this->category_id = $categoryId;
326
327
        return $this;
328
    }
329
330
    public function getCategoryId(): int
331
    {
332
        return $this->category_id;
333
    }
334
335
    public function getRoleId(): ?int
336
    {
337
        return $this->role_id;
338
    }
339
340
    public function setRoleId(?int $roleId): ShipRumpInterface
341
    {
342
        $this->role_id = $roleId;
343
        return $this;
344
    }
345
346
    public function getEvadeChance(): int
347
    {
348
        return $this->evade_chance;
349
    }
350
351
    public function setEvadeChance(int $evadeChance): ShipRumpInterface
352
    {
353
        $this->evade_chance = $evadeChance;
354
        return $this;
355
    }
356
357
    public function getHitChance(): int
358
    {
359
        return $this->hit_chance;
360
    }
361
362
    public function setHitChance(int $hitChance): ShipRumpInterface
363
    {
364
        $this->hit_chance = $hitChance;
365
        return $this;
366
    }
367
368
    public function getModuleLevel(): int
369
    {
370
        return $this->module_level;
371
    }
372
373
    public function setModuleLevel(int $moduleLevel): ShipRumpInterface
374
    {
375
        $this->module_level = $moduleLevel;
376
        return $this;
377
    }
378
379
    public function getBaseCrew(): int
380
    {
381
        return $this->base_crew;
382
    }
383
384
    public function setBaseCrew(int $baseCrew): ShipRumpInterface
385
    {
386
        $this->base_crew = $baseCrew;
387
        return $this;
388
    }
389
390
    public function getBaseEps(): int
391
    {
392
        return $this->base_eps;
393
    }
394
395
    public function setBaseEps(int $baseEps): ShipRumpInterface
396
    {
397
        $this->base_eps = $baseEps;
398
        return $this;
399
    }
400
401
    public function getBaseReactor(): int
402
    {
403
        return $this->base_reactor;
404
    }
405
406
    public function setBaseReactor(int $baseReactor): ShipRumpInterface
407
    {
408
        $this->base_reactor = $baseReactor;
409
        return $this;
410
    }
411
412
    public function getBaseHull(): int
413
    {
414
        return $this->base_hull;
415
    }
416
417
    public function setBaseHull(int $baseHull): ShipRumpInterface
418
    {
419
        $this->base_hull = $baseHull;
420
        return $this;
421
    }
422
423
    public function getBaseShield(): int
424
    {
425
        return $this->base_shield;
426
    }
427
428
    public function setBaseShield(int $baseShield): ShipRumpInterface
429
    {
430
        $this->base_shield = $baseShield;
431
        return $this;
432
    }
433
434
    public function getBaseDamage(): int
435
    {
436
        return $this->base_damage;
437
    }
438
439
    public function setBaseDamage(int $baseDamage): ShipRumpInterface
440
    {
441
        $this->base_damage = $baseDamage;
442
        return $this;
443
    }
444
445
    public function getBaseSensorRange(): int
446
    {
447
        return $this->base_sensor_range;
448
    }
449
450
    public function setBaseSensorRange(int $baseSensorRange): ShipRumpInterface
451
    {
452
        $this->base_sensor_range = $baseSensorRange;
453
        return $this;
454
    }
455
456
    public function getBaseTorpedoStorage(): int
457
    {
458
        return $this->base_torpedo_storage;
459
    }
460
461
    public function setBaseTorpedoStorage(int $baseTorpedoStorage): ShipRumpInterface
462
    {
463
        $this->base_torpedo_storage = $baseTorpedoStorage;
464
        return $this;
465
    }
466
467
    public function getBeamFactor(): int
468
    {
469
        return $this->beam_factor;
470
    }
471
472
    public function setBeamFactor(int $beamFactor): ShipRumpInterface
473
    {
474
        $this->beam_factor = $beamFactor;
475
        return $this;
476
    }
477
478
    public function getSpecialSlots(): int
479
    {
480
        return $this->special_slots;
481
    }
482
483
    public function setSpecialSlots(int $specialSlots): ShipRumpInterface
484
    {
485
        $this->special_slots = $specialSlots;
486
        return $this;
487
    }
488
489
    public function getShuttleSlots(): int
490
    {
491
        return $this->shuttle_slots;
492
    }
493
494
    public function setShuttleSlots(int $shuttleSlots): ShipRumpInterface
495
    {
496
        $this->shuttle_slots = $shuttleSlots;
497
        return $this;
498
    }
499
500
    public function getTractorMass(): int
501
    {
502
        return $this->tractor_mass;
503
    }
504
505
    public function getTractorPayload(): int
506
    {
507
        return $this->tractor_payload;
508
    }
509
510
    public function getBaseWarpDrive(): int
511
    {
512
        return $this->base_warpdrive;
513
    }
514
515
    public function setBaseWarpDrive(int $baseWarpDrive): ShipRumpInterface
516
    {
517
        $this->base_warpdrive = $baseWarpDrive;
518
        return $this;
519
    }
520
521
    public function getPhaserVolleys(): int
522
    {
523
        return $this->phaser_volleys;
524
    }
525
526
    public function setPhaserVolleys(int $phaserVolleys): ShipRumpInterface
527
    {
528
        $this->phaser_volleys = $phaserVolleys;
529
        return $this;
530
    }
531
532
    public function getPhaserHullDamageFactor(): int
533
    {
534
        return $this->phaser_hull_damage_factor;
535
    }
536
537
    public function setPhaserHullDamageFactor(int $phaserHullDamageFactor): ShipRumpInterface
538
    {
539
        $this->phaser_hull_damage_factor = $phaserHullDamageFactor;
540
        return $this;
541
    }
542
543
    public function getPhaserShieldDamageFactor(): int
544
    {
545
        return $this->phaser_shield_damage_factor;
546
    }
547
548
    public function setPhaserShieldDamageFactor(int $phaserShieldDamageFactor): ShipRumpInterface
549
    {
550
        $this->phaser_shield_damage_factor = $phaserShieldDamageFactor;
551
        return $this;
552
    }
553
554
    public function getTorpedoLevel(): int
555
    {
556
        return $this->torpedo_level;
557
    }
558
559
    public function setTorpedoLevel(int $torpedoLevel): ShipRumpInterface
560
    {
561
        $this->torpedo_level = $torpedoLevel;
562
        return $this;
563
    }
564
565
    public function getTorpedoVolleys(): int
566
    {
567
        return $this->torpedo_volleys;
568
    }
569
570
    public function setTorpedoVolleys(int $torpedoVolleys): ShipRumpInterface
571
    {
572
        $this->torpedo_volleys = $torpedoVolleys;
573
        return $this;
574
    }
575
576
    public function getName(): string
577
    {
578
        return $this->name;
579
    }
580
581
    public function setName(string $name): ShipRumpInterface
582
    {
583
        $this->name = $name;
584
        return $this;
585
    }
586
587
    public function getIsBuildable(): bool
588
    {
589
        return $this->is_buildable;
590
    }
591
592
    public function setIsBuildable(bool $isBuildable): ShipRumpInterface
593
    {
594
        $this->is_buildable = $isBuildable;
595
        return $this;
596
    }
597
598
    public function getIsNpc(): bool
599
    {
600
        return $this->is_npc;
601
    }
602
603
    public function setIsNpc(bool $isNpc): ShipRumpInterface
604
    {
605
        $this->is_npc = $isNpc;
606
        return $this;
607
    }
608
609
    public function getEpsCost(): int
610
    {
611
        return $this->eps_cost;
612
    }
613
614
    public function setEpsCost(int $energyCosts): ShipRumpInterface
615
    {
616
        $this->eps_cost = $energyCosts;
617
        return $this;
618
    }
619
620
    public function getStorage(): int
621
    {
622
        return $this->storage;
623
    }
624
625
    public function setStorage(int $storage): ShipRumpInterface
626
    {
627
        $this->storage = $storage;
628
        return $this;
629
    }
630
631
    public function getDockingSlots(): int
632
    {
633
        return $this->slots;
634
    }
635
636
    public function setDockingSlots(int $slots): ShipRumpInterface
637
    {
638
        $this->slots = $slots;
639
        return $this;
640
    }
641
642
    public function getBuildtime(): int
643
    {
644
        return $this->buildtime;
645
    }
646
647
    public function setBuildtime(int $buildtime): ShipRumpInterface
648
    {
649
        $this->buildtime = $buildtime;
650
        return $this;
651
    }
652
653
    public function getSort(): int
654
    {
655
        return $this->sort;
656
    }
657
658
    public function setSort(int $sort): ShipRumpInterface
659
    {
660
        $this->sort = $sort;
661
        return $this;
662
    }
663
664
    public function getDatabaseId(): ?int
665
    {
666
        return $this->database_id;
667
    }
668
669
    public function setDatabaseId(?int $databaseId): ShipRumpInterface
670
    {
671
        $this->database_id = $databaseId;
672
        return $this;
673
    }
674
675
    public function getCommodityId(): ?int
676
    {
677
        return $this->commodity_id;
678
    }
679
680
    public function setCommodityId(?int $commodityId): ShipRumpInterface
681
    {
682
        $this->commodity_id = $commodityId;
683
        return $this;
684
    }
685
686
    public function getFlightEcost(): int
687
    {
688
        return $this->flight_ecost;
689
    }
690
691
    public function setFlightEcost(int $flightEcost): ShipRumpInterface
692
    {
693
        $this->flight_ecost = $flightEcost;
694
        return $this;
695
    }
696
697
    public function getShipRumpRole(): ?ShipRumpRoleInterface
698
    {
699
        return $this->shipRumpRole;
700
    }
701
702
    public function setShipRumpRole(?ShipRumpRoleInterface $shipRumpRole): ShipRumpInterface
703
    {
704
        $this->shipRumpRole = $shipRumpRole;
705
        return $this;
706
    }
707
708
    public function getShipRumpCategory(): ShipRumpCategoryInterface
709
    {
710
        return $this->shipRumpCategory;
711
    }
712
713
    public function setShipRumpCategory(ShipRumpCategoryInterface $shipRumpCategory): ShipRumpInterface
714
    {
715
        $this->shipRumpCategory = $shipRumpCategory;
716
        return $this;
717
    }
718
719
    public function getCommodity(): ?CommodityInterface
720
    {
721
        return $this->commodity;
722
    }
723
724
    public function setCommodity(?CommodityInterface $commodity): ShipRumpInterface
725
    {
726
        $this->commodity = $commodity;
727
        return $this;
728
    }
729
730
    public function getNeededWorkbees(): ?int
731
    {
732
        return $this->needed_workbees;
733
    }
734
735
    public function getNeededRepairWorkbees(): ?int
736
    {
737
        return  $this->getNeededWorkbees() / 5;
738
    }
739
740
    public function getDatabaseEntry(): ?DatabaseEntryInterface
741
    {
742
        return $this->databaseEntry;
743
    }
744
745
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): ShipRumpInterface
746
    {
747
        $this->databaseEntry = $databaseEntry;
748
        return $this;
749
    }
750
751
    public function getPrestige(): int
752
    {
753
        return $this->prestige;
754
    }
755
756
    public function isTrumfield(): bool
757
    {
758
        return $this->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_DEBRISFIELD;
759
    }
760
761
    public function isEscapePods(): bool
762
    {
763
        return $this->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_ESCAPE_PODS;
764
    }
765
766
    public function isShipyard(): bool
767
    {
768
        return $this->getCategoryId() === ShipRumpEnum::SHIP_CATEGORY_STATION
769
            && $this->getRoleId() === ShipRumpEnum::SHIP_ROLE_SHIPYARD;
770
    }
771
772
    public function getStartHangar(): Collection
773
    {
774
        return $this->startHangar;
775
    }
776
777
    public function getBuildingCosts(): Collection
778
    {
779
        return $this->buildingCosts;
780
    }
781
782
    public function hasSpecialAbility(int $value): bool
783
    {
784
        return $this->specialAbilities->containsKey($value);
785
    }
786
787
    public function getFractionId(): int
788
    {
789
        //last digit of id shows fraction id
790
        return $this->getId() % 10;
791
    }
792
793
    /**
794
     * @return Collection<int, ShipRumpSpecialInterface>
795
     */
796
    public function getSpecialAbilities(): Collection
797
    {
798
        return $this->specialAbilities;
799
    }
800
}
801