Fix cultist circle craft not progressing due to lack of recipe

This commit is contained in:
Dev 2024-08-22 11:05:32 +01:00
parent 47fcff1338
commit 472c258187
2 changed files with 32 additions and 3 deletions

View File

@ -123,7 +123,7 @@ export class HideoutHelper {
sacrificedItems: Item[], sacrificedItems: Item[],
): void { ): void {
// TODO: hard coded 12 hour craft + no fuel use, where can we get this data // TODO: hard coded 12 hour craft + no fuel use, where can we get this data
const cultistProduction = this.initProduction(recipeId, 43200, false); const cultistProduction = this.initProduction(recipeId, 50, false, true);
cultistProduction.GivenItemsInStart = sacrificedItems; cultistProduction.GivenItemsInStart = sacrificedItems;
// Add circle production to profile // Add circle production to profile
@ -134,7 +134,12 @@ export class HideoutHelper {
* This convenience function initializes new Production Object * This convenience function initializes new Production Object
* with all the constants. * with all the constants.
*/ */
public initProduction(recipeId: string, productionTime: number, needFuelForAllProductionTime: boolean): Production { public initProduction(
recipeId: string,
productionTime: number,
needFuelForAllProductionTime: boolean,
isCultistCircle = false,
): Production {
return { return {
Progress: 0, Progress: 0,
inProgress: true, inProgress: true,
@ -147,6 +152,7 @@ export class HideoutHelper {
NeedFuelForAllProductionTime: needFuelForAllProductionTime, // Used when sending to client NeedFuelForAllProductionTime: needFuelForAllProductionTime, // Used when sending to client
needFuelForAllProductionTime: needFuelForAllProductionTime, // used when stored in production.json needFuelForAllProductionTime: needFuelForAllProductionTime, // used when stored in production.json
SkipTime: 0, SkipTime: 0,
sptIsCultistCircle: isCultistCircle,
}; };
} }
@ -303,7 +309,14 @@ export class HideoutHelper {
continue; continue;
} }
// Other recipes not covered by above // cultist circle has no recipe, needs special handling
if (craft.sptIsCultistCircle) {
this.updateCultistCircleCraftProgress(pmcData, prodId);
return;
}
// Ensure recipe exists before using it in updateProductionProgress()
const recipe = recipes.recipes.find((r) => r._id === prodId); const recipe = recipes.recipes.find((r) => r._id === prodId);
if (!recipe) { if (!recipe) {
this.logger.error(this.localisationService.getText("hideout-missing_recipe_for_area", prodId)); this.logger.error(this.localisationService.getText("hideout-missing_recipe_for_area", prodId));
@ -365,6 +378,20 @@ export class HideoutHelper {
} }
} }
protected updateCultistCircleCraftProgress(pmcData: IPmcData, prodId: string) {
// Production is complete, no need to do any calculations
if (this.doesProgressMatchProductionTime(pmcData, prodId)) {
return;
}
// Get seconds since last hideout update and now
const timeElapsedSeconds = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp;
// Increment progress by time passed
const production = pmcData.Hideout.Production[prodId];
production.Progress += timeElapsedSeconds;
}
/** /**
* Check if a productions progress value matches its corresponding recipes production time value * Check if a productions progress value matches its corresponding recipes production time value
* @param pmcData Player profile * @param pmcData Player profile

View File

@ -384,6 +384,8 @@ export interface Productive {
sptIsContinuous?: boolean; sptIsContinuous?: boolean;
/** Stores a list of tools used in this craft and whether they're FiR, to give back once the craft is done */ /** Stores a list of tools used in this craft and whether they're FiR, to give back once the craft is done */
sptRequiredTools?: Item[]; sptRequiredTools?: Item[];
// Craft is cultist circle sacrifice
sptIsCultistCircle?: boolean;
} }
export interface Production extends Productive { export interface Production extends Productive {