Moved cultist code into Cultist service
This commit is contained in:
parent
d18ef883da
commit
a578e01402
@ -117,49 +117,6 @@ export class HideoutHelper {
|
|||||||
pmcData.Hideout.Production[body.recipeId] = production;
|
pmcData.Hideout.Production[body.recipeId] = production;
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerCircleOfCultistProduction(
|
|
||||||
sessionId: string,
|
|
||||||
pmcData: IPmcData,
|
|
||||||
recipeId: string,
|
|
||||||
sacrificedItems: Item[],
|
|
||||||
rewardAmountRoubles: number,
|
|
||||||
): void {
|
|
||||||
// TODO: hard coded 5 hour (18000) craft + no fuel use, where can we get this data
|
|
||||||
const cultistProduction = this.initProduction(
|
|
||||||
recipeId,
|
|
||||||
this.getCircleCraftTime(rewardAmountRoubles),
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
cultistProduction.GivenItemsInStart = sacrificedItems;
|
|
||||||
|
|
||||||
// Add circle production to profile
|
|
||||||
pmcData.Hideout.Production[recipeId] = cultistProduction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the circle craft time as seconds, value is based on reward item value
|
|
||||||
* @param rewardAmountRoubles Value of rewards in roubles
|
|
||||||
* @returns craft time seconds
|
|
||||||
*/
|
|
||||||
protected getCircleCraftTime(rewardAmountRoubles: number): number {
|
|
||||||
// Edge case, check if override exists
|
|
||||||
if (this.hideoutConfig.cultistCircle.craftTimeOverride !== -1) {
|
|
||||||
return this.hideoutConfig.cultistCircle.craftTimeOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
const thresholds = this.hideoutConfig.cultistCircle.craftTimeThreshholds;
|
|
||||||
const matchingThreshold = thresholds.find(
|
|
||||||
(craftThreshold) => craftThreshold.min <= rewardAmountRoubles && craftThreshold.max >= rewardAmountRoubles,
|
|
||||||
);
|
|
||||||
if (!matchingThreshold) {
|
|
||||||
// No craft time found, default to 12 hours
|
|
||||||
return this.timeUtil.getHoursAsSeconds(12);
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchingThreshold.timeSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This convenience function initializes new Production Object
|
* This convenience function initializes new Production Object
|
||||||
* with all the constants.
|
* with all the constants.
|
||||||
|
@ -29,6 +29,7 @@ import { ItemFilterService } from "@spt/services/ItemFilterService";
|
|||||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||||
import { HashUtil } from "@spt/utils/HashUtil";
|
import { HashUtil } from "@spt/utils/HashUtil";
|
||||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||||
|
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ export class CircleOfCultistService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("PrimaryLogger") protected logger: ILogger,
|
@inject("PrimaryLogger") protected logger: ILogger,
|
||||||
|
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||||
@inject("PrimaryCloner") protected cloner: ICloner,
|
@inject("PrimaryCloner") protected cloner: ICloner,
|
||||||
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
|
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
|
||||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||||
@ -96,7 +98,13 @@ export class CircleOfCultistService {
|
|||||||
const rewardAmountRoubles = sacrificedItemCostRoubles * rewardAmountMultiplier;
|
const rewardAmountRoubles = sacrificedItemCostRoubles * rewardAmountMultiplier;
|
||||||
|
|
||||||
// Create production in pmc profile
|
// Create production in pmc profile
|
||||||
this.hideoutHelper.registerCircleOfCultistProduction(sessionId, pmcData, cultistCraftData._id, sacrificedItems);
|
this.registerCircleOfCultistProduction(
|
||||||
|
sessionId,
|
||||||
|
pmcData,
|
||||||
|
cultistCraftData._id,
|
||||||
|
sacrificedItems,
|
||||||
|
rewardAmountRoubles,
|
||||||
|
);
|
||||||
|
|
||||||
const output = this.eventOutputHolder.getOutput(sessionId);
|
const output = this.eventOutputHolder.getOutput(sessionId);
|
||||||
|
|
||||||
@ -151,6 +159,48 @@ export class CircleOfCultistService {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected registerCircleOfCultistProduction(
|
||||||
|
sessionId: string,
|
||||||
|
pmcData: IPmcData,
|
||||||
|
recipeId: string,
|
||||||
|
sacrificedItems: Item[],
|
||||||
|
rewardAmountRoubles: number,
|
||||||
|
): void {
|
||||||
|
const cultistProduction = this.hideoutHelper.initProduction(
|
||||||
|
recipeId,
|
||||||
|
this.getCircleCraftTime(rewardAmountRoubles),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
cultistProduction.GivenItemsInStart = sacrificedItems;
|
||||||
|
|
||||||
|
// Add circle production to profile
|
||||||
|
pmcData.Hideout.Production[recipeId] = cultistProduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the circle craft time as seconds, value is based on reward item value
|
||||||
|
* @param rewardAmountRoubles Value of rewards in roubles
|
||||||
|
* @returns craft time seconds
|
||||||
|
*/
|
||||||
|
protected getCircleCraftTime(rewardAmountRoubles: number): number {
|
||||||
|
// Edge case, check if override exists
|
||||||
|
if (this.hideoutConfig.cultistCircle.craftTimeOverride !== -1) {
|
||||||
|
return this.hideoutConfig.cultistCircle.craftTimeOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
const thresholds = this.hideoutConfig.cultistCircle.craftTimeThreshholds;
|
||||||
|
const matchingThreshold = thresholds.find(
|
||||||
|
(craftThreshold) => craftThreshold.min <= rewardAmountRoubles && craftThreshold.max >= rewardAmountRoubles,
|
||||||
|
);
|
||||||
|
if (!matchingThreshold) {
|
||||||
|
// No craft time found, default to 12 hours
|
||||||
|
return this.timeUtil.getHoursAsSeconds(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchingThreshold.timeSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the items player sacrificed in circle
|
* Get the items player sacrificed in circle
|
||||||
* @param pmcData Player profile
|
* @param pmcData Player profile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user