1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use RuntimeException; |
7
|
|
|
use Stu\Component\Colony\OrbitShipWrappersRetrieverInterface; |
8
|
|
|
use Stu\Lib\Colony\PlanetFieldHostProviderInterface; |
9
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
11
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
12
|
|
|
use Stu\Orm\Repository\ShipRumpBuildingFunctionRepositoryInterface; |
13
|
|
|
|
14
|
|
|
final class ShipRepairProvider implements PlanetFieldHostComponentInterface |
15
|
|
|
{ |
16
|
1 |
|
public function __construct( |
17
|
|
|
private ShipRumpBuildingFunctionRepositoryInterface $shipRumpBuildingFunctionRepository, |
18
|
|
|
private PlanetFieldHostProviderInterface $planetFieldHostProvider, |
19
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory, |
20
|
|
|
private OrbitShipWrappersRetrieverInterface $orbitShipWrappersRetriever |
21
|
1 |
|
) {} |
22
|
|
|
|
23
|
|
|
/** @param ColonyInterface $entity */ |
24
|
1 |
|
#[Override] |
25
|
|
|
public function setTemplateVariables( |
26
|
|
|
$entity, |
27
|
|
|
GameControllerInterface $game |
28
|
|
|
): void { |
29
|
1 |
|
$field = $this->planetFieldHostProvider->loadFieldViaRequestParameter($game->getUser(), false); |
30
|
|
|
|
31
|
1 |
|
$building = $field->getBuilding(); |
32
|
1 |
|
if ($building === null) { |
33
|
|
|
throw new RuntimeException('building is null'); |
34
|
|
|
} |
35
|
|
|
|
36
|
1 |
|
$fieldFunctions = $building->getFunctions()->toArray(); |
37
|
1 |
|
$colonySurface = $this->colonyLibFactory->createColonySurface($entity); |
38
|
|
|
|
39
|
1 |
|
if (!$colonySurface->hasShipyard()) { |
40
|
1 |
|
return; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$repairableShipWrappers = []; |
44
|
|
|
$groups = $this->orbitShipWrappersRetriever->retrieve($entity); |
45
|
|
|
|
46
|
|
|
foreach ($groups as $group) { |
47
|
|
|
|
48
|
|
|
foreach ($group->getWrappers() as $wrapper) { |
49
|
|
|
|
50
|
|
|
$ship = $wrapper->get(); |
51
|
|
|
if (!$wrapper->canBeRepaired() || $ship->isUnderRepair()) { |
52
|
|
|
continue; |
53
|
|
|
} |
54
|
|
|
foreach ($this->shipRumpBuildingFunctionRepository->getByShipRump($ship->getRump()) as $rump_rel) { |
55
|
|
|
if (array_key_exists($rump_rel->getBuildingFunction()->value, $fieldFunctions)) { |
56
|
|
|
$repairableShipWrappers[$ship->getId()] = $wrapper; |
57
|
|
|
break; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$game->setTemplateVar('REPAIRABLE_SHIP_WRAPPERS', $repairableShipWrappers); |
64
|
|
|
$game->setTemplateVar('FIELD', $field); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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