Passed
Pull Request — master (#1928)
by Janko
12:21
created

ColonyScanPanel::getEntryCallable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Colony\Lib\Gui;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Component\Building\BuildingEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Building\BuildingEnum was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Stu\Component\Colony\ColonyFunctionManagerInterface;
10
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel;
11
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountLayerTypeEnum;
12
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum;
13
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerCreationInterface;
14
use Stu\Lib\Map\VisualPanel\PanelBoundaries;
15
use Stu\Lib\Map\VisualPanel\VisualPanelElementInterface;
16
use Stu\Module\Logging\LoggerUtilInterface;
17
use Stu\Orm\Entity\ColonyInterface;
18
19
class ColonyScanPanel extends AbstractVisualPanel
20
{
21
    public function __construct(
22
        PanelLayerCreationInterface $panelLayerCreation,
23
        private ColonyInterface $colony,
24
        private ColonyFunctionManagerInterface $colonyFunctionManager,
25
        LoggerUtilInterface $loggerUtil
26
    ) {
27
        parent::__construct($panelLayerCreation, $loggerUtil);
28
    }
29
30
    #[Override]
31
    protected function createBoundaries(): PanelBoundaries
32
    {
33
        $range = 1;
34
        // TODO range = 2 for colony central
35
36
        if ($this->colonyFunctionManager->hasFunction($this->colony, BuildingEnum::BUILDING_FUNCTION_SUBSPACE_TELESCOPE)) {
37
            $range = 3;
38
        }
39
40
        return PanelBoundaries::fromLocation($this->colony->getStarsystemMap(), $range);
41
    }
42
43
    #[Override]
44
    protected function loadLayers(): void
45
    {
46
        //TODO cloaked for colony central
47
        $panelLayerCreation = $this->panelLayerCreation
48
            ->addShipCountLayer(false, null, ShipcountLayerTypeEnum::ALL, 0)
49
            ->addSystemLayer()
50
            ->addColonyShieldLayer();
51
52
        if ($this->colonyFunctionManager->hasFunction($this->colony, BuildingEnum::BUILDING_FUNCTION_SUBSPACE_TELESCOPE)) {
53
            $panelLayerCreation->addSubspaceLayer($this->colony->getUser()->getId(), SubspaceLayerTypeEnum::IGNORE_USER);
54
        }
55
56
        $this->layers = $panelLayerCreation->build($this);
57
    }
58
59
    #[Override]
60
    protected function getEntryCallable(): callable
61
    {
62
        return fn(int $x, int $y): VisualPanelElementInterface => new ColonyScanPanelEntry(
63
            $x,
64
            $y,
65
            $this->layers
66
        );
67
    }
68
69
    #[Override]
70
    protected function getPanelViewportPercentage(): int
71
    {
72
        return 8;
73
    }
74
}
75