1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Tick\Spacecraft\Handler; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use Stu\Component\Faction\FactionEnum; |
7
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
8
|
|
|
use Stu\Lib\Information\InformationInterface; |
9
|
|
|
use Stu\Lib\Transfer\Storage\StorageManagerInterface; |
10
|
|
|
use Stu\Module\Commodity\CommodityTypeConstants; |
|
|
|
|
11
|
|
|
use Stu\Module\Commodity\Lib\CommodityCacheInterface; |
12
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
13
|
|
|
use Stu\Module\Station\Lib\StationWrapperInterface; |
14
|
|
|
use Stu\Orm\Repository\StorageRepositoryInterface; |
15
|
|
|
|
16
|
|
|
class AggregationSystemHandler implements SpacecraftTickHandlerInterface |
17
|
|
|
{ |
18
|
1 |
|
public function __construct( |
19
|
|
|
private CommodityCacheInterface $commodityCache, |
20
|
|
|
private StorageRepositoryInterface $storageRepository, |
21
|
|
|
private StorageManagerInterface $storageManager |
22
|
1 |
|
) {} |
23
|
|
|
|
24
|
|
|
#[Override] |
25
|
|
|
public function handleSpacecraftTick( |
26
|
|
|
SpacecraftWrapperInterface $wrapper, |
27
|
|
|
InformationInterface $information |
28
|
|
|
): void { |
29
|
|
|
|
30
|
|
|
if (!$wrapper instanceof StationWrapperInterface) { |
31
|
|
|
return; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$station = $wrapper->get(); |
35
|
|
|
$aggsys = $wrapper->getAggregationSystemSystemData(); |
36
|
|
|
|
37
|
|
|
if ($aggsys === null) { |
38
|
|
|
return; |
39
|
|
|
} else { |
40
|
|
|
$module = $station->getSpacecraftSystem(SpacecraftSystemTypeEnum::AGGREGATION_SYSTEM)->getModule(); |
41
|
|
|
$producedAmount = 0; |
42
|
|
|
$usedAmount = 0; |
43
|
|
|
$usedCommodity = null; |
44
|
|
|
$producedCommodity = null; |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
if ($module !== null) { |
48
|
|
|
$commodity = $aggsys->getCommodityId(); |
49
|
|
|
$commodities = CommodityTypeConstants::COMMODITY_CONVERSIONS; |
50
|
|
|
|
51
|
|
|
if ($commodity > 0) { |
52
|
|
|
foreach ($commodities as $entry) { |
53
|
|
|
if ($entry[0] === $commodity) { |
54
|
|
|
$producedCommodityId = $entry[1]; |
55
|
|
|
$producedCommodity = $this->commodityCache->get($producedCommodityId); |
56
|
|
|
$usedCommodity = $this->commodityCache->get($entry[0]); |
57
|
|
|
$usedAmount = $entry[2]; |
58
|
|
|
$producedAmount = $entry[3]; |
59
|
|
|
break; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if ($module->getFactionId() == FactionEnum::FACTION_FERENGI) { |
64
|
|
|
$producedAmount *= 2; |
65
|
|
|
$usedAmount *= 2; |
66
|
|
|
} |
67
|
|
|
$storage = $this->storageRepository->findOneBy([ |
68
|
|
|
'commodity' => $usedCommodity, |
69
|
|
|
'spacecraft' => $station |
70
|
|
|
]); |
71
|
|
|
if (!$storage && $usedCommodity) { |
72
|
|
|
$information->addInformationf('Es ist kein %s vorhanden!', $usedCommodity->getName()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if ($storage && $producedCommodity && $usedCommodity) { |
76
|
|
|
if ($storage->getAmount() >= $usedAmount) { |
77
|
|
|
$this->storageManager->lowerStorage( |
78
|
|
|
$station, |
79
|
|
|
$usedCommodity, |
80
|
|
|
$usedAmount |
81
|
|
|
); |
82
|
|
|
$this->storageManager->upperStorage( |
83
|
|
|
$station, |
84
|
|
|
$producedCommodity, |
85
|
|
|
$producedAmount |
86
|
|
|
); |
87
|
|
|
} else { |
88
|
|
|
$information->addInformationf('Nicht genügend %s vorhanden!', $usedCommodity->getName()); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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