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\Game\GameEnum; |
21
|
|
|
use Stu\Component\Map\MapEnum; |
22
|
|
|
use Stu\Component\Player\UserAwardEnum; |
23
|
|
|
use Stu\Component\Player\UserRpgEnum; |
24
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @Entity(repositoryClass="Stu\Orm\Repository\UserRepository") |
28
|
|
|
* @Table( |
29
|
|
|
* name="stu_user", |
30
|
|
|
* indexes={ |
31
|
|
|
* @Index(name="user_alliance_idx", columns={"allys_id"}) |
32
|
|
|
* } |
33
|
|
|
* ) |
34
|
|
|
**/ |
35
|
|
|
class User implements UserInterface |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @Id |
39
|
|
|
* @Column(type="integer") |
40
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
41
|
|
|
* |
42
|
|
|
*/ |
43
|
|
|
private int $id; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @Column(type="string") |
47
|
|
|
* |
48
|
|
|
*/ |
49
|
|
|
private string $username = ''; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @Column(type="string", length=20) |
53
|
|
|
* |
54
|
|
|
*/ |
55
|
|
|
private string $login = ''; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Column(type="string", length=255) |
59
|
|
|
* |
60
|
|
|
*/ |
61
|
|
|
private string $pass = ''; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Column(type="string", length=6, nullable=true) |
65
|
|
|
* |
66
|
|
|
*/ |
67
|
|
|
private ?string $sms_code = null; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Column(type="string", length=200) |
71
|
|
|
* |
72
|
|
|
*/ |
73
|
|
|
private string $email = ''; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @Column(type="string", length=255, nullable=true) |
77
|
|
|
* |
78
|
|
|
*/ |
79
|
|
|
private ?string $mobile = null; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @Column(type="integer", nullable=true) |
83
|
|
|
* |
84
|
|
|
*/ |
85
|
|
|
private ?int $allys_id = null; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @Column(type="integer", nullable=true) |
89
|
|
|
* |
90
|
|
|
*/ |
91
|
|
|
private ?int $race = null; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @Column(type="smallint") |
95
|
|
|
* |
96
|
|
|
*/ |
97
|
|
|
private int $state = UserEnum::USER_STATE_NEW; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @Column(type="string", length=200) |
101
|
|
|
* |
102
|
|
|
*/ |
103
|
|
|
private string $propic = ''; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @Column(type="boolean") |
107
|
|
|
* |
108
|
|
|
*/ |
109
|
|
|
private bool $email_notification = true; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @Column(type="integer") |
113
|
|
|
* |
114
|
|
|
*/ |
115
|
|
|
private int $lastaction = 0; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @Column(type="integer") |
119
|
|
|
* |
120
|
|
|
*/ |
121
|
|
|
private int $creation = 0; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @Column(type="integer") |
125
|
|
|
* |
126
|
|
|
*/ |
127
|
|
|
private int $kn_lez = 0; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @Column(type="smallint") |
131
|
|
|
* |
132
|
|
|
*/ |
133
|
|
|
private int $delmark = 0; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @Column(type="boolean") |
137
|
|
|
* |
138
|
|
|
*/ |
139
|
|
|
private bool $vac_active = false; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @Column(type="integer") |
143
|
|
|
* |
144
|
|
|
*/ |
145
|
|
|
private int $vac_request_date = 0; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @Column(type="boolean") |
149
|
|
|
* |
150
|
|
|
*/ |
151
|
|
|
private bool $storage_notification = true; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @Column(type="text") |
155
|
|
|
* |
156
|
|
|
*/ |
157
|
|
|
private string $description = ''; |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @Column(type="boolean") |
161
|
|
|
* |
162
|
|
|
*/ |
163
|
|
|
private bool $show_online_status = true; |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @Column(type="boolean") |
167
|
|
|
* |
168
|
|
|
*/ |
169
|
|
|
private bool $show_pm_read_receipt = true; |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @Column(type="boolean") |
173
|
|
|
* |
174
|
|
|
*/ |
175
|
|
|
private bool $save_login = true; |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @Column(type="boolean") |
179
|
|
|
* |
180
|
|
|
*/ |
181
|
|
|
private bool $fleet_fixed_default = false; |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @Column(type="smallint") |
185
|
|
|
* |
186
|
|
|
*/ |
187
|
|
|
private int $tick = 1; |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @Column(type="smallint", nullable=true) |
191
|
|
|
* |
192
|
|
|
*/ |
193
|
|
|
private ?int $maptype = MapEnum::MAPTYPE_INSERT; |
|
|
|
|
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @Column(type="text") |
197
|
|
|
* |
198
|
|
|
*/ |
199
|
|
|
private string $sessiondata = ''; |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @Column(type="string", length=255) |
203
|
|
|
* |
204
|
|
|
*/ |
205
|
|
|
private string $password_token = ''; |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @Column(type="string", length=7) |
209
|
|
|
* |
210
|
|
|
*/ |
211
|
|
|
private string $rgb_code = ''; |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @Column(type="integer") |
215
|
|
|
* |
216
|
|
|
*/ |
217
|
|
|
private int $prestige = 0; |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @Column(type="string", length=100, nullable=true) |
221
|
|
|
* |
222
|
|
|
*/ |
223
|
|
|
private ?string $start_page = null; |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @Column(type="integer", options={"default": 0}) |
227
|
|
|
* |
228
|
|
|
*/ |
229
|
|
|
private int $rpg_behavior = UserRpgEnum::RPG_BEHAVIOR_NOT_SET; |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @Column(type="string", length=100) |
233
|
|
|
* |
234
|
|
|
*/ |
235
|
|
|
private string $css = 'schwarz'; |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* |
239
|
|
|
* @ManyToOne(targetEntity="Alliance", inversedBy="members") |
240
|
|
|
* @JoinColumn(name="allys_id", referencedColumnName="id") |
241
|
|
|
*/ |
242
|
|
|
private ?AllianceInterface $alliance = null; |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* |
246
|
|
|
* @ManyToOne(targetEntity="Faction") |
247
|
|
|
* @JoinColumn(name="race", referencedColumnName="id") |
248
|
|
|
*/ |
249
|
|
|
private ?FactionInterface $faction = null; |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @var ArrayCollection<int, UserAwardInterface> |
253
|
|
|
* |
254
|
|
|
* @OneToMany(targetEntity="UserAward", mappedBy="user", indexBy="award_id") |
255
|
|
|
* @OrderBy({"award_id": "ASC"}) |
256
|
|
|
*/ |
257
|
|
|
private Collection $awards; |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @var ArrayCollection<int, ColonyInterface> |
261
|
|
|
* |
262
|
|
|
* @OneToMany(targetEntity="Colony", mappedBy="user") |
263
|
|
|
* @OrderBy({"colonies_classes_id": "ASC", "id": "ASC"}) |
264
|
|
|
*/ |
265
|
|
|
private Collection $colonies; |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @var ArrayCollection<int, UserLayerInterface> |
269
|
|
|
* |
270
|
|
|
* @OneToMany(targetEntity="UserLayer", mappedBy="user", indexBy="layer_id") |
271
|
|
|
*/ |
272
|
|
|
private Collection $userLayers; |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @OneToOne(targetEntity="UserLock", mappedBy="user") |
276
|
|
|
*/ |
277
|
|
|
private ?UserLockInterface $userLock = null; |
278
|
|
|
|
279
|
|
|
/** @var null|array<mixed> */ |
280
|
|
|
private $sessiondataUnserialized; |
281
|
|
|
|
282
|
|
|
public function __construct() |
283
|
|
|
{ |
284
|
|
|
$this->awards = new ArrayCollection(); |
285
|
|
|
$this->colonies = new ArrayCollection(); |
286
|
|
|
$this->userLayers = new ArrayCollection(); |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function getId(): int |
290
|
|
|
{ |
291
|
|
|
return $this->id; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
public function getName(): string |
295
|
|
|
{ |
296
|
|
|
//if UMODE active, add info to user name |
297
|
|
|
if ($this->isVacationRequestOldEnough()) { |
298
|
|
|
return $this->username . '[b][color=red] (UMODE)[/color][/b]'; |
299
|
|
|
} |
300
|
|
|
return $this->username; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
public function setUsername(string $username): UserInterface |
304
|
|
|
{ |
305
|
|
|
$this->username = $username; |
306
|
|
|
return $this; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
public function getLogin(): string |
310
|
|
|
{ |
311
|
|
|
return $this->login; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
public function setLogin(string $login): UserInterface |
315
|
|
|
{ |
316
|
|
|
$this->login = $login; |
317
|
|
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
public function getPassword(): string |
321
|
|
|
{ |
322
|
|
|
return $this->pass; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
public function setPassword(string $password): UserInterface |
326
|
|
|
{ |
327
|
|
|
$this->pass = $password; |
328
|
|
|
return $this; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
public function getSmsCode(): ?string |
332
|
|
|
{ |
333
|
|
|
return $this->sms_code; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
public function setSmsCode(?string $code): UserInterface |
337
|
|
|
{ |
338
|
|
|
$this->sms_code = $code; |
339
|
|
|
return $this; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
public function getEmail(): string |
343
|
|
|
{ |
344
|
|
|
return $this->email; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function setEmail(string $email): UserInterface |
348
|
|
|
{ |
349
|
|
|
$this->email = $email; |
350
|
|
|
return $this; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
public function getMobile(): ?string |
354
|
|
|
{ |
355
|
|
|
return $this->mobile; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
public function setMobile(?string $mobile): UserInterface |
359
|
|
|
{ |
360
|
|
|
$this->mobile = $mobile; |
361
|
|
|
return $this; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
public function getRgbCode(): string |
365
|
|
|
{ |
366
|
|
|
return $this->rgb_code; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
public function setRgbCode(string $rgbCode): UserInterface |
370
|
|
|
{ |
371
|
|
|
$this->rgb_code = $rgbCode; |
372
|
|
|
return $this; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
public function getCss(): string |
376
|
|
|
{ |
377
|
|
|
return $this->css; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
public function setCss(string $Css): UserInterface |
381
|
|
|
{ |
382
|
|
|
$this->css = $Css; |
383
|
|
|
return $this; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
|
387
|
|
|
public function getFactionId(): ?int |
388
|
|
|
{ |
389
|
|
|
return $this->race; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
public function setFaction(FactionInterface $faction): UserInterface |
393
|
|
|
{ |
394
|
|
|
$this->faction = $faction; |
395
|
|
|
return $this; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
public function getFaction(): ?FactionInterface |
399
|
|
|
{ |
400
|
|
|
return $this->faction; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
public function getAwards(): Collection |
404
|
|
|
{ |
405
|
|
|
return $this->awards; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
public function getColonies(): Collection |
409
|
|
|
{ |
410
|
|
|
return $this->colonies; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
public function hasColony(): bool |
414
|
|
|
{ |
415
|
|
|
if ( |
416
|
|
|
$this->getState() === UserEnum::USER_STATE_COLONIZATION_SHIP |
417
|
|
|
|| $this->getState() === UserEnum::USER_STATE_UNCOLONIZED |
418
|
|
|
) { |
419
|
|
|
return false; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
return !$this->getColonies()->isEmpty(); |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
public function getState(): int |
426
|
|
|
{ |
427
|
|
|
return $this->state; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
public function isLocked(): bool |
431
|
|
|
{ |
432
|
|
|
return $this->getUserLock() !== null && $this->getUserLock()->getRemainingTicks() > 0; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
public function getUserStateDescription(): string |
436
|
|
|
{ |
437
|
|
|
if ($this->isLocked()) { |
438
|
|
|
return _('GESPERRT'); |
439
|
|
|
} |
440
|
|
|
return UserEnum::getUserStateDescription($this->getState()); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
public function setState(int $state): UserInterface |
444
|
|
|
{ |
445
|
|
|
$this->state = $state; |
446
|
|
|
return $this; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
public function getAvatar(): string |
450
|
|
|
{ |
451
|
|
|
return $this->propic; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
public function setAvatar(string $avatar): UserInterface |
455
|
|
|
{ |
456
|
|
|
$this->propic = $avatar; |
457
|
|
|
return $this; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
public function isEmailNotification(): bool |
461
|
|
|
{ |
462
|
|
|
return $this->email_notification; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
public function setEmailNotification(bool $email_notification): UserInterface |
466
|
|
|
{ |
467
|
|
|
$this->email_notification = $email_notification; |
468
|
|
|
return $this; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
public function getLastaction(): int |
472
|
|
|
{ |
473
|
|
|
return $this->lastaction; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
public function setLastaction(int $lastaction): UserInterface |
477
|
|
|
{ |
478
|
|
|
$this->lastaction = $lastaction; |
479
|
|
|
return $this; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
public function getCreationDate(): int |
483
|
|
|
{ |
484
|
|
|
return $this->creation; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
public function setCreationDate(int $creationDate): UserInterface |
488
|
|
|
{ |
489
|
|
|
$this->creation = $creationDate; |
490
|
|
|
return $this; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
public function getKnMark(): int |
494
|
|
|
{ |
495
|
|
|
return $this->kn_lez; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
public function setKnMark(int $knMark): UserInterface |
499
|
|
|
{ |
500
|
|
|
$this->kn_lez = $knMark; |
501
|
|
|
return $this; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
public function getDeletionMark(): int |
505
|
|
|
{ |
506
|
|
|
return $this->delmark; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
public function setDeletionMark(int $deletionMark): UserInterface |
510
|
|
|
{ |
511
|
|
|
$this->delmark = $deletionMark; |
512
|
|
|
return $this; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
public function isVacationMode(): bool |
516
|
|
|
{ |
517
|
|
|
return $this->vac_active; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
public function setVacationMode(bool $vacationMode): UserInterface |
521
|
|
|
{ |
522
|
|
|
$this->vac_active = $vacationMode; |
523
|
|
|
return $this; |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
public function getVacationRequestDate(): int |
527
|
|
|
{ |
528
|
|
|
return $this->vac_request_date; |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
public function setVacationRequestDate(int $date): UserInterface |
532
|
|
|
{ |
533
|
|
|
$this->vac_request_date = $date; |
534
|
|
|
|
535
|
|
|
return $this; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
public function isVacationRequestOldEnough(): bool |
539
|
|
|
{ |
540
|
|
|
return $this->isVacationMode() && (time() - $this->getVacationRequestDate() > UserEnum::VACATION_DELAY_IN_SECONDS); |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
public function isStorageNotification(): bool |
544
|
|
|
{ |
545
|
|
|
return $this->storage_notification; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
public function setStorageNotification(bool $storage_notification): UserInterface |
549
|
|
|
{ |
550
|
|
|
$this->storage_notification = $storage_notification; |
551
|
|
|
return $this; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
public function getDescription(): string |
555
|
|
|
{ |
556
|
|
|
return $this->description; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
public function setDescription(string $description): UserInterface |
560
|
|
|
{ |
561
|
|
|
$this->description = $description; |
562
|
|
|
return $this; |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
public function isShowOnlineState(): bool |
566
|
|
|
{ |
567
|
|
|
return $this->show_online_status; |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
public function setShowOnlineState(bool $showOnlineState): UserInterface |
571
|
|
|
{ |
572
|
|
|
$this->show_online_status = $showOnlineState; |
573
|
|
|
return $this; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
public function isShowPmReadReceipt(): bool |
577
|
|
|
{ |
578
|
|
|
return $this->show_pm_read_receipt; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
public function setShowPmReadReceipt(bool $showPmReadReceipt): UserInterface |
582
|
|
|
{ |
583
|
|
|
$this->show_pm_read_receipt = $showPmReadReceipt; |
584
|
|
|
return $this; |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
public function isSaveLogin(): bool |
588
|
|
|
{ |
589
|
|
|
return $this->save_login; |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
public function setSaveLogin(bool $save_login): UserInterface |
593
|
|
|
{ |
594
|
|
|
$this->save_login = $save_login; |
595
|
|
|
return $this; |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
public function getFleetFixedDefault(): bool |
599
|
|
|
{ |
600
|
|
|
return $this->fleet_fixed_default; |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
public function setFleetFixedDefault(bool $fleetFixedDefault): UserInterface |
604
|
|
|
{ |
605
|
|
|
$this->fleet_fixed_default = $fleetFixedDefault; |
606
|
|
|
return $this; |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
public function getTick(): int |
610
|
|
|
{ |
611
|
|
|
return $this->tick; |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
public function setTick(int $tick): UserInterface |
615
|
|
|
{ |
616
|
|
|
$this->tick = $tick; |
617
|
|
|
return $this; |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
public function getUserLayers(): Collection |
621
|
|
|
{ |
622
|
|
|
return $this->userLayers; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
public function hasSeen(int $layerId): bool |
626
|
|
|
{ |
627
|
|
|
return $this->getUserLayers()->containsKey($layerId); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
public function hasExplored(int $layerId): bool |
631
|
|
|
{ |
632
|
|
|
return $this->hasSeen($layerId) && $this->getUserLayers()->get($layerId)->isExplored(); |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
public function getSessiondata(): string |
636
|
|
|
{ |
637
|
|
|
return $this->sessiondata; |
638
|
|
|
} |
639
|
|
|
|
640
|
|
|
public function setSessiondata(string $sessiondata): UserInterface |
641
|
|
|
{ |
642
|
|
|
$this->sessiondata = $sessiondata; |
643
|
|
|
$this->sessiondataUnserialized = null; |
644
|
|
|
return $this; |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
public function getPasswordToken(): string |
648
|
|
|
{ |
649
|
|
|
return $this->password_token; |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
public function setPasswordToken(string $password_token): UserInterface |
653
|
|
|
{ |
654
|
|
|
$this->password_token = $password_token; |
655
|
|
|
return $this; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
public function getPrestige(): int |
659
|
|
|
{ |
660
|
|
|
return $this->prestige; |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
public function setPrestige(int $prestige): UserInterface |
664
|
|
|
{ |
665
|
|
|
$this->prestige = $prestige; |
666
|
|
|
return $this; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
public function getStartPage(): ?string |
670
|
|
|
{ |
671
|
|
|
return $this->start_page; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
public function setStartPage(?string $startPage): UserInterface |
675
|
|
|
{ |
676
|
|
|
$this->start_page = $startPage; |
677
|
|
|
return $this; |
678
|
|
|
} |
679
|
|
|
|
680
|
|
|
public function getRpgBehavior(): int |
681
|
|
|
{ |
682
|
|
|
return $this->rpg_behavior; |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
public function setRpgBehavior(int $RPGbehavior): UserInterface |
686
|
|
|
{ |
687
|
|
|
$this->rpg_behavior = $RPGbehavior; |
688
|
|
|
return $this; |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
public function getRpgBehaviorText(): string |
692
|
|
|
{ |
693
|
|
|
return UserRpgEnum::getRpgBehaviorText($this->getRpgBehavior()); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
public function isOnline(): bool |
697
|
|
|
{ |
698
|
|
|
return !($this->getLastAction() < time() - GameEnum::USER_ONLINE_PERIOD); |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
public function getAlliance(): ?AllianceInterface |
702
|
|
|
{ |
703
|
|
|
return $this->alliance; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
public function setAlliance(?AllianceInterface $alliance): UserInterface |
707
|
|
|
{ |
708
|
|
|
$this->alliance = $alliance; |
709
|
|
|
return $this; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
public function setAllianceId(?int $allianceId): UserInterface |
713
|
|
|
{ |
714
|
|
|
$this->allys_id = $allianceId; |
715
|
|
|
return $this; |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
public function getSessionDataUnserialized(): array |
719
|
|
|
{ |
720
|
|
|
if ($this->sessiondataUnserialized === null) { |
721
|
|
|
$this->sessiondataUnserialized = unserialize($this->getSessionData()); |
722
|
|
|
if (!is_array($this->sessiondataUnserialized)) { |
723
|
|
|
$this->sessiondataUnserialized = []; |
724
|
|
|
} |
725
|
|
|
} |
726
|
|
|
return $this->sessiondataUnserialized; |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
public function isContactable(): bool |
730
|
|
|
{ |
731
|
|
|
return $this->getId() != UserEnum::USER_NOONE; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
public function hasAward(int $awardId): bool |
735
|
|
|
{ |
736
|
|
|
return $this->awards->containsKey($awardId) === true; |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
public function hasStationsNavigation(): bool |
740
|
|
|
{ |
741
|
|
|
if ($this->isNpc()) { |
742
|
|
|
return true; |
743
|
|
|
} |
744
|
|
|
|
745
|
|
|
return $this->hasAward(UserAwardEnum::RESEARCHED_STATIONS); |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
public function isNpc(): bool |
749
|
|
|
{ |
750
|
|
|
return $this->getId() < UserEnum::USER_FIRST_ID; |
751
|
|
|
} |
752
|
|
|
|
753
|
|
|
public function getUserLock(): ?UserLockInterface |
754
|
|
|
{ |
755
|
|
|
return $this->userLock; |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
public function __toString(): string |
759
|
|
|
{ |
760
|
|
|
return sprintf('userName: %s', $this->getName()); |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
public function hasTranslation(): bool |
764
|
|
|
{ |
765
|
|
|
$text = $this->getDescription(); |
766
|
|
|
return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false; |
767
|
|
|
} |
768
|
|
|
} |
769
|
|
|
|