Passed
Pull Request — master (#1918)
by Janko
25:50
created

User::getUserStateDescription()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 6
rs 10
c 0
b 0
f 0
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
    public function __construct()
179
    {
180
        $this->awards = new ArrayCollection();
181
        $this->colonies = new ArrayCollection();
182
        $this->userLayers = new ArrayCollection();
183
        $this->settings = new ArrayCollection();
184
        $this->characters = new ArrayCollection();
185
        $this->buoys = new ArrayCollection();
186
        $this->colonyScans = new ArrayCollection();
187
        $this->tutorials = new ArrayCollection();
188
    }
189
190
    #[Override]
191
    public function getId(): int
192
    {
193
        return $this->id;
194
    }
195
196
    #[Override]
197
    public function getName(): string
198
    {
199
        //if UMODE active, add info to user name
200
        if ($this->isVacationRequestOldEnough()) {
201
            return $this->username . '[b][color=red] (UMODE)[/color][/b]';
202
        }
203
        return $this->username;
204
    }
205
206
    #[Override]
207
    public function setUsername(string $username): UserInterface
208
    {
209
        $this->username = $username;
210
        return $this;
211
    }
212
213
    #[Override]
214
    public function getLogin(): string
215
    {
216
        return $this->login;
217
    }
218
219
    #[Override]
220
    public function setLogin(string $login): UserInterface
221
    {
222
        $this->login = $login;
223
        return $this;
224
    }
225
226
    #[Override]
227
    public function getPassword(): string
228
    {
229
        return $this->pass;
230
    }
231
232
    #[Override]
233
    public function setPassword(string $password): UserInterface
234
    {
235
        $this->pass = $password;
236
        return $this;
237
    }
238
239
    #[Override]
240
    public function getSmsCode(): ?string
241
    {
242
        return $this->sms_code;
243
    }
244
245
    #[Override]
246
    public function setSmsCode(?string $code): UserInterface
247
    {
248
        $this->sms_code = $code;
249
        return $this;
250
    }
251
252
    #[Override]
253
    public function getEmail(): string
254
    {
255
        return $this->email;
256
    }
257
258
    #[Override]
259
    public function setEmail(string $email): UserInterface
260
    {
261
        $this->email = $email;
262
        return $this;
263
    }
264
265
    #[Override]
266
    public function getMobile(): ?string
267
    {
268
        return $this->mobile;
269
    }
270
271
    #[Override]
272
    public function setMobile(?string $mobile): UserInterface
273
    {
274
        $this->mobile = $mobile;
275
        return $this;
276
    }
277
278
    #[Override]
279
    public function getRgbCode(): string
280
    {
281
        $setting = $this->getSettings()->get(UserSettingEnum::RGB_CODE->value);
282
        if ($setting !== null) {
283
            return $setting->getValue();
284
        }
285
286
        return '';
287
    }
288
289
    #[Override]
290
    public function getCss(): string
291
    {
292
        $setting = $this->getSettings()->get(UserSettingEnum::CSS_COLOR_SHEET->value);
293
        if ($setting !== null) {
294
            return $setting->getValue();
295
        }
296
297
        return UserCssClassEnum::BLACK->value;
298
    }
299
300
    #[Override]
301
    public function getFactionId(): int
302
    {
303
        return $this->race;
304
    }
305
306
    #[Override]
307
    public function setFaction(FactionInterface $faction): UserInterface
308
    {
309
        $this->faction = $faction;
310
        return $this;
311
    }
312
313
    #[Override]
314
    public function getFaction(): FactionInterface
315
    {
316
        return $this->faction;
317
    }
318
319
    #[Override]
320
    public function getAwards(): Collection
321
    {
322
        return $this->awards;
323
    }
324
325
    #[Override]
326
    public function getColonies(): Collection
327
    {
328
        return $this->colonies;
329
    }
330
331
    #[Override]
332
    public function hasColony(): bool
333
    {
334
        if (
335
            $this->getState() === UserEnum::USER_STATE_COLONIZATION_SHIP
336
            || $this->getState() === UserEnum::USER_STATE_UNCOLONIZED
337
        ) {
338
            return false;
339
        }
340
341
        return !$this->getColonies()->isEmpty();
342
    }
343
344
    #[Override]
345
    public function getState(): int
346
    {
347
        return $this->state;
348
    }
349
350
    #[Override]
351
    public function isLocked(): bool
352
    {
353
        return $this->getUserLock() !== null && $this->getUserLock()->getRemainingTicks() > 0;
354
    }
355
356
    #[Override]
357
    public function getUserStateDescription(): string
358
    {
359
        if ($this->isLocked()) {
360
            return _('GESPERRT');
361
        }
362
        return UserEnum::getUserStateDescription($this->getState());
363
    }
364
365
    #[Override]
366
    public function setState(int $state): UserInterface
367
    {
368
        $this->state = $state;
369
        return $this;
370
    }
371
372
    #[Override]
373
    public function getAvatar(): string
374
    {
375
        $setting = $this->getSettings()->get(UserSettingEnum::AVATAR->value);
376
        if ($setting !== null) {
377
            return $setting->getValue();
378
        }
379
380
        return '';
381
    }
382
383
    #[Override]
384
    public function isEmailNotification(): bool
385
    {
386
        $setting = $this->getSettings()->get(UserSettingEnum::EMAIL_NOTIFICATION->value);
387
        if ($setting !== null) {
388
            return (bool)$setting->getValue();
389
        }
390
391
        return false;
392
    }
393
394
    #[Override]
395
    public function getLastaction(): int
396
    {
397
        return $this->lastaction;
398
    }
399
400
    #[Override]
401
    public function setLastaction(int $lastaction): UserInterface
402
    {
403
        $this->lastaction = $lastaction;
404
        return $this;
405
    }
406
407
    #[Override]
408
    public function getCreationDate(): int
409
    {
410
        return $this->creation;
411
    }
412
413
    #[Override]
414
    public function setCreationDate(int $creationDate): UserInterface
415
    {
416
        $this->creation = $creationDate;
417
        return $this;
418
    }
419
420
    #[Override]
421
    public function getKnMark(): int
422
    {
423
        return $this->kn_lez;
424
    }
425
426
    #[Override]
427
    public function setKnMark(int $knMark): UserInterface
428
    {
429
        $this->kn_lez = $knMark;
430
        return $this;
431
    }
432
433
    #[Override]
434
    public function getDeletionMark(): int
435
    {
436
        return $this->delmark;
437
    }
438
439
    #[Override]
440
    public function setDeletionMark(int $deletionMark): UserInterface
441
    {
442
        $this->delmark = $deletionMark;
443
        return $this;
444
    }
445
446
    #[Override]
447
    public function isVacationMode(): bool
448
    {
449
        return $this->vac_active;
450
    }
451
452
    #[Override]
453
    public function setVacationMode(bool $vacationMode): UserInterface
454
    {
455
        $this->vac_active = $vacationMode;
456
        return $this;
457
    }
458
459
    #[Override]
460
    public function getVacationRequestDate(): int
461
    {
462
        return $this->vac_request_date;
463
    }
464
465
    #[Override]
466
    public function setVacationRequestDate(int $date): UserInterface
467
    {
468
        $this->vac_request_date = $date;
469
470
        return $this;
471
    }
472
473
    #[Override]
474
    public function isVacationRequestOldEnough(): bool
475
    {
476
        return $this->isVacationMode() && (time() - $this->getVacationRequestDate() > UserEnum::VACATION_DELAY_IN_SECONDS);
477
    }
478
479
    #[Override]
480
    public function isStorageNotification(): bool
481
    {
482
        $setting = $this->getSettings()->get(UserSettingEnum::STORAGE_NOTIFICATION->value);
483
        if ($setting !== null) {
484
            return (bool)$setting->getValue();
485
        }
486
487
        return false;
488
    }
489
490
    #[Override]
491
    public function getDescription(): string
492
    {
493
        return $this->description;
494
    }
495
496
    #[Override]
497
    public function setDescription(string $description): UserInterface
498
    {
499
        $this->description = $description;
500
        return $this;
501
    }
502
503
    #[Override]
504
    public function isShowOnlineState(): bool
505
    {
506
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_ONLINE_STATUS->value);
507
        if ($setting !== null) {
508
            return (bool)$setting->getValue();
509
        }
510
511
        return false;
512
    }
