1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Tick\Spacecraft\Handler; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use Stu\Component\Spacecraft\SpacecraftStateEnum; |
7
|
|
|
use Stu\Component\Station\StationUtilityInterface; |
8
|
|
|
use Stu\Lib\Information\InformationInterface; |
9
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
10
|
|
|
use Stu\Module\Station\Lib\StationWrapperInterface; |
11
|
|
|
use Stu\Module\Tick\Spacecraft\SpacecraftTickFinishedException; |
12
|
|
|
|
13
|
|
|
class StationConstructionHandler implements SpacecraftTickHandlerInterface |
14
|
|
|
{ |
15
|
1 |
|
public function __construct( |
16
|
|
|
private StationUtilityInterface $stationUtility |
17
|
1 |
|
) {} |
18
|
|
|
|
19
|
1 |
|
#[Override] |
20
|
|
|
public function handleSpacecraftTick( |
21
|
|
|
SpacecraftWrapperInterface $wrapper, |
22
|
|
|
InformationInterface $information |
23
|
|
|
): void { |
24
|
|
|
|
25
|
|
|
if ( |
26
|
1 |
|
$wrapper instanceof StationWrapperInterface |
27
|
1 |
|
&& $this->doConstructionStuff($wrapper, $information) |
28
|
|
|
) { |
29
|
|
|
throw new SpacecraftTickFinishedException(); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
1 |
|
private function doConstructionStuff(StationWrapperInterface $wrapper, InformationInterface $information): bool |
34
|
|
|
{ |
35
|
1 |
|
$station = $wrapper->get(); |
36
|
|
|
|
37
|
1 |
|
$progress = $station->getConstructionProgress(); |
38
|
1 |
|
if ($progress === null) { |
39
|
|
|
return false; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
if ($progress->getRemainingTicks() === 0) { |
43
|
1 |
|
return false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$isUnderConstruction = $station->getState() === SpacecraftStateEnum::UNDER_CONSTRUCTION; |
47
|
|
|
|
48
|
|
|
if (!$this->stationUtility->hasEnoughDockedWorkbees($station, $station->getRump())) { |
49
|
|
|
$neededWorkbees = $isUnderConstruction ? $station->getRump()->getNeededWorkbees() : |
50
|
|
|
(int)ceil($station->getRump()->getNeededWorkbees() / 2); |
51
|
|
|
|
52
|
|
|
$information->addInformationf( |
53
|
|
|
'Nicht genügend Workbees (%d/%d) angedockt um %s weiterführen zu können', |
54
|
|
|
$this->stationUtility->getDockedWorkbeeCount($station), |
55
|
|
|
$neededWorkbees ?? 0, |
56
|
|
|
$isUnderConstruction ? 'den Bau' : 'die Demontage' |
57
|
|
|
); |
58
|
|
|
return true; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if ($isUnderConstruction) { |
62
|
|
|
// raise hull |
63
|
|
|
$increase = (int)ceil($station->getMaxHull() / (2 * $station->getRump()->getBuildtime())); |
64
|
|
|
$station->getCondition()->changeHull($increase); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if ($progress->getRemainingTicks() === 1) { |
68
|
|
|
|
69
|
|
|
$information->addInformationf( |
70
|
|
|
'%s: %s bei %s fertiggestellt', |
71
|
|
|
$station->getRump()->getName(), |
72
|
|
|
$isUnderConstruction ? 'Bau' : 'Demontage', |
73
|
|
|
$station->getSectorString() |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
if ($isUnderConstruction) { |
77
|
|
|
$this->stationUtility->finishStation($progress); |
78
|
|
|
} else { |
79
|
|
|
$this->stationUtility->finishScrapping($progress, $information); |
80
|
|
|
} |
81
|
|
|
} else { |
82
|
|
|
$this->stationUtility->reduceRemainingTicks($progress); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return true; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
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