Fixed name matching

This commit is contained in:
Sebastian Seedorf
2022-09-11 14:10:49 +02:00
parent cd7a6a565f
commit fadfa67574

View File

@@ -78,10 +78,27 @@ export const PageDetails: FC = () => {
}, [])
const statisticsUrl = useMemo(() => {
const toDashedKey = (n: string) => n.slice(1).toLowerCase().replace(/_/g, '-')
const toDashedKey = (n: string) => {
const key = n.slice(1).toLowerCase().replace(/_/g, '-').replace('efficiency', 'effectivity')
return (
{
wall: 'stone-wall',
lamp: 'small-lamp',
'active-provider-chest': 'logistic-chest-active-provider',
'passive-provider-chest': 'logistic-chest-passive-provider',
'storage-chest': 'logistic-chest-storage',
'buffer-chest': 'logistic-chest-buffer',
'requester-chest': 'logistic-chest-requester',
'uranium-235': 'uranium-ore',
'uranium-238': 'uranium-ore',
exoskeleton: 'exoskeleton-equipment',
'portable-fusion-reactor': 'fusion-reactor-equipment'
}[key] ?? key
)
}
const checkIfPresent = (dashedKey: string) => {
const b =
!!optimalModuleText?.match(new RegExp(`${dashedKey};`)) && dashedKey !== 'rail-signal'
const b = !!optimalModuleText?.match(new RegExp(`\\n${dashedKey};`))
if (optimalModuleText && !b) console.warn('Not found element', dashedKey)
return b
}
const getModuleString = (dashedKey: string, powerSaving?: boolean) => {
@@ -107,7 +124,7 @@ export const PageDetails: FC = () => {
if (beacons + modules[0] + modules[1] === 0 && modules[2] === 2)
res = res.replace(/e3/g, 'e2')
else if (beacons + modules[0] + modules[1] === 0 && modules[2] >= 3)
res = res.replace(/e3/g, 'e1')
res = res.replace(/e3/g, 'ee')
// console.log(beacons, modules, res, dashedKey)
return res + (beaconModules ? `;${map[maxIdx]}3:${beaconModules}` : '')
}