Line 332: |
Line 332: |
| local recipe = U.format{ | | local recipe = U.format{ |
| "${fuel}/${ammo}/${steel}/${bauxite}", | | "${fuel}/${ammo}/${steel}/${bauxite}", |
− | fuel = (resourceGroup == 1 and U.red or U.id)(fuel), | + | fuel = fuel, |
− | ammo = (resourceGroup == 2 and U.red or U.id)(ammo), | + | ammo = ammo, |
− | steel = (resourceGroup == 1 and U.red or U.id)(steel), | + | steel = steel, |
− | bauxite = (resourceGroup == 3 and U.red or U.id)(bauxite), | + | bauxite = bauxite, |
| + | } |
| + | result[recipe] = result[recipe] or { |
| + | fuel = fuel, |
| + | ammo = ammo, |
| + | steel = steel, |
| + | bauxite = bauxite, |
| + | resourceGroup = resourceGroup, |
| + | types = {}, |
| } | | } |
| local rate = U.round(100 * n / 50) | | local rate = U.round(100 * n / 50) |
− | result[recipe] = result[recipe] or {} | + | result[recipe].types[Self.typeGroups[typeGroup]] = rate |
− | result[recipe][Self.typeGroups[typeGroup]] = rate
| |
| if not maxRate or rate > maxRate then | | if not maxRate or rate > maxRate then |
| maxRate = rate | | maxRate = rate |
Line 349: |
Line 356: |
| U.isort(U.keys(result)), | | U.isort(U.keys(result)), |
| function(recipe) | | function(recipe) |
− | local types = U.isort(U.keys(result[recipe])) | + | local types = U.isort(U.keys(result[recipe].types)) |
| + | local resourceGroup = result[recipe].resourceGroup |
| return U.format{ | | return U.format{ |
| rates and "${rates}" or "${recipe} (${types})", | | rates and "${rates}" or "${recipe} (${types})", |
− | recipe = recipe, | + | recipe = U.format{ |
| + | "${fuel}/${ammo}/${steel}/${bauxite}", |
| + | fuel = (resourceGroup == 1 and U.red or U.id)(result[recipe].fuel), |
| + | ammo = (resourceGroup == 2 and U.red or U.id)(result[recipe].ammo), |
| + | steel = (resourceGroup == 1 and U.red or U.id)(result[recipe].steel), |
| + | bauxite = (resourceGroup == 3 and U.red or U.id)(result[recipe].bauxite), |
| + | }, |
| types = U.ijoin(U.imap(types, function(type) | | types = U.ijoin(U.imap(types, function(type) |
− | local rate = result[recipe][type] | + | local rate = result[recipe].types[type] |
| return (rate == maxRate and U.red or U.id)(type) | | return (rate == maxRate and U.red or U.id)(type) |
| end), "/"), | | end), "/"), |
| rates = U.ijoin(U.imap(types, function(type) | | rates = U.ijoin(U.imap(types, function(type) |
− | local rate = result[recipe][type] | + | local rate = result[recipe].types[type] |
− | return (rate == maxRate and U.red or U.id)(tostring(result[recipe][type]) .. "%") | + | return (rate == maxRate and U.red or U.id)(tostring(result[recipe].types[type]) .. "%") |
| end), "/"), | | end), "/"), |
| } | | } |