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