Migrate getBTC()
to use addItemToStash()
This commit is contained in:
parent
ceba6b3064
commit
80b549a2d5
@ -10,6 +10,7 @@ import { IHideoutContinuousProductionStartRequestData } from "@spt-aki/models/ef
|
|||||||
import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProduction";
|
import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProduction";
|
||||||
import { IHideoutSingleProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
import { IHideoutSingleProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
||||||
import { IHideoutTakeProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutTakeProductionRequestData";
|
import { IHideoutTakeProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutTakeProductionRequestData";
|
||||||
|
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest";
|
||||||
import { IAddItemRequestData } from "@spt-aki/models/eft/inventory/IAddItemRequestData";
|
import { IAddItemRequestData } from "@spt-aki/models/eft/inventory/IAddItemRequestData";
|
||||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||||
@ -955,11 +956,33 @@ export class HideoutHelper
|
|||||||
return this.httpResponse.appendErrorToOutput(output, errorMsg);
|
return this.httpResponse.appendErrorToOutput(output, errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const btcCoinCreationRequest = this.createBitcoinRequest(pmcData);
|
|
||||||
const coinSlotCount = this.getBTCSlots(pmcData);
|
const coinSlotCount = this.getBTCSlots(pmcData);
|
||||||
|
const btcCoinCreationRequest = this.createBitcoinRequest(pmcData, coinSlotCount);
|
||||||
|
|
||||||
// Run callback after coins are added to player inventory
|
// Add FiR coins to player inventory
|
||||||
const callback = () =>
|
this.inventoryHelper.addItemToStash(sessionId, btcCoinCreationRequest, pmcData, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a bitcoin request object
|
||||||
|
* @param pmcData Player profile
|
||||||
|
* @returns IAddItemRequestData
|
||||||
|
*/
|
||||||
|
protected createBitcoinRequest(pmcData: IPmcData, coinSlotCount: number): IAddItemDirectRequest
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
itemWithModsToAdd: [
|
||||||
|
{
|
||||||
|
_id: this.hashUtil.generate(),
|
||||||
|
_tpl: HideoutHelper.bitcoin,
|
||||||
|
upd: {
|
||||||
|
StackObjectsCount: pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
foundInRaid: true,
|
||||||
|
useSortingTable: true,
|
||||||
|
callback: () =>
|
||||||
{
|
{
|
||||||
// Is at max capacity
|
// Is at max capacity
|
||||||
if (pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length >= coinSlotCount)
|
if (pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length >= coinSlotCount)
|
||||||
@ -968,27 +991,9 @@ export class HideoutHelper
|
|||||||
pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].StartTimestamp = this.timeUtil.getTimestamp();
|
pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].StartTimestamp = this.timeUtil.getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove crafted coins from production in profile
|
// Remove crafted coins from production in profile now they've been collected
|
||||||
pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products = [];
|
pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products = [];
|
||||||
};
|
|
||||||
|
|
||||||
// Add FiR coins to player inventory
|
|
||||||
return this.inventoryHelper.addItem(pmcData, btcCoinCreationRequest, output, sessionId, callback, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a single bitcoin request object
|
|
||||||
* @param pmcData Player profile
|
|
||||||
* @returns IAddItemRequestData
|
|
||||||
*/
|
|
||||||
protected createBitcoinRequest(pmcData: IPmcData): IAddItemRequestData
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
items: [{
|
|
||||||
item_id: HideoutHelper.bitcoin,
|
|
||||||
count: pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length,
|
|
||||||
}],
|
|
||||||
tid: "ragfair",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user