1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib\Ui; |
6
|
|
|
|
7
|
|
|
use JBBCode\Parser; |
8
|
|
|
use Stu\Component\Ship\AstronomicalMappingEnum; |
|
|
|
|
9
|
|
|
use Stu\Component\Ship\ShipStateEnum; |
10
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
11
|
|
|
use Stu\Module\Control\GameControllerInterface; |
12
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class StateIconAndTitle |
16
|
|
|
{ |
17
|
8 |
|
public function __construct( |
18
|
|
|
private GameControllerInterface $game, |
19
|
|
|
private Parser $bbCodeParser |
20
|
8 |
|
) {} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @return array<string>|null |
24
|
|
|
*/ |
25
|
7 |
|
public function getStateIconAndTitle(ShipWrapperInterface $wrapper): ?array |
26
|
|
|
{ |
27
|
7 |
|
$ship = $wrapper->get(); |
28
|
7 |
|
$state = $ship->getState(); |
29
|
|
|
|
30
|
7 |
|
if ($state === ShipStateEnum::SHIP_STATE_RETROFIT) { |
31
|
|
|
return ['buttons/konstr1', 'Schiff wird umgerüstet']; |
32
|
|
|
} |
33
|
|
|
|
34
|
7 |
|
if ($state === ShipStateEnum::SHIP_STATE_REPAIR_ACTIVE) { |
35
|
2 |
|
$isBase = $ship->isBase(); |
36
|
2 |
|
return ['buttons/rep2', sprintf('%s repariert die Station', $isBase ? 'Stationscrew' : 'Schiffscrew')]; |
37
|
|
|
} |
38
|
|
|
|
39
|
5 |
|
if ($state === ShipStateEnum::SHIP_STATE_REPAIR_PASSIVE) { |
40
|
2 |
|
$isBase = $ship->isBase(); |
41
|
2 |
|
$repairDuration = $wrapper->getRepairDuration(); |
42
|
2 |
|
return ['buttons/rep2', sprintf('%s wird repariert (noch %d Runden)', $isBase ? 'Station' : 'Schiff', $repairDuration)]; |
43
|
|
|
} |
44
|
|
|
|
45
|
3 |
|
$currentTurn = $this->game->getCurrentRound()->getTurn(); |
46
|
3 |
|
$astroLab = $wrapper->getAstroLaboratorySystemData(); |
47
|
|
|
if ( |
48
|
3 |
|
$state === ShipStateEnum::SHIP_STATE_ASTRO_FINALIZING |
49
|
3 |
|
&& $astroLab !== null |
50
|
|
|
) { |
51
|
1 |
|
return ['buttons/map1', sprintf( |
52
|
1 |
|
'Schiff kartographiert (noch %d Runden)', |
53
|
1 |
|
$astroLab->getAstroStartTurn() + AstronomicalMappingEnum::TURNS_TO_FINISH - $currentTurn |
54
|
1 |
|
)]; |
55
|
|
|
} |
56
|
|
|
|
57
|
2 |
|
$takeover = $ship->getTakeoverActive(); |
58
|
|
|
if ( |
59
|
2 |
|
$state === ShipStateEnum::SHIP_STATE_ACTIVE_TAKEOVER |
60
|
2 |
|
&& $takeover !== null |
61
|
|
|
) { |
62
|
1 |
|
$targetNamePlainText = $this->bbCodeParser->parse($takeover->getTargetShip()->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
|
1 |
|
$takeover = $ship->getTakeoverPassive(); |
71
|
1 |
|
if ($takeover !== null) { |
72
|
1 |
|
$sourceUserNamePlainText = $this->bbCodeParser->parse($takeover->getSourceShip()->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 ($state === ShipStateEnum::SHIP_STATE_GATHER_RESOURCES) { |
81
|
|
|
$miningqueue = $ship->getMiningQueue(); |
82
|
|
|
$module = $ship->getShipSystem(ShipSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR)->getModule(); |
83
|
|
|
$gathercount = 0; |
|
|
|
|
84
|
|
|
if ($miningqueue !== null) { |
85
|
|
|
$locationmining = $miningqueue->getLocationMining(); |
86
|
|
|
if ($module !== null) { |
87
|
|
|
$gathercount = $module->getFactionId() == null ? 100 : 200; |
|
|
|
|
88
|
|
|
return [sprintf('commodities/%s', $locationmining->getCommodity()->getId()), sprintf( |
89
|
|
|
'Schiff sammelt Ressourcen (~%d %s/Tick)', |
90
|
|
|
$gathercount, |
91
|
|
|
$locationmining->getCommodity()->getName() |
92
|
|
|
)]; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return null; |
98
|
|
|
} |
99
|
|
|
} |
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