mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
more corp API
This commit is contained in:
parent
eb01051ad6
commit
2866bfaa70
@ -218,4 +218,11 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
|||||||
|
|
||||||
export function SetSmartSupply(warehouse: Warehouse, smartSupply: boolean): void {
|
export function SetSmartSupply(warehouse: Warehouse, smartSupply: boolean): void {
|
||||||
warehouse.smartSupplyEnabled = smartSupply;
|
warehouse.smartSupplyEnabled = smartSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BuyMaterial(material: Material, amt: number): void {
|
||||||
|
if (isNaN(amt)) {
|
||||||
|
throw new Error(`Invalid amount '${amt}' to buy material '${material.name}'`);
|
||||||
|
}
|
||||||
|
material.buy = amt;
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import { Material } from "../Material";
|
|||||||
import { IIndustry } from "../IIndustry";
|
import { IIndustry } from "../IIndustry";
|
||||||
import { ICorporation } from "../ICorporation";
|
import { ICorporation } from "../ICorporation";
|
||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
|
import { BuyMaterial } from "../Actions";
|
||||||
|
|
||||||
interface IBulkPurchaseTextProps {
|
interface IBulkPurchaseTextProps {
|
||||||
warehouse: Warehouse;
|
warehouse: Warehouse;
|
||||||
@ -94,13 +95,13 @@ export function PurchaseMaterialPopup(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function purchaseMaterial(): void {
|
function purchaseMaterial(): void {
|
||||||
if(buyAmt === null) return;
|
if(buyAmt === null) return;
|
||||||
if (isNaN(buyAmt)) {
|
try {
|
||||||
dialogBoxCreate("Invalid amount");
|
BuyMaterial(props.mat, buyAmt)
|
||||||
} else {
|
} catch(err) {
|
||||||
props.mat.buy = buyAmt;
|
dialogBoxCreate(err+'');
|
||||||
if (isNaN(props.mat.buy)) props.mat.buy = 0;
|
|
||||||
removePopup(props.popupId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removePopup(props.popupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearPurchase(): void {
|
function clearPurchase(): void {
|
||||||
|
@ -28,7 +28,8 @@ import {
|
|||||||
IssueDividends,
|
IssueDividends,
|
||||||
SellMaterial,
|
SellMaterial,
|
||||||
SellProduct,
|
SellProduct,
|
||||||
SetSmartSupply } from "./Corporation/Actions";
|
SetSmartSupply,
|
||||||
|
BuyMaterial } from "./Corporation/Actions";
|
||||||
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
||||||
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
||||||
import {
|
import {
|
||||||
@ -4176,6 +4177,9 @@ function NetscriptFunctions(workerScript) {
|
|||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
SetSmartSupply(warehouse, enabled);
|
SetSmartSupply(warehouse, enabled);
|
||||||
},
|
},
|
||||||
|
BuyMaterial: function(divisionName, cityName, materialName, amt) {
|
||||||
|
|
||||||
|
},
|
||||||
}, // End Corporation API
|
}, // End Corporation API
|
||||||
|
|
||||||
// Coding Contract API
|
// Coding Contract API
|
||||||
|
Loading…
Reference in New Issue
Block a user