diff --git a/src/Corporation/ui/MaterialElem.tsx b/src/Corporation/ui/MaterialElem.tsx index cd72d29e6..67f250a7b 100644 --- a/src/Corporation/ui/MaterialElem.tsx +++ b/src/Corporation/ui/MaterialElem.tsx @@ -61,7 +61,9 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { division.newInd && Object.keys(division.reqMats).includes(mat.name) && mat.buy === 0 && mat.imp === 0; // Purchase material button - const purchaseButtonText = `Buy (${numeralWrapper.format(mat.buy, nfB)})`; + const purchaseButtonText = `Buy (${ + mat.buy >= 1e33 ? mat.buy.toExponential(3) : numeralWrapper.format(mat.buy, nfB) + })`; // Sell material button let sellButtonText: JSX.Element; @@ -125,7 +127,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { - Buy: {numeralWrapper.format(mat.buy, nfB)}
+ Buy: {mat.buy >= 1e33 ? mat.buy.toExponential(3) : numeralWrapper.format(mat.buy, nfB)}
Prod: {numeralWrapper.format(mat.prd, nfB)}
Sell: {numeralWrapper.format(mat.sll, nfB)}
Export: {numeralWrapper.format(mat.totalExp, nfB)}
@@ -138,7 +140,8 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { } > - {mat.name}: {numeralWrapper.format(mat.qty, nfB)} ({numeralWrapper.format(totalGain, nfB)}/s) + {mat.name}: {numeralWrapper.format(mat.qty, nfB)} ( + {totalGain >= 1e33 ? totalGain.toExponential(3) : numeralWrapper.format(totalGain, nfB)}/s)
{ const cityName = helpers.city(ctx, "cityName", _cityName); const materialName = helpers.string(ctx, "materialName", _materialName); const amt = helpers.number(ctx, "amt", _amt); - if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0"); + if (amt < 0 || !Number.isFinite(amt)) + throw new Error("Invalid value for amount field! Must be numeric and greater than 0"); const material = getMaterial(divisionName, cityName, materialName); BuyMaterial(material, amt); },