Fix issue with hideout crafts being collectable twice
This commit is contained in:
parent
f727b13215
commit
2132ea7adb
@ -721,19 +721,20 @@ export class HideoutController
|
||||
): IItemEventRouterResponse
|
||||
{
|
||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||
const hideoutDb = this.databaseServer.getTables().hideout;
|
||||
|
||||
if (request.recipeId === HideoutHelper.bitcoinFarm)
|
||||
{
|
||||
return this.hideoutHelper.getBTC(pmcData, request, sessionID);
|
||||
}
|
||||
|
||||
const recipe = this.databaseServer.getTables().hideout.production.find((r) => r._id === request.recipeId);
|
||||
const recipe = hideoutDb.production.find((r) => r._id === request.recipeId);
|
||||
if (recipe)
|
||||
{
|
||||
return this.handleRecipe(sessionID, recipe, pmcData, request, output);
|
||||
}
|
||||
|
||||
const scavCase = this.databaseServer.getTables().hideout.scavcase.find((r) => r._id === request.recipeId);
|
||||
const scavCase = hideoutDb.scavcase.find((r) => r._id === request.recipeId);
|
||||
if (scavCase)
|
||||
{
|
||||
return this.handleScavCase(sessionID, pmcData, request, output);
|
||||
@ -831,7 +832,7 @@ export class HideoutController
|
||||
return this.httpResponse.appendErrorToOutput(output);
|
||||
}
|
||||
|
||||
// check if the recipe is the same as the last one
|
||||
// Check if the recipe is the same as the last one
|
||||
const area = pmcData.Hideout.Areas.find((x) => x.type === recipe.areaType);
|
||||
if (area && request.recipeId !== area.lastRecipe)
|
||||
{
|
||||
@ -848,13 +849,13 @@ export class HideoutController
|
||||
hoursCrafting -= this.hideoutConfig.hoursForSkillCrafting * multiplierCrafting;
|
||||
}
|
||||
|
||||
// increment
|
||||
// Increment
|
||||
// if addItem passes validation:
|
||||
// - increment skill point for crafting
|
||||
// - delete the production in profile Hideout.Production
|
||||
const callback = () =>
|
||||
{
|
||||
// manager Hideout skill
|
||||
// Manager Hideout skill
|
||||
// ? use a configuration variable for the value?
|
||||
const globals = this.databaseServer.getTables().globals;
|
||||
this.profileHelper.addSkillPointsToPlayer(
|
||||
@ -876,12 +877,16 @@ export class HideoutController
|
||||
area.lastRecipe = request.recipeId;
|
||||
counterHoursCrafting.value = hoursCrafting;
|
||||
|
||||
// Null production data now it's complete - will be cleaned up later by update() process
|
||||
// Continuous crafts have special handling in EventOutputHolder.updateOutputProperties()
|
||||
pmcData.Hideout.Production[prodId].sptIsComplete = true;
|
||||
};
|
||||
pmcData.Hideout.Production[prodId].sptIsContinuous = recipe.continuous;
|
||||
|
||||
// Remove the old production from output object before its sent to client
|
||||
delete output.profileChanges[sessionID].production[request.recipeId];
|
||||
// Flag normal crafts as complete
|
||||
if (!recipe.continuous)
|
||||
{
|
||||
pmcData.Hideout.Production[prodId].inProgress = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Handle the isEncoded flag from recipe
|
||||
if (recipe.isEncoded)
|
||||
|
@ -390,6 +390,8 @@ export interface Productive
|
||||
sptIsScavCase?: boolean;
|
||||
/** Some crafts are always inProgress, but need to be reset, e.g. water collector */
|
||||
sptIsComplete?: boolean;
|
||||
/** Is the craft a Continuous, e.g bitcoins/water collector */
|
||||
sptIsContinuous?: boolean;
|
||||
}
|
||||
|
||||
export interface Production extends Productive
|
||||
|
@ -84,8 +84,8 @@ export class EventOutputHolder
|
||||
profileChanges.improvements = this.jsonUtil.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData));
|
||||
profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo);
|
||||
|
||||
// Fixes container craft from water collector not resetting after collection
|
||||
this.resetSptIsCompleteFlaggedCrafts(pmcData.Hideout.Production);
|
||||
// Fixes container craft from water collector not resetting after collection + removed completed normal crafts
|
||||
this.cleanUpCompleteCraftsInProfile(pmcData.Hideout.Production);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,9 +156,8 @@ export class EventOutputHolder
|
||||
continue;
|
||||
}
|
||||
|
||||
// Complete and is a water collector craft
|
||||
// Needed as canister craft (water collector) is continuous
|
||||
if (production.sptIsComplete && productionKey === "5d5589c1f934db045e6c5492")
|
||||
// Complete and is Continuous e.g. water collector
|
||||
if (production.sptIsComplete && production.sptIsContinuous)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -184,7 +183,7 @@ export class EventOutputHolder
|
||||
}
|
||||
}
|
||||
|
||||
// Return null of there's no crafts to send to client to match live behaviour
|
||||
// Return null if there's no crafts to send to client to match live behaviour
|
||||
return (Object.keys(productions).length > 0) ? productions : null
|
||||
}
|
||||
|
||||
@ -192,17 +191,23 @@ export class EventOutputHolder
|
||||
* Required as continuous productions don't reset and stay at 100% completion but client thinks it hasn't started
|
||||
* @param productions Productions in a profile
|
||||
*/
|
||||
protected resetSptIsCompleteFlaggedCrafts(productions: Record<string, Productive>): void
|
||||
protected cleanUpCompleteCraftsInProfile(productions: Record<string, Productive>): void
|
||||
{
|
||||
for (const productionKey in productions)
|
||||
{
|
||||
const production = productions[productionKey];
|
||||
if (production.sptIsComplete)
|
||||
if (production.sptIsComplete && production.sptIsContinuous)
|
||||
{
|
||||
// Water collector / Bitcoin etc
|
||||
production.sptIsComplete = false;
|
||||
production.Progress = 0;
|
||||
production.StartTimestamp = this.timeUtil.getTimestamp();
|
||||
}
|
||||
else if (!production.inProgress)
|
||||
{
|
||||
// Normal completed craft, delete
|
||||
delete productions[productionKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user