|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Tick\Spacecraft\ManagerComponent; |
|
4
|
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
|
|
6
|
|
|
use Stu\Lib\Information\InformationFactoryInterface; |
|
7
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
8
|
|
|
use Stu\Lib\Information\InformationWrapper; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface; |
|
11
|
|
|
use Stu\Module\Message\Lib\PrivateMessageSenderInterface; |
|
12
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
13
|
|
|
use Stu\Module\Tick\Spacecraft\Handler\StationConstructionHandler; |
|
14
|
|
|
use Stu\Module\Tick\Spacecraft\Handler\StationPassiveRepairHandler; |
|
15
|
|
|
use Stu\Module\Tick\Spacecraft\SpacecraftTickFinishedException; |
|
16
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
17
|
|
|
use Stu\Orm\Repository\SpacecraftRepositoryInterface; |
|
18
|
|
|
|
|
19
|
|
|
class NpcShipHandling implements ManagerComponentInterface |
|
20
|
|
|
{ |
|
21
|
1 |
|
public function __construct( |
|
22
|
|
|
private readonly SpacecraftRepositoryInterface $spacecraftRepository, |
|
23
|
|
|
private readonly StationConstructionHandler $stationConstructionHandler, |
|
24
|
|
|
private readonly StationPassiveRepairHandler $stationPassiveRepairHandler, |
|
25
|
|
|
private readonly PrivateMessageSenderInterface $privateMessageSender, |
|
26
|
|
|
private readonly SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory, |
|
27
|
|
|
private readonly InformationFactoryInterface $informationFactory |
|
28
|
1 |
|
) {} |
|
29
|
|
|
|
|
30
|
|
|
#[Override] |
|
31
|
|
|
public function work(): void |
|
32
|
|
|
{ |
|
33
|
|
|
foreach ($this->spacecraftRepository->getNpcSpacecraftsForTick() as $spacecraft) { |
|
34
|
|
|
|
|
35
|
|
|
$informationWrapper = $this->informationFactory->createInformationWrapper(); |
|
36
|
|
|
$wrapper = $this->spacecraftWrapperFactory->wrapSpacecraft($spacecraft); |
|
37
|
|
|
|
|
38
|
|
|
$this->workSpacecraft($wrapper, $informationWrapper); |
|
39
|
|
|
|
|
40
|
|
|
$this->sendMessage($wrapper->get(), $informationWrapper); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
private function workSpacecraft(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
try { |
|
48
|
|
|
$this->stationConstructionHandler->handleSpacecraftTick($wrapper, $information); |
|
49
|
|
|
$this->stationPassiveRepairHandler->handleSpacecraftTick($wrapper, $information); |
|
50
|
|
|
} catch (SpacecraftTickFinishedException) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$reactor = $wrapper->getReactorWrapper(); |
|
55
|
|
|
if ($reactor === null) { |
|
56
|
|
|
return; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$epsSystem = $wrapper->getEpsSystemData(); |
|
60
|
|
|
$warpdrive = $wrapper->getWarpDriveSystemData(); |
|
61
|
|
|
|
|
62
|
|
|
//load EPS |
|
63
|
|
|
if ($epsSystem !== null) { |
|
64
|
|
|
$epsSystem->setEps($epsSystem->getEps() + $reactor->getEffectiveEpsProduction())->update(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
//load warpdrive |
|
68
|
|
|
if ($warpdrive !== null) { |
|
69
|
|
|
$warpdrive->setWarpDrive($warpdrive->getWarpDrive() + $reactor->getEffectiveWarpDriveProduction())->update(); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
private function sendMessage(SpacecraftInterface $ship, InformationWrapper $informationWrapper): void |
|
74
|
|
|
{ |
|
75
|
|
|
if ($informationWrapper->isEmpty()) { |
|
76
|
|
|
return; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$text = sprintf("Tickreport der %s\n%s", $ship->getName(), $informationWrapper->getInformationsAsString()); |
|
80
|
|
|
|
|
81
|
|
|
$this->privateMessageSender->send( |
|
82
|
|
|
UserEnum::USER_NOONE, |
|
83
|
|
|
$ship->getUser()->getId(), |
|
84
|
|
|
$text, |
|
85
|
|
|
$ship->getType()->getMessageFolderType(), |
|
86
|
|
|
$ship |
|
87
|
|
|
); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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