Skip to main content
The Deno 2 Release Candidate is here
Learn more
class RepeatableQuestController
import { RepeatableQuestController } from "https://deno.land/x/sptaki@1.2.0/controllers/mod.ts";

Constructors

new
RepeatableQuestController(
logger: ILogger,
databaseServer: DatabaseServer,
timeUtil: TimeUtil,
randomUtil: RandomUtil,
httpResponse: HttpResponseUtil,
jsonUtil: JsonUtil,
profileHelper: ProfileHelper,
profileFixerService: ProfileFixerService,
eventOutputHolder: EventOutputHolder,
paymentService: PaymentService,
objectId: ObjectId,
repeatableQuestGenerator: RepeatableQuestGenerator,
repeatableQuestHelper: RepeatableQuestHelper,
questHelper: QuestHelper,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
eventOutputHolder: EventOutputHolder
protected
httpResponse: HttpResponseUtil
protected
jsonUtil: JsonUtil
protected
logger: ILogger
protected
objectId: ObjectId
protected
paymentService: PaymentService
protected
profileFixerService: ProfileFixerService
protected
profileHelper: ProfileHelper
protected
questConfig: IQuestConfig
protected
questHelper: QuestHelper
protected
randomUtil: RandomUtil
protected
repeatableQuestGenerator: RepeatableQuestGenerator
protected
repeatableQuestHelper: RepeatableQuestHelper
protected
timeUtil: TimeUtil

Methods

protected
generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool

Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests where you have to e.g. kill scavs in same locations.

protected
getAllowedLocations(locations: Record<ELocationName, string[]>, pmcLevel: number): Partial<Record<ELocationName, string[]>>

Return the locations this PMC is allowed to get daily quests for based on their level

protected
getQuestCount(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): number

Get the number of quests to generate - takes into account charisma state of player

Get repeatable quest data from profile from name (daily/weekly), creates base repeatable quest object if none exists

protected
isPmcLevelAllowedOnLocation(location: string, pmcLevel: number): boolean

Return true if the given pmcLevel is allowed on the given location

Handle RepeatableQuestChange event

generateDebugDailies(
dailiesPool: any,
factory: any,
number: number,
): any

Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps

Handle client/repeatalbeQuests/activityPeriods Returns an array of objects in the format of repeatable quests to the client. repeatableQuestObject = { id: Unique Id, name: "Daily", endTime: the time when the quests expire activeQuests: currently available quests in an array. Each element of quest type format (see assets/database/templates/repeatableQuests.json). inactiveQuests: the quests which were previously active (required by client to fail them if they are not completed) }

The method checks if the player level requirement for repeatable quests (e.g. daily lvl5, weekly lvl15) is met and if the previously active quests are still valid. This ischecked by endTime persisted in profile accordning to the resetTime configured for each repeatable kind (daily, weekly) in QuestCondig.js

If the condition is met, new repeatableQuests are created, old quests (which are persisted in the profile.RepeatableQuests[i].activeQuests) are moved to profile.RepeatableQuests[i].inactiveQuests. This memory is required to get rid of old repeatable quest data in the profile, otherwise they'll litter the profile's Quests field. (if the are on "Succeed" but not "Completed" we keep them, to allow the player to complete them and get the rewards) The new quests generated are again persisted in profile.RepeatableQuests