|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Battle\AlertDetection; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\Collection; |
|
6
|
|
|
use Override; |
|
|
|
|
|
|
7
|
|
|
use Stu\Component\Game\TimeConstants; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Player\Relation\PlayerRelationDeterminatorInterface; |
|
9
|
|
|
use Stu\Component\Spacecraft\SpacecraftAlertStateEnum; |
|
10
|
|
|
use Stu\Module\Control\StuTime; |
|
11
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
12
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
13
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
14
|
|
|
|
|
15
|
|
|
//TODO convert conditions to implementations of SkipConditionInterface |
|
16
|
|
|
class SkipDetection implements SkipDetectionInterface |
|
17
|
|
|
{ |
|
18
|
14 |
|
public function __construct( |
|
19
|
|
|
private PlayerRelationDeterminatorInterface $playerRelationDeterminator, |
|
20
|
|
|
private StuTime $stuTime |
|
21
|
14 |
|
) {} |
|
22
|
|
|
|
|
23
|
13 |
|
#[Override] |
|
24
|
|
|
public function isSkipped( |
|
25
|
|
|
SpacecraftInterface $incomingSpacecraft, |
|
26
|
|
|
SpacecraftInterface $alertedSpacecraft, |
|
27
|
|
|
?SpacecraftInterface $tractoringSpacecraft, |
|
28
|
|
|
Collection $usersToInformAboutTrojanHorse |
|
29
|
|
|
): bool { |
|
30
|
13 |
|
$alertUser = $alertedSpacecraft->getUser(); |
|
31
|
13 |
|
$incomingShipUser = $incomingSpacecraft->getUser(); |
|
32
|
|
|
|
|
33
|
|
|
//alert yellow only attacks if incoming is foe |
|
34
|
|
|
if ( |
|
35
|
13 |
|
$alertedSpacecraft->getAlertState() === SpacecraftAlertStateEnum::ALERT_YELLOW |
|
36
|
13 |
|
&& !$this->playerRelationDeterminator->isEnemy($alertUser, $incomingShipUser) |
|
37
|
|
|
) { |
|
38
|
1 |
|
return true; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
//now ALERT-MODE: RED or YELLOW+ENEMY |
|
42
|
|
|
|
|
43
|
|
|
//ships of friends from tractoring ship dont attack |
|
44
|
|
|
if ( |
|
45
|
12 |
|
$tractoringSpacecraft !== null |
|
46
|
12 |
|
&& $this->playerRelationDeterminator->isFriend($alertUser, $tractoringSpacecraft->getUser()) |
|
47
|
|
|
) { |
|
48
|
|
|
if ( |
|
49
|
2 |
|
!$usersToInformAboutTrojanHorse->contains($alertUser) |
|
50
|
2 |
|
&& !$this->playerRelationDeterminator->isFriend($alertUser, $incomingShipUser) |
|
51
|
|
|
) { |
|
52
|
1 |
|
$usersToInformAboutTrojanHorse->add($alertUser); |
|
53
|
|
|
} |
|
54
|
2 |
|
return true; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
//ships of friends dont attack |
|
58
|
10 |
|
if ($this->playerRelationDeterminator->isFriend($alertUser, $incomingShipUser)) { |
|
59
|
1 |
|
return true; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
//ships in finished tholian web dont attack |
|
63
|
9 |
|
$holdingWeb = $alertedSpacecraft->getHoldingWeb(); |
|
64
|
9 |
|
if ($holdingWeb !== null && $holdingWeb->isFinished()) { |
|
65
|
1 |
|
return true; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
8 |
|
return $this->skipDueToPirateProtection( |
|
69
|
8 |
|
$incomingShipUser, |
|
70
|
8 |
|
$alertedSpacecraft |
|
71
|
8 |
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
8 |
|
private function skipDueToPirateProtection( |
|
75
|
|
|
UserInterface $incomingShipUser, |
|
76
|
|
|
SpacecraftInterface $alertedSpacecraft |
|
77
|
|
|
): bool { |
|
78
|
|
|
|
|
79
|
8 |
|
$time = $this->stuTime->time(); |
|
80
|
|
|
|
|
81
|
|
|
//pirates don't attack new players |
|
82
|
8 |
|
if ($incomingShipUser->getCreationDate() > $time - TimeConstants::EIGHT_WEEKS_IN_SECONDS) { |
|
83
|
1 |
|
return true; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
//pirates don't attack if user is protected |
|
87
|
7 |
|
$pirateWrath = $incomingShipUser->getPirateWrath(); |
|
88
|
|
|
if ( |
|
89
|
7 |
|
$alertedSpacecraft->getUserId() === UserEnum::USER_NPC_KAZON |
|
90
|
7 |
|
&& $pirateWrath !== null |
|
91
|
7 |
|
&& $pirateWrath->getProtectionTimeout() > $time |
|
92
|
|
|
) { |
|
93
|
1 |
|
return true; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
//players don't attack pirates if protection is active |
|
97
|
6 |
|
$pirateWrath = $alertedSpacecraft->getUser()->getPirateWrath(); |
|
98
|
6 |
|
return $incomingShipUser->getId() === UserEnum::USER_NPC_KAZON |
|
99
|
6 |
|
&& $pirateWrath !== null |
|
100
|
6 |
|
&& $pirateWrath->getProtectionTimeout() > $time; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths