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