Skip to content

Commit

Permalink
GH-131 Create shields takedown calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Nov 20, 2020
1 parent 38f3653 commit 30db9af
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions includes/ares/calculations.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace UniEngine\Engine\Includes\Ares\Calculations;

use UniEngine\Engine\Includes\Ares;

function calculateShipForce($params) {
global $_Vars_CombatUpgrades, $_Vars_CombatData;

Expand Down Expand Up @@ -62,4 +64,43 @@ function calculateShipHull($params) {
);
}

function calculateShieldsTakeDownStats($params) {
$shotForce = $params['shotForce'];
$targetUserId = $params['targetUserId'];
$targetShipId = $params['targetShipId'];
$targetShipShield = $params['targetShipShield'];
$targetShipCount = $params['targetShipCount'];
$roundShieldStateCache = $params['roundShieldStateCacheByTargetKey'];

$targetKey = "{$targetShipId}|{$targetUserId}";

$isShotBypassingShield = Ares\Evaluators\isShotBypassingShield([
'shotForce' => $shotForce,
'targetShipShield' => $targetShipShield,
]);

if ($isShotBypassingShield) {
return [
'forceNeeded' => 0,
'isShotBypassingShield' => true,
];
}

$isTargetsShieldDamaged = (
isset($roundShieldStateCache[$targetKey]['left']) &&
$roundShieldStateCache[$targetKey]['left'] === true
);

$forceNeeded = (
$isTargetsShieldDamaged ?
$roundShieldStateCache[$targetKey]['shield'] :
($targetShipShield * $targetShipCount)
);

return [
'forceNeeded' => $forceNeeded,
'isShotBypassingShield' => false,
];
}

?>

0 comments on commit 30db9af

Please sign in to comment.