From bd20f16a2d5a70ad83af4a2f2c3870cc967a198a Mon Sep 17 00:00:00 2001 From: pigalot Date: Thu, 13 Jan 2022 22:21:05 +0000 Subject: [PATCH] Fix for AI Cores in smart supply --- src/Corporation/Actions.ts | 4 ++-- src/Corporation/ui/SmartSupplyModal.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index d044867e8..e69d5bd72 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -233,9 +233,9 @@ export function SetSmartSupply(warehouse: Warehouse, smartSupply: boolean): void } export function SetSmartSupplyUseLeftovers(warehouse: Warehouse, material: Material, useLeftover: boolean): void { - if (!Object.keys(warehouse.smartSupplyUseLeftovers).includes(material.name)) + if (!Object.keys(warehouse.smartSupplyUseLeftovers).includes(material.name.replace(/ /g, ""))) throw new Error(`Invalid material '${material.name}'`); - warehouse.smartSupplyUseLeftovers[material.name] = useLeftover; + warehouse.smartSupplyUseLeftovers[material.name.replace(/ /g, "")] = useLeftover; } export function BuyMaterial(material: Material, amt: number): void { diff --git a/src/Corporation/ui/SmartSupplyModal.tsx b/src/Corporation/ui/SmartSupplyModal.tsx index b4c031d99..083fb8ed5 100644 --- a/src/Corporation/ui/SmartSupplyModal.tsx +++ b/src/Corporation/ui/SmartSupplyModal.tsx @@ -16,7 +16,7 @@ interface ILeftoverProps { } function Leftover(props: ILeftoverProps): React.ReactElement { - const [checked, setChecked] = useState(!!props.warehouse.smartSupplyUseLeftovers[props.matName]); + const [checked, setChecked] = useState(!!props.warehouse.smartSupplyUseLeftovers[props.matName.replace(/ /g, "")]); function onChange(event: React.ChangeEvent): void { try { @@ -33,7 +33,7 @@ function Leftover(props: ILeftoverProps): React.ReactElement { <> } - label={{props.warehouse.materials[props.matName].name}} + label={{props.warehouse.materials[props.matName.replace(/ /g, "")].name}} />