1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Tick\Spacecraft\Handler; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
7
|
|
|
use Stu\Lib\Information\InformationInterface; |
8
|
|
|
use Stu\Lib\Transfer\Storage\StorageManagerInterface; |
9
|
|
|
use Stu\Module\Control\StuRandom; |
10
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
12
|
|
|
use Stu\Orm\Repository\LocationMiningRepositoryInterface; |
13
|
|
|
|
14
|
|
|
class BussardCollectorHandler implements SpacecraftTickHandlerInterface |
15
|
|
|
{ |
16
|
1 |
|
public function __construct( |
17
|
|
|
private readonly LocationMiningRepositoryInterface $locationMiningRepository, |
18
|
|
|
private readonly StorageManagerInterface $storageManager, |
19
|
|
|
private readonly StuRandom $stuRandom |
20
|
1 |
|
) {} |
21
|
|
|
|
22
|
|
|
#[Override] |
23
|
|
|
public function handleSpacecraftTick( |
24
|
|
|
SpacecraftWrapperInterface $wrapper, |
25
|
|
|
InformationInterface $information |
26
|
|
|
): void { |
27
|
|
|
|
28
|
|
|
if (!$wrapper instanceof ShipWrapperInterface) { |
29
|
|
|
return; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$ship = $wrapper->get(); |
33
|
|
|
$bussard = $wrapper->getBussardCollectorSystemData(); |
34
|
|
|
$miningqueue = $ship->getMiningQueue(); |
35
|
|
|
|
36
|
|
|
if ($bussard === null) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if ($miningqueue == null) { |
41
|
|
|
return; |
42
|
|
|
} else { |
43
|
|
|
$locationmining = $miningqueue->getLocationMining(); |
44
|
|
|
$actualAmount = $locationmining->getActualAmount(); |
45
|
|
|
$freeStorage = $ship->getMaxStorage() - $ship->getStorageSum(); |
46
|
|
|
$module = $ship->getSpacecraftSystem(SpacecraftSystemTypeEnum::BUSSARD_COLLECTOR)->getModule(); |
47
|
|
|
$gathercount = 0; |
48
|
|
|
|
49
|
|
|
if ($module !== null) { |
50
|
|
|
if ($module->getFactionId() == null) { |
51
|
|
|
$gathercount = (int) min(min(round($this->stuRandom->rand(95, 105)), $actualAmount), $freeStorage); |
52
|
|
|
} else { |
53
|
|
|
$gathercount = (int) min(min(round($this->stuRandom->rand(190, 220)), $actualAmount), $freeStorage); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$newAmount = $actualAmount - $gathercount; |
58
|
|
|
if ($gathercount > 0 && $locationmining->getDepletedAt() !== null) { |
59
|
|
|
$locationmining->setDepletedAt(null); |
60
|
|
|
} |
61
|
|
|
if ($newAmount == 0 && $actualAmount > 0) { |
62
|
|
|
$locationmining->setDepletedAt(time()); |
63
|
|
|
$information->addInformationf( |
64
|
|
|
'Es sind keine %s bei den Koordinaten %s|%s vorhanden!', |
65
|
|
|
$locationmining->getCommodity()->getName(), |
66
|
|
|
(string)$locationmining->getLocation()->getCx(), |
67
|
|
|
(string)$locationmining->getLocation()->getCy() |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
$locationmining->setActualAmount($newAmount); |
71
|
|
|
|
72
|
|
|
$this->locationMiningRepository->save($locationmining); |
73
|
|
|
if ($gathercount + $ship->getStorageSum() >= $ship->getMaxStorage()) { |
74
|
|
|
$information->addInformationf('Der Lagerraum des Schiffes wurde beim Sammeln von %s voll!', $locationmining->getCommodity()->getName()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if ($gathercount > 0) { |
78
|
|
|
$this->storageManager->upperStorage( |
79
|
|
|
$ship, |
80
|
|
|
$locationmining->getCommodity(), |
81
|
|
|
$gathercount |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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