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
|
|
|
|
16
|
|
|
class StateIconAndTitle |
17
|
|
|
{ |
18
|
8 |
|
public function __construct( |
19
|
|
|
private GameControllerInterface $game, |
20
|
|
|
private Parser $bbCodeParser |
21
|
8 |
|
) {} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return array<string>|null |
25
|
|
|
*/ |
26
|
11 |
|
public function getStateIconAndTitle(SpacecraftWrapperInterface $wrapper): ?array |
27
|
|
|
{ |
28
|
11 |
|
$spacecraft = $wrapper->get(); |
29
|
11 |
|
$state = $spacecraft->getState(); |
30
|
|
|
|
31
|
11 |
|
if ($state === SpacecraftStateEnum::SHIP_STATE_RETROFIT) { |
32
|
|
|
return ['buttons/konstr1', 'Schiff wird umgerüstet']; |
33
|
|
|
} |
34
|
|
|
|
35
|
11 |
|
if ($state === SpacecraftStateEnum::SHIP_STATE_REPAIR_ACTIVE) { |
36
|
2 |
|
$isStation = $spacecraft->isStation(); |
37
|
2 |
|
return ['buttons/rep2', sprintf('%s repariert die Station', $isStation ? 'Stationscrew' : 'Schiffscrew')]; |
38
|
|
|
} |
39
|
|
|
|
40
|
9 |
|
if ($state === SpacecraftStateEnum::SHIP_STATE_REPAIR_PASSIVE) { |
41
|
2 |
|
$isStation = $spacecraft->isStation(); |
42
|
2 |
|
$repairDuration = $wrapper->getRepairDuration(); |
43
|
2 |
|
return ['buttons/rep2', sprintf('%s wird repariert (noch %d Runden)', $isStation ? 'Station' : 'Schiff', $repairDuration)]; |
44
|
|
|
} |
45
|
|
|
|
46
|
7 |
|
$astroLab = $wrapper instanceof ShipWrapperInterface ? $wrapper->getAstroLaboratorySystemData() : null; |
47
|
|
|
if ( |
48
|
7 |
|
$state === SpacecraftStateEnum::SHIP_STATE_ASTRO_FINALIZING |
49
|
7 |
|
&& $astroLab !== null |
50
|
|
|
) { |
51
|
1 |
|
return ['buttons/map1', sprintf( |
52
|
1 |
|
'Schiff kartographiert (noch %d Runden)', |
53
|
1 |
|
$astroLab->getAstroStartTurn() + AstronomicalMappingEnum::TURNS_TO_FINISH - $this->game->getCurrentRound()->getTurn() |
54
|
1 |
|
)]; |
55
|
|
|
} |
56
|
|
|
|
57
|
6 |
|
$takeover = $spacecraft->getTakeoverActive(); |
58
|
|
|
if ( |
59
|
6 |
|
$state === SpacecraftStateEnum::SHIP_STATE_ACTIVE_TAKEOVER |
60
|
6 |
|
&& $takeover !== null |
61
|
|
|
) { |
62
|
1 |
|
$targetNamePlainText = $this->bbCodeParser->parse($takeover->getTargetSpacecraft()->getName())->getAsText(); |
63
|
1 |
|
return ['buttons/take2', sprintf( |
64
|
1 |
|
'Schiff übernimmt die "%s" (noch %d Runden)', |
65
|
1 |
|
$targetNamePlainText, |
66
|
1 |
|
$wrapper->getTakeoverTicksLeft($takeover) |
67
|
1 |
|
)]; |
68
|
|
|
} |
69
|
|
|
|
70
|
5 |
|
$takeover = $spacecraft->getTakeoverPassive(); |
71
|
5 |
|
if ($takeover !== null) { |
72
|
1 |
|
$sourceUserNamePlainText = $this->bbCodeParser->parse($takeover->getSourceSpacecraft()->getUser()->getName())->getAsText(); |
73
|
1 |
|
return ['buttons/untake2', sprintf( |
74
|
1 |
|
'Schiff wird von Spieler "%s" übernommen (noch %d Runden)', |
75
|
1 |
|
$sourceUserNamePlainText, |
76
|
1 |
|
$wrapper->getTakeoverTicksLeft($takeover) |
77
|
1 |
|
)]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if ( |
81
|
4 |
|
$state === SpacecraftStateEnum::SHIP_STATE_GATHER_RESOURCES |
82
|
4 |
|
&& $spacecraft instanceof ShipInterface |
83
|
|
|
) { |
84
|
|
|
$miningqueue = $spacecraft->getMiningQueue(); |
85
|
|
|
$module = $spacecraft->getShipSystem(SpacecraftSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR)->getModule(); |
86
|
|
|
$gathercount = 0; |
|
|
|
|
87
|
|
|
if ($miningqueue !== null) { |
88
|
|
|
$locationmining = $miningqueue->getLocationMining(); |
89
|
|
|
if ($module !== null) { |
90
|
|
|
$gathercount = $module->getFactionId() == null ? 100 : 200; |
|
|
|
|
91
|
|
|
return [sprintf('commodities/%s', $locationmining->getCommodity()->getId()), sprintf( |
92
|
|
|
'Schiff sammelt Ressourcen (~%d %s/Tick)', |
93
|
|
|
$gathercount, |
94
|
|
|
$locationmining->getCommodity()->getName() |
95
|
|
|
)]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
4 |
|
return null; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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