Fix not being able to collect bitcoins
Improved handling of server/client sync when clicking 'get iems' to reduce chance of `no bitcoins to collect` error
This commit is contained in:
parent
f5d56f8ae3
commit
d0af930dc9
@ -492,7 +492,8 @@ export class HideoutController
|
|||||||
{
|
{
|
||||||
const slotIndexToRemove = removeResourceRequest.slots[0];
|
const slotIndexToRemove = removeResourceRequest.slots[0];
|
||||||
|
|
||||||
const itemToReturn = hideoutArea.slots.find((x) => x.locationIndex === slotIndexToRemove).item[0];
|
// Assume only one item in slot
|
||||||
|
const itemToReturn = hideoutArea.slots.find((slot) => slot.locationIndex === slotIndexToRemove).item[0];
|
||||||
|
|
||||||
const request: IAddItemDirectRequest = {
|
const request: IAddItemDirectRequest = {
|
||||||
itemWithModsToAdd: [
|
itemWithModsToAdd: [
|
||||||
@ -507,15 +508,15 @@ export class HideoutController
|
|||||||
useSortingTable: false
|
useSortingTable: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// If returned with errors, drop out
|
|
||||||
this.inventoryHelper.addItemToStash(sessionID, request, pmcData, output);
|
this.inventoryHelper.addItemToStash(sessionID, request, pmcData, output);
|
||||||
if (output.warnings && output.warnings.length > 0)
|
if (output.warnings && output.warnings.length > 0)
|
||||||
{
|
{
|
||||||
|
// Adding to stash failed, drop out - dont remove item from hideout area slot
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove items from slot, locationIndex remains
|
// Remove items from slot, locationIndex remains
|
||||||
const hideoutSlotIndex = hideoutArea.slots.findIndex((x) => x.locationIndex === slotIndexToRemove);
|
const hideoutSlotIndex = hideoutArea.slots.findIndex((slot) => slot.locationIndex === slotIndexToRemove);
|
||||||
hideoutArea.slots[hideoutSlotIndex].item = undefined;
|
hideoutArea.slots[hideoutSlotIndex].item = undefined;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
@ -723,7 +724,9 @@ export class HideoutController
|
|||||||
|
|
||||||
if (request.recipeId === HideoutHelper.bitcoinFarm)
|
if (request.recipeId === HideoutHelper.bitcoinFarm)
|
||||||
{
|
{
|
||||||
return this.hideoutHelper.getBTC(pmcData, request, sessionID);
|
// Ensure server and client are in-sync when player presses 'get items' on farm
|
||||||
|
this.hideoutHelper.updatePlayerHideout(sessionID);
|
||||||
|
return this.hideoutHelper.getBTC(pmcData, request, sessionID, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recipe = hideoutDb.production.find((r) => r._id === request.recipeId);
|
const recipe = hideoutDb.production.find((r) => r._id === request.recipeId);
|
||||||
|
@ -832,7 +832,7 @@ export class HideoutHelper
|
|||||||
{
|
{
|
||||||
btcProd.Products.push({
|
btcProd.Products.push({
|
||||||
_id: this.hashUtil.generate(),
|
_id: this.hashUtil.generate(),
|
||||||
_tpl: "59faff1d86f7746c51718c9c",
|
_tpl: HideoutHelper.bitcoin,
|
||||||
upd: { StackObjectsCount: 1 },
|
upd: { StackObjectsCount: 1 },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -869,26 +869,26 @@ export class HideoutHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a count of how many BTC can be gathered by the profile
|
* Get a count of how many possible BTC can be gathered by the profile
|
||||||
* @param pmcData Profile to look up
|
* @param pmcData Profile to look up
|
||||||
* @returns coin slot count
|
* @returns Coin slot count
|
||||||
*/
|
*/
|
||||||
protected getBTCSlots(pmcData: IPmcData): number
|
protected getBTCSlots(pmcData: IPmcData): number
|
||||||
{
|
{
|
||||||
const bitcoinProduction = this.databaseServer.getTables().hideout.production.find((p) =>
|
const bitcoinProductions = this.databaseServer.getTables().hideout.production.find((production) =>
|
||||||
p._id === HideoutHelper.bitcoinFarm
|
production._id === HideoutHelper.bitcoinFarm
|
||||||
);
|
);
|
||||||
const productionSlots = bitcoinProduction?.productionLimitCount || 3;
|
const productionSlots = bitcoinProductions?.productionLimitCount || 3; // Default to 3 if none found
|
||||||
const hasManagementSkillSlots = this.profileHelper.hasEliteSkillLevel(SkillTypes.HIDEOUT_MANAGEMENT, pmcData);
|
const hasManagementSkillSlots = this.profileHelper.hasEliteSkillLevel(SkillTypes.HIDEOUT_MANAGEMENT, pmcData);
|
||||||
const managementSlotsCount = this.getBitcoinMinerContainerSlotSize() || 2;
|
const managementSlotsCount = this.getEliteSkillAdditionalBitcoinSlotCount() || 2;
|
||||||
|
|
||||||
return productionSlots + (hasManagementSkillSlots ? managementSlotsCount : 0);
|
return productionSlots + (hasManagementSkillSlots ? managementSlotsCount : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a count of bitcoins player miner can hold
|
* Get a count of how many additional bitcoins player hideout can hold with elite skill
|
||||||
*/
|
*/
|
||||||
protected getBitcoinMinerContainerSlotSize(): number
|
protected getEliteSkillAdditionalBitcoinSlotCount(): number
|
||||||
{
|
{
|
||||||
return this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement.EliteSlots.BitcoinFarm
|
return this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement.EliteSlots.BitcoinFarm
|
||||||
.Container;
|
.Container;
|
||||||
@ -949,16 +949,16 @@ export class HideoutHelper
|
|||||||
* @param pmcData Player profile
|
* @param pmcData Player profile
|
||||||
* @param request Take production request
|
* @param request Take production request
|
||||||
* @param sessionId Session id
|
* @param sessionId Session id
|
||||||
|
* @param output Output object to update
|
||||||
* @returns IItemEventRouterResponse
|
* @returns IItemEventRouterResponse
|
||||||
*/
|
*/
|
||||||
public getBTC(
|
public getBTC(
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
request: IHideoutTakeProductionRequestData,
|
request: IHideoutTakeProductionRequestData,
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
|
output: IItemEventRouterResponse
|
||||||
): IItemEventRouterResponse
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
const output = this.eventOutputHolder.getOutput(sessionId);
|
|
||||||
|
|
||||||
// Get how many coins were crafted and ready to pick up
|
// Get how many coins were crafted and ready to pick up
|
||||||
const craftedCoinCount = pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length;
|
const craftedCoinCount = pmcData.Hideout.Production[HideoutHelper.bitcoinFarm].Products.length;
|
||||||
if (!craftedCoinCount)
|
if (!craftedCoinCount)
|
||||||
@ -974,6 +974,8 @@ export class HideoutHelper
|
|||||||
|
|
||||||
// Add FiR coins to player inventory
|
// Add FiR coins to player inventory
|
||||||
this.inventoryHelper.addItemToStash(sessionId, btcCoinCreationRequest, pmcData, output);
|
this.inventoryHelper.addItemToStash(sessionId, btcCoinCreationRequest, pmcData, output);
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -994,7 +996,7 @@ export class HideoutHelper
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
foundInRaid: true,
|
foundInRaid: true,
|
||||||
useSortingTable: true,
|
useSortingTable: false,
|
||||||
callback: () =>
|
callback: () =>
|
||||||
{
|
{
|
||||||
// Is at max capacity
|
// Is at max capacity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user