Skip to content
Permalink
Browse files

Supply filter added.

  • Loading branch information...
mfendeksilverstripe committed Mar 10, 2019
1 parent f8a9a24 commit ab2ef5e930c79c0bf3991c9b12b257d998d947b1
Showing with 23 additions and 5 deletions.
  1. +15 −4 index.php
  2. +1 −1 src/dist/js/main.js
  3. +7 −0 src/react/js/utils/ListManipulation.jsx
@@ -46,7 +46,7 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
error_reporting(-1);
ini_set('error_log', 'logs/oobgdw-error-' . strftime('%Y%m%d') . '.log');
$version = '2019-03-02';
$version = '2019-03-11';
// configuration
$dataPath = 'src/game_data/Data/';
@@ -61,6 +61,7 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
'available',
'trait',
'switch',
'supply',
];
// number of items per one page
@@ -413,6 +414,7 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
$filterTraits = [];
$filterSwitch = [];
$filterFactions = [];
$filterSupply = [];
$filterAvailable = '';
$filterExpire = '';
$units = [];
@@ -440,10 +442,11 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
$category = $line[3];
$type = $line[4];
$chassis = $line[15];
$cargo = (!empty($line[34])) ? (int) $line[34] : 0;
$supply = (int) $line[20];
$steps = (int) $line[24];
$fuel = (!empty($line[25])) ? (int) $line[25] : 0;
$blast = (!empty($line[33])) ? (int) $line[33] : 0;
$steps = (int) $line[24];
$cargo = (!empty($line[34])) ? (int) $line[34] : 0;
// collect all ids that belong to specific unit name
$name = strtolower($name);
@@ -456,6 +459,8 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
$unitNames[$name] = [$id];
}
$supplyFilterValue = (string) $supply;
$filterSupply[$supplyFilterValue] = $supplyFilterValue;
$filterCategories[$category] = $category;
$filterTypes[$type] = $type;
$filterChassis[$chassis] = $chassis;
@@ -662,7 +667,7 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
'expire' => $expire,
'series' => $series,
'cost' => (!empty($line[19])) ? (int) $line[19] : 0,
'supply' => (int) $line[20],
'supply' => $supply,
'movement' => (int) $line[22],
'actions' => (int) $line[23],
'steps' => $steps,
@@ -944,6 +949,7 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
sort($filterFactions, SORT_STRING);
sort($filterTraits, SORT_STRING);
sort($filterSwitch, SORT_STRING);
sort($filterSupply, SORT_STRING);
// sort terrain data
foreach ($terrain as $climate => $climateData) {
@@ -993,6 +999,11 @@ function openDataFile($sourcePath, $filePath, $url = '', array &$files = [])
'label' => 'chassis',
'list' => $filterChassis,
],
'supply' => [
'type' => 'drop-down',
'label' => 'supply',
'list' => $filterSupply,
],
'trait' => [
'type' => 'drop-down',
'label' => 'unit trait',

Large diffs are not rendered by default.

@@ -73,6 +73,13 @@ export const getFilteredList = (unitsData, unitsList, filters) => {
}
}

// supply filter
if (typeof filters.supply !== 'undefined' && filters.supply.value !== '') {
if (unitData.supply !== parseInt(filters.supply.value)) {
continue;
}
}

// trait filter
if (typeof filters.trait !== 'undefined' && filters.trait.value !== '') {
let itemFound = false;

0 comments on commit ab2ef5e

Please sign in to comment.
You can’t perform that action at this time.