|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Game\Component; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Lib\Component\ComponentInterface; |
|
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
10
|
|
|
use Stu\Module\Research\TechlistRetrieverInterface; |
|
11
|
|
|
use Stu\Module\Template\StatusBarColorEnum; |
|
|
|
|
|
|
12
|
|
|
use Stu\Module\Template\StatusBarFactoryInterface; |
|
13
|
|
|
use Stu\Orm\Repository\BuildingCommodityRepositoryInterface; |
|
14
|
|
|
use Stu\Orm\Repository\ResearchedRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Renders the research state view in the header |
|
18
|
|
|
*/ |
|
19
|
|
|
final class ResearchComponent implements ComponentInterface |
|
20
|
|
|
{ |
|
21
|
3 |
|
public function __construct( |
|
22
|
|
|
private ResearchedRepositoryInterface $researchedRepository, |
|
23
|
|
|
private StatusBarFactoryInterface $statusBarFactory, |
|
24
|
|
|
private TechlistRetrieverInterface $techlistRetriever, |
|
25
|
|
|
private BuildingCommodityRepositoryInterface $buildingCommodityRepository |
|
26
|
3 |
|
) {} |
|
27
|
|
|
|
|
28
|
5 |
|
#[Override] |
|
29
|
|
|
public function setTemplateVariables(GameControllerInterface $game): void |
|
30
|
|
|
{ |
|
31
|
5 |
|
$user = $game->getUser(); |
|
32
|
5 |
|
$researchStatusBar = ''; |
|
33
|
5 |
|
$currentResearch = $this->researchedRepository->getCurrentResearch($user); |
|
34
|
|
|
|
|
35
|
5 |
|
if ($currentResearch !== []) { |
|
36
|
1 |
|
$research = current($currentResearch)->getResearch(); |
|
37
|
1 |
|
$researchPoints = $research->getPoints(); |
|
38
|
|
|
|
|
39
|
1 |
|
$researchStatusBar = $this |
|
40
|
1 |
|
->statusBarFactory |
|
41
|
1 |
|
->createStatusBar() |
|
42
|
1 |
|
->setColor(StatusBarColorEnum::STATUSBAR_BLUE) |
|
43
|
1 |
|
->setLabel('Forschung') |
|
44
|
1 |
|
->setMaxValue($researchPoints) |
|
45
|
1 |
|
->setValue($researchPoints - current($currentResearch)->getActive()) |
|
46
|
1 |
|
->setSizeModifier(2); |
|
47
|
|
|
|
|
48
|
1 |
|
$game->setTemplateVar( |
|
49
|
1 |
|
'CURRENT_RESEARCH_PRODUCTION_COMMODITY', |
|
50
|
1 |
|
max( |
|
51
|
1 |
|
0, |
|
52
|
1 |
|
$this->buildingCommodityRepository->getProductionByCommodityAndUser( |
|
53
|
1 |
|
$research->getCommodityId(), |
|
54
|
1 |
|
$user |
|
55
|
1 |
|
) |
|
56
|
1 |
|
) |
|
57
|
1 |
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
5 |
|
$researchList = $this->techlistRetriever->getResearchList($user); |
|
61
|
5 |
|
$hasResearchList = $researchList !== []; |
|
62
|
5 |
|
$hasCurrentResearch = $currentResearch !== []; |
|
63
|
|
|
|
|
64
|
5 |
|
$game->setTemplateVar('CURRENT_RESEARCH', current($currentResearch)); |
|
65
|
5 |
|
$game->setTemplateVar('CURRENT_RESEARCH_STATUS', $researchStatusBar); |
|
66
|
5 |
|
$game->setTemplateVar('WAITING_RESEARCH', count($currentResearch) === 2 ? $currentResearch[1] : null); |
|
67
|
5 |
|
$game->setTemplateVar('RESEARCH_POSSIBLE', $hasResearchList || $hasCurrentResearch); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
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