|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Lib\Interaction\Member; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Anomaly\Type\AnomalyTypeEnum; |
|
6
|
|
|
use Stu\Lib\Interaction\InteractionCheckType; |
|
7
|
|
|
use Stu\Module\Ship\Lib\TholianWebUtilInterface; |
|
8
|
|
|
use Stu\Orm\Entity\Colony; |
|
9
|
|
|
use Stu\Orm\Entity\Map; |
|
10
|
|
|
use Stu\Orm\Entity\StarSystemMap; |
|
11
|
|
|
use Stu\Orm\Entity\User; |
|
12
|
|
|
|
|
13
|
|
|
class ColonyMember implements InteractionMemberInterface |
|
14
|
|
|
{ |
|
15
|
4 |
|
public function __construct( |
|
16
|
|
|
private TholianWebUtilInterface $tholianWebUtil, |
|
17
|
|
|
private Colony $colony |
|
18
|
4 |
|
) {} |
|
19
|
|
|
|
|
20
|
2 |
|
#[\Override] |
|
21
|
|
|
public function get(): Colony |
|
22
|
|
|
{ |
|
23
|
2 |
|
return $this->colony; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
2 |
|
#[\Override] |
|
27
|
|
|
public function canAccess( |
|
28
|
|
|
InteractionMemberInterface $other, |
|
29
|
|
|
callable $shouldCheck |
|
30
|
|
|
): ?InteractionCheckType { |
|
31
|
|
|
|
|
32
|
|
|
if ( |
|
33
|
2 |
|
$shouldCheck(InteractionCheckType::EXPECT_SOURCE_UNBLOCKED) |
|
34
|
2 |
|
&& $this->colony->isBlocked() |
|
35
|
|
|
) { |
|
36
|
|
|
return InteractionCheckType::EXPECT_SOURCE_UNBLOCKED; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
2 |
|
return null; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
2 |
|
#[\Override] |
|
43
|
|
|
public function canBeAccessedFrom( |
|
44
|
|
|
InteractionMemberInterface $other, |
|
45
|
|
|
callable $shouldCheck |
|
46
|
|
|
): ?InteractionCheckType { |
|
47
|
|
|
|
|
48
|
|
|
if ( |
|
49
|
2 |
|
$shouldCheck(InteractionCheckType::EXPECT_TARGET_DOCKED_OR_NO_ION_STORM) |
|
50
|
2 |
|
&& $this->colony->getLocation()->hasAnomaly(AnomalyTypeEnum::ION_STORM) |
|
51
|
|
|
) { |
|
52
|
|
|
return InteractionCheckType::EXPECT_TARGET_DOCKED_OR_NO_ION_STORM; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
if ( |
|
56
|
2 |
|
$shouldCheck(InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB) |
|
57
|
2 |
|
&& $this->tholianWebUtil->isTargetOutsideFinishedTholianWeb($other->get(), $this->colony) |
|
58
|
|
|
) { |
|
59
|
|
|
return InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if ( |
|
63
|
2 |
|
$shouldCheck(InteractionCheckType::EXPECT_TARGET_UNBLOCKED) |
|
64
|
2 |
|
&& $this->colony->isBlocked() |
|
65
|
|
|
) { |
|
66
|
|
|
return InteractionCheckType::EXPECT_TARGET_UNBLOCKED; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
2 |
|
return null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
4 |
|
#[\Override] |
|
73
|
|
|
public function getLocation(): Map|StarSystemMap |
|
74
|
|
|
{ |
|
75
|
4 |
|
return $this->colony->getLocation(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
2 |
|
#[\Override] |
|
79
|
|
|
public function getUser(): ?User |
|
80
|
|
|
{ |
|
81
|
2 |
|
return $this->colony->getUser(); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|