From d8fee8e25a4add5d6cc3ff759542db8c107dfc6c Mon Sep 17 00:00:00 2001 From: zerbosh <115591472+zerbosh@users.noreply.github.com> Date: Sun, 4 Jun 2023 06:13:26 +0200 Subject: [PATCH] CORPORATION: fixed Sell Buttons (#564) --- src/Corporation/Division.ts | 5 ++-- src/Corporation/Material.ts | 2 +- src/Corporation/Product.ts | 2 +- src/Corporation/ui/MaterialElem.tsx | 35 ++++------------------------ src/Corporation/ui/ProductElem.tsx | 36 ++++------------------------- 5 files changed, 13 insertions(+), 67 deletions(-) diff --git a/src/Corporation/Division.ts b/src/Corporation/Division.ts index b2e555c8b..ceae207f8 100644 --- a/src/Corporation/Division.ts +++ b/src/Corporation/Division.ts @@ -545,7 +545,6 @@ export class Division { // We'll store this "Optimal Price" in a property so that we don't have // to re-calculate it for the UI - mat.marketTa2Price = optimalPrice; sCost = optimalPrice; } else if (mat.marketTa1) { @@ -556,6 +555,7 @@ export class Division { } else { sCost = mat.desiredSellPrice; } + mat.uiMarketPrice = sCost; // Calculate how much of the material sells (per second) let markup = 1; @@ -890,7 +890,6 @@ export class Division { } // Store this "optimal Price" in a property so we don't have to re-calculate for UI - product.marketTa2Price[city] = optimalPrice; sCost = optimalPrice; } else if (product.marketTa1) { sCost = product.productionCost + markupLimit; @@ -905,7 +904,7 @@ export class Division { } else { sCost = sellPrice; } - + product.uiMarketPrice[city] = sCost; let markup = 1; if (sCost > product.productionCost) { if (sCost - product.productionCost > markupLimit) { diff --git a/src/Corporation/Material.ts b/src/Corporation/Material.ts index ab9a7aa9d..e87eaba7b 100644 --- a/src/Corporation/Material.ts +++ b/src/Corporation/Material.ts @@ -62,7 +62,7 @@ export class Material { // Flags that signal whether automatic sale pricing through Market TA is enabled marketTa1 = false; marketTa2 = false; - marketTa2Price = 0; + uiMarketPrice = 0; // Determines the maximum amount of this material that can be sold in one market cycle maxSellPerCycle = 0; diff --git a/src/Corporation/Product.ts b/src/Corporation/Product.ts index ab57c703d..21379e5d9 100644 --- a/src/Corporation/Product.ts +++ b/src/Corporation/Product.ts @@ -93,7 +93,7 @@ export class Product { // Flags that signal whether automatic sale pricing through Market TA is enabled marketTa1 = false; marketTa2 = false; - marketTa2Price = createEnumKeyedRecord(CityName, () => 0); + uiMarketPrice = createEnumKeyedRecord(CityName, () => 0); /** Effective number that "MAX" represents in a sell amount */ maxSellAmount = 0; diff --git a/src/Corporation/ui/MaterialElem.tsx b/src/Corporation/ui/MaterialElem.tsx index 90e17a772..4f0226e23 100644 --- a/src/Corporation/ui/MaterialElem.tsx +++ b/src/Corporation/ui/MaterialElem.tsx @@ -44,7 +44,6 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { const warehouse = props.warehouse; const city = props.city; const mat = props.mat; - const markupLimit = mat.getMarkupLimit(); const office = division.offices[city]; if (!office) { throw new Error(`Could not get OfficeSpace object for this city (${city})`); @@ -68,7 +67,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { if (isString(mat.desiredSellAmount)) { sellButtonText = ( <> - Sell ({formatBigNumber(mat.actualSellAmount)}/{mat.desiredSellAmount[1]}) + Sell ({formatBigNumber(mat.actualSellAmount)}/{mat.desiredSellAmount}) ); } else { @@ -78,35 +77,9 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement { ); } - - if (mat.marketTa2) { - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else if (mat.marketTa1) { - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else if (mat.desiredSellPrice) { - if (isString(mat.desiredSellPrice)) { - const sCost = mat.desiredSellPrice.replace(/MP/g, mat.marketPrice + ""); - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else { - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } - } + <> + {sellButtonText} @ + ; } else { sellButtonText = <>Sell (0.000/0.000); } diff --git a/src/Corporation/ui/ProductElem.tsx b/src/Corporation/ui/ProductElem.tsx index 662540905..e77aa47f7 100644 --- a/src/Corporation/ui/ProductElem.tsx +++ b/src/Corporation/ui/ProductElem.tsx @@ -66,37 +66,11 @@ export function ProductElem(props: IProductProps): React.ReactElement { sellButtonText = <>Sell (0.000/0.000); } - if (product.marketTa2) { - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else if (product.marketTa1) { - const markupLimit = product.rating / product.markup; - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else if (product.cityData[city].desiredSellPrice) { - const desiredSellPrice = product.cityData[city].desiredSellPrice; - if (isString(desiredSellPrice)) { - const sCost = desiredSellPrice.replace(/MP/g, product.productionCost + product.rating / product.markup + ""); - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } else { - sellButtonText = ( - <> - {sellButtonText} @ - - ); - } - } - + sellButtonText = ( + <> + {sellButtonText} @ + + ); // Limit Production button const productionLimit = product.cityData[city].productionLimit; const limitProductionButtonText =