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\JoinColumn; |
14
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
15
|
|
|
use Doctrine\ORM\Mapping\OneToOne; |
16
|
|
|
use Doctrine\ORM\Mapping\Table; |
17
|
|
|
use Stu\Component\Colony\ColonyEnum; |
18
|
|
|
use Stu\Component\Colony\ColonyTypeEnum; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @Entity(repositoryClass="Stu\Orm\Repository\ColonyClassRepository") |
22
|
|
|
* @Table( |
23
|
|
|
* name="stu_colonies_classes", |
24
|
|
|
* indexes={ |
25
|
|
|
* } |
26
|
|
|
* ) |
27
|
|
|
**/ |
28
|
|
|
class ColonyClass implements ColonyClassInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @Id |
32
|
|
|
* @Column(type="integer") |
33
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
34
|
|
|
* |
35
|
|
|
*/ |
36
|
|
|
private int $id; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Column(type="string") |
40
|
|
|
* |
41
|
|
|
*/ |
42
|
|
|
private string $name = ''; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @Column(type="integer") |
46
|
|
|
* |
47
|
|
|
*/ |
48
|
|
|
private int $type; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @Column(type="integer", nullable=true) |
52
|
|
|
* |
53
|
|
|
*/ |
54
|
|
|
private ?int $database_id = null; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Column(type="json") |
58
|
|
|
* |
59
|
|
|
* @var array<int> |
60
|
|
|
*/ |
61
|
|
|
private array $colonizeable_fields = []; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Column(type="smallint") * |
65
|
|
|
* |
66
|
|
|
*/ |
67
|
|
|
private int $bev_growth_rate = 0; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Column(type="smallint") * |
71
|
|
|
* |
72
|
|
|
*/ |
73
|
|
|
private int $special = 0; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @Column(type="boolean") |
77
|
|
|
* |
78
|
|
|
*/ |
79
|
|
|
private bool $allow_start = false; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @Column(type="integer") |
83
|
|
|
* |
84
|
|
|
*/ |
85
|
|
|
private int $min_rot = 1; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @Column(type="integer") |
89
|
|
|
* |
90
|
|
|
*/ |
91
|
|
|
private int $max_rot = 1; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var DatabaseEntryInterface|null |
95
|
|
|
* |
96
|
|
|
* @OneToOne(targetEntity="DatabaseEntry") |
97
|
|
|
* @JoinColumn(name="database_id", referencedColumnName="id") |
98
|
|
|
*/ |
99
|
|
|
private $databaseEntry; |
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var ArrayCollection<int, ColonyClassDepositInterface> |
103
|
|
|
* |
104
|
|
|
* @OneToMany(targetEntity="ColonyClassDeposit", mappedBy="colonyClass", indexBy="commodity_id") |
105
|
|
|
*/ |
106
|
|
|
private Collection $colonyClassDeposits; |
107
|
|
|
|
108
|
|
|
public function __construct() |
109
|
|
|
{ |
110
|
|
|
$this->colonyClassDeposits = new ArrayCollection(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getId(): int |
114
|
|
|
{ |
115
|
|
|
return $this->id; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getName(): string |
119
|
|
|
{ |
120
|
|
|
return $this->name; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function setName(string $name): ColonyClassInterface |
124
|
|
|
{ |
125
|
|
|
$this->name = $name; |
126
|
|
|
|
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getType(): int |
131
|
|
|
{ |
132
|
|
|
return $this->type; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function isPlanet(): bool |
136
|
|
|
{ |
137
|
|
|
return $this->getType() === ColonyTypeEnum::COLONY_TYPE_PLANET; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function isMoon(): bool |
141
|
|
|
{ |
142
|
|
|
return $this->getType() === ColonyTypeEnum::COLONY_TYPE_MOON; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function isAsteroid(): bool |
146
|
|
|
{ |
147
|
|
|
return $this->getType() === ColonyTypeEnum::COLONY_TYPE_ASTEROID; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function getDatabaseId(): ?int |
151
|
|
|
{ |
152
|
|
|
return $this->database_id; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function setDatabaseId(?int $databaseId): ColonyClassInterface |
156
|
|
|
{ |
157
|
|
|
$this->database_id = $databaseId; |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function getColonizeableFields(): array |
163
|
|
|
{ |
164
|
|
|
return $this->colonizeable_fields; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function setColonizeableFields(array $colonizeableFields): ColonyClassInterface |
168
|
|
|
{ |
169
|
|
|
$this->colonizeable_fields = $colonizeableFields; |
170
|
|
|
|
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function getBevGrowthRate(): int |
175
|
|
|
{ |
176
|
|
|
return $this->bev_growth_rate; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function setBevGrowthRate(int $bevGroethRate): ColonyClassInterface |
180
|
|
|
{ |
181
|
|
|
$this->bev_growth_rate = $bevGroethRate; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function getSpecialId(): int |
187
|
|
|
{ |
188
|
|
|
return $this->special; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
public function setSpecialId(int $specialId): ColonyClassInterface |
192
|
|
|
{ |
193
|
|
|
$this->special = $specialId; |
194
|
|
|
|
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function getAllowStart(): bool |
199
|
|
|
{ |
200
|
|
|
return $this->allow_start; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function setAllowStart(bool $allowStart): ColonyClassInterface |
204
|
|
|
{ |
205
|
|
|
$this->allow_start = $allowStart; |
206
|
|
|
|
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function getColonyClassDeposits(): Collection |
211
|
|
|
{ |
212
|
|
|
return $this->colonyClassDeposits; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public function hasRing(): bool |
216
|
|
|
{ |
217
|
|
|
return $this->getSpecialId() == ColonyEnum::COLONY_CLASS_SPECIAL_RING; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function getMinRotation(): int |
221
|
|
|
{ |
222
|
|
|
return $this->min_rot; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function setMinRotation(int $rotation): ColonyClassInterface |
226
|
|
|
{ |
227
|
|
|
$this->min_rot = $rotation; |
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function getMaxRotation(): int |
233
|
|
|
{ |
234
|
|
|
return $this->max_rot; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function setMaxRotation(int $rotation): ColonyClassInterface |
238
|
|
|
{ |
239
|
|
|
$this->max_rot = $rotation; |
240
|
|
|
|
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
|