|
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\Game\GameEnum; |
|
|
|
|
|
|
22
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
23
|
|
|
use Stu\Orm\Repository\UserRepository; |
|
24
|
|
|
|
|
25
|
|
|
#[Table(name: 'stu_user')] |
|
26
|
|
|
#[Index(name: 'user_alliance_idx', columns: ['allys_id'])] |
|
27
|
|
|
#[Entity(repositoryClass: UserRepository::class)] |
|
28
|
|
|
class User implements UserInterface |
|
29
|
|
|
{ |
|
30
|
|
|
#[Id] |
|
31
|
|
|
#[Column(type: 'integer')] |
|
32
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
33
|
|
|
private int $id; |
|
34
|
|
|
|
|
35
|
|
|
#[Column(type: 'string')] |
|
36
|
|
|
private string $username = ''; |
|
37
|
|
|
|
|
38
|
|
|
#[Column(type: 'smallint')] |
|
39
|
|
|
private int $state = UserEnum::USER_STATE_NEW; |
|
40
|
|
|
|
|
41
|
|
|
#[Column(type: 'integer')] |
|
42
|
|
|
private int $lastaction = 0; |
|
43
|
|
|
|
|
44
|
|
|
#[Column(type: 'integer')] |
|
45
|
|
|
private int $kn_lez = 0; |
|
46
|
|
|
|
|
47
|
|
|
#[Column(type: 'boolean')] |
|
48
|
|
|
private bool $vac_active = false; |
|
49
|
|
|
|
|
50
|
|
|
#[Column(type: 'integer')] |
|
51
|
|
|
private int $vac_request_date = 0; |
|
52
|
|
|
|
|
53
|
|
|
#[Column(type: 'text')] |
|
54
|
|
|
private string $description = ''; |
|
55
|
|
|
|
|
56
|
|
|
#[Column(type: 'text')] |
|
57
|
|
|
private string $sessiondata = ''; |
|
58
|
|
|
|
|
59
|
|
|
#[Column(type: 'integer')] |
|
60
|
|
|
private int $prestige = 0; |
|
61
|
|
|
|
|
62
|
|
|
#[Column(type: 'boolean')] |
|
63
|
|
|
private bool $deals = false; |
|
64
|
|
|
|
|
65
|
|
|
#[Column(type: 'integer', nullable: true)] |
|
66
|
|
|
private ?int $last_boarding = null; |
|
67
|
|
|
|
|
68
|
|
|
#[OneToOne(targetEntity: 'UserRegistration', mappedBy: 'user', cascade: ['all'])] |
|
69
|
|
|
private UserRegistrationInterface $registration; |
|
70
|
|
|
|
|
71
|
|
|
#[ManyToOne(targetEntity: 'Alliance', inversedBy: 'members')] |
|
72
|
|
|
#[JoinColumn(name: 'allys_id', referencedColumnName: 'id')] |
|
73
|
|
|
private ?AllianceInterface $alliance = null; |
|
74
|
|
|
|
|
75
|
|
|
#[ManyToOne(targetEntity: 'Faction')] |
|
76
|
|
|
#[JoinColumn(name: 'race', referencedColumnName: 'id')] |
|
77
|
|
|
private FactionInterface $faction; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var ArrayCollection<int, BuoyInterface> |
|
81
|
|
|
*/ |
|
82
|
|
|
#[OneToMany(targetEntity: 'Buoy', mappedBy: 'user')] |
|
83
|
|
|
private Collection $buoys; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @var ArrayCollection<int, UserAwardInterface> |
|
87
|
|
|
*/ |
|
88
|
|
|
#[OneToMany(targetEntity: 'UserAward', mappedBy: 'user', indexBy: 'award_id')] |
|
89
|
|
|
#[OrderBy(['award_id' => 'ASC'])] |
|
90
|
|
|
private Collection $awards; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @var ArrayCollection<int, ColonyInterface> |
|
94
|
|
|
*/ |
|
95
|
|
|
#[OneToMany(targetEntity: 'Colony', mappedBy: 'user', indexBy: 'id')] |
|
96
|
|
|
#[OrderBy(['colonies_classes_id' => 'ASC', 'id' => 'ASC'])] |
|
97
|
|
|
private Collection $colonies; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @var ArrayCollection<int, UserLayerInterface> |
|
101
|
|
|
*/ |
|
102
|
|
|
#[OneToMany(targetEntity: 'UserLayer', mappedBy: 'user', indexBy: 'layer_id')] |
|
103
|
|
|
private Collection $userLayers; |
|
104
|
|
|
|
|
105
|
|
|
#[OneToOne(targetEntity: 'UserLock', mappedBy: 'user')] |
|
106
|
|
|
private ?UserLockInterface $userLock = null; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @var ArrayCollection<string, UserSettingInterface> |
|
110
|
|
|
*/ |
|
111
|
|
|
#[OneToMany(targetEntity: 'UserSetting', mappedBy: 'user', indexBy: 'setting')] |
|
112
|
|
|
private Collection $settings; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @var ArrayCollection<int, UserCharacterInterface> |
|
116
|
|
|
*/ |
|
117
|
|
|
#[OneToMany(targetEntity: 'UserCharacter', mappedBy: 'user')] |
|
118
|
|
|
private Collection $characters; |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @var ArrayCollection<int, ColonyScanInterface> |
|
122
|
|
|
*/ |
|
123
|
|
|
#[OneToMany(targetEntity: 'ColonyScan', mappedBy: 'user', indexBy: 'id', fetch: 'EXTRA_LAZY')] |
|
124
|
|
|
#[OrderBy(['colony_id' => 'ASC', 'date' => 'ASC'])] |
|
125
|
|
|
private Collection $colonyScans; |
|
126
|
|
|
|
|
127
|
|
|
#[OneToOne(targetEntity: 'PirateWrath', mappedBy: 'user')] |
|
128
|
|
|
private ?PirateWrathInterface $pirateWrath = null; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @var ArrayCollection<int, UserTutorialInterface> |
|
132
|
|
|
*/ |
|
133
|
|
|
#[OneToMany(targetEntity: 'UserTutorial', mappedBy: 'user', indexBy: 'tutorial_step_id', fetch: 'EXTRA_LAZY')] |
|
134
|
|
|
private Collection $tutorials; |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @var ArrayCollection<int, WormholeRestriction> |
|
138
|
|
|
*/ |
|
139
|
|
|
#[OneToMany(targetEntity: 'WormholeRestriction', mappedBy: 'user')] |
|
140
|
|
|
private Collection $wormholeRestrictions; |
|
141
|
|
|
|
|
142
|
|
|
public function __construct() |
|
143
|
|
|
{ |
|
144
|
|
|
$this->awards = new ArrayCollection(); |
|
145
|
|
|
$this->colonies = new ArrayCollection(); |
|
146
|
|
|
$this->userLayers = new ArrayCollection(); |
|
147
|
|
|
$this->settings = new ArrayCollection(); |
|
148
|
|
|
$this->characters = new ArrayCollection(); |
|
149
|
|
|
$this->buoys = new ArrayCollection(); |
|
150
|
|
|
$this->colonyScans = new ArrayCollection(); |
|
151
|
|
|
$this->tutorials = new ArrayCollection(); |
|
152
|
|
|
$this->wormholeRestrictions = new ArrayCollection(); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
202 |
|
#[Override] |
|
156
|
|
|
public function getId(): int |
|
157
|
|
|
{ |
|
158
|
202 |
|
return $this->id; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
3 |
|
#[Override] |
|
162
|
|
|
public function getRegistration(): UserRegistrationInterface |
|
163
|
|
|
{ |
|
164
|
3 |
|
return $this->registration; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
#[Override] |
|
168
|
|
|
public function setRegistration(UserRegistrationInterface $registration): UserInterface |
|
169
|
|
|
{ |
|
170
|
|
|
$this->registration = $registration; |
|
171
|
|
|
|
|
172
|
|
|
return $this; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
202 |
|
#[Override] |
|
176
|
|
|
public function getName(): string |
|
177
|
|
|
{ |
|
178
|
|
|
//if UMODE active, add info to user name |
|
179
|
202 |
|
if ($this->isVacationRequestOldEnough()) { |
|
180
|
|
|
return $this->username . '[b][color=red] (UMODE)[/color][/b]'; |
|
181
|
|
|
} |
|
182
|
202 |
|
return $this->username; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
#[Override] |
|
186
|
|
|
public function setUsername(string $username): UserInterface |
|
187
|
|
|
{ |
|
188
|
|
|
$this->username = $username; |
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
202 |
|
#[Override] |
|
193
|
|
|
public function getFactionId(): int |
|
194
|
|
|
{ |
|
195
|
202 |
|
return $this->faction->getId(); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
#[Override] |
|
199
|
|
|
public function setFaction(FactionInterface $faction): UserInterface |
|
200
|
|
|
{ |
|
201
|
|
|
$this->faction = $faction; |
|
202
|
|
|
return $this; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
12 |
|
#[Override] |
|
206
|
|
|
public function getFaction(): FactionInterface |
|
207
|
|
|
{ |
|
208
|
12 |
|
return $this->faction; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
1 |
|
#[Override] |
|
212
|
|
|
public function getAwards(): Collection |
|
213
|
|
|
{ |
|
214
|
1 |
|
return $this->awards; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
12 |
|
#[Override] |
|
218
|
|
|
public function getColonies(): Collection |
|
219
|
|
|
{ |
|
220
|
12 |
|
return $this->colonies; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
2 |
|
#[Override] |
|
224
|
|
|
public function hasColony(): bool |
|
225
|
|
|
{ |
|
226
|
|
|
if ( |
|
227
|
2 |
|
$this->getState() === UserEnum::USER_STATE_COLONIZATION_SHIP |
|
228
|
2 |
|
|| $this->getState() === UserEnum::USER_STATE_UNCOLONIZED |
|
229
|
|
|
) { |
|
230
|
|
|
return false; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
2 |
|
return !$this->getColonies()->isEmpty(); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
6 |
|
#[Override] |
|
237
|
|
|
public function getState(): int |
|
238
|
|
|
{ |
|
239
|
6 |
|
return $this->state; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
1 |
|
#[Override] |
|
243
|
|
|
public function isLocked(): bool |
|
244
|
|
|
{ |
|
245
|
1 |
|
return $this->getUserLock() !== null && $this->getUserLock()->getRemainingTicks() > 0; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
#[Override] |
|
249
|
|
|
public function setState(int $state): UserInterface |
|
250
|
|
|
{ |
|
251
|
|
|
$this->state = $state; |
|
252
|
|
|
return $this; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
4 |
|
#[Override] |
|
256
|
|
|
public function getLastaction(): int |
|
257
|
|
|
{ |
|
258
|
4 |
|
return $this->lastaction; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
#[Override] |
|
262
|
|
|
public function setLastaction(int $lastaction): UserInterface |
|
263
|
|
|
{ |
|
264
|
|
|
$this->lastaction = $lastaction; |
|
265
|
|
|
return $this; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
4 |
|
#[Override] |
|
269
|
|
|
public function getKnMark(): int |
|
270
|
|
|
{ |
|
271
|
4 |
|
return $this->kn_lez; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
#[Override] |
|
275
|
|
|
public function setKnMark(int $knMark): UserInterface |
|
276
|
|
|
{ |
|
277
|
|
|
$this->kn_lez = $knMark; |
|
278
|
|
|
return $this; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
202 |
|
#[Override] |
|
282
|
|
|
public function isVacationMode(): bool |
|
283
|
|
|
{ |
|
284
|
202 |
|
return $this->vac_active; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
#[Override] |
|
288
|
|
|
public function setVacationMode(bool $vacationMode): UserInterface |
|
289
|
|
|
{ |
|
290
|
|
|
$this->vac_active = $vacationMode; |
|
291
|
|
|
return $this; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
#[Override] |
|
295
|
|
|
public function getVacationRequestDate(): int |
|
296
|
|
|
{ |
|
297
|
|
|
return $this->vac_request_date; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
#[Override] |
|
301
|
|
|
public function setVacationRequestDate(int $date): UserInterface |
|
302
|
|
|
{ |
|
303
|
|
|
$this->vac_request_date = $date; |
|
304
|
|
|
|
|
305
|
|
|
return $this; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
202 |
|
#[Override] |
|
309
|
|
|
public function isVacationRequestOldEnough(): bool |
|
310
|
|
|
{ |
|
311
|
202 |
|
return $this->isVacationMode() && (time() - $this->getVacationRequestDate() > UserEnum::VACATION_DELAY_IN_SECONDS); |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
2 |
|
#[Override] |
|
315
|
|
|
public function getDescription(): string |
|
316
|
|
|
{ |
|
317
|
2 |
|
return $this->description; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
#[Override] |
|
321
|
|
|
public function setDescription(string $description): UserInterface |
|
322
|
|
|
{ |
|
323
|
|
|
$this->description = $description; |
|
324
|
|
|
return $this; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
5 |
|
#[Override] |
|
328
|
|
|
public function getUserLayers(): Collection |
|
329
|
|
|
{ |
|
330
|
5 |
|
return $this->userLayers; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
202 |
|
#[Override] |
|
334
|
|
|
public function getSettings(): Collection |
|
335
|
|
|
{ |
|
336
|
202 |
|
return $this->settings; |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
1 |
|
#[Override] |
|
340
|
|
|
public function getSessiondata(): string |
|
341
|
|
|
{ |
|
342
|
1 |
|
return $this->sessiondata; |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
#[Override] |
|
346
|
|
|
public function setSessiondata(string $sessiondata): UserInterface |
|
347
|
|
|
{ |
|
348
|
|
|
$this->sessiondata = $sessiondata; |
|
349
|
|
|
return $this; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
5 |
|
#[Override] |
|
353
|
|
|
public function getPrestige(): int |
|
354
|
|
|
{ |
|
355
|
5 |
|
return $this->prestige; |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
#[Override] |
|
359
|
|
|
public function setPrestige(int $prestige): UserInterface |
|
360
|
|
|
{ |
|
361
|
|
|
$this->prestige = $prestige; |
|
362
|
|
|
return $this; |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
3 |
|
#[Override] |
|
366
|
|
|
public function getDeals(): bool |
|
367
|
|
|
{ |
|
368
|
3 |
|
return $this->deals; |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
1 |
|
#[Override] |
|
372
|
|
|
public function setDeals(bool $deals): UserInterface |
|
373
|
|
|
{ |
|
374
|
1 |
|
$this->deals = $deals; |
|
375
|
1 |
|
return $this; |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
#[Override] |
|
379
|
|
|
public function getLastBoarding(): ?int |
|
380
|
|
|
{ |
|
381
|
|
|
return $this->last_boarding; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
#[Override] |
|
385
|
|
|
public function setLastBoarding(int $lastBoarding): UserInterface |
|
386
|
|
|
{ |
|
387
|
|
|
$this->last_boarding = $lastBoarding; |
|
388
|
|
|
return $this; |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
2 |
|
#[Override] |
|
392
|
|
|
public function isOnline(): bool |
|
393
|
|
|
{ |
|
394
|
2 |
|
return !($this->getLastAction() < time() - GameEnum::USER_ONLINE_PERIOD); |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
20 |
|
#[Override] |
|
398
|
|
|
public function getAlliance(): ?AllianceInterface |
|
399
|
|
|
{ |
|
400
|
20 |
|
return $this->alliance; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
#[Override] |
|
404
|
|
|
public function setAlliance(?AllianceInterface $alliance): UserInterface |
|
405
|
|
|
{ |
|
406
|
|
|
$this->alliance = $alliance; |
|
407
|
|
|
return $this; |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
1 |
|
#[Override] |
|
411
|
|
|
public function isContactable(): bool |
|
412
|
|
|
{ |
|
413
|
1 |
|
return $this->getId() != UserEnum::USER_NOONE; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
201 |
|
#[Override] |
|
417
|
|
|
public function hasAward(int $awardId): bool |
|
418
|
|
|
{ |
|
419
|
201 |
|
return $this->awards->containsKey($awardId) === true; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
206 |
|
public static function isUserNpc(int $userId): bool |
|
423
|
|
|
{ |
|
424
|
206 |
|
return $userId < UserEnum::USER_FIRST_ID; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
202 |
|
#[Override] |
|
428
|
|
|
public function isNpc(): bool |
|
429
|
|
|
{ |
|
430
|
202 |
|
return self::isUserNpc($this->getId()); |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
1 |
|
#[Override] |
|
434
|
|
|
public function getUserLock(): ?UserLockInterface |
|
435
|
|
|
{ |
|
436
|
1 |
|
return $this->userLock; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
#[Override] |
|
440
|
|
|
public function __toString(): string |
|
441
|
|
|
{ |
|
442
|
|
|
return sprintf('userName: %s', $this->getName()); |
|
443
|
|
|
} |
|
444
|
|
|
|
|
445
|
1 |
|
#[Override] |
|
446
|
|
|
public function getCharacters(): Collection |
|
447
|
|
|
{ |
|
448
|
1 |
|
return $this->characters; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
1 |
|
#[Override] |
|
452
|
|
|
public function getColonyScans(): Collection |
|
453
|
|
|
{ |
|
454
|
1 |
|
return $this->colonyScans; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
#[Override] |
|
458
|
|
|
public function getBuoys(): Collection |
|
459
|
|
|
{ |
|
460
|
|
|
return $this->buoys; |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
2 |
|
#[Override] |
|
464
|
|
|
public function getPirateWrath(): ?PirateWrathInterface |
|
465
|
|
|
{ |
|
466
|
2 |
|
return $this->pirateWrath; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
#[Override] |
|
470
|
|
|
public function setPirateWrath(?PirateWrathInterface $wrath): UserInterface |
|
471
|
|
|
{ |
|
472
|
|
|
$this->pirateWrath = $wrath; |
|
473
|
|
|
|
|
474
|
|
|
return $this; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
#[Override] |
|
478
|
|
|
public function getTutorials(): Collection |
|
479
|
|
|
{ |
|
480
|
|
|
return $this->tutorials; |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
#[Override] |
|
484
|
|
|
public function getWormholeRestrictions(): Collection |
|
485
|
|
|
{ |
|
486
|
|
|
return $this->wormholeRestrictions; |
|
487
|
|
|
} |
|
488
|
|
|
} |
|
489
|
|
|
|
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