smrealms /
smr
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | class SmrCombatDrones extends AbstractSmrCombatWeapon { |
||||||
| 4 | |||||||
| 5 | use Traits\CombatWeaponForce; |
||||||
| 6 | |||||||
| 7 | protected const MAX_CDS_RAND = 54; |
||||||
| 8 | |||||||
| 9 | public function __construct(int $numberOfCDs, bool $portPlanetDrones = false) { |
||||||
| 10 | $this->amount = $numberOfCDs; |
||||||
| 11 | $this->name = 'Combat Drones'; |
||||||
| 12 | if ($portPlanetDrones === false) { |
||||||
| 13 | $this->shieldDamage = 2; |
||||||
| 14 | $this->armourDamage = 2; |
||||||
| 15 | } else { |
||||||
| 16 | $this->shieldDamage = 1; |
||||||
| 17 | $this->armourDamage = 1; |
||||||
| 18 | } |
||||||
| 19 | $this->accuracy = 3; |
||||||
| 20 | $this->damageRollover = true; |
||||||
| 21 | } |
||||||
| 22 | |||||||
| 23 | public function getModifiedAccuracy(): float { |
||||||
| 24 | return $this->getBaseAccuracy(); |
||||||
| 25 | } |
||||||
| 26 | |||||||
| 27 | protected function getModifiedAccuracyAgainstForcesUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrForce $forces, int $random): float { |
||||||
|
0 ignored issues
–
show
The parameter
$weaponPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 28 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
||||||
| 29 | $modifiedAccuracy += $random; |
||||||
| 30 | |||||||
| 31 | return max(0, min(100, $modifiedAccuracy)); |
||||||
| 32 | } |
||||||
| 33 | |||||||
| 34 | public function getModifiedAccuracyAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces): float { |
||||||
| 35 | return $this->getModifiedAccuracyAgainstForcesUsingRandom($weaponPlayer, $forces, rand(3, self::MAX_CDS_RAND)); |
||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | protected function getModifiedAccuracyAgainstPortUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrPort $port, int $random): float { |
||||||
|
0 ignored issues
–
show
The parameter
$weaponPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$port is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 39 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
||||||
| 40 | $modifiedAccuracy += $random; |
||||||
| 41 | |||||||
| 42 | return max(0, min(100, $modifiedAccuracy)); |
||||||
| 43 | } |
||||||
| 44 | |||||||
| 45 | public function getModifiedAccuracyAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port): float { |
||||||
| 46 | return $this->getModifiedAccuracyAgainstPortUsingRandom($weaponPlayer, $port, rand(3, self::MAX_CDS_RAND)); |
||||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | protected function getModifiedAccuracyAgainstPlanetUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, int $random): float { |
||||||
|
0 ignored issues
–
show
The parameter
$weaponPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$planet is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 50 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
||||||
| 51 | $modifiedAccuracy += $random; |
||||||
| 52 | |||||||
| 53 | return max(0, min(100, $modifiedAccuracy)); |
||||||
| 54 | } |
||||||
| 55 | |||||||
| 56 | public function getModifiedAccuracyAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet): float { |
||||||
| 57 | return $this->getModifiedAccuracyAgainstPlanetUsingRandom($weaponPlayer, $planet, rand(3, self::MAX_CDS_RAND)); |
||||||
| 58 | } |
||||||
| 59 | |||||||
| 60 | public function getModifiedAccuracyAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer): float { |
||||||
| 61 | return $this->getModifiedAccuracyAgainstPlayerUsingRandom($weaponPlayer, $targetPlayer, rand(3, self::MAX_CDS_RAND)); |
||||||
| 62 | } |
||||||
| 63 | |||||||
| 64 | protected function getModifiedAccuracyAgainstPlayerUsingRandom(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer, int $random): float { |
||||||
| 65 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
||||||
| 66 | $levelRand = rand(IFloor($weaponPlayer->getLevelID() / 2), $weaponPlayer->getLevelID()); |
||||||
|
0 ignored issues
–
show
The function
IFloor was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 67 | $modifiedAccuracy += ($random + $levelRand - ($targetPlayer->getLevelID() - $weaponPlayer->getLevelID()) / 3) / 1.5; |
||||||
| 68 | |||||||
| 69 | $weaponShip = $weaponPlayer->getShip(); |
||||||
| 70 | $targetShip = $targetPlayer->getShip(); |
||||||
| 71 | $mrDiff = $targetShip->getMR() - $weaponShip->getMR(); |
||||||
| 72 | if ($mrDiff > 0) { |
||||||
| 73 | $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
||||||
| 74 | } |
||||||
| 75 | |||||||
| 76 | return max(0, min(100, $modifiedAccuracy)); |
||||||
| 77 | } |
||||||
| 78 | |||||||
| 79 | public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer): float { |
||||||
| 80 | return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, rand(3, self::MAX_CDS_RAND)); |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces, AbstractSmrPlayer $targetPlayer, int $random): float { |
||||||
|
0 ignored issues
–
show
The parameter
$targetPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$forces is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 84 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
||||||
| 85 | $modifiedAccuracy += $random; |
||||||
| 86 | |||||||
| 87 | return max(0, min(100, $modifiedAccuracy)); |
||||||
| 88 | } |
||||||
| 89 | |||||||
| 90 | protected function getModifiedPortAccuracyAgainstPlayer(AbstractSmrPort $port, AbstractSmrPlayer $targetPlayer): float { |
||||||
|
0 ignored issues
–
show
The parameter
$targetPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$port is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 91 | return 100; |
||||||
| 92 | } |
||||||
| 93 | |||||||
| 94 | protected function getModifiedPlanetAccuracyAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer): float { |
||||||
|
0 ignored issues
–
show
The parameter
$planet is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$targetPlayer is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 95 | return 100; |
||||||
| 96 | } |
||||||
| 97 | |||||||
| 98 | public function getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces): array { |
||||||
| 99 | if (!$this->canShootForces()) { |
||||||
| 100 | // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 101 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 102 | } |
||||||
| 103 | $damage = $this->getDamage(); |
||||||
| 104 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 105 | $damage['Kamikaze'] = 0; |
||||||
| 106 | if ($weaponPlayer->isCombatDronesKamikazeOnMines()) { // If kamikaze then damage is same as MINE_ARMOUR |
||||||
| 107 | $damage['Kamikaze'] = min($damage['Launched'], $forces->getMines()); |
||||||
| 108 | $damage['Launched'] -= $damage['Kamikaze']; |
||||||
| 109 | } |
||||||
| 110 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield']); |
||||||
| 111 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour']); |
||||||
| 112 | |||||||
| 113 | $damage['Launched'] += $damage['Kamikaze']; |
||||||
| 114 | $damage['Shield'] += $damage['Kamikaze'] * MINE_ARMOUR; |
||||||
| 115 | $damage['Armour'] += $damage['Kamikaze'] * MINE_ARMOUR; |
||||||
| 116 | |||||||
| 117 | return $damage; |
||||||
| 118 | } |
||||||
| 119 | |||||||
| 120 | public function getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port): array { |
||||||
| 121 | if (!$this->canShootPorts()) { |
||||||
| 122 | // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 123 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 124 | } |
||||||
| 125 | $damage = $this->getDamage(); |
||||||
| 126 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 127 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield']); |
||||||
| 128 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour']); |
||||||
| 129 | |||||||
| 130 | return $damage; |
||||||
| 131 | } |
||||||
| 132 | |||||||
| 133 | public function getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet): array { |
||||||
| 134 | if (!$this->canShootPlanets()) { |
||||||
| 135 | // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 136 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 137 | } |
||||||
| 138 | $damage = $this->getDamage(); |
||||||
| 139 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 140 | $planetMod = self::PLANET_DAMAGE_MOD; |
||||||
| 141 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield'] * $planetMod); |
||||||
| 142 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour'] * $planetMod); |
||||||
| 143 | |||||||
| 144 | return $damage; |
||||||
| 145 | } |
||||||
| 146 | |||||||
| 147 | public function getModifiedDamageAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 148 | if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 149 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 150 | } |
||||||
| 151 | $damage = $this->getDamage(); |
||||||
| 152 | $dcsMod = $targetPlayer->getShip()->hasDCS() ? DCS_PLAYER_DAMAGE_DECIMAL_PERCENT : 1; |
||||||
| 153 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedAccuracyAgainstPlayer($weaponPlayer, $targetPlayer) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 154 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield'] * $dcsMod); |
||||||
| 155 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour'] * $dcsMod); |
||||||
| 156 | return $damage; |
||||||
| 157 | } |
||||||
| 158 | |||||||
| 159 | public function getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 160 | if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 161 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 162 | } |
||||||
| 163 | $damage = $this->getDamage(); |
||||||
| 164 | $dcsMod = $targetPlayer->getShip()->hasDCS() ? DCS_FORCE_DAMAGE_DECIMAL_PERCENT : 1; |
||||||
| 165 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedForceAccuracyAgainstPlayer($forces, $targetPlayer) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 166 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield'] * $dcsMod); |
||||||
| 167 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour'] * $dcsMod); |
||||||
| 168 | return $damage; |
||||||
| 169 | } |
||||||
| 170 | |||||||
| 171 | public function getModifiedPortDamageAgainstPlayer(AbstractSmrPort $port, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 172 | if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 173 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 174 | } |
||||||
| 175 | $damage = $this->getDamage(); |
||||||
| 176 | $dcsMod = $targetPlayer->getShip()->hasDCS() ? DCS_PORT_DAMAGE_DECIMAL_PERCENT : 1; |
||||||
| 177 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedPortAccuracyAgainstPlayer($port, $targetPlayer) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 178 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield'] * $dcsMod); |
||||||
| 179 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour'] * $dcsMod); |
||||||
| 180 | return $damage; |
||||||
| 181 | } |
||||||
| 182 | |||||||
| 183 | public function getModifiedPlanetDamageAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 184 | if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
||||||
| 185 | return ['Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()]; |
||||||
| 186 | } |
||||||
| 187 | $damage = $this->getDamage(); |
||||||
| 188 | $dcsMod = $targetPlayer->getShip()->hasDCS() ? DCS_PLANET_DAMAGE_DECIMAL_PERCENT : 1; |
||||||
| 189 | $damage['Launched'] = ICeil($this->getAmount() * $this->getModifiedPlanetAccuracyAgainstPlayer($planet, $targetPlayer) / 100); |
||||||
|
0 ignored issues
–
show
The function
ICeil was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 190 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield'] * $dcsMod); |
||||||
| 191 | $damage['Armour'] = ICeil($damage['Launched'] * $damage['Armour'] * $dcsMod); |
||||||
| 192 | return $damage; |
||||||
| 193 | } |
||||||
| 194 | |||||||
| 195 | public function shootForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces): array { |
||||||
| 196 | $return = ['Weapon' => $this, 'TargetForces' => $forces, 'Hit' => true]; |
||||||
| 197 | $return = $this->doPlayerDamageToForce($return, $weaponPlayer, $forces); |
||||||
| 198 | if ($return['WeaponDamage']['Kamikaze'] > 0) { |
||||||
| 199 | $weaponPlayer->getShip()->decreaseCDs($return['WeaponDamage']['Kamikaze']); |
||||||
| 200 | } |
||||||
| 201 | return $return; |
||||||
| 202 | } |
||||||
| 203 | |||||||
| 204 | /** |
||||||
| 205 | * @return array<string, mixed> |
||||||
| 206 | */ |
||||||
| 207 | public function shootPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port): array { |
||||||
| 208 | $return = ['Weapon' => $this, 'TargetPort' => $port, 'Hit' => true]; |
||||||
| 209 | return $this->doPlayerDamageToPort($return, $weaponPlayer, $port); |
||||||
| 210 | } |
||||||
| 211 | |||||||
| 212 | /** |
||||||
| 213 | * @return array<string, mixed> |
||||||
| 214 | */ |
||||||
| 215 | public function shootPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet): array { |
||||||
| 216 | $return = ['Weapon' => $this, 'TargetPlanet' => $planet, 'Hit' => true]; |
||||||
| 217 | return $this->doPlayerDamageToPlanet($return, $weaponPlayer, $planet); |
||||||
| 218 | } |
||||||
| 219 | |||||||
| 220 | public function shootPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 221 | $return = ['Weapon' => $this, 'TargetPlayer' => $targetPlayer, 'Hit' => true]; |
||||||
| 222 | return $this->doPlayerDamageToPlayer($return, $weaponPlayer, $targetPlayer); |
||||||
| 223 | } |
||||||
| 224 | |||||||
| 225 | public function shootPlayerAsForce(SmrForce $forces, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 226 | $return = ['Weapon' => $this, 'TargetPlayer' => $targetPlayer, 'Hit' => true]; |
||||||
| 227 | return $this->doForceDamageToPlayer($return, $forces, $targetPlayer); |
||||||
| 228 | } |
||||||
| 229 | |||||||
| 230 | /** |
||||||
| 231 | * @return array<string, mixed> |
||||||
| 232 | */ |
||||||
| 233 | public function shootPlayerAsPort(AbstractSmrPort $forces, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 234 | $return = ['Weapon' => $this, 'TargetPlayer' => $targetPlayer, 'Hit' => true]; |
||||||
| 235 | return $this->doPortDamageToPlayer($return, $forces, $targetPlayer); |
||||||
| 236 | } |
||||||
| 237 | |||||||
| 238 | /** |
||||||
| 239 | * @return array<string, mixed> |
||||||
| 240 | */ |
||||||
| 241 | public function shootPlayerAsPlanet(SmrPlanet $forces, AbstractSmrPlayer $targetPlayer): array { |
||||||
| 242 | $return = ['Weapon' => $this, 'TargetPlayer' => $targetPlayer, 'Hit' => true]; |
||||||
| 243 | return $this->doPlanetDamageToPlayer($return, $forces, $targetPlayer); |
||||||
| 244 | } |
||||||
| 245 | |||||||
| 246 | } |
||||||
| 247 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.