Skip to content

Commit

Permalink
GH-230 Use existing functions to sum all resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jul 7, 2022
1 parent f05f60f commit a11d186
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\ResourcesTransport;

use UniEngine\Engine\Includes\Helpers\World\Elements;
use UniEngine\Engine\Includes\Helpers\World\Resources;

/**
* @param array $props
Expand All @@ -21,10 +22,13 @@ function render($props) {
'shipRow' => $localTemplateLoader('shipRow'),
];

$resourcesTotalSum = (
$planet['metal'] +
$planet['crystal'] +
$planet['deuterium']
$resourcesTotalSum = array_sum(
array_map_withkeys(
Resources\getKnownPillagableResourceKeys(),
function ($resourceKey) use (&$user, &$planet) {
return Resources\getResourceState($resourceKey, $user, $planet);
}
)
);

$shipRows = [];
Expand Down

0 comments on commit a11d186

Please sign in to comment.