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