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
5 changed files with 13 additions and 67 deletions
+4 -31
View File
@@ -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)</>;
}
+5 -31
View File
@@ -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 =