513
514
    #[Override]
515
    public function isShowPmReadReceipt(): bool
516
    {
517
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PM_READ_RECEIPT->value);
518
        if ($setting !== null) {
519
            return (bool)$setting->getValue();
520
        }
521
522
        return false;
523
    }
524
525
    #[Override]
526
    public function isSaveLogin(): bool
527
    {
528
        $setting = $this->getSettings()->get(UserSettingEnum::SAVE_LOGIN->value);
529
        if ($setting !== null) {
530
            return (bool)$setting->getValue();
531
        }
532
533
        return false;
534
    }
535
536
    #[Override]
537
    public function getFleetFixedDefault(): bool
538
    {
539
        $setting = $this->getSettings()->get(UserSettingEnum::FLEET_FIXED_DEFAULT->value);
540
        if ($setting !== null) {
541
            return (bool)$setting->getValue();
542
        }
543
544
        return false;
545
    }
546
547
    #[Override]
548
    public function getWarpsplitAutoCarryoverDefault(): bool
549
    {
550
        $setting = $this->getSettings()->get(UserSettingEnum::WARPSPLIT_AUTO_CARRYOVER_DEFAULT->value);
551
        if ($setting !== null) {
552
            return (bool)$setting->getValue();
553
        }
554
555
        return false;
556
    }
