Passed
Push — dev ( 4c76dc...4abd48 )
by Janko
09:59
created

User::isInboxMessengerStyle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
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;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use Stu\Component\Game\GameEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Game\GameEnum was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Stu\Component\Game\ModuleViewEnum;
23
use Stu\Component\Map\MapEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Map\MapEnum was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Stu\Component\Player\UserAwardEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Player\UserAwardEnum was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use Stu\Component\Player\UserCssClassEnum;
26
use Stu\Component\Player\UserRpgBehaviorEnum;
27
use Stu\Module\PlayerSetting\Lib\UserEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Module\PlayerSetting\Lib\UserEnum was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use Stu\Module\PlayerSetting\Lib\UserSettingEnum;
29
use Stu\Orm\Repository\UserRepository;
30
31
#[Table(name: 'stu_user')]
32
#[Index(name: 'user_alliance_idx', columns: ['allys_id'])]
33
#[Entity(repositoryClass: UserRepository::class)]
34
class User implements UserInterface
35
{
36
    #[Id]
37
    #[Column(type: 'integer')]
38
    #[GeneratedValue(strategy: 'IDENTITY')]
39
    private int $id;
40
41
    #[Column(type: 'string')]
42
    private string $username = '';
43
44
    #[Column(type: 'string', length: 20)]
45
    private string $login = '';
46
47
    #[Column(type: 'string', length: 255)]
48
    private string $pass = '';
49
50
    #[Column(type: 'string', length: 6, nullable: true)]
51
    private ?string $sms_code = null;
52
53
    #[Column(type: 'string', length: 200)]
54
    private string $email = '';
55
56
    #[Column(type: 'string', length: 255, nullable: true)]
57
    private ?string $mobile = null;
58
59
    #[Column(type: 'integer', nullable: true)]
60
    private ?int $allys_id = null;
61
62
    #[Column(type: 'integer')]
63
    private int $race = 9;
64
65
    #[Column(type: 'smallint')]
66
    private int $state = UserEnum::USER_STATE_NEW;
67
68
    #[Column(type: 'integer')]
69
    private int $lastaction = 0;
70
71
    #[Column(type: 'integer')]
72
    private int $creation = 0;
73
74
    #[Column(type: 'integer')]
75
    private int $kn_lez = 0;
76
77
    #[Column(type: 'smallint')]
78
    private int $delmark = 0;
79
80
    #[Column(type: 'boolean')]
81
    private bool $vac_active = false;
82
83
    #[Column(type: 'integer')]
84
    private int $vac_request_date = 0;
85
86
    #[Column(type: 'text')]
87
    private string $description = '';
88
89
    #[Column(type: 'smallint')]
90
    private int $tick = 1;
91
92
    #[Column(type: 'smallint', nullable: true)]
93
    private ?int $maptype = MapEnum::MAPTYPE_INSERT;
0 ignored issues
show
introduced by
The private property $maptype is not used, and could be removed.
Loading history...
94
95
    #[Column(type: 'text')]
96
    private string $sessiondata = '';
97
98
    #[Column(type: 'string', length: 255)]
99
    private string $password_token = '';
100
101
    #[Column(type: 'integer')]
102
    private int $prestige = 0;
103
104
    #[Column(type: 'boolean', options: ['default' => false])]
105
    private bool $deals = false;
106
107
    #[Column(type: 'integer', nullable: true)]
108
    private ?int $last_boarding = null;
109
110
    #[ManyToOne(targetEntity: 'Alliance', inversedBy: 'members')]
111
    #[JoinColumn(name: 'allys_id', referencedColumnName: 'id')]
112
    private ?AllianceInterface $alliance = null;
113
114
    #[ManyToOne(targetEntity: 'Faction')]
115
    #[JoinColumn(name: 'race', referencedColumnName: 'id')]
116
    private FactionInterface $faction;
117
118
    /**
119
     * @var ArrayCollection<int, BuoyInterface>
120
     */
121
    #[OneToMany(targetEntity: 'Buoy', mappedBy: 'user')]
122
    private Collection $buoys;
123
124
    /**
125
     * @var ArrayCollection<int, UserAwardInterface>
126
     */
127
    #[OneToMany(targetEntity: 'UserAward', mappedBy: 'user', indexBy: 'award_id')]
128
    #[OrderBy(['award_id' => 'ASC'])]
129
    private Collection $awards;
130
131
    /**
132
     * @var ArrayCollection<int, ColonyInterface>
133
     */
134
    #[OneToMany(targetEntity: 'Colony', mappedBy: 'user', indexBy: 'id')]
135
    #[OrderBy(['colonies_classes_id' => 'ASC', 'id' => 'ASC'])]
136
    private Collection $colonies;
137
138
    /**
139
     * @var ArrayCollection<int, UserLayerInterface>
140
     */
141
    #[OneToMany(targetEntity: 'UserLayer', mappedBy: 'user', indexBy: 'layer_id')]
142
    private Collection $userLayers;
143
144
    #[OneToOne(targetEntity: 'UserLock', mappedBy: 'user')]
145
    private ?UserLockInterface $userLock = null;
146
147
    /**
148
     * @var ArrayCollection<string, UserSettingInterface>
149
     */
150
    #[OneToMany(targetEntity: 'UserSetting', mappedBy: 'user', indexBy: 'setting')]
151
    private Collection $settings;
152
153
    /**
154
     * @var ArrayCollection<int, UserCharacterInterface>
155
     */
156
    #[OneToMany(targetEntity: 'UserCharacter', mappedBy: 'user')]
157
    private Collection $characters;
158
159
    /**
160
     * @var ArrayCollection<int, ColonyScanInterface>
161
     */
162
    #[OneToMany(targetEntity: 'ColonyScan', mappedBy: 'user', indexBy: 'id', fetch: 'EXTRA_LAZY')]
163
    #[OrderBy(['colony_id' => 'ASC', 'date' => 'ASC'])]
164
    private Collection $colonyScans;
165
166
    #[OneToOne(targetEntity: 'PirateWrath', mappedBy: 'user')]
167
    private ?PirateWrathInterface $pirateWrath = null;
168
169
    /**
170
     * @var ArrayCollection<int, UserTutorialInterface>
171
     */
172
    #[OneToMany(targetEntity: 'UserTutorial', mappedBy: 'user', indexBy: 'tutorial_step_id', fetch: 'EXTRA_LAZY')]
173
    private Collection $tutorials;
174
175
    /** @var null|array<mixed> */
176
    private $sessiondataUnserialized;
177
178
    /**
179
     * @var ArrayCollection<int, WormholeRestriction>
180
     */
181
    #[OneToMany(targetEntity: 'WormholeRestriction', mappedBy: 'user')]
182
    private Collection $wormholeRestrictions;
183
184
    #[OneToOne(targetEntity: 'UserReferer', mappedBy: 'user')]
185
    private ?UserRefererInterface $referer = null;
186
187
188
    public function __construct()
189
    {
190
        $this->awards = new ArrayCollection();
191
        $this->colonies = new ArrayCollection();
192
        $this->userLayers = new ArrayCollection();
193
        $this->settings = new ArrayCollection();
194
        $this->characters = new ArrayCollection();
195
        $this->buoys = new ArrayCollection();
196
        $this->colonyScans = new ArrayCollection();
197
        $this->tutorials = new ArrayCollection();
198
        $this->wormholeRestrictions = new ArrayCollection();
199
    }
200
201 184
    #[Override]
202
    public function getId(): int
203
    {
204 184
        return $this->id;
205
    }
206
207 184
    #[Override]
208
    public function getName(): string
209
    {
210
        //if UMODE active, add info to user name
211 184
        if ($this->isVacationRequestOldEnough()) {
212
            return $this->username . '[b][color=red] (UMODE)[/color][/b]';
213
        }
214 184
        return $this->username;
215
    }
216
217
    #[Override]
218
    public function setUsername(string $username): UserInterface
219
    {
220
        $this->username = $username;
221
        return $this;
222
    }
223
224
    #[Override]
225
    public function getLogin(): string
226
    {
227
        return $this->login;
228
    }
229
230
    #[Override]
231
    public function setLogin(string $login): UserInterface
232
    {
233
        $this->login = $login;
234
        return $this;
235
    }
236
237
    #[Override]
238
    public function getPassword(): string
239
    {
240
        return $this->pass;
241
    }
242
243
    #[Override]
244
    public function setPassword(string $password): UserInterface
245
    {
246
        $this->pass = $password;
247
        return $this;
248
    }
249
250
    #[Override]
251
    public function getSmsCode(): ?string
252
    {
253
        return $this->sms_code;
254
    }
255
256
    #[Override]
257
    public function setSmsCode(?string $code): UserInterface
258
    {
259
        $this->sms_code = $code;
260
        return $this;
261
    }
262
263 1
    #[Override]
264
    public function getEmail(): string
265
    {
266 1
        return $this->email;
267
    }
268
269
    #[Override]
270
    public function setEmail(string $email): UserInterface
271
    {
272
        $this->email = $email;
273
        return $this;
274
    }
275
276
    #[Override]
277
    public function getMobile(): ?string
278
    {
279
        return $this->mobile;
280
    }
281
282
    #[Override]
283
    public function setMobile(?string $mobile): UserInterface
284
    {
285
        $this->mobile = $mobile;
286
        return $this;
287
    }
288
289 1
    #[Override]
290
    public function getRgbCode(): string
291
    {
292 1
        $setting = $this->getSettings()->get(UserSettingEnum::RGB_CODE->value);
293 1
        if ($setting !== null) {
294
            return $setting->getValue();
295
        }
296
297 1
        return '';
298
    }
299
300 184
    #[Override]
301
    public function getCss(): string
302
    {
303 184
        $setting = $this->getSettings()->get(UserSettingEnum::CSS_COLOR_SHEET->value);
304 184
        if ($setting !== null) {
305
            return $setting->getValue();
306
        }
307
308 184
        return UserCssClassEnum::BLACK->value;
309
    }
310
311 184
    #[Override]
312
    public function getFactionId(): int
313
    {
314 184
        return $this->race;
315
    }
316
317
    #[Override]
318
    public function setFaction(FactionInterface $faction): UserInterface
319
    {
320
        $this->faction = $faction;
321
        return $this;
322
    }
323
324 10
    #[Override]
325
    public function getFaction(): FactionInterface
326
    {
327 10
        return $this->faction;
328
    }
329
330 1
    #[Override]
331
    public function getAwards(): Collection
332
    {
333 1
        return $this->awards;
334
    }
335
336 9
    #[Override]
337
    public function getColonies(): Collection
338
    {
339 9
        return $this->colonies;
340
    }
341
342 1
    #[Override]
343
    public function hasColony(): bool
344
    {
345
        if (
346 1
            $this->getState() === UserEnum::USER_STATE_COLONIZATION_SHIP
347 1
            || $this->getState() === UserEnum::USER_STATE_UNCOLONIZED
348
        ) {
349
            return false;
350
        }
351
352 1
        return !$this->getColonies()->isEmpty();
353
    }
354
355 3
    #[Override]
356
    public function getState(): int
357
    {
358 3
        return $this->state;
359
    }
360
361 1
    #[Override]
362
    public function isLocked(): bool
363
    {
364 1
        return $this->getUserLock() !== null && $this->getUserLock()->getRemainingTicks() > 0;
365
    }
366
367 1
    #[Override]
368
    public function getUserStateDescription(): string
369
    {
370 1
        if ($this->isLocked()) {
371
            return _('GESPERRT');
372
        }
373 1
        return UserEnum::getUserStateDescription($this->getState());
374
    }
375
376
    #[Override]
377
    public function setState(int $state): UserInterface
378
    {
379
        $this->state = $state;
380
        return $this;
381
    }
382
383 184
    #[Override]
384
    public function getAvatar(): string
385
    {
386 184
        $setting = $this->getSettings()->get(UserSettingEnum::AVATAR->value);
387 184
        if ($setting !== null) {
388
            return $setting->getValue();
389
        }
390
391 184
        return '';
392
    }
393
394 1
    #[Override]
395
    public function isEmailNotification(): bool
396
    {
397 1
        $setting = $this->getSettings()->get(UserSettingEnum::EMAIL_NOTIFICATION->value);
398 1
        if ($setting !== null) {
399
            return (bool)$setting->getValue();
400
        }
401
402 1
        return false;
403
    }
404
405 4
    #[Override]
406
    public function getLastaction(): int
407
    {
408 4
        return $this->lastaction;
409
    }
410
411
    #[Override]
412
    public function setLastaction(int $lastaction): UserInterface
413
    {
414
        $this->lastaction = $lastaction;
415
        return $this;
416
    }
417
418 1
    #[Override]
419
    public function getCreationDate(): int
420
    {
421 1
        return $this->creation;
422
    }
423
424
    #[Override]
425
    public function setCreationDate(int $creationDate): UserInterface
426
    {
427
        $this->creation = $creationDate;
428
        return $this;
429
    }
430
431 4
    #[Override]
432
    public function getKnMark(): int
433
    {
434 4
        return $this->kn_lez;
435
    }
436
437
    #[Override]
438
    public function setKnMark(int $knMark): UserInterface
439
    {
440
        $this->kn_lez = $knMark;
441
        return $this;
442
    }
443
444
    #[Override]
445
    public function getDeletionMark(): int
446
    {
447
        return $this->delmark;
448
    }
449
450
    #[Override]
451
    public function setDeletionMark(int $deletionMark): UserInterface
452
    {
453
        $this->delmark = $deletionMark;
454
        return $this;
455
    }
456
457 184
    #[Override]
458
    public function isVacationMode(): bool
459
    {
460 184
        return $this->vac_active;
461
    }
462
463
    #[Override]
464
    public function setVacationMode(bool $vacationMode): UserInterface
465
    {
466
        $this->vac_active = $vacationMode;
467
        return $this;
468
    }
469
470
    #[Override]
471
    public function getVacationRequestDate(): int
472
    {
473
        return $this->vac_request_date;
474
    }
475
476
    #[Override]
477
    public function setVacationRequestDate(int $date): UserInterface
478
    {
479
        $this->vac_request_date = $date;
480
481
        return $this;
482
    }
483
484 184
    #[Override]
485
    public function isVacationRequestOldEnough(): bool
486
    {
487 184
        return $this->isVacationMode() && (time() - $this->getVacationRequestDate() > UserEnum::VACATION_DELAY_IN_SECONDS);
488
    }
489
490 1
    #[Override]
491
    public function isStorageNotification(): bool
492
    {
493 1
        $setting = $this->getSettings()->get(UserSettingEnum::STORAGE_NOTIFICATION->value);
494 1
        if ($setting !== null) {
495
            return (bool)$setting->getValue();
496
        }
497
498 1
        return false;
499
    }
500
501 2
    #[Override]
502
    public function getDescription(): string
503
    {
504 2
        return $this->description;
505
    }
506
507
    #[Override]
508
    public function setDescription(string $description): UserInterface
509
    {
510
        $this->description = $description;
511
        return $this;
512
    }
513
514 3
    #[Override]
515
    public function isShowOnlineState(): bool
516
    {
517 3
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_ONLINE_STATUS->value);
518 3
        if ($setting !== null) {
519
            return (bool)$setting->getValue();
520
        }
521
522 3
        return false;
523
    }
