Skip to content

Commit

Permalink
GH-139 Unify max speed calculation in galaxyfleet as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed May 27, 2022
1 parent edf811e commit a688604
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ajax/galaxyfleet.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ function CreateReturn($ReturnCode)
$ShipCount = $CurrentPlanet[$_Vars_GameElements[$ShipID]];
}

$FleetArray = [
$ShipID => $ShipCount
];

$availableSpeeds = FlightControl\Utils\Helpers\getAvailableSpeeds([
'user' => &$_User,
'timestamp' => $Time,
Expand All @@ -370,15 +374,11 @@ function CreateReturn($ReturnCode)

$GenFleetSpeed = current($availableSpeeds);
$SpeedFactor = getUniFleetsSpeedFactor();
$MaxFleetSpeed = getShipsCurrentSpeed($ShipID, $_User);

if(MORALE_ENABLED)
{
if($_User['morale_level'] <= MORALE_PENALTY_FLEETSLOWDOWN)
{
$MaxFleetSpeed *= MORALE_PENALTY_FLEETSLOWDOWN_VALUE;
}
}
$slowestShipSpeed = FlightControl\Utils\Helpers\getSlowestShipSpeed([
'shipsDetails' => getFleetShipsSpeeds($FleetArray, $_User),
'user' => &$_User,
]);

$distance = getFlightDistanceBetween(
$CurrentPlanet,
Expand All @@ -391,7 +391,7 @@ function CreateReturn($ReturnCode)
$duration = getFlightDuration([
'speedFactor' => $GenFleetSpeed,
'distance' => $distance,
'maxShipsSpeed' => $MaxFleetSpeed
'maxShipsSpeed' => $slowestShipSpeed
]);
$consumption = getFlightTotalConsumption(
[
Expand Down Expand Up @@ -423,7 +423,7 @@ function CreateReturn($ReturnCode)
$duration = getFlightDuration([
'speedFactor' => $GenFleetSpeed,
'distance' => $distance,
'maxShipsSpeed' => $MaxFleetSpeed
'maxShipsSpeed' => $slowestShipSpeed
]);
$consumption = getFlightTotalConsumption(
[
Expand Down Expand Up @@ -466,10 +466,6 @@ function CreateReturn($ReturnCode)
CreateReturn('608');
}

$FleetArray = [
$ShipID => $ShipCount
];

$fleetEntry = [
'Mission' => $Mission,
'count' => $ShipCount,
Expand Down

0 comments on commit a688604

Please sign in to comment.