| Line 305: |
Line 305: |
| | function ensureResourceGroup(fuel, ammo, steel, bauxite, resourceGroup) | | function ensureResourceGroup(fuel, ammo, steel, bauxite, resourceGroup) |
| | local main = math.max(unpack({fuel, ammo, steel, bauxite})) | | local main = math.max(unpack({fuel, ammo, steel, bauxite})) |
| | + | function fix(x) |
| | + | return x < main and main + 1 or x |
| | + | end |
| | if resourceGroup == 1 then | | if resourceGroup == 1 then |
| − | return math.max(main + 1, fuel), ammo, math.max(main + 1, steel), bauxite | + | return fix(fuel), ammo, fix(steel), bauxite |
| | elseif resourceGroup == 2 then | | elseif resourceGroup == 2 then |
| − | return fuel, math.max(main + 1, ammo), steel, bauxite | + | return fuel, fix(ammo), steel, bauxite |
| | elseif resourceGroup == 3 then | | elseif resourceGroup == 3 then |
| − | return fuel, ammo, steel, math.max(main + 1, bauxite) | + | return fuel, ammo, steel, fix(bauxite) |
| | end | | end |
| | end | | end |
| Line 326: |
Line 329: |
| | for resourceGroup, _ in pairs(resourceGroups) do | | for resourceGroup, _ in pairs(resourceGroups) do |
| | local fuel, ammo, steel, bauxite = ensureResourceGroup(fuel, ammo, steel, bauxite, resourceGroup) | | local fuel, ammo, steel, bauxite = ensureResourceGroup(fuel, ammo, steel, bauxite, resourceGroup) |
| − | table.insert(result, U.format{ | + | result[U.format{ |
| | "${fuel}/${ammo}/${steel}/${bauxite} (${typeGroup})", | | "${fuel}/${ammo}/${steel}/${bauxite} (${typeGroup})", |
| | fuel = fuel, | | fuel = fuel, |
| Line 333: |
Line 336: |
| | bauxite = bauxite, | | bauxite = bauxite, |
| | typeGroup = Self.typeGroups[typeGroup], | | typeGroup = Self.typeGroups[typeGroup], |
| − | }) | + | }] = true |
| | end | | end |
| | end | | end |
| − | return table.concat(result, "<br>") | + | return table.concat(table.sort(U.keys(result)), "<br>") |
| | else | | else |
| | return 'N/A' | | return 'N/A' |