524
525 1
    #[Override]
526
    public function isShowPmReadReceipt(): bool
527
    {
528 1
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PM_READ_RECEIPT->value);
529 1
        if ($setting !== null) {
530
            return (bool)$setting->getValue();
531
        }
532
533 1
        return false;
534
    }
535
536 1
    #[Override]
537
    public function isSaveLogin(): bool
538
    {
539 1
        $setting = $this->getSettings()->get(UserSettingEnum::SAVE_LOGIN->value);
540 1
        if ($setting !== null) {
541
            return (bool)$setting->getValue();
542
        }
543
544 1
        return false;
545
    }
546
547 1
    #[Override]
548
    public function getFleetFixedDefault(): bool
549
    {
550 1
        $setting = $this->getSettings()->get(UserSettingEnum::FLEET_FIXED_DEFAULT->value);
551 1
        if ($setting !== null) {
552
            return (bool)$setting->getValue();
553
        }
554
555 1
        return false;
556
    }
557
558 1
    #[Override]
559
    public function getWarpsplitAutoCarryoverDefault(): bool
560
    {
561 1
        $setting = $this->getSettings()->get(UserSettingEnum::WARPSPLIT_AUTO_CARRYOVER_DEFAULT->value);
562 1
        if ($setting !== null) {
563
            return (bool)$setting->getValue();
564
        }
565
566 1
        return false;
567
    }
