|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Destruction\Handler; |
|
4
|
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
|
|
6
|
|
|
use RuntimeException; |
|
7
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
8
|
|
|
use Stu\Lib\Pirate\Component\PirateRoundManagerInterface; |
|
9
|
|
|
use Stu\Module\Logging\LoggerUtilFactoryInterface; |
|
10
|
|
|
use Stu\Module\Logging\PirateLoggerInterface; |
|
11
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
12
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestroyerInterface; |
|
13
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestructionCauseEnum; |
|
14
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
15
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
16
|
|
|
use Stu\Orm\Repository\UserRepositoryInterface; |
|
17
|
|
|
|
|
18
|
|
|
class UpdatePirateRoundPrestige implements SpacecraftDestructionHandlerInterface |
|
19
|
|
|
{ |
|
20
|
|
|
private PirateLoggerInterface $logger; |
|
21
|
|
|
|
|
22
|
1 |
|
public function __construct( |
|
23
|
|
|
private PirateRoundManagerInterface $pirateRoundManager, |
|
24
|
|
|
private UserRepositoryInterface $userRepository, |
|
25
|
|
|
LoggerUtilFactoryInterface $loggerUtilFactory |
|
26
|
|
|
) { |
|
27
|
1 |
|
$this->logger = $loggerUtilFactory->getPirateLogger(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function handleSpacecraftDestruction( |
|
31
|
|
|
?SpacecraftDestroyerInterface $destroyer, |
|
32
|
|
|
SpacecraftWrapperInterface $destroyedSpacecraftWrapper, |
|
33
|
|
|
SpacecraftDestructionCauseEnum $cause, |
|
34
|
|
|
InformationInterface $informations |
|
35
|
|
|
): void { |
|
36
|
|
|
|
|
37
|
|
|
$spacecraft = $destroyedSpacecraftWrapper->get(); |
|
38
|
|
|
$userOfDestroyed = $spacecraft->getUser(); |
|
39
|
|
|
|
|
40
|
|
|
if ( |
|
41
|
|
|
$userOfDestroyed->getId() === UserEnum::USER_NPC_KAZON |
|
42
|
|
|
&& $spacecraft instanceof ShipInterface |
|
43
|
|
|
&& $destroyer !== null |
|
44
|
|
|
) { |
|
45
|
|
|
$destroyerUser = $this->userRepository->find($destroyer->getUserId()); |
|
46
|
|
|
if ($destroyerUser === null) { |
|
47
|
|
|
throw new RuntimeException('this should not happen'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if ($destroyerUser->isNpc()) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$targetPrestige = $spacecraft->getRump()->getPrestige(); |
|
55
|
|
|
if ($targetPrestige < 1) { |
|
56
|
|
|
return; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$fleet = $spacecraft->getFleet(); |
|
60
|
|
|
$this->logger->log(sprintf( |
|
61
|
|
|
' %s (%s) of fleet %d got destroyed, decreasing pirate round prestige by %d', |
|
62
|
|
|
$spacecraft->getName(), |
|
63
|
|
|
$spacecraft->getRump()->getName(), |
|
64
|
|
|
$fleet === null ? 0 : $fleet->getId(), |
|
65
|
|
|
$targetPrestige |
|
66
|
|
|
)); |
|
67
|
|
|
|
|
68
|
|
|
$this->pirateRoundManager->decreasePrestige($targetPrestige); |
|
69
|
|
|
$this->pirateRoundManager->addUserStats($destroyerUser, $targetPrestige); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
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