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