557
558
    #[Override]
559
    public function getTick(): int
560
    {
561
        return $this->tick;
562
    }
563
564
    #[Override]
565
    public function setTick(int $tick): UserInterface
566
    {
567
        $this->tick = $tick;
568
        return $this;
569
    }
570
571
    #[Override]
572
    public function getUserLayers(): Collection
573
    {
574
        return $this->userLayers;
575
    }
576
577
    #[Override]
578
    public function hasSeen(int $layerId): bool
579
    {
580
        return $this->getUserLayers()->containsKey($layerId);
581
    }
582
583
    #[Override]
584
    public function hasExplored(int $layerId): bool
585
    {
586
        return $this->hasSeen($layerId) && $this->getUserLayers()->get($layerId)->isExplored();
587
    }
588
589
    #[Override]
590
    public function getSettings(): Collection
591
    {
592
        return $this->settings;
593
    }
594
595
    #[Override]
596
    public function getSessiondata(): string
597
    {
598
        return $this->sessiondata;
599
    }
600
601
    #[Override]
602
    public function setSessiondata(string $sessiondata): UserInterface
603
    {
604
        $this->sessiondata = $sessiondata;
605
        $this->sessiondataUnserialized = null;
606
        return $this;
607
    }
608
609
    #[Override]
610
    public function getPasswordToken(): string
611
    {
612
        return $this->password_token;
613
    }
614
615
    #[Override]
616
    public function setPasswordToken(string $password_token): UserInterface
617
    {
618
        $this->password_token = $password_token;
619
        return $this;
620
    }
621
622
    #[Override]
623
    public function getPrestige(): int
624
    {
625
        return $this->prestige;
626
    }
627
628
    #[Override]
629
    public function setPrestige(int $prestige): UserInterface
630
    {
631
        $this->prestige = $prestige;
632
        return $this;
633
    }
634
635
    #[Override]
636
    public function getDefaultView(): ModuleViewEnum
637
    {
638
        $setting = $this->getSettings()->get(UserSettingEnum::DEFAULT_VIEW->value);
639
        if ($setting !== null) {
640
            return ModuleViewEnum::from($setting->getValue());
641
        }
642
643
        return ModuleViewEnum::MAINDESK;
644
    }
645
646
    #[Override]
647
    public function getRpgBehavior(): UserRpgBehaviorEnum
648
    {
649
        $setting = $this->getSettings()->get(UserSettingEnum::RPG_BEHAVIOR->value);
650
        if ($setting !== null) {
651
            return UserRpgBehaviorEnum::from((int)$setting->getValue());
652
        }
653
654
        return UserRpgBehaviorEnum::RPG_BEHAVIOR_NOT_SET;
655
    }
656
657
    #[Override]
658
    public function getDeals(): bool
659
    {
660
        return $this->deals;
661
    }
662
663
    #[Override]
664
    public function setDeals(bool $deals): UserInterface
665
    {
666
        $this->deals = $deals;
667
        return $this;
668
    }
669
670
    #[Override]
671
    public function getLastBoarding(): ?int
672
    {
673
        return $this->last_boarding;
674
    }
675
676
    #[Override]
