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