568
569
    #[Override]
570
    public function getTick(): int
571
    {
572
        return $this->tick;
573
    }
574
575
    #[Override]
576
    public function setTick(int $tick): UserInterface
577
    {
578
        $this->tick = $tick;
579
        return $this;
580
    }
581
582 5
    #[Override]
583
    public function getUserLayers(): Collection
584
    {
585 5
        return $this->userLayers;
586
    }
587
588 4
    #[Override]
589
    public function hasSeen(int $layerId): bool
590
    {
591 4
        return $this->getUserLayers()->containsKey($layerId);
592
    }
593
594 4
    #[Override]
595
    public function hasExplored(int $layerId): bool
596
    {
597 4
        return $this->hasSeen($layerId) && $this->getUserLayers()->get($layerId)->isExplored();
598
    }
599
600 184
    #[Override]
601
    public function getSettings(): Collection
602
    {
603 184
        return $this->settings;
604
    }
605
606
    #[Override]
607
    public function getSessiondata(): string
608
    {
609
        return $this->sessiondata;
610
    }
611
612
    #[Override]
613
    public function setSessiondata(string $sessiondata): UserInterface
614
    {
615
        $this->sessiondata = $sessiondata;
616
        $this->sessiondataUnserialized = null;
617
        return $this;
618
    }
