1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Component\Spacecraft\System\Data; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
9
|
|
|
use Stu\Module\Template\StatusBarColorEnum; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class EpsSystemData extends AbstractSystemData |
12
|
|
|
{ |
13
|
|
|
// eps fields |
14
|
|
|
public int $eps = 0; |
15
|
|
|
public int $maxEps = 0; |
16
|
|
|
|
17
|
|
|
// battery fields |
18
|
|
|
public int $maxBattery = 0; |
19
|
|
|
public int $battery = 0; |
20
|
|
|
public int $batteryCooldown = 0; |
21
|
|
|
public bool $reloadBattery = false; |
22
|
|
|
|
23
|
1 |
|
#[Override] |
24
|
|
|
public function getSystemType(): SpacecraftSystemTypeEnum |
25
|
|
|
{ |
26
|
1 |
|
return SpacecraftSystemTypeEnum::EPS; |
27
|
|
|
} |
28
|
|
|
|
29
|
13 |
|
public function getEps(): int |
30
|
|
|
{ |
31
|
13 |
|
return $this->eps; |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
public function setEps(int $eps): EpsSystemData |
35
|
|
|
{ |
36
|
1 |
|
$this->eps = $eps; |
37
|
1 |
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
public function lowerEps(int $amount): EpsSystemData |
41
|
|
|
{ |
42
|
1 |
|
$this->eps -= $amount; |
43
|
1 |
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
public function setMaxEps(int $maxEps): EpsSystemData |
47
|
|
|
{ |
48
|
1 |
|
$this->maxEps = $maxEps; |
49
|
1 |
|
$this->maxBattery = (int) round($maxEps / 3); |
50
|
1 |
|
return $this; |
51
|
|
|
} |
52
|
|
|
|
53
|
2 |
|
public function getTheoreticalMaxEps(): int |
54
|
|
|
{ |
55
|
2 |
|
return $this->maxEps; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* proportional to eps system status |
60
|
|
|
*/ |
61
|
10 |
|
public function getMaxEps(): int |
62
|
|
|
{ |
63
|
10 |
|
if (!$this->spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::EPS)) { |
64
|
1 |
|
return $this->maxEps; |
65
|
|
|
} |
66
|
|
|
|
67
|
9 |
|
return (int) (ceil($this->maxEps |
68
|
9 |
|
* $this->spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::EPS)->getStatus() / 100)); |
69
|
|
|
} |
70
|
|
|
|
71
|
6 |
|
public function getMaxBattery(): int |
72
|
|
|
{ |
73
|
6 |
|
return $this->maxBattery; |
74
|
|
|
} |
75
|
|
|
|
76
|
6 |
|
public function getBattery(): int |
77
|
|
|
{ |
78
|
6 |
|
return $this->battery; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function setBattery(int $battery): EpsSystemData |
82
|
|
|
{ |
83
|
|
|
$this->battery = $battery; |
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
2 |
|
public function getBatteryCooldown(): int |
88
|
|
|
{ |
89
|
2 |
|
return $this->batteryCooldown; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function setBatteryCooldown(int $batteryCooldown): EpsSystemData |
93
|
|
|
{ |
94
|
|
|
$this->batteryCooldown = $batteryCooldown; |
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
2 |
|
public function reloadBattery(): bool |
99
|
|
|
{ |
100
|
2 |
|
return $this->reloadBattery; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setReloadBattery(bool $reloadBattery): EpsSystemData |
104
|
|
|
{ |
105
|
|
|
$this->reloadBattery = $reloadBattery; |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
3 |
|
public function isEBattUseable(): bool |
110
|
|
|
{ |
111
|
3 |
|
return $this->batteryCooldown < time(); |
112
|
|
|
} |
113
|
|
|
|
114
|
1 |
|
public function getEpsPercentage(): int |
115
|
|
|
{ |
116
|
1 |
|
$currentEps = $this->getEps(); |
117
|
1 |
|
$maxEps = $this->getMaxEps(); |
118
|
|
|
|
119
|
1 |
|
if ($currentEps === 0) { |
120
|
|
|
return 0; |
121
|
|
|
} |
122
|
1 |
|
if ($maxEps === 0) { |
123
|
|
|
return 100; |
124
|
|
|
} |
125
|
|
|
|
126
|
1 |
|
return (int)floor($currentEps / $maxEps * 100); |
127
|
|
|
} |
128
|
|
|
|
129
|
3 |
|
public function getEpsStatusBar(): string |
130
|
|
|
{ |
131
|
3 |
|
return $this->getStatusBar( |
132
|
3 |
|
_('Energie'), |
133
|
3 |
|
$this->getEps(), |
134
|
3 |
|
$this->getMaxEps(), |
135
|
3 |
|
StatusBarColorEnum::STATUSBAR_YELLOW |
136
|
3 |
|
) |
137
|
3 |
|
->render(); |
138
|
|
|
} |
139
|
|
|
|
140
|
2 |
|
public function getEpsStatusBarBig(): string |
141
|
|
|
{ |
142
|
2 |
|
return $this->getStatusBar( |
143
|
2 |
|
_('Energie'), |
144
|
2 |
|
$this->getEps(), |
145
|
2 |
|
$this->getMaxEps(), |
146
|
2 |
|
StatusBarColorEnum::STATUSBAR_YELLOW |
147
|
2 |
|
) |
148
|
2 |
|
->setSizeModifier(1.6) |
149
|
2 |
|
->render(); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
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