Skip to content

Commit

Permalink
GH-139 Create shared fleet array ships counter
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed May 26, 2022
1 parent d3a8842 commit 95b5a75
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions fleet2.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@
}

$Fleet['array'] = $fleetArrayParsingResult['payload']['parsedFleet'];
$Fleet['count'] = FlightControl\Utils\Helpers\FleetArray\getAllShipsCount($Fleet['array']);

foreach ($Fleet['array'] as $shipID => $shipCount) {
$Fleet['count'] += $shipCount;

$allShipsOfTypeStorage = getShipsStorageCapacity($shipID) * $shipCount;

if (canShipPillage($shipID)) {
Expand Down
3 changes: 1 addition & 2 deletions fleet3.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,9 @@ function messageRed($Text, $Title)
}

$Fleet['array'] = $fleetArrayParsingResult['payload']['parsedFleet'];
$Fleet['count'] = FlightControl\Utils\Helpers\FleetArray\getAllShipsCount($Fleet['array']);

foreach ($Fleet['array'] as $shipID => $shipCount) {
$Fleet['count'] += $shipCount;

$allShipsOfTypeStorage = getShipsStorageCapacity($shipID) * $shipCount;

if (canShipPillage($shipID)) {
Expand Down
1 change: 1 addition & 0 deletions modules/flightControl/_includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
include($includePath . './utils/helpers/getAvailableExpeditionTimes.helper.php');
include($includePath . './utils/helpers/getAvailableHoldTimes.helper.php');
include($includePath . './utils/helpers/getAvailableSpeeds.helper.php');
include($includePath . './utils/helpers/getFleetArrayInfo.helper.php');
include($includePath . './utils/helpers/getFleetsInFlightCounters.helper.php');
include($includePath . './utils/helpers/getFleetUnionJoinData.helper.php');
include($includePath . './utils/helpers/getFlightParams.helper.php');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace UniEngine\Engine\Modules\FlightControl\Utils\Helpers\FleetArray;

function getAllShipsCount($fleetArray) {
return array_sum($fleetArray);
}

?>

0 comments on commit 95b5a75

Please sign in to comment.