|
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\OneToMany; |
|
15
|
|
|
use Doctrine\ORM\Mapping\OrderBy; |
|
16
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
17
|
|
|
use Stu\Component\Building\BuildingFunctionEnum; |
|
18
|
|
|
use Stu\Component\Colony\Shields\ColonyShieldingManager; |
|
19
|
|
|
use Stu\Orm\Repository\BuildingRepository; |
|
20
|
|
|
|
|
21
|
|
|
#[Table(name: 'stu_buildings')] |
|
22
|
|
|
#[Index(name: 'eps_production_idx', columns: ['eps_proc'])] |
|
23
|
|
|
#[Index(name: 'buildmenu_column_idx', columns: ['bm_col'])] |
|
24
|
|
|
#[Index(name: 'building_research_idx', columns: ['research_id'])] |
|
25
|
|
|
#[Entity(repositoryClass: BuildingRepository::class)] |
|
26
|
|
|
class Building |
|
27
|
|
|
{ |
|
28
|
|
|
#[Id] |
|
29
|
|
|
#[Column(type: 'integer')] |
|
30
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
31
|
|
|
private int $id; |
|
32
|
|
|
|
|
33
|
|
|
#[Column(type: 'string')] |
|
34
|
|
|
private string $name = ''; |
|
35
|
|
|
|
|
36
|
|
|
#[Column(type: 'smallint')] |
|
37
|
|
|
private int $lager = 0; |
|
38
|
|
|
|
|
39
|
|
|
#[Column(type: 'smallint')] |
|
40
|
|
|
private int $eps = 0; |
|
41
|
|
|
|
|
42
|
|
|
#[Column(type: 'smallint')] |
|
43
|
|
|
private int $eps_cost = 0; |
|
44
|
|
|
|
|
45
|
|
|
#[Column(type: 'smallint')] |
|
46
|
|
|
private int $eps_proc = 0; |
|
47
|
|
|
|
|
48
|
|
|
#[Column(type: 'smallint')] |
|
49
|
|
|
private int $bev_pro = 0; |
|
50
|
|
|
|
|
51
|
|
|
#[Column(type: 'smallint')] |
|
52
|
|
|
private int $bev_use = 0; |
|
53
|
|
|
|
|
54
|
|
|
#[Column(type: 'smallint')] |
|
55
|
|
|
private int $integrity = 0; |
|
56
|
|
|
|
|
57
|
|
|
#[Column(type: 'integer')] |
|
58
|
|
|
private int $research_id = 0; |
|
59
|
|
|
|
|
60
|
|
|
#[Column(type: 'boolean')] |
|
61
|
|
|
private bool $view = false; |
|
62
|
|
|
|
|
63
|
|
|
#[Column(type: 'integer')] |
|
64
|
|
|
private int $buildtime = 0; |
|
65
|
|
|
|
|
66
|
|
|
#[Column(type: 'smallint')] |
|
67
|
|
|
private int $blimit = 0; |
|
68
|
|
|
|
|
69
|
|
|
#[Column(type: 'smallint')] |
|
70
|
|
|
private int $bclimit = 0; |
|
71
|
|
|
|
|
72
|
|
|
#[Column(type: 'boolean')] |
|
73
|
|
|
private bool $is_activateable = false; |
|
74
|
|
|
|
|
75
|
|
|
#[Column(type: 'smallint')] |
|
76
|
|
|
private int $bm_col = 0; |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @var ArrayCollection<int, BuildingCost> |
|
80
|
|
|
*/ |
|
81
|
|
|
#[OneToMany(targetEntity: BuildingCost::class, mappedBy: 'building')] |
|
82
|
|
|
#[OrderBy(['commodity_id' => 'ASC'])] |
|
83
|
|
|
private Collection $costs; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @var ArrayCollection<int, BuildingFunction> |
|
87
|
|
|
*/ |
|
88
|
|
|
#[OneToMany(targetEntity: BuildingFunction::class, mappedBy: 'building', indexBy: 'function')] |
|
89
|
|
|
private Collection $functions; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @var ArrayCollection<int, BuildingCommodity> |
|
93
|
|
|
*/ |
|
94
|
|
|
#[OneToMany(targetEntity: BuildingCommodity::class, mappedBy: 'building', indexBy: 'commodity_id')] |
|
95
|
|
|
#[OrderBy(['commodity_id' => 'ASC'])] |
|
96
|
|
|
private Collection $commodities; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @var ArrayCollection<int, PlanetFieldTypeBuilding> |
|
100
|
|
|
*/ |
|
101
|
|
|
#[OneToMany(targetEntity: PlanetFieldTypeBuilding::class, mappedBy: 'building', indexBy: 'type')] |
|
102
|
|
|
private Collection $possibleFieldTypes; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @var ArrayCollection<int, ColonyClassRestriction> |
|
106
|
|
|
*/ |
|
107
|
|
|
#[OneToMany(mappedBy: 'building', targetEntity: ColonyClassRestriction::class)] |
|
108
|
|
|
private Collection $restrictions; |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
public function __construct() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->costs = new ArrayCollection(); |
|
114
|
|
|
$this->functions = new ArrayCollection(); |
|
115
|
|
|
$this->commodities = new ArrayCollection(); |
|
116
|
|
|
$this->possibleFieldTypes = new ArrayCollection(); |
|
117
|
|
|
$this->restrictions = new ArrayCollection(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
7 |
|
public function getId(): int |
|
121
|
|
|
{ |
|
122
|
7 |
|
return $this->id; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
8 |
|
public function getName(): string |
|
126
|
|
|
{ |
|
127
|
8 |
|
return $this->name; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
public function setName(string $name): Building |
|
131
|
|
|
{ |
|
132
|
|
|
$this->name = $name; |
|
133
|
|
|
return $this; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
2 |
|
public function getStorage(): int |
|
137
|
|
|
{ |
|
138
|
2 |
|
return $this->lager; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function setStorage(int $storage): Building |
|
142
|
|
|
{ |
|
143
|
|
|
$this->lager = $storage; |
|
144
|
|
|
return $this; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
2 |
|
public function getEpsStorage(): int |
|
148
|
|
|
{ |
|
149
|
2 |
|
return $this->eps; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setEpsStorage(int $epsStorage): Building |
|
153
|
|
|
{ |
|
154
|
|
|
$this->eps = $epsStorage; |
|
155
|
|
|
return $this; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
1 |
|
public function getEpsCost(): int |
|
159
|
|
|
{ |
|
160
|
1 |
|
return $this->eps_cost; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function setEpsCost(int $epsCost): Building |
|
164
|
|
|
{ |
|
165
|
|
|
$this->eps_cost = $epsCost; |
|
166
|
|
|
return $this; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
2 |
|
public function getEpsProduction(): int |
|
170
|
|
|
{ |
|
171
|
2 |
|
return $this->eps_proc; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function setEpsProduction(int $epsProduction): Building |
|
175
|
|
|
{ |
|
176
|
|
|
$this->eps_proc = $epsProduction; |
|
177
|
|
|
return $this; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
2 |
|
public function getHousing(): int |
|
181
|
|
|
{ |
|
182
|
2 |
|
return $this->bev_pro; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function setHousing(int $housing): Building |
|
186
|
|
|
{ |
|
187
|
|
|
$this->bev_pro = $housing; |
|
188
|
|
|
return $this; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
2 |
|
public function getWorkers(): int |
|
192
|
|
|
{ |
|
193
|
2 |
|
return $this->bev_use; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function setWorkers(int $workers): Building |
|
197
|
|
|
{ |
|
198
|
|
|
$this->bev_use = $workers; |
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
6 |
|
public function getIntegrity(): int |
|
203
|
|
|
{ |
|
204
|
6 |
|
return $this->integrity; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function setIntegrity(int $integrity): Building |
|
208
|
|
|
{ |
|
209
|
|
|
$this->integrity = $integrity; |
|
210
|
|
|
return $this; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
public function getResearchId(): int |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->research_id; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function setResearchId(int $researchId): Building |
|
219
|
|
|
{ |
|
220
|
|
|
$this->research_id = $researchId; |
|
221
|
|
|
return $this; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
public function getView(): bool |
|
225
|
|
|
{ |
|
226
|
|
|
return $this->view; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function setView(bool $view): Building |
|
230
|
|
|
{ |
|
231
|
|
|
$this->view = $view; |
|
232
|
|
|
return $this; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
1 |
|
public function getBuildtime(): int |
|
236
|
|
|
{ |
|
237
|
1 |
|
return $this->buildtime; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function setBuildtime(int $buildtime): Building |
|
241
|
|
|
{ |
|
242
|
|
|
$this->buildtime = $buildtime; |
|
243
|
|
|
return $this; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
1 |
|
public function getLimit(): int |
|
247
|
|
|
{ |
|
248
|
1 |
|
return $this->blimit; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public function setLimit(int $limit): Building |
|
252
|
|
|
{ |
|
253
|
|
|
$this->blimit = $limit; |
|
254
|
|
|
return $this; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
1 |
|
public function getLimitColony(): int |
|
258
|
|
|
{ |
|
259
|
1 |
|
return $this->bclimit; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function setLimitColony(int $limitColony): Building |
|
263
|
|
|
{ |
|
264
|
|
|
$this->bclimit = $limitColony; |
|
265
|
|
|
return $this; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
8 |
|
public function getIsActivateable(): bool |
|
269
|
|
|
{ |
|
270
|
8 |
|
return $this->is_activateable; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
public function setIsActivateable(bool $isActivateable): Building |
|
274
|
|
|
{ |
|
275
|
|
|
$this->is_activateable = $isActivateable; |
|
276
|
|
|
return $this; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
public function isActivateable(): bool |
|
280
|
|
|
{ |
|
281
|
|
|
return $this->getIsActivateable(); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
public function isViewable(): bool |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->getView(); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
public function getBuildingType(): int |
|
290
|
8 |
|
{ |
|
291
|
|
|
// return 0 for now |
|
292
|
8 |
|
return 0; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
public function getEpsProductionCss(): string |
|
296
|
|
|
{ |
|
297
|
|
|
if ($this->getEpsProduction() < 0) { |
|
298
|
|
|
return 'negative'; |
|
299
|
|
|
} |
|
300
|
6 |
|
if ($this->getEpsProduction() > 0) { |
|
301
|
|
|
return 'positive'; |
|
302
|
|
|
} |
|
303
|
6 |
|
return ''; |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
1 |
|
public function hasLimit(): bool |
|
307
|
|
|
{ |
|
308
|
1 |
|
return $this->getLimit() > 0; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
1 |
|
public function hasLimitColony(): bool |
|
312
|
1 |
|
{ |
|
313
|
|
|
return $this->getLimitColony() > 0; |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
/** |
|
317
|
1 |
|
* @return Collection<int, PlanetFieldTypeBuilding> |
|
318
|
|
|
*/ |
|
319
|
1 |
|
public function getBuildableFields(): Collection |
|
320
|
|
|
{ |
|
321
|
|
|
return $this->possibleFieldTypes; |
|
322
|
1 |
|
} |
|
323
|
|
|
|
|
324
|
1 |
|
/** |
|
325
|
|
|
* @return Collection<int, BuildingCost> |
|
326
|
|
|
*/ |
|
327
|
|
|
public function getCosts(): Collection |
|
328
|
|
|
{ |
|
329
|
|
|
return $this->costs; |
|
330
|
5 |
|
} |
|
331
|
|
|
|
|
332
|
5 |
|
/** |
|
333
|
|
|
* @return Collection<int, BuildingCommodity> |
|
334
|
|
|
*/ |
|
335
|
|
|
public function getCommodities(): Collection |
|
336
|
|
|
{ |
|
337
|
|
|
return $this->commodities; |
|
338
|
1 |
|
} |
|
339
|
|
|
|
|
340
|
1 |
|
/** |
|
341
|
|
|
* @return Collection<int, BuildingFunction> |
|
342
|
|
|
*/ |
|
343
|
|
|
public function getFunctions(): Collection |
|
344
|
|
|
{ |
|
345
|
|
|
return $this->functions; |
|
346
|
2 |
|
} |
|
347
|
|
|
|
|
348
|
2 |
|
public function isRemovable(): bool |
|
349
|
|
|
{ |
|
350
|
|
|
return !$this->getFunctions()->containsKey(BuildingFunctionEnum::COLONY_CENTRAL->value) |
|
351
|
|
|
&& !$this->getFunctions()->containsKey(BuildingFunctionEnum::BASE_CAMP->value); |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
5 |
|
public function getShieldCapacity(): ?int |
|
355
|
|
|
{ |
|
356
|
5 |
|
if ($this->getFunctions()->containsKey(BuildingFunctionEnum::SHIELD_GENERATOR->value) === true) { |
|
357
|
|
|
return ColonyShieldingManager::SHIELD_GENERATOR_CAPACITY; |
|
358
|
|
|
} |
|
359
|
1 |
|
|
|
360
|
|
|
if ($this->getFunctions()->containsKey(BuildingFunctionEnum::SHIELD_BATTERY->value) === true) { |
|
361
|
1 |
|
return ColonyShieldingManager::SHIELD_BATTERY_CAPACITY; |
|
362
|
1 |
|
} |
|
363
|
|
|
return null; |
|
364
|
|
|
} |
|
365
|
2 |
|
|
|
366
|
|
|
/** |
|
367
|
2 |
|
* @return Collection<int, ColonyClassRestriction> |
|
368
|
|
|
*/ |
|
369
|
|
|
public function getRestrictions(): Collection |
|
370
|
|
|
{ |
|
371
|
2 |
|
return $this->restrictions; |
|
372
|
|
|
} |
|
373
|
|
|
} |
|
374
|
|
|
|