619
620 1
    #[Override]
621
    public function getPasswordToken(): string
622
    {
623 1
        return $this->password_token;
624
    }
625
626
    #[Override]
627
    public function setPasswordToken(string $password_token): UserInterface
628
    {
629
        $this->password_token = $password_token;
630
        return $this;
631
    }
632
633 4
    #[Override]
634
    public function getPrestige(): int
635
    {
636 4
        return $this->prestige;
637
    }
638
639
    #[Override]
640
    public function setPrestige(int $prestige): UserInterface
641
    {
642
        $this->prestige = $prestige;
643
        return $this;
644
    }
645
646 1
    #[Override]
647
    public function getDefaultView(): ModuleViewEnum
648
    {
649 1
        $setting = $this->getSettings()->get(UserSettingEnum::DEFAULT_VIEW->value);
650 1
        if ($setting !== null) {
651
            return ModuleViewEnum::from($setting->getValue());
652
        }
653
654 1
        return ModuleViewEnum::MAINDESK;
655
    }
656
657 3
    #[Override]
658
    public function getRpgBehavior(): UserRpgBehaviorEnum
659
    {
660 3
        $setting = $this->getSettings()->get(UserSettingEnum::RPG_BEHAVIOR->value);
661 3
        if ($setting !== null) {
662
            return UserRpgBehaviorEnum::from((int)$setting->getValue());
663
        }
664
665 3
        return UserRpgBehaviorEnum::RPG_BEHAVIOR_NOT_SET;
666
    }
