|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Ship\Lib\Destruction\Handler; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
6
|
|
|
use Stu\Lib\Pirate\Component\PirateWrathManagerInterface; |
|
7
|
|
|
use Stu\Module\Logging\LoggerUtilFactoryInterface; |
|
8
|
|
|
use Stu\Module\Logging\PirateLoggerInterface; |
|
9
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
10
|
|
|
use Stu\Module\Ship\Lib\Destruction\ShipDestroyerInterface; |
|
11
|
|
|
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum; |
|
12
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
13
|
|
|
|
|
14
|
|
|
class UpdatePirateWrath implements ShipDestructionHandlerInterface |
|
15
|
|
|
{ |
|
16
|
|
|
private PirateLoggerInterface $logger; |
|
17
|
|
|
|
|
18
|
1 |
|
public function __construct( |
|
19
|
|
|
private PirateWrathManagerInterface $pirateWrathManager, |
|
20
|
|
|
LoggerUtilFactoryInterface $loggerUtilFactory |
|
21
|
|
|
) { |
|
22
|
1 |
|
$this->logger = $loggerUtilFactory->getPirateLogger(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function handleShipDestruction( |
|
26
|
|
|
?ShipDestroyerInterface $destroyer, |
|
27
|
|
|
ShipWrapperInterface $destroyedShipWrapper, |
|
28
|
|
|
ShipDestructionCauseEnum $cause, |
|
29
|
|
|
InformationInterface $informations |
|
30
|
|
|
): void { |
|
31
|
|
|
|
|
32
|
|
|
if ($destroyer === null) { |
|
33
|
|
|
return; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$ship = $destroyedShipWrapper->get(); |
|
37
|
|
|
$targetPrestige = $ship->getRump()->getPrestige(); |
|
38
|
|
|
if ($targetPrestige < 1) { |
|
39
|
|
|
return; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$destroyerUser = $destroyer->getUser(); |
|
43
|
|
|
$userOfDestroyed = $destroyedShipWrapper->get()->getUser(); |
|
44
|
|
|
|
|
45
|
|
|
if ($destroyerUser->getId() === UserEnum::USER_NPC_KAZON) { |
|
46
|
|
|
$this->pirateWrathManager->decreaseWrath($userOfDestroyed, $targetPrestige); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if ($userOfDestroyed->getId() === UserEnum::USER_NPC_KAZON) { |
|
50
|
|
|
|
|
51
|
|
|
$fleet = $ship->getFleet(); |
|
52
|
|
|
$this->logger->log(sprintf( |
|
53
|
|
|
' %s (%s) of fleet %d got destroyed by %s', |
|
54
|
|
|
$ship->getName(), |
|
55
|
|
|
$ship->getRump()->getName(), |
|
56
|
|
|
$fleet === null ? 0 : $fleet->getId(), |
|
57
|
|
|
$destroyer->getName() |
|
58
|
|
|
)); |
|
59
|
|
|
|
|
60
|
|
|
$this->pirateWrathManager->increaseWrath($userOfDestroyed, $targetPrestige); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|