Passed
Push — master ( 48bfaa...170129 )
by Nico
25:44
created

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