667
668 4
    #[Override]
669
    public function getDeals(): bool
670
    {
671 4
        return $this->deals;
672
    }
673
674
    #[Override]
675
    public function setDeals(bool $deals): UserInterface
676
    {
677
        $this->deals = $deals;
678
        return $this;
679
    }
680
681
    #[Override]
682
    public function getLastBoarding(): ?int
683
    {
684
        return $this->last_boarding;
685
    }
686
687
    #[Override]
688
    public function setLastBoarding(int $lastBoarding): UserInterface
689
    {
690
        $this->last_boarding = $lastBoarding;
691
        return $this;
692
    }
693
694 2
    #[Override]
695
    public function isOnline(): bool
696
    {
697 2
        return !($this->getLastAction() < time() - GameEnum::USER_ONLINE_PERIOD);
698
    }
699
700 32
    #[Override]
701
    public function getAlliance(): ?AllianceInterface
702
    {
703 32
        return $this->alliance;
704
    }
705
706
    #[Override]
707
    public function setAlliance(?AllianceInterface $alliance): UserInterface
708
    {
709
        $this->alliance = $alliance;
710
        return $this;
711
    }
712
713
    #[Override]
714
    public function setAllianceId(?int $allianceId): UserInterface
715
    {
716
        $this->allys_id = $allianceId;
717
        return $this;
718
    }
719
720
    #[Override]
721
    public function getSessionDataUnserialized(): array
