mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
CORPORATION: Added check to buy amount (#149)
This commit is contained in:
parent
d22d0a25ef
commit
6dc5990b63
@ -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 {
|
||||
<Tooltip
|
||||
title={
|
||||
<Typography>
|
||||
Buy: {numeralWrapper.format(mat.buy, nfB)} <br />
|
||||
Buy: {mat.buy >= 1e33 ? mat.buy.toExponential(3) : numeralWrapper.format(mat.buy, nfB)} <br />
|
||||
Prod: {numeralWrapper.format(mat.prd, nfB)} <br />
|
||||
Sell: {numeralWrapper.format(mat.sll, nfB)} <br />
|
||||
Export: {numeralWrapper.format(mat.totalExp, nfB)} <br />
|
||||
@ -138,7 +140,8 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
|
||||
}
|
||||
>
|
||||
<Typography>
|
||||
{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)
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
|
@ -457,7 +457,8 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
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);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user