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
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||||
|
const hideoutDb = this.databaseServer.getTables().hideout;
|
||||||
|
|
||||||
if (request.recipeId === HideoutHelper.bitcoinFarm)
|
if (request.recipeId === HideoutHelper.bitcoinFarm)
|
||||||
{
|
{
|
||||||
return this.hideoutHelper.getBTC(pmcData, request, sessionID);
|
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)
|
if (recipe)
|
||||||
{
|
{
|
||||||
return this.handleRecipe(sessionID, recipe, pmcData, request, output);
|
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)
|
if (scavCase)
|
||||||
{
|
{
|
||||||
return this.handleScavCase(sessionID, pmcData, request, output);
|
return this.handleScavCase(sessionID, pmcData, request, output);
|
||||||
@ -831,7 +832,7 @@ export class HideoutController
|
|||||||
return this.httpResponse.appendErrorToOutput(output);
|
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);
|
const area = pmcData.Hideout.Areas.find((x) => x.type === recipe.areaType);
|
||||||
if (area && request.recipeId !== area.lastRecipe)
|
if (area && request.recipeId !== area.lastRecipe)
|
||||||
{
|
{
|
||||||
@ -848,13 +849,13 @@ export class HideoutController
|
|||||||
hoursCrafting -= this.hideoutConfig.hoursForSkillCrafting * multiplierCrafting;
|
hoursCrafting -= this.hideoutConfig.hoursForSkillCrafting * multiplierCrafting;
|
||||||
}
|
}
|
||||||
|
|
||||||
// increment
|
// Increment
|
||||||
// if addItem passes validation:
|
// if addItem passes validation:
|
||||||
// - increment skill point for crafting
|
// - increment skill point for crafting
|
||||||
// - delete the production in profile Hideout.Production
|
// - delete the production in profile Hideout.Production
|
||||||
const callback = () =>
|
const callback = () =>
|
||||||
{
|
{
|
||||||
// manager Hideout skill
|
// Manager Hideout skill
|
||||||
// ? use a configuration variable for the value?
|
// ? use a configuration variable for the value?
|
||||||
const globals = this.databaseServer.getTables().globals;
|
const globals = this.databaseServer.getTables().globals;
|
||||||
this.profileHelper.addSkillPointsToPlayer(
|
this.profileHelper.addSkillPointsToPlayer(
|
||||||
@ -876,12 +877,16 @@ export class HideoutController
|
|||||||
area.lastRecipe = request.recipeId;
|
area.lastRecipe = request.recipeId;
|
||||||
counterHoursCrafting.value = hoursCrafting;
|
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].sptIsComplete = true;
|
||||||
};
|
pmcData.Hideout.Production[prodId].sptIsContinuous = recipe.continuous;
|
||||||
|
|
||||||
// Remove the old production from output object before its sent to client
|
// Flag normal crafts as complete
|
||||||
delete output.profileChanges[sessionID].production[request.recipeId];
|
if (!recipe.continuous)
|
||||||
|
{
|
||||||
|
pmcData.Hideout.Production[prodId].inProgress = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Handle the isEncoded flag from recipe
|
// Handle the isEncoded flag from recipe
|
||||||
if (recipe.isEncoded)
|
if (recipe.isEncoded)
|
||||||
|
@ -390,6 +390,8 @@ export interface Productive
|
|||||||
sptIsScavCase?: boolean;
|
sptIsScavCase?: boolean;
|
||||||
/** Some crafts are always inProgress, but need to be reset, e.g. water collector */
|
/** Some crafts are always inProgress, but need to be reset, e.g. water collector */
|
||||||
sptIsComplete?: boolean;
|
sptIsComplete?: boolean;
|
||||||
|
/** Is the craft a Continuous, e.g bitcoins/water collector */
|
||||||
|
sptIsContinuous?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Production extends Productive
|
export interface Production extends Productive
|
||||||
|
@ -84,8 +84,8 @@ export class EventOutputHolder
|
|||||||
profileChanges.improvements = this.jsonUtil.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData));
|
profileChanges.improvements = this.jsonUtil.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData));
|
||||||
profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo);
|
profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo);
|
||||||
|
|
||||||
// Fixes container craft from water collector not resetting after collection
|
// Fixes container craft from water collector not resetting after collection + removed completed normal crafts
|
||||||
this.resetSptIsCompleteFlaggedCrafts(pmcData.Hideout.Production);
|
this.cleanUpCompleteCraftsInProfile(pmcData.Hideout.Production);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,9 +156,8 @@ export class EventOutputHolder
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete and is a water collector craft
|
// Complete and is Continuous e.g. water collector
|
||||||
// Needed as canister craft (water collector) is continuous
|
if (production.sptIsComplete && production.sptIsContinuous)
|
||||||
if (production.sptIsComplete && productionKey === "5d5589c1f934db045e6c5492")
|
|
||||||
{
|
{
|
||||||
continue;
|
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
|
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
|
* 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
|
* @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)
|
for (const productionKey in productions)
|
||||||
{
|
{
|
||||||
const production = productions[productionKey];
|
const production = productions[productionKey];
|
||||||
if (production.sptIsComplete)
|
if (production.sptIsComplete && production.sptIsContinuous)
|
||||||
{
|
{
|
||||||
|
// Water collector / Bitcoin etc
|
||||||
production.sptIsComplete = false;
|
production.sptIsComplete = false;
|
||||||
production.Progress = 0;
|
production.Progress = 0;
|
||||||
production.StartTimestamp = this.timeUtil.getTimestamp();
|
production.StartTimestamp = this.timeUtil.getTimestamp();
|
||||||
}
|
}
|
||||||
|
else if (!production.inProgress)
|
||||||
|
{
|
||||||
|
// Normal completed craft, delete
|
||||||
|
delete productions[productionKey];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user