|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright 2010 Daniel Jakob All Rights Reserved |
|
6
|
|
|
* This software is the proprietary information of Daniel Jakob |
|
7
|
|
|
* Use is subject to license terms |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/* $Id:$ */ |
|
12
|
|
|
|
|
13
|
|
|
namespace Stu\Lib; |
|
14
|
|
|
|
|
15
|
|
|
use Stu\Component\Ship\ShipEnum; |
|
|
|
|
|
|
16
|
|
|
use Stu\Lib\Pirate\Component\PirateWrathManager; |
|
17
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
18
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
|
19
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
20
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @author Daniel Jakob <[email protected]> |
|
24
|
|
|
* @access public |
|
25
|
|
|
*/ |
|
26
|
|
|
class DamageWrapper |
|
27
|
|
|
{ |
|
28
|
|
|
private bool $isCrit = false; |
|
29
|
|
|
private bool $isShieldPenetration = false; |
|
30
|
|
|
private int $modificator = 100; |
|
31
|
|
|
private ?int $pirateWrath = null; |
|
32
|
|
|
|
|
33
|
14 |
|
public function __construct(private float $netDamage) {} |
|
34
|
|
|
|
|
35
|
|
|
private int $hull_damage_factor = 100; |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
1 |
|
public function setHullDamageFactor(int $value): void |
|
39
|
|
|
{ |
|
40
|
1 |
|
$this->hull_damage_factor = $value; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
5 |
|
public function getHullDamageFactor(): int |
|
45
|
|
|
{ |
|
46
|
5 |
|
return $this->hull_damage_factor; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
public function setCrit(bool $isCrit): void |
|
50
|
|
|
{ |
|
51
|
1 |
|
$this->isCrit = $isCrit; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function isCrit(): bool |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->isCrit; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setShieldPenetration(bool $isShieldPenetration): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->isShieldPenetration = $isShieldPenetration; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function isShieldPenetration(): bool |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->isShieldPenetration; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
private int $shield_damage_factor = 100; |
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
1 |
|
public function setShieldDamageFactor(int $value): void |
|
73
|
|
|
{ |
|
74
|
1 |
|
$this->shield_damage_factor = $value; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
6 |
|
public function getShieldDamageFactor(): int |
|
79
|
|
|
{ |
|
80
|
6 |
|
return $this->shield_damage_factor; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
private bool $is_phaser_damage = false; |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
7 |
|
public function setIsPhaserDamage(bool $value): void |
|
87
|
|
|
{ |
|
88
|
7 |
|
$this->is_phaser_damage = $value; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
6 |
|
public function getIsPhaserDamage(): bool |
|
93
|
|
|
{ |
|
94
|
6 |
|
return $this->is_phaser_damage; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
private bool $is_torpedo_damage = false; |
|
98
|
|
|
|
|
99
|
|
|
|
|
100
|
5 |
|
public function setIsTorpedoDamage(bool $value): void |
|
101
|
|
|
{ |
|
102
|
5 |
|
$this->is_torpedo_damage = $value; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
5 |
|
public function getIsTorpedoDamage(): bool |
|
107
|
|
|
{ |
|
108
|
5 |
|
return $this->is_torpedo_damage; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
11 |
|
public function setNetDamage(float $value): void |
|
112
|
|
|
{ |
|
113
|
11 |
|
$this->netDamage = $value; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
13 |
|
public function getNetDamage(): float |
|
117
|
|
|
{ |
|
118
|
13 |
|
return $this->netDamage; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
3 |
|
public function getModificator(): int |
|
122
|
|
|
{ |
|
123
|
3 |
|
return $this->modificator; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
11 |
|
public function setModificator(int $value): void |
|
127
|
|
|
{ |
|
128
|
11 |
|
$this->modificator = $value; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
1 |
|
public function setPirateWrath(UserInterface $attacker, ShipInterface $target): void |
|
132
|
|
|
{ |
|
133
|
1 |
|
if ($attacker->getId() !== UserEnum::USER_NPC_KAZON) { |
|
134
|
1 |
|
return; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
$pirateWrath = $target->getUser()->getPirateWrath(); |
|
138
|
|
|
if ($pirateWrath === null) { |
|
139
|
|
|
return; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
$this->pirateWrath = $pirateWrath->getWrath(); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
11 |
|
public function getDamageRelative(ColonyInterface|ShipInterface $target, int $mode): float |
|
146
|
|
|
{ |
|
147
|
11 |
|
if ($target instanceof ColonyInterface) { |
|
148
|
|
|
if ($mode === ShipEnum::DAMAGE_MODE_HULL) { |
|
149
|
|
|
return $this->calculateDamageBuilding(); |
|
150
|
|
|
} |
|
151
|
|
|
return $this->calculateDamageColonyShields($target); |
|
152
|
|
|
} |
|
153
|
11 |
|
if ($mode === ShipEnum::DAMAGE_MODE_HULL) { |
|
154
|
5 |
|
return $this->calculateDamageHull(); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
6 |
|
return $this->calculateDamageShields($target); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
|
|
161
|
6 |
|
private function calculateDamageShields(ShipInterface $target): float |
|
162
|
|
|
{ |
|
163
|
6 |
|
$netDamage = $this->getNetDamage(); |
|
164
|
6 |
|
$netDamage = $this->mindPirateWrath($netDamage); |
|
165
|
|
|
|
|
166
|
6 |
|
$targetShields = $target->getShield(); |
|
167
|
|
|
|
|
168
|
6 |
|
$grossModificator = round($this->getShieldDamageFactor() / 100); |
|
169
|
6 |
|
if ($this->getIsPhaserDamage() === true) { |
|
170
|
3 |
|
$grossModificator = round($grossModificator * $this->modificator / 100); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
6 |
|
$neededNetDamageForShields = min($netDamage, (int)ceil($targetShields / $grossModificator)); |
|
174
|
6 |
|
$grossDamage = min($targetShields, $neededNetDamageForShields * $grossModificator); |
|
175
|
|
|
|
|
176
|
6 |
|
if ($neededNetDamageForShields >= $netDamage) { |
|
177
|
3 |
|
$this->setNetDamage(0); |
|
178
|
|
|
} else { |
|
179
|
3 |
|
$this->setNetDamage($netDamage - $neededNetDamageForShields); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
6 |
|
return $grossDamage; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
private function calculateDamageColonyShields(ColonyInterface $target): float |
|
187
|
|
|
{ |
|
188
|
|
|
$damage = round($this->getNetDamage() / 100 * $this->getShieldDamageFactor()); |
|
189
|
|
|
|
|
190
|
|
|
if ($damage < $target->getShields()) { |
|
191
|
|
|
$this->setNetDamage(0); |
|
192
|
|
|
} else { |
|
193
|
|
|
$this->setNetDamage(round($damage - $target->getShields() / $this->getShieldDamageFactor() * 100)); |
|
194
|
|
|
} |
|
195
|
|
|
return $damage; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
|
|
199
|
5 |
|
private function calculateDamageHull(): float |
|
200
|
|
|
{ |
|
201
|
5 |
|
$damage = round($this->getNetDamage() / 100 * $this->getHullDamageFactor()); |
|
202
|
5 |
|
$damage = $this->mindPirateWrath($damage); |
|
203
|
|
|
|
|
204
|
5 |
|
if ($this->getIsTorpedoDamage() === true) { |
|
205
|
3 |
|
$damage = round($damage * ($this->getModificator() / 100)); |
|
206
|
|
|
} |
|
207
|
5 |
|
return $damage; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
private function calculateDamageBuilding(): float |
|
212
|
|
|
{ |
|
213
|
|
|
return round($this->getNetDamage() / 100 * $this->getHullDamageFactor()); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
11 |
|
private function mindPirateWrath(float $damage): float |
|
217
|
|
|
{ |
|
218
|
11 |
|
if ($this->pirateWrath === null) { |
|
219
|
11 |
|
return $damage; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
return round($damage / PirateWrathManager::DEFAULT_WRATH * $this->pirateWrath); |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|
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