BUGFIX: Fix corp issues relating to imports (#568)

Also clarify the Smart Supply options to be more clear on what they do.
This commit is contained in:
David Walker 2023-06-03 21:11:07 -07:00 committed by GitHub
parent 403beef69e
commit 3c6b5a1a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 12 deletions

@ -246,6 +246,7 @@ GENERAL / MISC:
* Changed tail window buttons into icon buttons, plus tail window bugfixes (@d0sboots) * Changed tail window buttons into icon buttons, plus tail window bugfixes (@d0sboots)
* Terminal no longer scrolls to the bottom constantly while an action is being performed (@bezrodnov) * Terminal no longer scrolls to the bottom constantly while an action is being performed (@bezrodnov)
* Added a close button to modals (@bezrodnov) * Added a close button to modals (@bezrodnov)
* Fixes for Corp import/export issues, such as -IPROD and Smart Supply not working right (@d0sboots)
* Documentation fixes (various) * Documentation fixes (various)
* Nerf noodle bar * Nerf noodle bar

@ -93,10 +93,14 @@ export class Corporation {
const gameCycles = marketCycles * corpConstants.gameCyclesPerCorpStateCycle; const gameCycles = marketCycles * corpConstants.gameCyclesPerCorpStateCycle;
this.storedCycles -= gameCycles; this.storedCycles -= gameCycles;
this.divisions.forEach((ind) => { // Can't combine these loops, imports must be completely cleared before
// we start processing exports of any division.
for (const ind of this.divisions.values()) {
ind.resetImports(state); ind.resetImports(state);
}
for (const ind of this.divisions.values()) {
ind.process(marketCycles, state, this); ind.process(marketCycles, state, this);
}); }
// Process cooldowns // Process cooldowns
if (this.shareSaleCooldown > 0) { if (this.shareSaleCooldown > 0) {

@ -355,7 +355,10 @@ export class Division {
if (warehouse.smartSupplyOptions[matName] === "leftovers") { if (warehouse.smartSupplyOptions[matName] === "leftovers") {
buyArray[0] = Math.max(0, buyArray[0] - mat.stored); buyArray[0] = Math.max(0, buyArray[0] - mat.stored);
} else { } else {
buyArray[0] = Math.max(0, buyArray[0] - mat.importAmount); buyArray[0] = Math.max(
0,
buyArray[0] - mat.importAmount * corpConstants.secondsPerMarketCycle * marketCycles,
);
} }
} }
@ -365,7 +368,7 @@ export class Division {
if (mat.stored + buyAmt != 0) mat.quality = (mat.quality * mat.stored + 1 * buyAmt) / (mat.stored + buyAmt); if (mat.stored + buyAmt != 0) mat.quality = (mat.quality * mat.stored + 1 * buyAmt) / (mat.stored + buyAmt);
else mat.quality = 1; else mat.quality = 1;
mat.stored += buyAmt; mat.stored += buyAmt;
mat.buyAmount = buyAmt / 10; mat.buyAmount = buyAmt / (corpConstants.secondsPerMarketCycle * marketCycles);
expenses += buyAmt * mat.marketPrice; expenses += buyAmt * mat.marketPrice;
} }
break; break;
@ -639,8 +642,8 @@ export class Division {
/MAX/g, /MAX/g,
(mat.stored / (corpConstants.secondsPerMarketCycle * marketCycles) + "").toUpperCase(), (mat.stored / (corpConstants.secondsPerMarketCycle * marketCycles) + "").toUpperCase(),
); );
amtStr = amtStr.replace(/EPROD/g, mat.productionAmount.toString()); amtStr = amtStr.replace(/EPROD/g, "(" + mat.productionAmount + ")");
amtStr = amtStr.replace(/IPROD/g, tempMaterial.productionAmount.toString()); amtStr = amtStr.replace(/IPROD/g, "(" + tempMaterial.productionAmount + ")");
amtStr = amtStr.replace(/EINV/g, mat.stored.toString()); amtStr = amtStr.replace(/EINV/g, mat.stored.toString());
amtStr = amtStr.replace(/IINV/g, tempMaterial.stored.toString()); amtStr = amtStr.replace(/IINV/g, tempMaterial.stored.toString());
let amt = 0; let amt = 0;

@ -97,12 +97,20 @@ export function SmartSupplyModal(props: IProps): React.ReactElement {
<br /> <br />
<Typography> <Typography>
Options: Options:
<ul>
<li>
Use leftovers takes the amount of that material already in storage into account when purchasing new ones.
This also accounts for imports, since they are "leftovers" by the time purchasing happens.
<br /> <br />
- Use leftovers takes the amount of that material already in storage into account when purchasing new ones. <i>This is usually the option you want.</i>
<br /> </li>
- Use imported takes the amount of that materials that was imported in previous cycle into account. <li>
<br /> Use imported takes <b>only</b> the amount of that materials that were imported in the previous cycle into
if neither is toggled on, Smart Supply will ignore any materials in store and attempts to buy as much as is account. This is useful when dealing with specialty situations, like importing materials that also boost
production.
</li>
</ul>
If neither is toggled on, Smart Supply will ignore any materials stored and attempts to buy as much as is
needed for production. needed for production.
</Typography> </Typography>
{mats} {mats}