Do not progress bitcoin production when power is off
Small cleanup of function to reduce nesting and duplication
This commit is contained in:
parent
23570f4e2a
commit
f333d45d70
@ -890,20 +890,11 @@ export class HideoutHelper {
|
||||
|
||||
protected updateBitcoinFarm(pmcData: IPmcData, btcFarmCGs: number, isGeneratorOn: boolean): Production | undefined {
|
||||
const btcProd = pmcData.Hideout.Production[HideoutHelper.bitcoinFarm];
|
||||
const bitcoinProdData = this.databaseService
|
||||
.getHideout()
|
||||
.production.recipes.find((production) => production._id === HideoutHelper.bitcoinProductionId);
|
||||
const coinSlotCount = this.getBTCSlots(pmcData);
|
||||
|
||||
// Full on bitcoins, halt progress
|
||||
if (this.isProduction(btcProd) && btcProd.Products.length >= coinSlotCount) {
|
||||
// Set progress to 0
|
||||
btcProd.Progress = 0;
|
||||
|
||||
return btcProd;
|
||||
const isBtcProd = this.isProduction(btcProd);
|
||||
if (!isBtcProd) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (this.isProduction(btcProd)) {
|
||||
// The wiki has a wrong formula!
|
||||
// Do not change unless you validate it with the Client code files!
|
||||
// This formula was found on the client files:
|
||||
@ -938,6 +929,26 @@ export class HideoutHelper {
|
||||
this.gclass1678_1.Type = EDetailsType.Farming;
|
||||
}
|
||||
*/
|
||||
// Needs power to function
|
||||
if (!isGeneratorOn) {
|
||||
// Return with no changes
|
||||
return btcProd;
|
||||
}
|
||||
|
||||
const coinSlotCount = this.getBTCSlots(pmcData);
|
||||
|
||||
// Full on bitcoins, halt progress
|
||||
if (btcProd.Products.length >= coinSlotCount) {
|
||||
// Set progress to 0
|
||||
btcProd.Progress = 0;
|
||||
|
||||
return btcProd;
|
||||
}
|
||||
|
||||
const bitcoinProdData = this.databaseService
|
||||
.getHideout()
|
||||
.production.recipes.find((production) => production._id === HideoutHelper.bitcoinProductionId);
|
||||
|
||||
// BSG finally fixed their settings, they now get loaded from the settings and used in the client
|
||||
const adjustedCraftTime =
|
||||
(this.profileHelper.isDeveloperAccount(pmcData.sessionId) ? 40 : bitcoinProdData.productionTime) /
|
||||
@ -950,7 +961,7 @@ export class HideoutHelper {
|
||||
|
||||
while (btcProd.Progress >= bitcoinProdData.productionTime) {
|
||||
if (btcProd.Products.length < coinSlotCount) {
|
||||
// Has space to add a coin to production
|
||||
// Has space to add a coin to production rewards
|
||||
this.addBtcToProduction(btcProd, bitcoinProdData.productionTime);
|
||||
} else {
|
||||
// Filled up bitcoin storage
|
||||
@ -963,9 +974,6 @@ export class HideoutHelper {
|
||||
return btcProd;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add bitcoin object to btc production products array and set progress time
|
||||
* @param btcProd Bitcoin production object
|
||||
|
Loading…
Reference in New Issue
Block a user