677
    public function setLastBoarding(int $lastBoarding): UserInterface
678
    {
679
        $this->last_boarding = $lastBoarding;
680
        return $this;
681
    }
682
683
    #[Override]
684
    public function isOnline(): bool
685
    {
686
        return !($this->getLastAction() < time() - GameEnum::USER_ONLINE_PERIOD);
687
    }
688
689
    #[Override]
690
    public function getAlliance(): ?AllianceInterface
691
    {
692
        return $this->alliance;
693
    }
694
695
    #[Override]
696
    public function setAlliance(?AllianceInterface $alliance): UserInterface
697
    {
698
        $this->alliance = $alliance;
699
        return $this;
700
    }
701
702
    #[Override]
703
    public function setAllianceId(?int $allianceId): UserInterface
704
    {
705
        $this->allys_id = $allianceId;
706
        return $this;
707
    }
708
709
    #[Override]
710
    public function getSessionDataUnserialized(): array
711
    {
712
        if ($this->sessiondataUnserialized === null) {
713
            $this->sessiondataUnserialized = unserialize($this->getSessionData());
714
            if (!is_array($this->sessiondataUnserialized)) {
715
                $this->sessiondataUnserialized = [];
716
            }
717
        }
718
        return $this->sessiondataUnserialized;
719
    }
720
721
    #[Override]
722
    public function isContactable(): bool
723
    {
724
        return $this->getId() != UserEnum::USER_NOONE;
725
    }
726
727
    #[Override]
728
    public function hasAward(int $awardId): bool
729
    {
730
        return $this->awards->containsKey($awardId) === true;
731
    }
732
733
    #[Override]
734
    public function hasStationsNavigation(): bool
735
    {
736
        if ($this->isNpc()) {
737
            return true;
738
        }
739
740
        return $this->hasAward(UserAwardEnum::RESEARCHED_STATIONS);
741
    }
742
743 6
    public static function isUserNpc(int $userId): bool
744
    {
745 6
        return $userId < UserEnum::USER_FIRST_ID;
746
    }
747
748
    #[Override]
749
    public function isNpc(): bool
750
    {
751
        return self::isUserNpc($this->getId());
752
    }
753
754
    #[Override]
755
    public function getUserLock(): ?UserLockInterface
756
    {
757
        return $this->userLock;
758
    }
759
760
    #[Override]
761
    public function __toString(): string
762
    {
763
        return sprintf('userName: %s', $this->getName());
764
    }
765
766
    #[Override]
767
    public function hasTranslation(): bool
768
    {
769
        $text = $this->getDescription();
770
        return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false;
771
    }
772
773
    #[Override]
774
    public function isShowPirateHistoryEntrys(): bool
775
    {
776
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PIRATE_HISTORY_ENTRYS->value);
777
        if ($setting !== null) {
778
            return (bool)$setting->getValue();
779
        }
780
781
        return false;
782
    }
783
784
    #[Override]
785
    public function getCharacters(): Collection
786
    {
787
        return $this->characters;
788
    }
789
790
    #[Override]
791
    public function getColonyScans(): Collection
792
    {
793
        return $this->colonyScans;
794
    }
795
796
    /**
797
     * @return Collection<int, BuoyInterface>
798
     */
799
    public function getBuoys(): Collection
800
    {
801
        return $this->buoys;
802
    }
803
804
    #[Override]
805
    public function getPirateWrath(): ?PirateWrathInterface
806
    {
807
        return $this->pirateWrath;
808
    }
809
810
    #[Override]
811
    public function setPirateWrath(?PirateWrathInterface $wrath): UserInterface
812
    {
813
        $this->pirateWrath = $wrath;
814
815
        return $this;
816
    }
817
818
    #[Override]
819
    public function isProtectedAgainstPirates(): bool
820
    {
821
        $pirateWrath = $this->pirateWrath;
822
        if ($pirateWrath === null) {
823
            return false;
824
        }
825
826
        $timeout = $pirateWrath->getProtectionTimeout();
827
        if ($timeout === null) {
828
            return false;
829
        }
830
831
        return $timeout > time();
832
    }
833
834
835
    /**
836
     * @return Collection<int, UserTutorialInterface>
837
     */
838
    #[Override]
839
    public function getTutorials(): Collection
840
    {
841
        return $this->tutorials;
842
    }
843
}
844