CORPORATION: fixed Sell Buttons (#564)

This commit is contained in:
zerbosh 2023-06-04 06:13:26 +02:00 committed by GitHub
parent 3c6b5a1a83
commit d8fee8e25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 67 deletions

@ -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) {

@ -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;

@ -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;

@ -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} @ <Money money={mat.marketTa2Price} />
</>
);
} else if (mat.marketTa1) {
sellButtonText = (
<>
{sellButtonText} @ <Money money={mat.marketPrice + markupLimit} />
</>
);
} else if (mat.desiredSellPrice) {
if (isString(mat.desiredSellPrice)) {
const sCost = mat.desiredSellPrice.replace(/MP/g, mat.marketPrice + "");
sellButtonText = (
<>
{sellButtonText} @ <Money money={eval(sCost)} />
</>
);
} else {
sellButtonText = (
<>
{sellButtonText} @ <Money money={mat.desiredSellPrice} />
</>
);
}
}
<>
{sellButtonText} @ <Money money={mat.uiMarketPrice} />
</>;
} else {
sellButtonText = <>Sell (0.000/0.000)</>;
}

@ -66,37 +66,11 @@ export function ProductElem(props: IProductProps): React.ReactElement {
sellButtonText = <>Sell (0.000/0.000)</>;
}
if (product.marketTa2) {
sellButtonText = (
<>
{sellButtonText} @ <Money money={product.marketTa2Price[city]} />
</>
);
} else if (product.marketTa1) {
const markupLimit = product.rating / product.markup;
sellButtonText = (
<>
{sellButtonText} @ <Money money={product.productionCost + markupLimit} />
</>
);
} 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} @ <Money money={eval(sCost)} />
</>
);
} else {
sellButtonText = (
<>
{sellButtonText} @ <Money money={product.cityData[city].desiredSellPrice} />
</>
);
}
}
sellButtonText = (
<>
{sellButtonText} @ <Money money={product.uiMarketPrice[city]} />
</>
);
// Limit Production button
const productionLimit = product.cityData[city].productionLimit;
const limitProductionButtonText =