Skip to content

Commit

Permalink
GH-139 Use getAvailableSpeeds() in galaxyfleet.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Dec 21, 2020
1 parent ecb0b14 commit 6562e9a
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions ajax/galaxyfleet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

include($_EnginePath.'common.php');

include($_EnginePath . 'modules/flightControl/_includes.php');

use UniEngine\Engine\Modules\FlightControl;

function CreateReturn($ReturnCode)
{
global $Update, $ShipCount, $Galaxy, $System, $Planet, $Type, $ActualFleets, $Spy_Probes, $Recyclers, $Colonizers;
Expand Down Expand Up @@ -431,32 +435,14 @@ function CreateReturn($ReturnCode)
$ShipCount = $CurrentPlanet[$_Vars_GameElements[$ShipID]];
}

// Create SpeedsArray
$SpeedsAvailable = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
$availableSpeeds = FlightControl\Utils\Helpers\getAvailableSpeeds([
'user' => &$_User,
'timestamp' => $Time,
]);

if($_User['admiral_time'] > $Time)
{
$SpeedsAvailable[] = 12;
$SpeedsAvailable[] = 11;
$SpeedsAvailable[] = 0.5;
$SpeedsAvailable[] = 0.25;
}
if(MORALE_ENABLED)
{
$MaxAvailableSpeed = max($SpeedsAvailable);
if($_User['morale_level'] >= MORALE_BONUS_FLEETSPEEDUP1)
{
$SpeedsAvailable[] = $MaxAvailableSpeed + (MORALE_BONUS_FLEETSPEEDUP1_VALUE / 10);
}
if($_User['morale_level'] >= MORALE_BONUS_FLEETSPEEDUP2)
{
$SpeedsAvailable[] = $MaxAvailableSpeed + (MORALE_BONUS_FLEETSPEEDUP2_VALUE / 10);
}
}
arsort($SpeedsAvailable);
reset($SpeedsAvailable);
reset($availableSpeeds);

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

Expand Down Expand Up @@ -503,7 +489,7 @@ function CreateReturn($ReturnCode)
// Try to SlowDown fleet only if it's Espionage Mission
while($FleetStorage < $consumption)
{
$GenFleetSpeed = next($SpeedsAvailable);
$GenFleetSpeed = next($availableSpeeds);
if($GenFleetSpeed !== false)
{
$duration = getFlightDuration([
Expand Down

0 comments on commit 6562e9a

Please sign in to comment.