|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Ui; |
|
6
|
|
|
|
|
7
|
|
|
use JBBCode\Parser; |
|
8
|
|
|
use Stu\Component\Ship\AstronomicalMappingEnum; |
|
|
|
|
|
|
9
|
|
|
use Stu\Component\Spacecraft\SpacecraftStateEnum; |
|
10
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
11
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
12
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
13
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
14
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
15
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
16
|
|
|
|
|
17
|
|
|
class StateIconAndTitle |
|
18
|
|
|
{ |
|
19
|
8 |
|
public function __construct( |
|
20
|
|
|
private GameControllerInterface $game, |
|
21
|
|
|
private Parser $bbCodeParser |
|
22
|
8 |
|
) {} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return array<string>|null |
|
26
|
|
|
*/ |
|
27
|
11 |
|
public function getStateIconAndTitle(SpacecraftWrapperInterface $wrapper): ?array |
|
28
|
|
|
{ |
|
29
|
11 |
|
$spacecraft = $wrapper->get(); |
|
30
|
11 |
|
$state = $spacecraft->getState(); |
|
31
|
|
|
|
|
32
|
|
|
return match ($state) { |
|
33
|
11 |
|
SpacecraftStateEnum::RETROFIT => ['buttons/konstr1', 'Schiff wird umgerüstet'], |
|
34
|
11 |
|
SpacecraftStateEnum::REPAIR_ACTIVE => $this->getForActiveRepair($spacecraft), |
|
35
|
9 |
|
SpacecraftStateEnum::REPAIR_PASSIVE => $this->getForActivePassive($wrapper), |
|
36
|
7 |
|
SpacecraftStateEnum::ASTRO_FINALIZING => $this->getForAstroFinalizing($wrapper), |
|
37
|
6 |
|
SpacecraftStateEnum::ACTIVE_TAKEOVER => $this->getForActiveTakeover($wrapper), |
|
38
|
5 |
|
SpacecraftStateEnum::GATHER_RESOURCES => $this->getForGatherResources($spacecraft), |
|
39
|
11 |
|
default => $this->getForPassiveTakeover($wrapper) |
|
40
|
|
|
}; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** @return array<string> */ |
|
44
|
2 |
|
private function getForActiveRepair(SpacecraftInterface $spacecraft): array |
|
45
|
|
|
{ |
|
46
|
2 |
|
$isStation = $spacecraft->isStation(); |
|
47
|
2 |
|
return ['buttons/rep2', sprintf( |
|
48
|
2 |
|
'%s repariert %s', |
|
49
|
2 |
|
$isStation ? 'Stationscrew' : 'Schiffscrew', |
|
50
|
2 |
|
$isStation ? 'die Station' : 'das Schiff', |
|
51
|
2 |
|
)]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** @return array<string> */ |
|
55
|
2 |
|
private function getForActivePassive(SpacecraftWrapperInterface $wrapper): array |
|
56
|
|
|
{ |
|
57
|
2 |
|
return ['buttons/rep2', sprintf( |
|
58
|
2 |
|
'%s wird repariert (noch %d Runden)', |
|
59
|
2 |
|
$wrapper->get()->isStation() ? 'Station' : 'Schiff', |
|
60
|
2 |
|
$wrapper->getRepairDuration() |
|
61
|
2 |
|
)]; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** @return array<string>|null */ |
|
65
|
1 |
|
private function getForAstroFinalizing(SpacecraftWrapperInterface $wrapper): ?array |
|
66
|
|
|
{ |
|
67
|
1 |
|
$astroLab = $wrapper instanceof ShipWrapperInterface ? $wrapper->getAstroLaboratorySystemData() : null; |
|
68
|
1 |
|
if ($astroLab === null) { |
|
69
|
|
|
return null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
return ['buttons/map1', sprintf( |
|
73
|
1 |
|
'Schiff kartographiert (noch %d Runden)', |
|
74
|
1 |
|
$astroLab->getAstroStartTurn() + AstronomicalMappingEnum::TURNS_TO_FINISH - $this->game->getCurrentRound()->getTurn() |
|
75
|
1 |
|
)]; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** @return array<string>|null */ |
|
79
|
1 |
|
private function getForActiveTakeover(SpacecraftWrapperInterface $wrapper): ?array |
|
80
|
|
|
{ |
|
81
|
1 |
|
$takeover = $wrapper->get()->getTakeoverActive(); |
|
82
|
1 |
|
if ($takeover === null) { |
|
83
|
|
|
return null; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
1 |
|
return ['buttons/take2', sprintf( |
|
87
|
1 |
|
'Schiff übernimmt die "%s" (noch %d Runden)', |
|
88
|
1 |
|
$this->bbCodeParser->parse($takeover->getTargetSpacecraft()->getName())->getAsText(), |
|
89
|
1 |
|
$wrapper->getTakeoverTicksLeft($takeover) |
|
90
|
1 |
|
)]; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** @return array<string>|null */ |
|
94
|
|
|
private function getForGatherResources(SpacecraftInterface $spacecraft): ?array |
|
95
|
|
|
{ |
|
96
|
|
|
if (!$spacecraft instanceof ShipInterface) { |
|
97
|
|
|
return null; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
$miningqueue = $spacecraft->getMiningQueue(); |
|
101
|
|
|
$module = $spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::BUSSARD_COLLECTOR)->getModule(); |
|
102
|
|
|
if ($miningqueue === null || $module === null) { |
|
103
|
|
|
return null; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$locationmining = $miningqueue->getLocationMining(); |
|
107
|
|
|
$gathercount = $module->getFactionId() == null ? 100 : 200; |
|
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
return [sprintf('commodities/%s', $locationmining->getCommodity()->getId()), sprintf( |
|
110
|
|
|
'Schiff sammelt Ressourcen (~%d %s/Tick)', |
|
111
|
|
|
$gathercount, |
|
112
|
|
|
$locationmining->getCommodity()->getName() |
|
113
|
|
|
)]; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** @return array<string>|null */ |
|
117
|
5 |
|
private function getForPassiveTakeover(SpacecraftWrapperInterface $wrapper): ?array |
|
118
|
|
|
{ |
|
119
|
5 |
|
$takeover = $wrapper->get()->getTakeoverPassive(); |
|
120
|
5 |
|
if ($takeover === null) { |
|
121
|
4 |
|
return null; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
1 |
|
$sourceUserNamePlainText = $this->bbCodeParser->parse($takeover->getSourceSpacecraft()->getUser()->getName())->getAsText(); |
|
125
|
1 |
|
return ['buttons/untake2', sprintf( |
|
126
|
1 |
|
'Schiff wird von Spieler "%s" übernommen (noch %d Runden)', |
|
127
|
1 |
|
$sourceUserNamePlainText, |
|
128
|
1 |
|
$wrapper->getTakeoverTicksLeft($takeover) |
|
129
|
1 |
|
)]; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
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