From 65ffbcc27ea73bc4ae06a6f6b6f6bd09b9391e41 Mon Sep 17 00:00:00 2001 From: Phil Despotos Date: Tue, 25 Jan 2022 12:51:07 -0600 Subject: [PATCH] Corp API: Add setSmartSupplyUseLeftovers The API can already toggle smart supply on/off, but can't manage the related controls for whether smart supply will draw from the existing materials in the warehouse. Without it, we can't keep some resources in storage to boost the production multiplier without disabling smart supply entirely. --- src/NetscriptFunctions/Corporation.ts | 11 +++++++++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 05845801c..c961b1482 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -49,6 +49,7 @@ import { SetMaterialMarketTA2, SetProductMarketTA1, SetProductMarketTA2, + SetSmartSupplyUseLeftovers, } from "../Corporation/Actions"; import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades"; import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades"; @@ -410,6 +411,16 @@ export function NetscriptCorporation( const warehouse = getWarehouse(divisionName, cityName); SetSmartSupply(warehouse, enabled); }, + setSmartSupplyUseLeftovers: function (adivisionName: any, acityName: any, amaterialName: any, aenabled: any): void { + checkAccess("setSmartSupplyUseLeftovers", 7); + const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName); + const cityName = helper.string("sellProduct", "cityName", acityName); + const materialName = helper.string("sellProduct", "materialName", amaterialName); + const enabled = helper.boolean(aenabled); + const warehouse = getWarehouse(divisionName, cityName); + const material = getMaterial(divisionName, cityName, materialName); + SetSmartSupplyUseLeftovers(warehouse, material, enabled); + }, buyMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void { checkAccess("buyMaterial", 7); const divisionName = helper.string("buyMaterial", "divisionName", adivisionName); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 6021a88ef..f25fd9a91 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -6255,6 +6255,14 @@ export interface WarehouseAPI { * @param enabled - smart supply enabled */ setSmartSupply(divisionName: string, cityName: string, enabled: boolean): void; + /** + * Set whether smart supply uses leftovers before buying + * @param divisionName - Name of the division + * @param cityName - Name of the city + * @param materialName - Name of the material + * @param enabled - smart supply use leftovers enabled + */ + setSmartSupplyUseLeftovers(divisionName: string, cityName: string, materialName: string, enabled: boolean): void; /** * Set material buy data * @param divisionName - Name of the division