722
    {
723
        if ($this->sessiondataUnserialized === null) {
724
            $this->sessiondataUnserialized = unserialize($this->getSessionData());
725
            if (!is_array($this->sessiondataUnserialized)) {
726
                $this->sessiondataUnserialized = [];
727
            }
728
        }
729
        return $this->sessiondataUnserialized;
730
    }
731
732
    #[Override]
733
    public function isContactable(): bool
734
    {
735
        return $this->getId() != UserEnum::USER_NOONE;
736
    }
737
738 184
    #[Override]
739
    public function hasAward(int $awardId): bool
740
    {
741 184
        return $this->awards->containsKey($awardId) === true;
742
    }
743
744 184
    #[Override]
745
    public function hasStationsNavigation(): bool
746
    {
747 184
        if ($this->isNpc()) {
748
            return true;
749
        }
750
751 184
        return $this->hasAward(UserAwardEnum::RESEARCHED_STATIONS);
752
    }
753
754 190
    public static function isUserNpc(int $userId): bool
755
    {
756 190
        return $userId < UserEnum::USER_FIRST_ID;
757
    }
758
759 184
    #[Override]
760
    public function isNpc(): bool
761
    {
762 184
        return self::isUserNpc($this->getId());
763
    }
764
765 1
    #[Override]
766
    public function getUserLock(): ?UserLockInterface
767
    {
768 1
        return $this->userLock;
769
    }
770
771
    #[Override]
772
    public function __toString(): string
773
    {
774
        return sprintf('userName: %s', $this->getName());
775
    }
776
777
    #[Override]
778
    public function hasTranslation(): bool
779
    {
780
        $text = $this->getDescription();
781
        return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false;
782
    }
783
784 3
    #[Override]
785
    public function isShowPirateHistoryEntrys(): bool
786
    {
787 3
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PIRATE_HISTORY_ENTRYS->value);
788 3
        if ($setting !== null) {
789
            return (bool)$setting->getValue();
790
        }
791
792 3
        return false;
793
    }
794
795 2
    #[Override]
796
    public function isInboxMessengerStyle(): bool
797
    {
798 2
        $setting = $this->getSettings()->get(UserSettingEnum::INBOX_MESSENGER_STYLE->value);
799 2
        if ($setting !== null) {
800
            return (bool)$setting->getValue();
801
        }
802
803 2
        return false;
804
    }
805
806 1
    #[Override]
807
    public function getCharacters(): Collection
808
    {
809 1
        return $this->characters;
810
    }
811
812 1
    #[Override]
813
    public function getColonyScans(): Collection
814
    {
815 1
        return $this->colonyScans;
816
    }
817
818
    /**
819
     * @return Collection<int, BuoyInterface>
820
     */
821
    public function getBuoys(): Collection
822
    {
823
        return $this->buoys;
824
    }
825
826 2
    #[Override]
827
    public function getPirateWrath(): ?PirateWrathInterface
828
    {
829 2
        return $this->pirateWrath;
830
    }
831
832
    #[Override]
833
    public function setPirateWrath(?PirateWrathInterface $wrath): UserInterface
834
    {
835
        $this->pirateWrath = $wrath;
836
837
        return $this;
838
    }
839
840
    #[Override]
841
    public function isProtectedAgainstPirates(): bool
842
    {
843
        $pirateWrath = $this->pirateWrath;
844
        if ($pirateWrath === null) {
845
            return false;
846
        }
847
848
        $timeout = $pirateWrath->getProtectionTimeout();
849
        if ($timeout === null) {
850
            return false;
851
        }
852
853
        return $timeout > time();
854
    }
855
856
    /**
857
     * @return Collection<int, UserTutorialInterface>
858
     */
859
    #[Override]
860
    public function getTutorials(): Collection
861
    {
862
        return $this->tutorials;
863
    }
864
865
    #[Override]
866
    /**
867
     * @return Collection<int, WormholeRestriction>
868
     */
869
    public function getWormholeRestrictions(): iterable
870
    {
871
        return $this->wormholeRestrictions;
872
    }
873
874
    #[Override]
875
    public function getReferer(): ?UserRefererInterface
876
    {
877
        return $this->referer;
878
    }
879
880
    #[Override]
881
    public function setReferer(?UserRefererInterface $referer): UserInterface
882
    {
883
        $this->referer = $referer;
884
        return $this;
885
    }
886
}
887