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