diff --git a/.gitattributes b/.gitattributes index 982110c0..a32b9f86 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ ############################################################################### # Set default behavior to automatically normalize line endings. ############################################################################### -* text=auto +* text=auto eol=lf ############################################################################### # Set default behavior for command prompt diff. # diff --git a/project/.vscode/launch.json b/project/.vscode/launch.json index a4a405ec..ebd31c51 100644 --- a/project/.vscode/launch.json +++ b/project/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { diff --git a/project/.vscode/settings.json b/project/.vscode/settings.json deleted file mode 100644 index 02965ef3..00000000 --- a/project/.vscode/settings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "editor.defaultFormatter": "dbaeumer.vscode-eslint", - "eslint.format.enable": true, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, - "[json]": { - "editor.defaultFormatter": "vscode.json-language-features", - "editor.detectIndentation": false, - "editor.tabSize": 4, - "editor.insertSpaces": true - }, - "cSpell.words": [ - "Baseclass", - "IIIA", - "medkit", - "Superfors", - "ULACH" - ] -} diff --git a/project/gulpfile.mjs b/project/gulpfile.mjs index 40ad8c12..476c1797 100644 --- a/project/gulpfile.mjs +++ b/project/gulpfile.mjs @@ -1,12 +1,10 @@ -/* eslint-disable @typescript-eslint/naming-convention */ - -import gulp from "gulp"; -import { exec } from "gulp-execa"; -import rename from "gulp-rename"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; +import gulp from "gulp"; +import { exec } from "gulp-execa"; +import rename from "gulp-rename"; import pkg from "pkg"; import pkgfetch from "pkg-fetch"; import * as ResEdit from "resedit"; @@ -27,7 +25,7 @@ const entries = { const licenseFile = "../LICENSE.md"; /** - * Transpiles the src files into javascript with swc + * Transpile src files into Javascript with SWC */ const compile = async () => await exec("swc src -d obj", { stdio }); diff --git a/project/package.json b/project/package.json index bb904aba..9f313feb 100644 --- a/project/package.json +++ b/project/package.json @@ -72,7 +72,6 @@ "pkg": "5.8.1", "pkg-fetch": "3.5.2", "resedit": "2.0.0", - "rome": "12.1.3", "ts-node-dev": "2.0.0", "tsconfig-paths": "4.2.0", "typedoc": "0.25.2", diff --git a/project/src/callbacks/BotCallbacks.ts b/project/src/callbacks/BotCallbacks.ts index 42f649f7..3867921a 100644 --- a/project/src/callbacks/BotCallbacks.ts +++ b/project/src/callbacks/BotCallbacks.ts @@ -41,7 +41,6 @@ export class BotCallbacks { return this.httpResponse.noBody(this.botController.getBotCoreDifficulty()); } - return this.httpResponse.noBody(this.botController.getBotDifficulty(type, difficulty)); } diff --git a/project/src/callbacks/DataCallbacks.ts b/project/src/callbacks/DataCallbacks.ts index 86355d49..dd2d2f21 100644 --- a/project/src/callbacks/DataCallbacks.ts +++ b/project/src/callbacks/DataCallbacks.ts @@ -190,9 +190,11 @@ export class DataCallbacks supplyNextTime: 1672236024, // todo: get trader refresh time? prices: handbookPrices, currencyCourses: { + /* eslint-disable @typescript-eslint/naming-convention */ "5449016a4bdc2d6f028b456f": handbookPrices[Money.ROUBLES], "569668774bdc2da2298b4568": handbookPrices[Money.EUROS], "5696686a4bdc2da3298b456a": handbookPrices[Money.DOLLARS], + /* eslint-enable @typescript-eslint/naming-convention */ }, }; return this.httpResponse.getBody(response); diff --git a/project/src/callbacks/DialogueCallbacks.ts b/project/src/callbacks/DialogueCallbacks.ts index a4da11c6..23221dbe 100644 --- a/project/src/callbacks/DialogueCallbacks.ts +++ b/project/src/callbacks/DialogueCallbacks.ts @@ -41,8 +41,7 @@ export class DialogueCallbacks implements OnUpdate @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, @inject("DialogueController") protected dialogueController: DialogueController, ) - { - } + {} /** * Handle client/friend/list @@ -73,7 +72,7 @@ export class DialogueCallbacks implements OnUpdate DateTime: this.timeUtil.getTimestamp(), IsDeveloper: true, Regions: ["EUR"], - VersionId: "bgkidft87ddd", + VersionId: "bgkidft87ddd", // TODO: Is this... correct? Ip: "", Port: 0, Chats: [{ _id: "0", Members: 0 }], diff --git a/project/src/callbacks/GameCallbacks.ts b/project/src/callbacks/GameCallbacks.ts index 06f3d77e..20712f55 100644 --- a/project/src/callbacks/GameCallbacks.ts +++ b/project/src/callbacks/GameCallbacks.ts @@ -20,7 +20,7 @@ import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { Watermark } from "@spt-aki/utils/Watermark"; @injectable() -class GameCallbacks implements OnLoad +export class GameCallbacks implements OnLoad { constructor( @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, @@ -58,9 +58,7 @@ class GameCallbacks implements OnLoad const today = new Date().toUTCString(); const startTimeStampMS = Date.parse(today); this.gameController.gameStart(url, info, sessionID, startTimeStampMS); - return this.httpResponse.getBody({ - utc_time: startTimeStampMS / 1000, - }); + return this.httpResponse.getBody({ utc_time: startTimeStampMS / 1000 }); } /** @@ -150,5 +148,3 @@ class GameCallbacks implements OnLoad return this.httpResponse.nullResponse(); } } - -export {GameCallbacks}; diff --git a/project/src/callbacks/HandbookCallbacks.ts b/project/src/callbacks/HandbookCallbacks.ts index 7f0c323b..588fb04a 100644 --- a/project/src/callbacks/HandbookCallbacks.ts +++ b/project/src/callbacks/HandbookCallbacks.ts @@ -7,12 +7,13 @@ import { OnLoad } from "@spt-aki/di/OnLoad"; export class HandbookCallbacks implements OnLoad { constructor(@inject("HandbookController") protected handbookController: HandbookController) - { - } + {} + public async onLoad(): Promise { this.handbookController.load(); } + public getRoute(): string { return "aki-handbook"; diff --git a/project/src/callbacks/HealthCallbacks.ts b/project/src/callbacks/HealthCallbacks.ts index e05b1578..1cbaaf49 100644 --- a/project/src/callbacks/HealthCallbacks.ts +++ b/project/src/callbacks/HealthCallbacks.ts @@ -45,7 +45,6 @@ export class HealthCallbacks public handleWorkoutEffects(url: string, info: IWorkoutData, sessionID: string): IGetBodyResponseData { this.healthController.applyWorkoutChanges(this.profileHelper.getPmcProfile(sessionID), info, sessionID); - return this.httpResponse.emptyResponse(); } diff --git a/project/src/callbacks/HideoutCallbacks.ts b/project/src/callbacks/HideoutCallbacks.ts index 61b5931b..306a30e5 100644 --- a/project/src/callbacks/HideoutCallbacks.ts +++ b/project/src/callbacks/HideoutCallbacks.ts @@ -193,7 +193,6 @@ export class HideoutCallbacks implements OnUpdate this.hideoutController.update(); return true; } - return false; } diff --git a/project/src/callbacks/HttpCallbacks.ts b/project/src/callbacks/HttpCallbacks.ts index a2363027..ef34a6ea 100644 --- a/project/src/callbacks/HttpCallbacks.ts +++ b/project/src/callbacks/HttpCallbacks.ts @@ -7,8 +7,7 @@ import { HttpServer } from "@spt-aki/servers/HttpServer"; export class HttpCallbacks implements OnLoad { constructor(@inject("HttpServer") protected httpServer: HttpServer) - { - } + {} public async onLoad(): Promise { diff --git a/project/src/callbacks/InsuranceCallbacks.ts b/project/src/callbacks/InsuranceCallbacks.ts index 7cde4123..1af24868 100644 --- a/project/src/callbacks/InsuranceCallbacks.ts +++ b/project/src/callbacks/InsuranceCallbacks.ts @@ -57,7 +57,6 @@ export class InsuranceCallbacks implements OnUpdate this.insuranceController.processReturn(); return true; } - return false; } diff --git a/project/src/callbacks/ItemEventCallbacks.ts b/project/src/callbacks/ItemEventCallbacks.ts index d166284a..ad396ff9 100644 --- a/project/src/callbacks/ItemEventCallbacks.ts +++ b/project/src/callbacks/ItemEventCallbacks.ts @@ -41,7 +41,6 @@ export class ItemEventCallbacks { return Number(warnings[0].code); } - return BackendErrorCodes.UNKNOWN_ERROR; } } diff --git a/project/src/callbacks/LauncherCallbacks.ts b/project/src/callbacks/LauncherCallbacks.ts index d72c1040..dfaf0467 100644 --- a/project/src/callbacks/LauncherCallbacks.ts +++ b/project/src/callbacks/LauncherCallbacks.ts @@ -11,7 +11,7 @@ import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { Watermark } from "@spt-aki/utils/Watermark"; @injectable() -class LauncherCallbacks +export class LauncherCallbacks { constructor( @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, @@ -92,5 +92,3 @@ class LauncherCallbacks return this.httpResponse.noBody(this.launcherController.getServerModsProfileUsed(sessionId)); } } - -export {LauncherCallbacks}; diff --git a/project/src/callbacks/MatchCallbacks.ts b/project/src/callbacks/MatchCallbacks.ts index ad71a689..6ed551a9 100644 --- a/project/src/callbacks/MatchCallbacks.ts +++ b/project/src/callbacks/MatchCallbacks.ts @@ -91,6 +91,7 @@ export class MatchCallbacks { return this.httpResponse.getBody(true); } + /** Handle client/match/group/transfer */ public transferGroup(url: string, info: ITransferGroupRequest, sessionID: string): IGetBodyResponseData { diff --git a/project/src/callbacks/ModCallbacks.ts b/project/src/callbacks/ModCallbacks.ts index b56b0851..9396cef9 100644 --- a/project/src/callbacks/ModCallbacks.ts +++ b/project/src/callbacks/ModCallbacks.ts @@ -11,7 +11,7 @@ import { HttpFileUtil } from "@spt-aki/utils/HttpFileUtil"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; @injectable() -class ModCallbacks implements OnLoad +export class ModCallbacks implements OnLoad { protected httpConfig: IHttpConfig; @@ -40,5 +40,3 @@ class ModCallbacks implements OnLoad return "aki-mods"; } } - -export {ModCallbacks}; diff --git a/project/src/callbacks/PresetCallbacks.ts b/project/src/callbacks/PresetCallbacks.ts index 0b4f62d9..23b11de8 100644 --- a/project/src/callbacks/PresetCallbacks.ts +++ b/project/src/callbacks/PresetCallbacks.ts @@ -7,8 +7,7 @@ import { OnLoad } from "@spt-aki/di/OnLoad"; export class PresetCallbacks implements OnLoad { constructor(@inject("PresetController") protected presetController: PresetController) - { - } + {} public async onLoad(): Promise { diff --git a/project/src/callbacks/QuestCallbacks.ts b/project/src/callbacks/QuestCallbacks.ts index 1c3a2891..b2c76970 100644 --- a/project/src/callbacks/QuestCallbacks.ts +++ b/project/src/callbacks/QuestCallbacks.ts @@ -46,7 +46,6 @@ export class QuestCallbacks { return this.questController.acceptRepeatableQuest(pmcData, body, sessionID); } - return this.questController.acceptQuest(pmcData, body, sessionID); } diff --git a/project/src/callbacks/RagfairCallbacks.ts b/project/src/callbacks/RagfairCallbacks.ts index 1617e771..4b5012ec 100644 --- a/project/src/callbacks/RagfairCallbacks.ts +++ b/project/src/callbacks/RagfairCallbacks.ts @@ -67,7 +67,6 @@ export class RagfairCallbacks implements OnLoad, OnUpdate return true; } - return false; } @@ -96,7 +95,7 @@ export class RagfairCallbacks implements OnLoad, OnUpdate return this.ragfairController.addPlayerOffer(pmcData, info, sessionID); } - /** \Handle RagFairRemoveOffer event */ + /** Handle RagFairRemoveOffer event */ public removeOffer(pmcData: IPmcData, info: IRemoveOfferRequestData, sessionID: string): IItemEventRouterResponse { return this.ragfairController.removeOffer(info.offerId, sessionID); diff --git a/project/src/callbacks/SaveCallbacks.ts b/project/src/callbacks/SaveCallbacks.ts index 583a665e..7af5ec16 100644 --- a/project/src/callbacks/SaveCallbacks.ts +++ b/project/src/callbacks/SaveCallbacks.ts @@ -38,7 +38,6 @@ export class SaveCallbacks implements OnLoad, OnUpdate this.saveServer.save(); return true; } - return false; } } diff --git a/project/src/callbacks/TraderCallbacks.ts b/project/src/callbacks/TraderCallbacks.ts index 4c734406..607272b7 100644 --- a/project/src/callbacks/TraderCallbacks.ts +++ b/project/src/callbacks/TraderCallbacks.ts @@ -12,12 +12,11 @@ import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; export class TraderCallbacks implements OnLoad, OnUpdate { constructor( - @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, + @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, // TODO: delay required @inject("TraderController") protected traderController: TraderController, ) - // TODO: delay required - { - } + {} + public async onLoad(): Promise { this.traderController.load(); diff --git a/project/src/context/ApplicationContext.ts b/project/src/context/ApplicationContext.ts index afb85008..c210a01f 100644 --- a/project/src/context/ApplicationContext.ts +++ b/project/src/context/ApplicationContext.ts @@ -11,13 +11,16 @@ export class ApplicationContext private static holderMaxSize = 10; /** - * Called like: + * @examples * - * const registerPlayerInfo = this.applicationContext.getLatestValue(ContextVariableType.REGISTER_PLAYER_REQUEST).getValue(); + * const registerPlayerInfo = this.applicationContext.getLatestValue(ContextVariableType.REGISTER_PLAYER_REQUEST) + * .getValue(); * - * const activePlayerSessionId = this.applicationContext.getLatestValue(ContextVariableType.SESSION_ID).getValue(); + * const activePlayerSessionId = this.applicationContext.getLatestValue(ContextVariableType.SESSION_ID) + * .getValue(); * - * const matchInfo = this.applicationContext.getLatestValue(ContextVariableType.MATCH_INFO).getValue(); + * const matchInfo = this.applicationContext.getLatestValue(ContextVariableType.MATCH_INFO) + * .getValue(); * @param type * @returns */ @@ -27,7 +30,6 @@ export class ApplicationContext { return this.variables.get(type)?.getTail()?.getValue(); } - return undefined; } @@ -37,7 +39,6 @@ export class ApplicationContext { return this.variables.get(type).toList(); } - return undefined; } diff --git a/project/src/context/ContextVariableType.ts b/project/src/context/ContextVariableType.ts index 0187ce47..8d45403d 100644 --- a/project/src/context/ContextVariableType.ts +++ b/project/src/context/ContextVariableType.ts @@ -1,11 +1,7 @@ export enum ContextVariableType { - /** Logged in users session id */ - SESSION_ID, - /** Currently acive raid information */ - RAID_CONFIGURATION, - /** Timestamp when client first connected */ - CLIENT_START_TIMESTAMP, - /** When player is loading into map and loot is requested */ - REGISTER_PLAYER_REQUEST, + SESSION_ID = 0, // Logged in users session id + RAID_CONFIGURATION = 1, // Currently active raid information + CLIENT_START_TIMESTAMP = 2, // Timestamp when client first connected + REGISTER_PLAYER_REQUEST = 3, // When player is loading into map and loot is requested } diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index 18cb1ba9..1a8d0479 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -51,8 +51,8 @@ export class BotController } /** - * Return the number of bot loadout varieties to be generated - * @param type bot Type we want the loadout gen count for + * Return the number of bot load-out varieties to be generated + * @param type bot Type we want the load-out gen count for * @returns number of bots to generate */ public getBotPresetGenerationLimit(type: string): number @@ -62,16 +62,14 @@ export class BotController if (!value) { this.logger.warning(`No value found for bot type ${type}, defaulting to 30`); - return value; } - return value; } /** * Handle singleplayer/settings/bot/difficulty - * Get the core.json difficulty settings from database\bots + * Get the core.json difficulty settings from database/bots * @returns IBotCore */ public getBotCoreDifficulty(): IBotCore @@ -130,7 +128,7 @@ export class BotController break; default: difficultySettings = this.botDifficultyHelper.getBotDifficultySettings(type, difficulty); - // Don't add pmcs to event enemies (e.g. gifter/peacefullzryachiyevent) + // Don't add PMCs to event enemies (e.g. gifter/peacefullzryachiyevent) if (!this.botConfig.botsToNotAddPMCsAsEnemiesTo.includes(type.toLowerCase())) { this.botHelper.addBotToEnemyList(difficultySettings, [ @@ -138,7 +136,6 @@ export class BotController this.pmcConfig.usecType, ], lowercasedBotType); } - break; } @@ -211,6 +208,7 @@ export class BotController } cacheKey = `${botRole}${details.botDifficulty}`; + // Check for bot in cache, add if not if (!this.botGenerationCacheService.cacheHasBotOfRole(cacheKey)) { @@ -219,6 +217,7 @@ export class BotController this.botGenerationCacheService.storeBots(cacheKey, botsToAddToCache); } } + // Get bot from cache, add to return array const botToReturn = this.botGenerationCacheService.getBot(cacheKey); @@ -236,13 +235,13 @@ export class BotController } /** - * Get the difficulty passed in, if its not "asoline", get selected difficulty from config + * Get the difficulty passed in, if its not "asonline", get selected difficulty from config * @param requestedDifficulty * @returns */ public getPMCDifficulty(requestedDifficulty: string): string { - // maybe retrun a random difficulty... + // Maybe return a random difficulty... if (this.pmcConfig.difficulty.toLowerCase() === "asonline") { return requestedDifficulty; diff --git a/project/src/controllers/CustomizationController.ts b/project/src/controllers/CustomizationController.ts index f9d680b0..d1aac172 100644 --- a/project/src/controllers/CustomizationController.ts +++ b/project/src/controllers/CustomizationController.ts @@ -42,7 +42,7 @@ export class CustomizationController const templates = this.databaseServer.getTables().templates.customization; const suits = this.databaseServer.getTables().traders[traderID].suits; - // Get an inner join of clothing from templates.customization and ragmans suits array + // Get an inner join of clothing from templates.customization and Ragman's suits array const matchingSuits = suits.filter((x) => x.suiteId in templates); // Return all suits that have a side array containing the players side (usec/bear) diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index 7bfb417e..1c74a1c3 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -141,7 +141,7 @@ export class DialogueController /** * Handle client/mail/dialog/view - * Handle player clicking 'messenger' and seeing all the messages they've recieved + * Handle player clicking 'messenger' and seeing all the messages they've received * Set the content of the dialogue on the details panel, showing all the messages * for the specified dialogue. * @param request Get dialog request @@ -173,7 +173,7 @@ export class DialogueController /** * Get dialog from player profile, create if doesn't exist * @param profile Player profile - * @param request get dialog request (params used when dialog doesnt exist in profile) + * @param request get dialog request (params used when dialog doesn't exist in profile) * @returns Dialogue */ protected getDialogByIdFromProfile(profile: IAkiProfile, request: IGetMailDialogViewRequestData): Dialogue @@ -211,7 +211,7 @@ export class DialogueController { result.push(...dialogUsers); - // Player doesnt exist, add them in before returning + // Player doesn't exist, add them in before returning if (!result.find((x) => x._id === fullProfile.info.id)) { const pmcProfile = fullProfile.characters.pmc; @@ -274,7 +274,6 @@ export class DialogueController if (!dialog) { this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`); - return; } @@ -288,7 +287,6 @@ export class DialogueController if (!dialog) { this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`); - return; } @@ -307,7 +305,6 @@ export class DialogueController if (!dialogs) { this.logger.error(`No dialog object in profile: ${sessionId}`); - return; } @@ -332,7 +329,6 @@ export class DialogueController if (!dialog) { this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`); - return; } @@ -371,9 +367,7 @@ export class DialogueController protected handleChatWithSPTFriend(sessionId: string, request: ISendMessageRequest): void { const sender = this.profileHelper.getPmcProfile(sessionId); - const sptFriendUser = this.getSptFriendData(); - const giftSent = this.giftService.sendGiftToPlayer(sessionId, request.text); if (giftSent === GiftSentResult.SUCCESS) @@ -387,7 +381,6 @@ export class DialogueController "You found a gift code!", ]), ); - return; } @@ -398,7 +391,6 @@ export class DialogueController sptFriendUser, this.randomUtil.getArrayValue(["Looks like you already used that code", "You already have that!!"]), ); - return; } @@ -435,7 +427,7 @@ export class DialogueController "Hi", "Greetings", "Hello", - "bonjor", + "Bonjour", "Yo", "Sup", "Heyyyyy", diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index cae75c60..1700783b 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -82,10 +82,10 @@ export class GameController public load(): void { - // Regenerate basecache now mods are loaded and game is starting - // Mods that add items and use the baseclass service generate the cache including their items, the next mod that add items gets left out,causing warnings + // Regenerate base cache now mods are loaded and game is starting + // Mods that add items and use the baseClass service generate the cache including their items, the next mod that + // add items gets left out,causing warnings this.itemBaseClassService.hydrateItemBaseClassCache(); - this.addCustomLooseLootPositions(); } @@ -121,9 +121,9 @@ export class GameController this.checkTraderRepairValuesExist(); - // repeatableQuests are stored by in profile.Quests due to the responses of the client (e.g. Quests in offraidData) - // Since we don't want to clutter the Quests list, we need to remove all completed (failed / successful) repeatable quests. - // We also have to remove the Counters from the repeatableQuests + // repeatableQuests are stored by in profile.Quests due to the responses of the client (e.g. Quests in + // offraidData). Since we don't want to clutter the Quests list, we need to remove all completed (failed or + // successful) repeatable quests. We also have to remove the Counters from the repeatableQuests if (sessionID) { const fullProfile = this.profileHelper.getFullProfile(sessionID); @@ -253,6 +253,9 @@ export class GameController this.logger.warning( `Trader ${trader.base._id} ${trader.base.nickname} is missing a repair quality value, adding in default value`, ); + trader.base.repair.quality = this.jsonUtil.clone( + this.databaseServer.getTables().traders.ragfair.base.repair.quality, + ); trader.base.repair.quality = this.databaseServer.getTables().traders.ragfair.base.repair.quality; } } @@ -289,7 +292,7 @@ export class GameController continue; } - // new postion, add entire object + // New position, add entire object mapLooseLoot.spawnpoints.push(positionToAdd); } } @@ -386,6 +389,7 @@ export class GameController } else { + // Bot type not found, add new object map.base.MinMaxBots.push({ // Bot type not found, add new object WildSpawnType: botToLimit.type, @@ -457,10 +461,7 @@ export class GameController */ public getKeepAlive(sessionId: string): IGameKeepAliveResponse { - return { - msg: "OK", - utc_time: new Date().getTime() / 1000, - }; + return { msg: "OK", utc_time: new Date().getTime() / 1000 }; } /** @@ -510,7 +511,7 @@ export class GameController /** * When player logs in, iterate over all active effects and reduce timer - * TODO - add body part HP regen + * // TODO: Add body part HP regeneration * @param pmcProfile */ protected updateProfileHealthValues(pmcProfile: IPmcData): void @@ -641,7 +642,7 @@ export class GameController */ protected fixRoguesSpawningInstantlyOnLighthouse(): void { - const lighthouse = this.databaseServer.getTables().locations["lighthouse"].base; + const lighthouse = this.databaseServer.getTables().locations.lighthouse.base; for (const wave of lighthouse.BossLocationSpawn) { // Find Rogues that spawn instantly @@ -676,7 +677,8 @@ export class GameController } /** - * Find and split waves with large numbers of bots into smaller waves - BSG appears to reduce the size of these waves to one bot when they're waiting to spawn for too long + * Find and split waves with large numbers of bots into smaller waves - BSG appears to reduce the size of these + * waves to one bot when they're waiting to spawn for too long */ protected splitBotWavesIntoSingleWaves(): void { @@ -724,12 +726,12 @@ export class GameController waveToAdd.number = index; } - // Place wave into array in just-edited postion + 1 + // Place wave into array in just-edited position + 1 location.base.waves.splice(index, 0, waveToAdd); wavesAddedCount++; } - // Update subsequent wave number property to accomodate the new waves + // Update subsequent wave number property to accommodate the new waves for ( let index = indexOfWaveToSplit + wavesAddedCount + 1; index < location.base.waves.length; @@ -784,7 +786,7 @@ export class GameController } /** - * Check for any missing assorts inside each traders assort.json data, checking against traders qeustassort.json + * Check for any missing assorts inside each traders assort.json data, checking against traders questassort.json */ protected validateQuestAssortUnlocksExist(): void { @@ -802,18 +804,18 @@ export class GameController // Merge started/success/fail quest assorts into one dictionary const mergedQuestAssorts = { - ...traderData.questassort["started"], - ...traderData.questassort["success"], - ...traderData.questassort["fail"], + ...traderData.questassort.started, + ...traderData.questassort.success, + ...traderData.questassort.fail, }; - // loop over all assorts for trader + // Loop over all assorts for trader for (const [assortKey, questKey] of Object.entries(mergedQuestAssorts)) { // Does assort key exist in trader assort file if (!traderAssorts.loyal_level_items[assortKey]) { - // reverse lookup of enum key by value + // Reverse lookup of enum key by value const messageValues = { traderName: Object.keys(Traders)[Object.values(Traders).indexOf(traderId)], questName: quests[questKey]?.QuestName ?? "UNKNOWN", @@ -837,14 +839,14 @@ export class GameController { const bots = this.databaseServer.getTables().bots.types; - if (bots["bear"]) + if (bots.bear) { - bots["bear"].firstName.push(playerName); + bots.bear.firstName.push(playerName); } - if (bots["usec"]) + if (bots.usec) { - bots["usec"].firstName.push(playerName); + bots.usec.firstName.push(playerName); } } } @@ -855,10 +857,10 @@ export class GameController */ protected checkForAndRemoveUndefinedDialogs(fullProfile: IAkiProfile): void { - const undefinedDialog = fullProfile.dialogues["undefined"]; + const undefinedDialog = fullProfile.dialogues.undefined; if (undefinedDialog) { - delete fullProfile.dialogues["undefined"]; + delete fullProfile.dialogues.undefined; } } @@ -867,7 +869,7 @@ export class GameController */ protected removePraporTestMessage(): void { - // Iterate over all langauges (e.g. "en", "fr") + // Iterate over all languages (e.g. "en", "fr") for (const localeKey in this.databaseServer.getTables().locales.global) { this.databaseServer.getTables().locales.global[localeKey]["61687e2c3e526901fa76baf9"] = ""; diff --git a/project/src/controllers/HealthController.ts b/project/src/controllers/HealthController.ts index f4721606..afc3c39a 100644 --- a/project/src/controllers/HealthController.ts +++ b/project/src/controllers/HealthController.ts @@ -91,8 +91,8 @@ export class HealthController else { // Get max healing from db - const maxhp = this.itemHelper.getItem(healingItemToUse._tpl)[1]._props.MaxHpResource; - healingItemToUse.upd.MedKit = { HpResource: maxhp - request.count }; // Subtract amout used from max + const maxHp = this.itemHelper.getItem(healingItemToUse._tpl)[1]._props.MaxHpResource; + healingItemToUse.upd.MedKit = { HpResource: maxHp - request.count }; // Subtract amount used from max } // Resource in medkit is spent, delete it @@ -188,7 +188,7 @@ export class HealthController const partRequest: BodyPart = healthTreatmentRequest.difference.BodyParts[bodyPartKey]; const profilePart = pmcData.Health.BodyParts[bodyPartKey]; - // Set profile bodypart to max + // Set profile body part to max profilePart.Health.Current = profilePart.Health.Maximum; // Check for effects to remove diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index 9df3a034..bb6e0356 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -320,7 +320,6 @@ export class HideoutController { // Update existing items container tpl to point to new id (tpl) existingInventoryItem._tpl = hideoutStage.container; - return; } @@ -358,7 +357,7 @@ export class HideoutController * Handle HideoutPutItemsInAreaSlots * Create item in hideout slot item array, remove item from player inventory * @param pmcData Profile data - * @param addItemToHideoutRequest reqeust from client to place item in area slot + * @param addItemToHideoutRequest request from client to place item in area slot * @param sessionID Session id * @returns IItemEventRouterResponse object */ @@ -372,7 +371,7 @@ export class HideoutController const itemsToAdd = Object.entries(addItemToHideoutRequest.items).map((kvp) => { - const item = pmcData.Inventory.items.find((invItem) => invItem._id === kvp[1]["id"]); + const item = pmcData.Inventory.items.find((invItem) => invItem._id === kvp[1].id); return { inventoryItem: item, requestedItem: kvp[1], slot: kvp[0] }; }); @@ -394,7 +393,7 @@ export class HideoutController { this.logger.error( this.localisationService.getText("hideout-unable_to_find_item_in_inventory", { - itemId: item.requestedItem["id"], + itemId: item.requestedItem.id, area: hideoutArea.type, }), ); @@ -557,7 +556,7 @@ export class HideoutController * Handle HideoutSingleProductionStart event * Start production for an item from hideout area * @param pmcData Player profile - * @param body Start prodution of single item request + * @param body Start production of single item request * @param sessionID Session id * @returns IItemEventRouterResponse */ @@ -672,7 +671,6 @@ export class HideoutController { return productionTime; } - return productionTime * fenceLevel.ScavCaseTimeModifier; } @@ -690,7 +688,7 @@ export class HideoutController /** * Start production of continuously created item * @param pmcData Player profile - * @param request Continious production request + * @param request Continuous production request * @param sessionID Session id * @returns IItemEventRouterResponse */ @@ -701,7 +699,6 @@ export class HideoutController ): IItemEventRouterResponse { this.registerProduction(pmcData, request, sessionID); - return this.eventOutputHolder.getOutput(sessionID); } @@ -765,7 +762,7 @@ export class HideoutController output: IItemEventRouterResponse, ): IItemEventRouterResponse { - // Variables for managemnet of skill + // Variables for management of skill let craftingExpAmount = 0; // ? move the logic of BackendCounters in new method? @@ -789,13 +786,7 @@ export class HideoutController id = this.presetHelper.getDefaultPreset(id)._id; } - const newReq = { - items: [{ - item_id: id, - count: recipe.count, - }], - tid: "ragfair", - }; + const newReq = { items: [{ item_id: id, count: recipe.count }], tid: "ragfair" }; const entries = Object.entries(pmcData.Hideout.Production); let prodId: string; @@ -911,6 +902,7 @@ export class HideoutController let prodId: string; for (const production of ongoingProductions) { + // Production or ScavCase if (this.hideoutHelper.isProductionType(production[1])) { // Production or ScavCase if ((production[1] as ScavCase).RecipeId === request.recipeId) @@ -983,7 +975,7 @@ export class HideoutController /** * Get quick time event list for hideout - * // TODO - implement this + * // TODO: Implement this * @param sessionId Session id * @returns IQteData array */ @@ -1006,10 +998,10 @@ export class HideoutController ): IItemEventRouterResponse { // { - // "Action": "HideoutQuickTimeEvent", - // "results": [true, false, true, true, true, true, true, true, true, false, false, false, false, false, false], - // "id": "63b16feb5d012c402c01f6ef", - // "timestamp": 1672585349 + // Action: "HideoutQuickTimeEvent", + // results: [true, false, true, true, true, true, true, true, true, false, false, false, false, false, false], + // id: "63b16feb5d012c402c01f6ef", + // timestamp: 1672585349 // } // Skill changes are done in @@ -1043,7 +1035,7 @@ export class HideoutController request: IRecordShootingRangePoints, ): IItemEventRouterResponse { - // Check if counter exists, add placeholder if it doesnt + // Check if counter exists, add placeholder if it doesn't if (!pmcData.Stats.Eft.OverallCounters.Items.find((x) => x.Key.includes("ShootingRangePoints"))) { pmcData.Stats.Eft.OverallCounters.Items.push({ Key: ["ShootingRangePoints"], Value: 0 }); @@ -1055,7 +1047,7 @@ export class HideoutController ); shootingRangeHighScore.Value = request.points; - // Check against live, maybe a response isnt necessary + // Check against live, maybe a response isn't necessary return this.eventOutputHolder.getOutput(sessionId); } @@ -1073,7 +1065,7 @@ export class HideoutController { const output = this.eventOutputHolder.getOutput(sessionId); - // Create mapping of required item with corrisponding item from player inventory + // Create mapping of required item with corresponding item from player inventory const items = request.items.map((reqItem) => { const item = pmcData.Inventory.items.find((invItem) => invItem._id === reqItem.id); @@ -1122,7 +1114,7 @@ export class HideoutController return this.httpResponse.appendErrorToOutput(output); } - // Add all improvemets to output object + // Add all improvements to output object const improvements = hideoutDbData.stages[profileHideoutArea.level].improvements; const timestamp = this.timeUtil.getTimestamp(); for (const improvement of improvements) @@ -1170,7 +1162,7 @@ export class HideoutController // Null out production data so client gets informed when response send back pmcData.Hideout.Production[request.recipeId] = null; - // TODO - handle timestamp somehow? + // TODO: handle timestamp somehow? return output; } diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index f949644d..35da378e 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -188,7 +188,7 @@ export class InraidController /** * Make changes to pmc profile after they've died in raid, - * Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items + * Alter body part hp, handle insurance, delete inventory items, remove carried quest items * @param postRaidSaveRequest Post-raid save request * @param pmcData Pmc profile * @param sessionID Session id @@ -205,7 +205,8 @@ export class InraidController if (this.inRaidHelper.removeQuestItemsOnDeath()) { - // Find and remove the completed condition from profile if player died, otherwise quest is stuck in limbo and quest items cannot be picked up again + // Find and remove the completed condition from profile if player died, otherwise quest is stuck in limbo + // and quest items cannot be picked up again const allQuests = this.questHelper.getQuestsFromDb(); const activeQuestIdsInProfile = pmcData.Quests.filter((x) => ![QuestStatus.AvailableForStart, QuestStatus.Success, QuestStatus.Expired].includes(x.status) @@ -232,7 +233,7 @@ export class InraidController } /** - * Adjust player characters bodypart hp post-raid + * Adjust player characters body part hp post-raid * @param postRaidSaveRequest post raid data * @param pmcData player profile */ @@ -257,13 +258,13 @@ export class InraidController /** * Reduce body part hp to % of max * @param pmcData profile to edit - * @param multipler multipler to apply to max health + * @param multiplier multiplier to apply to max health */ - protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void + protected reducePmcHealthToPercent(pmcData: IPmcData, multiplier: number): void { for (const bodyPart of Object.values(pmcData.Health.BodyParts)) { - (bodyPart).Health.Current = (bodyPart).Health.Maximum * multipler; + (bodyPart).Health.Current = (bodyPart).Health.Maximum * multiplier; } } @@ -314,7 +315,6 @@ export class InraidController { return false; } - return profile.ConditionCounters.Counters.length > 0; } @@ -365,7 +365,6 @@ export class InraidController { // Doesn't exist yet, push it straight in pmcProfile.ConditionCounters.Counters.push(scavCounter); - continue; } @@ -400,7 +399,7 @@ export class InraidController { if (offraidData.exit !== PlayerRaidEndState.SURVIVED) { - // Remove FIR status if the player havn't survived + // Remove FIR status if the player hasn't survived offraidData.profile = this.inRaidHelper.removeSpawnedInSessionPropertyFromItems(offraidData.profile); } } diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index 6035a587..9a08f430 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -24,9 +24,9 @@ import { SaveServer } from "@spt-aki/servers/SaveServer"; import { InsuranceService } from "@spt-aki/services/InsuranceService"; import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; +import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; -import { MathUtil } from "@spt-aki/utils/MathUtil"; @injectable() export class InsuranceController @@ -124,7 +124,7 @@ export class InsuranceController ); // Iterate over each of the insurance packages. - insuranceDetails.forEach((insured) => + for (const insured of insuranceDetails) { // Find items that should be deleted from the insured items. const itemsToDelete = this.findItemsToDelete(insured); @@ -140,7 +140,7 @@ export class InsuranceController // Remove the fully processed insurance package from the profile. this.removeInsurancePackageFromProfile(sessionID, insured.messageContent.systemData); - }); + } } /** @@ -224,7 +224,10 @@ export class InsuranceController protected populateItemsMap(insured: Insurance): Map { const itemsMap = new Map(); - insured.items.forEach((item) => itemsMap.set(item._id, item)); + for (const item of insured.items) + { + itemsMap.set(item._id, item); + } return itemsMap; } @@ -325,7 +328,10 @@ export class InsuranceController ); if (allChildrenAreAttachments) { - itemAndChildren.forEach((item) => toDelete.add(item._id)); + for (const item of itemAndChildren) + { + toDelete.add(item._id); + } } } } @@ -346,7 +352,7 @@ export class InsuranceController toDelete: Set, ): void { - mainParentToAttachmentsMap.forEach((attachmentItems, parentId) => + for (const [parentId, attachmentItems] of mainParentToAttachmentsMap) { // Log the parent item's name. const parentItem = itemsMap.get(parentId); @@ -355,7 +361,7 @@ export class InsuranceController // Process the attachments for this individual parent item. this.processAttachmentByParent(attachmentItems, traderId, toDelete); - }); + } } /** @@ -402,10 +408,10 @@ export class InsuranceController */ protected logAttachmentsDetails(attachments: EnrichedItem[]): void { - attachments.forEach(({ name, maxPrice }) => + for (const attachment of attachments) { - this.logger.debug(`Child Item - Name: ${name}, Max Price: ${maxPrice}`); - }); + this.logger.debug(`Child Item - Name: ${attachment.name}, Max Price: ${attachment.maxPrice}`); + } } /** @@ -436,7 +442,7 @@ export class InsuranceController { const valuableToDelete = attachments.slice(0, successfulRolls).map(({ _id }) => _id); - valuableToDelete.forEach((attachmentsId) => + for (const attachmentsId of valuableToDelete) { const valuableChild = attachments.find(({ _id }) => _id === attachmentsId); if (valuableChild) @@ -445,7 +451,7 @@ export class InsuranceController this.logger.debug(`Marked for removal - Child Item: ${name}, Max Price: ${maxPrice}`); toDelete.add(attachmentsId); } - }); + } } /** @@ -471,7 +477,7 @@ export class InsuranceController { const hideoutParentId = this.fetchHideoutItemParent(insured.items); - insured.items.forEach((item) => + for (const item of insured.items) { // Check if the item's parent exists in the insured items list. const parentExists = insured.items.some((parentItem) => parentItem._id === item.parentId); @@ -483,7 +489,7 @@ export class InsuranceController item.slotId = "hideout"; delete item.location; } - }); + } } /** diff --git a/project/src/controllers/InventoryController.ts b/project/src/controllers/InventoryController.ts index ebbf3504..9a7847d5 100644 --- a/project/src/controllers/InventoryController.ts +++ b/project/src/controllers/InventoryController.ts @@ -93,7 +93,7 @@ export class InventoryController const ownerInventoryItems = this.inventoryHelper.getOwnerInventoryItems(moveRequest, sessionID); if (ownerInventoryItems.sameInventory) { - // Dont move items from trader to profile, this can happen when editing a traders preset weapons + // Don't move items from trader to profile, this can happen when editing a traders preset weapons if (moveRequest.fromOwner?.type === "Trader" && !ownerInventoryItems.isMail) { return this.getTraderExploitErrorResponse(output); @@ -182,7 +182,7 @@ export class InventoryController /** * Split Item - * spliting 1 stack into 2 + * splitting 1 stack into 2 * @param pmcData Player profile (unused, getOwnerInventoryItems() gets profile) * @param request Split request * @param sessionID Session/player id @@ -206,7 +206,8 @@ export class InventoryController request.container.location = matchingItems.length; // Wrong location for first cartridge } - // The item being merged has three possible sources: pmc, scav or mail, getOwnerInventoryItems() handles getting correct one + // The item being merged has three possible sources: pmc, scav or mail, getOwnerInventoryItems() handles getting + // correct one. const itemToSplit = inventoryItems.from.find((x) => x._id === request.splitItem); if (!itemToSplit) { @@ -280,7 +281,7 @@ export class InventoryController if (!(destinationItem.upd?.StackObjectsCount)) { - // No stackcount on destination, add one + // No stack count on destination, add one destinationItem.upd = { StackObjectsCount: 1 }; } @@ -290,11 +291,11 @@ export class InventoryController } else if (!sourceItem.upd.StackObjectsCount) { - // Items pulled out of raid can have no stackcount if the stack should be 1 + // Items pulled out of raid can have no stack count if the stack should be 1 sourceItem.upd.StackObjectsCount = 1; } - destinationItem.upd.StackObjectsCount += sourceItem.upd.StackObjectsCount; // Add source stackcount to destination + destinationItem.upd.StackObjectsCount += sourceItem.upd.StackObjectsCount; // Add source stack count to destination output.profileChanges[sessionID].items.del.push({ _id: sourceItem._id }); // Inform client source item being deleted const indexOfItemToRemove = inventoryItems.from.findIndex((x) => x._id === sourceItem._id); @@ -311,8 +312,8 @@ export class InventoryController } /** - * TODO: Adds no data to output to send to client, is this by design? - * TODO: should make use of getOwnerInventoryItems(), stack being transferred may not always be on pmc + * // TODO: Adds no data to output to send to client, is this by design? + * // TODO: should make use of getOwnerInventoryItems(), stack being transferred may not always be on pmc * Transfer items from one stack into another while keeping original stack * Used to take items from scav inventory into stash or to insert ammo into mags (shotgun ones) and reloading weapon by clicking "Reload" * @param pmcData Player profile @@ -418,10 +419,10 @@ export class InventoryController this.logger.error(`Unable to find item: ${request.item2} to swap positions with: ${request.item}`); } - // to.id is the parentid + // to.id is the parentId itemOne.parentId = request.to.id; - // to.container is the slotid + // to.container is the slotId itemOne.slotId = request.to.container; // Request object has location data, add it in, otherwise remove existing location from object @@ -473,7 +474,7 @@ export class InventoryController } /** - * Toggles "Toggleable" items like night vision goggles and face shields. + * Toggles "toggleable" items like night vision goggles and face shields. * @param pmcData player profile * @param body Toggle request * @param sessionID Session id @@ -545,7 +546,7 @@ export class InventoryController * Bind an inventory item to the quick access menu at bottom of player screen * Handle bind event * @param pmcData Player profile - * @param bindRequest Reqeust object + * @param bindRequest Request object * @param sessionID Session id * @returns IItemEventRouterResponse */ @@ -663,9 +664,9 @@ export class InventoryController } /** - * Get the tplid of an item from the examine request object + * Get the tplId of an item from the examine request object * @param body response request - * @returns tplid + * @returns string */ protected getExaminedItemTpl(body: IInventoryExamineRequestData): string { @@ -675,40 +676,41 @@ export class InventoryController } else if (body.fromOwner.id === Traders.FENCE) { - // get tpl from fence assorts + // Get tpl from fence assorts return this.fenceService.getRawFenceAssorts().items.find((x) => x._id === body.item)._tpl; } else if (body.fromOwner.type === "Trader") { // not fence - // get tpl from trader assort + // Not fence + // Get tpl from trader assort return this.databaseServer.getTables().traders[body.fromOwner.id].assort.items.find((item) => item._id === body.item )._tpl; } else if (body.fromOwner.type === "RagFair") { - // try to get tplid from items.json first + // try to get tplId from items.json first const item = this.databaseServer.getTables().templates.items[body.item]; if (item) { return item._id; } - // try alternate way of getting offer if first approach fails + // Try alternate way of getting offer if first approach fails let offer = this.ragfairOfferService.getOfferByOfferId(body.item); if (!offer) { offer = this.ragfairOfferService.getOfferByOfferId(body.fromOwner.id); } - // try find examine item inside offer items array + // Try find examine item inside offer items array const matchingItem = offer.items.find((x) => x._id === body.item); if (matchingItem) { return matchingItem._tpl; } - // unable to find item in database or ragfair + // Unable to find item in database or ragfair throw new Error(this.localisationService.getText("inventory-unable_to_find_item", body.item)); } } @@ -723,7 +725,6 @@ export class InventoryController { pmcData.Encyclopedia[id] = true; } - return this.eventOutputHolder.getOutput(sessionID); } diff --git a/project/src/controllers/LauncherController.ts b/project/src/controllers/LauncherController.ts index 2378b228..748135ab 100644 --- a/project/src/controllers/LauncherController.ts +++ b/project/src/controllers/LauncherController.ts @@ -47,12 +47,13 @@ export class LauncherController } /** - * Get descriptive text for each of the profile edtions a player can choose + * Get descriptive text for each of the profile editions a player can choose * @returns */ protected getProfileDescriptions(): Record { return { + /* eslint-disable @typescript-eslint/naming-convention */ Standard: this.localisationService.getText("launcher-profile_standard"), "Left Behind": this.localisationService.getText("launcher-profile_leftbehind"), "Prepare To Escape": this.localisationService.getText("launcher-profile_preparetoescape"), @@ -60,6 +61,7 @@ export class LauncherController "SPT Easy start": this.localisationService.getText("launcher-profile_spteasystart"), "SPT Zero to hero": this.localisationService.getText("launcher-profile_sptzerotohero"), "SPT Developer": this.localisationService.getText("launcher-profile_sptdeveloper"), + /* eslint-enable @typescript-eslint/naming-convention */ }; } @@ -115,6 +117,7 @@ export class LauncherController this.saveServer.loadProfile(sessionID); this.saveServer.saveProfile(sessionID); + return sessionID; } diff --git a/project/src/controllers/LocationController.ts b/project/src/controllers/LocationController.ts index 82045da8..d69eef58 100644 --- a/project/src/controllers/LocationController.ts +++ b/project/src/controllers/LocationController.ts @@ -89,7 +89,7 @@ export class LocationController const staticLoot = this.locationGenerator.generateStaticContainers(location.base, staticAmmoDist); output.Loot.push(...staticLoot); - // Add dyanmic loot to output loot + // Add dynamic loot to output loot const dynamicLootDist: ILooseLoot = this.jsonUtil.clone(location.looseLoot); const dynamicSpawnPoints: SpawnpointTemplate[] = this.locationGenerator.generateDynamicLoot( dynamicLootDist, @@ -140,7 +140,7 @@ export class LocationController /** * Handle client/location/getAirdropLoot - * Get loot for an airdop container + * Get loot for an airdrop container * Generates it randomly based on config/airdrop.json values * @returns Array of LootItem objects */ diff --git a/project/src/controllers/MatchController.ts b/project/src/controllers/MatchController.ts index f9114d8c..fa906259 100644 --- a/project/src/controllers/MatchController.ts +++ b/project/src/controllers/MatchController.ts @@ -140,7 +140,7 @@ export class MatchController // TODO: add code to strip PMC of equipment now they've started the raid - // Set pmcs to difficulty set in pre-raid screen if override in bot config isnt enabled + // Set PMCs to difficulty set in pre-raid screen if override in bot config isn't enabled if (!this.pmcConfig.useDifficultyOverride) { this.pmcConfig.difficulty = this.convertDifficultyDropdownIntoBotDifficulty( @@ -299,8 +299,8 @@ export class MatchController { let fenceStanding = Number(pmcData.TradersInfo[fenceId].standing); - // Not exact replica of Live behaviour - // Simplified for now, no real reason to do the whole (unconfirmed) extra 0.01 standing per day regeneration mechanic + // Not exact replica of Live behaviour... Simplified for now. No real reason to do the whole (unconfirmed) + // extra 0.01 standing per day regeneration mechanic. const baseGain: number = this.inraidConfig.carExtractBaseStandingGain; const extractCount: number = pmcData.CarExtractCounts[extractName]; diff --git a/project/src/controllers/PresetBuildController.ts b/project/src/controllers/PresetBuildController.ts index 959e90f2..6c19797b 100644 --- a/project/src/controllers/PresetBuildController.ts +++ b/project/src/controllers/PresetBuildController.ts @@ -48,7 +48,7 @@ export class PresetBuildController ); if (playerSecureContainer && playerSecureContainer?._tpl !== firstDefaultItemsSecureContainer?._tpl) { - // Default equipment presets' secure container tpl doesnt match players secure container tpl + // Default equipment presets' secure container tpl doesn't match players secure container tpl for (const defaultPreset of defaultEquipmentPresets) { // Find presets secure container @@ -74,7 +74,7 @@ export class PresetBuildController sessionId: string, ): IItemEventRouterResponse { - // TODO - could be merged into saveBuild, maybe + // TODO: Could be merged into saveBuild, maybe const output = this.eventOutputHolder.getOutput(sessionId); // Replace duplicate Id's. The first item is the base item. @@ -182,7 +182,7 @@ export class PresetBuildController sessionID: string, ): IItemEventRouterResponse { - // todo - does this get called? + // TODO: Does this get called? return this.removePlayerBuild(pmcData, body.id, sessionID); } @@ -193,7 +193,7 @@ export class PresetBuildController sessionID: string, ): IItemEventRouterResponse { - // todo - does this get called? + // TODO: Does this get called? return this.removePlayerBuild(pmcData, body.id, sessionID); } diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index d7bdfc4a..044af090 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -133,7 +133,7 @@ export class QuestController break; } - // Prereq does not have its status requirement fulfilled + // Prerequisite does not have its status requirement fulfilled if (!conditionToFulfil._props.status.includes(prerequisiteQuest.status)) { haveCompletedPreviousQuest = false; @@ -402,15 +402,15 @@ export class QuestController // Can be started text or description text based on above function result let questStartedMessageText = locale[questStartedMessageKey]; - // TODO: remove this whole if statement, possibly not required? + // TODO: Remove this whole if statement, possibly not required? if (!questStartedMessageText) { this.logger.debug( `Unable to accept quest ${acceptedQuest.qid}, cannot find the quest started message text with id ${questStartedMessageKey}. attempting to find it in en locale instead`, ); - // For some reason non-en locales dont have repeatable quest ids, fall back to en and grab it if possible - const enLocale = this.databaseServer.getTables().locales.global["en"]; + // For some reason non-en locales don't have repeatable quest ids, fall back to en and grab it if possible + const enLocale = this.databaseServer.getTables().locales.global.en; questStartedMessageText = enLocale[repeatableQuestProfile.startedMessageText]; if (!questStartedMessageText) @@ -532,7 +532,7 @@ export class QuestController // Add diff of quests before completion vs after for client response const questDelta = this.questHelper.getDeltaQuests(beforeQuests, this.getClientQuests(sessionID)); - // Check newly available + failed quests for timegates and add them to profile + // Check newly available + failed quests for time gates and add them to profile this.addTimeLockedQuestsToProfile(pmcData, [...questDelta, ...questsToFail], body.qid); // Inform client of quest changes @@ -593,12 +593,12 @@ export class QuestController /** * Return quests that have different statuses - * @param preQuestStatusus Quests before + * @param preQuestStatuses Quests before * @param postQuestStatuses Quests after * @returns QuestStatusChange array */ protected getQuestsWithDifferentStatuses( - preQuestStatusus: IQuestStatus[], + preQuestStatuses: IQuestStatus[], postQuestStatuses: IQuestStatus[], ): IQuestStatus[] { @@ -607,7 +607,7 @@ export class QuestController for (const quest of postQuestStatuses) { // Add quest if status differs or quest not found - const preQuest = preQuestStatusus.find((x) => x.qid === quest.qid); + const preQuest = preQuestStatuses.find((x) => x.qid === quest.qid); if (!preQuest || preQuest.status !== quest.status) { result.push(quest); @@ -659,7 +659,7 @@ export class QuestController // Iterate over quests, look for quests with right criteria for (const quest of quests) { - // If quest has prereq of completed quest + availableAfter value > 0 (quest has wait time) + // If quest has prerequisite of completed quest + availableAfter value > 0 (quest has wait time) const nextQuestWaitCondition = quest.conditions.AvailableForStart.find((x) => x._props.target === completedQuestId && x._props.availableAfter > 0 ); @@ -686,7 +686,7 @@ export class QuestController startTime: 0, status: QuestStatus.AvailableAfter, statusTimers: { - "9": this.timeUtil.getTimestamp(), + "9": this.timeUtil.getTimestamp(), // eslint-disable-line @typescript-eslint/naming-convention }, availableAfter: availableAfterTimestamp, }); @@ -832,7 +832,7 @@ export class QuestController const matchingItemInProfile = pmcData.Inventory.items.find((x) => x._id === itemHandover.id); if (!handoverRequirements._props.target.includes(matchingItemInProfile._tpl)) { - // Item handed in by player doesnt match what was requested + // Item handed in by player doesn't match what was requested return this.showQuestItemHandoverMatchError( handoverQuestRequest, matchingItemInProfile, diff --git a/project/src/controllers/RagfairController.ts b/project/src/controllers/RagfairController.ts index 218b801e..b76d12e6 100644 --- a/project/src/controllers/RagfairController.ts +++ b/project/src/controllers/RagfairController.ts @@ -118,8 +118,8 @@ export class RagfairController { if (offer.user.memberType === MemberCategory.TRADER) { - // for the items, check the barter schemes. The method getDisplayableAssorts sets a flag sptQuestLocked to true if the quest - // is not completed yet + // for the items, check the barter schemes. The method getDisplayableAssorts sets a flag sptQuestLocked + // to true if the quest is not completed yet if (this.ragfairOfferHelper.traderOfferItemQuestLocked(offer, traderAssorts)) { offer.locked = true; @@ -174,7 +174,7 @@ export class RagfairController * Get categories for the type of search being performed, linked/required/all * @param searchRequest Client search request data * @param offers ragfair offers to get categories for - * @returns record with tpls + counts + * @returns record with templates + counts */ protected getSpecificCategories(searchRequest: ISearchRequestData, offers: IRagfairOffer[]): Record { @@ -228,7 +228,7 @@ export class RagfairController for (const offer of offers) { offer.intId = ++counter; - offer.items[0].parentId = ""; // without this it causes error: "Item deserialization error: No parent with id hideout found for item x" + offer.items[0].parentId = ""; // Without this it causes error: "Item deserialization error: No parent with id hideout found for item x" } } @@ -547,7 +547,7 @@ export class RagfairController } /** - * Using item ids from flea offer request, find corrispnding items from player inventory and return as array + * Using item ids from flea offer request, find corresponding items from player inventory and return as array * @param pmcData Player profile * @param itemIdsFromFleaOfferRequest Ids from request * @param errorMessage if item is not found, add error message to this parameter @@ -673,7 +673,8 @@ export class RagfairController const differenceInSeconds = offers[index].endTime - this.timeUtil.getTimestamp(); if (differenceInSeconds > this.ragfairConfig.sell.expireSeconds) - { // expireSeconds Default is 71 seconds + { + // expireSeconds Default is 71 seconds const newEndTime = this.ragfairConfig.sell.expireSeconds + this.timeUtil.getTimestamp(); offers[index].endTime = Math.round(newEndTime); } diff --git a/project/src/controllers/RepeatableQuestController.ts b/project/src/controllers/RepeatableQuestController.ts index b5207601..d7e2aa2c 100644 --- a/project/src/controllers/RepeatableQuestController.ts +++ b/project/src/controllers/RepeatableQuestController.ts @@ -72,8 +72,8 @@ export class RepeatableQuestController * } * * 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 + * are still valid. This is checked by endTime persisted in profile according to the resetTime configured for each repeatable kind (daily, weekly) + * in QuestConfig.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 @@ -82,7 +82,7 @@ export class RepeatableQuestController * The new quests generated are again persisted in profile.RepeatableQuests * * @param {string} sessionId Player's session id - * @returns {array} array of "repeatableQuestObjects" as descibed above + * @returns {array} array of "repeatableQuestObjects" as described above */ public getClientRepeatableQuests(_info: IEmptyRequestData, sessionID: string): IPmcDataRepeatableQuest[] { @@ -304,7 +304,7 @@ export class RepeatableQuestController } // Add "any" to pickup quest pool - questPool.pool.Pickup.locations["any"] = ["any"]; + questPool.pool.Pickup.locations.any = ["any"]; const eliminationConfig = this.repeatableQuestHelper.getEliminationConfigByPmcLevel(pmcLevel, repeatableConfig); const targetsConfig = this.repeatableQuestHelper.probabilityObjectArray(eliminationConfig.targets); @@ -319,7 +319,7 @@ export class RepeatableQuestController { const possibleLocations = Object.keys(repeatableConfig.locations); - // Set possible locations for elimination task, ift arget is savage, exclude labs from locations + // Set possible locations for elimination task, if target is savage, exclude labs from locations questPool.pool.Elimination.targets[probabilityObject.key] = (probabilityObject.key === "Savage") ? { locations: possibleLocations.filter((x) => x !== "laboratory") } : { locations: possibleLocations }; @@ -394,7 +394,8 @@ export class RepeatableQuestController // Get cost to replace existing quest changeRequirement = this.jsonUtil.clone(currentRepeatablePool.changeRequirement[changeRequest.qid]); delete currentRepeatablePool.changeRequirement[changeRequest.qid]; - // TODO: somehow we need to reduce the questPool by the currently active quests (for all repeatables) + + // TODO: somehow we need to reduce the questPool by the currently active quests (for all repeatable) const repeatableConfig = this.questConfig.repeatableQuests.find((x) => x.name === currentRepeatablePool.name @@ -484,7 +485,6 @@ export class RepeatableQuestController break; } } - return newRepeatableQuest; } } diff --git a/project/src/controllers/TradeController.ts b/project/src/controllers/TradeController.ts index 04b13e1f..19ea8ce0 100644 --- a/project/src/controllers/TradeController.ts +++ b/project/src/controllers/TradeController.ts @@ -29,7 +29,7 @@ import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { JsonUtil } from "@spt-aki/utils/JsonUtil"; @injectable() -class TradeController +export class TradeController { protected ragfairConfig: IRagfairConfig; protected traderConfig: ITraderConfig; @@ -119,7 +119,8 @@ class TradeController scheme_items: offer.items, }; - // confirmTrading() must occur prior to removing the offer stack, otherwise item inside offer doesn't exist for confirmTrading() to use + // confirmTrading() must occur prior to removing the offer stack, otherwise item inside offer doesn't exist + // for confirmTrading() to use output = this.confirmTradingInternal( pmcData, buyData, @@ -157,7 +158,7 @@ class TradeController } /** - * Sell all sellable items to a trader from inventory + * Sell all items (that can be sold) to a trader from inventory * WILL DELETE ITEMS FROM INVENTORY + CHILDREN OF ITEMS SOLD * @param sessionId Session id * @param profileWithItemsToSell Profile with items to be sold to trader @@ -173,7 +174,7 @@ class TradeController ): IItemEventRouterResponse { const handbookPrices = this.ragfairPriceService.getAllStaticPrices(); - // TODO, apply trader sell bonuses? + // TODO: apply trader sell bonuses? const traderDetails = this.traderHelper.getTrader(trader, sessionId); // Prep request object @@ -237,7 +238,7 @@ class TradeController && this.itemHelper.isOfBaseclasses(itemDetails[1]._id, traderDetails.items_buy.category)) ) { - // Skip if tpl isnt item OR item doesn't fulfill match traders buy categories + // Skip if tpl isn't item OR item doesn't fulfill match traders buy categories continue; } @@ -273,5 +274,3 @@ class TradeController return null; } } - -export {TradeController}; diff --git a/project/src/controllers/WishlistController.ts b/project/src/controllers/WishlistController.ts index e6ef50d4..eefa8c9b 100644 --- a/project/src/controllers/WishlistController.ts +++ b/project/src/controllers/WishlistController.ts @@ -16,7 +16,7 @@ export class WishlistController { for (const item in pmcData.WishList) { - // don't add the item + // Don't add the item if (pmcData.WishList[item] === body.templateId) { return this.eventOutputHolder.getOutput(sessionID); diff --git a/project/src/di/Container.ts b/project/src/di/Container.ts index 8ff7ec3d..fd9e87d6 100644 --- a/project/src/di/Container.ts +++ b/project/src/di/Container.ts @@ -255,397 +255,388 @@ export class Container childContainer.registerType("HttpListener", "AkiHttpListener"); } - public static registerTypes(depContainer: DependencyContainer): void + public static registerTypes(con: DependencyContainer): void { - depContainer.register("ApplicationContext", ApplicationContext, { lifecycle: Lifecycle.Singleton }); - Container.registerUtils(depContainer); - - Container.registerRouters(depContainer); - - Container.registerGenerators(depContainer); - - Container.registerHelpers(depContainer); - - Container.registerLoaders(depContainer); - - Container.registerCallbacks(depContainer); - - Container.registerServers(depContainer); - - Container.registerServices(depContainer); - - Container.registerControllers(depContainer); + con.register("ApplicationContext", ApplicationContext, { lifecycle: Lifecycle.Singleton }); + Container.registerUtils(con); + Container.registerRouters(con); + Container.registerGenerators(con); + Container.registerHelpers(con); + Container.registerLoaders(con); + Container.registerCallbacks(con); + Container.registerServers(con); + Container.registerServices(con); + Container.registerControllers(con); } - public static registerListTypes(depContainer: DependencyContainer): void + public static registerListTypes(con: DependencyContainer): void { - depContainer.register("OnLoadModService", { useValue: new OnLoadModService(depContainer) }); - depContainer.register("HttpListenerModService", { useValue: new HttpListenerModService(depContainer) }); - depContainer.register("OnUpdateModService", { useValue: new OnUpdateModService(depContainer) }); - depContainer.register("DynamicRouterModService", { useValue: new DynamicRouterModService(depContainer) }); - depContainer.register("StaticRouterModService", { useValue: new StaticRouterModService(depContainer) }); + con.register("OnLoadModService", { useValue: new OnLoadModService(con) }); + con.register("HttpListenerModService", { useValue: new HttpListenerModService(con) }); + con.register("OnUpdateModService", { useValue: new OnUpdateModService(con) }); + con.register("DynamicRouterModService", { useValue: new DynamicRouterModService(con) }); + con.register("StaticRouterModService", { useValue: new StaticRouterModService(con) }); - depContainer.registerType("OnLoad", "DatabaseImporter"); - depContainer.registerType("OnLoad", "PostDBModLoader"); - depContainer.registerType("OnLoad", "HandbookCallbacks"); - depContainer.registerType("OnLoad", "HttpCallbacks"); - depContainer.registerType("OnLoad", "PresetCallbacks"); - depContainer.registerType("OnLoad", "SaveCallbacks"); - depContainer.registerType("OnLoad", "TraderCallbacks"); // must occur prior to RagfairCallbacks - depContainer.registerType("OnLoad", "RagfairPriceService"); - depContainer.registerType("OnLoad", "RagfairCallbacks"); - depContainer.registerType("OnLoad", "ModCallbacks"); - depContainer.registerType("OnLoad", "GameCallbacks"); - depContainer.registerType("OnUpdate", "DialogueCallbacks"); - depContainer.registerType("OnUpdate", "HideoutCallbacks"); - depContainer.registerType("OnUpdate", "TraderCallbacks"); - depContainer.registerType("OnUpdate", "RagfairCallbacks"); - depContainer.registerType("OnUpdate", "InsuranceCallbacks"); - depContainer.registerType("OnUpdate", "SaveCallbacks"); + con.registerType("OnLoad", "DatabaseImporter"); + con.registerType("OnLoad", "PostDBModLoader"); + con.registerType("OnLoad", "HandbookCallbacks"); + con.registerType("OnLoad", "HttpCallbacks"); + con.registerType("OnLoad", "PresetCallbacks"); + con.registerType("OnLoad", "SaveCallbacks"); + con.registerType("OnLoad", "TraderCallbacks"); // Must occur prior to RagfairCallbacks + con.registerType("OnLoad", "RagfairPriceService"); + con.registerType("OnLoad", "RagfairCallbacks"); + con.registerType("OnLoad", "ModCallbacks"); + con.registerType("OnLoad", "GameCallbacks"); + con.registerType("OnUpdate", "DialogueCallbacks"); + con.registerType("OnUpdate", "HideoutCallbacks"); + con.registerType("OnUpdate", "TraderCallbacks"); + con.registerType("OnUpdate", "RagfairCallbacks"); + con.registerType("OnUpdate", "InsuranceCallbacks"); + con.registerType("OnUpdate", "SaveCallbacks"); - depContainer.registerType("StaticRoutes", "BotStaticRouter"); - depContainer.registerType("StaticRoutes", "ClientLogStaticRouter"); - depContainer.registerType("StaticRoutes", "CustomizationStaticRouter"); - depContainer.registerType("StaticRoutes", "DataStaticRouter"); - depContainer.registerType("StaticRoutes", "DialogStaticRouter"); - depContainer.registerType("StaticRoutes", "GameStaticRouter"); - depContainer.registerType("StaticRoutes", "HealthStaticRouter"); - depContainer.registerType("StaticRoutes", "InraidStaticRouter"); - depContainer.registerType("StaticRoutes", "InsuranceStaticRouter"); - depContainer.registerType("StaticRoutes", "ItemEventStaticRouter"); - depContainer.registerType("StaticRoutes", "LauncherStaticRouter"); - depContainer.registerType("StaticRoutes", "LocationStaticRouter"); - depContainer.registerType("StaticRoutes", "WeatherStaticRouter"); - depContainer.registerType("StaticRoutes", "MatchStaticRouter"); - depContainer.registerType("StaticRoutes", "QuestStaticRouter"); - depContainer.registerType("StaticRoutes", "RagfairStaticRouter"); - depContainer.registerType("StaticRoutes", "PresetStaticRouter"); - depContainer.registerType("StaticRoutes", "BundleStaticRouter"); - depContainer.registerType("StaticRoutes", "NotifierStaticRouter"); - depContainer.registerType("StaticRoutes", "ProfileStaticRouter"); - depContainer.registerType("StaticRoutes", "TraderStaticRouter"); - depContainer.registerType("DynamicRoutes", "BotDynamicRouter"); - depContainer.registerType("DynamicRoutes", "BundleDynamicRouter"); - depContainer.registerType("DynamicRoutes", "CustomizationDynamicRouter"); - depContainer.registerType("DynamicRoutes", "DataDynamicRouter"); - depContainer.registerType("DynamicRoutes", "HttpDynamicRouter"); - depContainer.registerType("DynamicRoutes", "InraidDynamicRouter"); - depContainer.registerType("DynamicRoutes", "LocationDynamicRouter"); - depContainer.registerType("DynamicRoutes", "NotifierDynamicRouter"); - depContainer.registerType("DynamicRoutes", "TraderDynamicRouter"); + con.registerType("StaticRoutes", "BotStaticRouter"); + con.registerType("StaticRoutes", "ClientLogStaticRouter"); + con.registerType("StaticRoutes", "CustomizationStaticRouter"); + con.registerType("StaticRoutes", "DataStaticRouter"); + con.registerType("StaticRoutes", "DialogStaticRouter"); + con.registerType("StaticRoutes", "GameStaticRouter"); + con.registerType("StaticRoutes", "HealthStaticRouter"); + con.registerType("StaticRoutes", "InraidStaticRouter"); + con.registerType("StaticRoutes", "InsuranceStaticRouter"); + con.registerType("StaticRoutes", "ItemEventStaticRouter"); + con.registerType("StaticRoutes", "LauncherStaticRouter"); + con.registerType("StaticRoutes", "LocationStaticRouter"); + con.registerType("StaticRoutes", "WeatherStaticRouter"); + con.registerType("StaticRoutes", "MatchStaticRouter"); + con.registerType("StaticRoutes", "QuestStaticRouter"); + con.registerType("StaticRoutes", "RagfairStaticRouter"); + con.registerType("StaticRoutes", "PresetStaticRouter"); + con.registerType("StaticRoutes", "BundleStaticRouter"); + con.registerType("StaticRoutes", "NotifierStaticRouter"); + con.registerType("StaticRoutes", "ProfileStaticRouter"); + con.registerType("StaticRoutes", "TraderStaticRouter"); + con.registerType("DynamicRoutes", "BotDynamicRouter"); + con.registerType("DynamicRoutes", "BundleDynamicRouter"); + con.registerType("DynamicRoutes", "CustomizationDynamicRouter"); + con.registerType("DynamicRoutes", "DataDynamicRouter"); + con.registerType("DynamicRoutes", "HttpDynamicRouter"); + con.registerType("DynamicRoutes", "InraidDynamicRouter"); + con.registerType("DynamicRoutes", "LocationDynamicRouter"); + con.registerType("DynamicRoutes", "NotifierDynamicRouter"); + con.registerType("DynamicRoutes", "TraderDynamicRouter"); - depContainer.registerType("IERouters", "CustomizationItemEventRouter"); - depContainer.registerType("IERouters", "HealthItemEventRouter"); - depContainer.registerType("IERouters", "HideoutItemEventRouter"); - depContainer.registerType("IERouters", "InsuranceItemEventRouter"); - depContainer.registerType("IERouters", "InventoryItemEventRouter"); - depContainer.registerType("IERouters", "NoteItemEventRouter"); - depContainer.registerType("IERouters", "PresetBuildItemEventRouter"); - depContainer.registerType("IERouters", "QuestItemEventRouter"); - depContainer.registerType("IERouters", "RagfairItemEventRouter"); - depContainer.registerType("IERouters", "RepairItemEventRouter"); - depContainer.registerType("IERouters", "TradeItemEventRouter"); - depContainer.registerType("IERouters", "WishlistItemEventRouter"); + con.registerType("IERouters", "CustomizationItemEventRouter"); + con.registerType("IERouters", "HealthItemEventRouter"); + con.registerType("IERouters", "HideoutItemEventRouter"); + con.registerType("IERouters", "InsuranceItemEventRouter"); + con.registerType("IERouters", "InventoryItemEventRouter"); + con.registerType("IERouters", "NoteItemEventRouter"); + con.registerType("IERouters", "PresetBuildItemEventRouter"); + con.registerType("IERouters", "QuestItemEventRouter"); + con.registerType("IERouters", "RagfairItemEventRouter"); + con.registerType("IERouters", "RepairItemEventRouter"); + con.registerType("IERouters", "TradeItemEventRouter"); + con.registerType("IERouters", "WishlistItemEventRouter"); - depContainer.registerType("Serializer", "ImageSerializer"); - depContainer.registerType("Serializer", "BundleSerializer"); - depContainer.registerType("Serializer", "NotifySerializer"); - depContainer.registerType("SaveLoadRouter", "HealthSaveLoadRouter"); - depContainer.registerType("SaveLoadRouter", "InraidSaveLoadRouter"); - depContainer.registerType("SaveLoadRouter", "InsuranceSaveLoadRouter"); - depContainer.registerType("SaveLoadRouter", "ProfileSaveLoadRouter"); + con.registerType("Serializer", "ImageSerializer"); + con.registerType("Serializer", "BundleSerializer"); + con.registerType("Serializer", "NotifySerializer"); + con.registerType("SaveLoadRouter", "HealthSaveLoadRouter"); + con.registerType("SaveLoadRouter", "InraidSaveLoadRouter"); + con.registerType("SaveLoadRouter", "InsuranceSaveLoadRouter"); + con.registerType("SaveLoadRouter", "ProfileSaveLoadRouter"); } - private static registerUtils(depContainer: DependencyContainer): void + private static registerUtils(con: DependencyContainer): void { // Utils - depContainer.register("App", App, { lifecycle: Lifecycle.Singleton }); - depContainer.register("DatabaseImporter", DatabaseImporter, { + con.register("App", App, { lifecycle: Lifecycle.Singleton }); + con.register("DatabaseImporter", DatabaseImporter, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("HashUtil", HashUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ImporterUtil", ImporterUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("HttpResponseUtil", HttpResponseUtil); - depContainer.register("EncodingUtil", EncodingUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("JsonUtil", JsonUtil); - depContainer.register("WinstonLogger", WinstonMainLogger, { + con.register("HashUtil", HashUtil, { lifecycle: Lifecycle.Singleton }); + con.register("ImporterUtil", ImporterUtil, { lifecycle: Lifecycle.Singleton }); + con.register("HttpResponseUtil", HttpResponseUtil); + con.register("EncodingUtil", EncodingUtil, { lifecycle: Lifecycle.Singleton }); + con.register("JsonUtil", JsonUtil); + con.register("WinstonLogger", WinstonMainLogger, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("RequestsLogger", WinstonRequestLogger, { + con.register("RequestsLogger", WinstonRequestLogger, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("MathUtil", MathUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ObjectId", ObjectId); - depContainer.register("RandomUtil", RandomUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("TimeUtil", TimeUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("VFS", VFS, { lifecycle: Lifecycle.Singleton }); - depContainer.register("WatermarkLocale", WatermarkLocale, { lifecycle: Lifecycle.Singleton }); - depContainer.register("Watermark", Watermark, { lifecycle: Lifecycle.Singleton }); - depContainer.register("AsyncQueue", AsyncQueue, { lifecycle: Lifecycle.Singleton }); - depContainer.register("HttpFileUtil", HttpFileUtil, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ModLoadOrder", ModLoadOrder, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ModTypeCheck", ModTypeCheck, { lifecycle: Lifecycle.Singleton }); + con.register("MathUtil", MathUtil, { lifecycle: Lifecycle.Singleton }); + con.register("ObjectId", ObjectId); + con.register("RandomUtil", RandomUtil, { lifecycle: Lifecycle.Singleton }); + con.register("TimeUtil", TimeUtil, { lifecycle: Lifecycle.Singleton }); + con.register("VFS", VFS, { lifecycle: Lifecycle.Singleton }); + con.register("WatermarkLocale", WatermarkLocale, { lifecycle: Lifecycle.Singleton }); + con.register("Watermark", Watermark, { lifecycle: Lifecycle.Singleton }); + con.register("AsyncQueue", AsyncQueue, { lifecycle: Lifecycle.Singleton }); + con.register("HttpFileUtil", HttpFileUtil, { lifecycle: Lifecycle.Singleton }); + con.register("ModLoadOrder", ModLoadOrder, { lifecycle: Lifecycle.Singleton }); + con.register("ModTypeCheck", ModTypeCheck, { lifecycle: Lifecycle.Singleton }); } - private static registerRouters(depContainer: DependencyContainer): void + private static registerRouters(con: DependencyContainer): void { // Routers - depContainer.register("HttpRouter", HttpRouter, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ImageRouter", ImageRouter); - depContainer.register("EventOutputHolder", EventOutputHolder, { + con.register("HttpRouter", HttpRouter, { lifecycle: Lifecycle.Singleton }); + con.register("ImageRouter", ImageRouter); + con.register("EventOutputHolder", EventOutputHolder, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("ItemEventRouter", ItemEventRouter); + con.register("ItemEventRouter", ItemEventRouter); // Dynamic routes - depContainer.register("BotDynamicRouter", { useClass: BotDynamicRouter }); - depContainer.register("BundleDynamicRouter", { useClass: BundleDynamicRouter }); - depContainer.register("CustomizationDynamicRouter", { + con.register("BotDynamicRouter", { useClass: BotDynamicRouter }); + con.register("BundleDynamicRouter", { useClass: BundleDynamicRouter }); + con.register("CustomizationDynamicRouter", { useClass: CustomizationDynamicRouter, }); - depContainer.register("DataDynamicRouter", { useClass: DataDynamicRouter }); - depContainer.register("HttpDynamicRouter", { useClass: HttpDynamicRouter }); - depContainer.register("InraidDynamicRouter", { useClass: InraidDynamicRouter }); - depContainer.register("LocationDynamicRouter", { useClass: LocationDynamicRouter }); - depContainer.register("NotifierDynamicRouter", { useClass: NotifierDynamicRouter }); - depContainer.register("TraderDynamicRouter", { useClass: TraderDynamicRouter }); + con.register("DataDynamicRouter", { useClass: DataDynamicRouter }); + con.register("HttpDynamicRouter", { useClass: HttpDynamicRouter }); + con.register("InraidDynamicRouter", { useClass: InraidDynamicRouter }); + con.register("LocationDynamicRouter", { useClass: LocationDynamicRouter }); + con.register("NotifierDynamicRouter", { useClass: NotifierDynamicRouter }); + con.register("TraderDynamicRouter", { useClass: TraderDynamicRouter }); // Item event routes - depContainer.register("CustomizationItemEventRouter", { + con.register("CustomizationItemEventRouter", { useClass: CustomizationItemEventRouter, }); - depContainer.register("HealthItemEventRouter", { useClass: HealthItemEventRouter }); - depContainer.register("HideoutItemEventRouter", { useClass: HideoutItemEventRouter }); - depContainer.register("InsuranceItemEventRouter", { + con.register("HealthItemEventRouter", { useClass: HealthItemEventRouter }); + con.register("HideoutItemEventRouter", { useClass: HideoutItemEventRouter }); + con.register("InsuranceItemEventRouter", { useClass: InsuranceItemEventRouter }); useClass: InsuranceItemEventRouter, }); - depContainer.register("InventoryItemEventRouter", { + con.register("InventoryItemEventRouter", { useClass: InventoryItemEventRouter }); useClass: InventoryItemEventRouter, }); - depContainer.register("NoteItemEventRouter", { useClass: NoteItemEventRouter }); - depContainer.register("PresetBuildItemEventRouter", { + con.register("NoteItemEventRouter", { useClass: NoteItemEventRouter }); + con.register("PresetBuildItemEventRouter", { useClass: PresetBuildItemEventRouter, }); - depContainer.register("QuestItemEventRouter", { useClass: QuestItemEventRouter }); - depContainer.register("RagfairItemEventRouter", { useClass: RagfairItemEventRouter }); - depContainer.register("RepairItemEventRouter", { useClass: RepairItemEventRouter }); - depContainer.register("TradeItemEventRouter", { useClass: TradeItemEventRouter }); - depContainer.register("WishlistItemEventRouter", { + con.register("QuestItemEventRouter", { useClass: QuestItemEventRouter }); + con.register("RagfairItemEventRouter", { useClass: RagfairItemEventRouter }); + con.register("RepairItemEventRouter", { useClass: RepairItemEventRouter }); + con.register("TradeItemEventRouter", { useClass: TradeItemEventRouter }); + con.register("WishlistItemEventRouter", { useClass: WishlistItemEventRouter }); useClass: WishlistItemEventRouter, }); // save load routes - depContainer.register("HealthSaveLoadRouter", { useClass: HealthSaveLoadRouter }); - depContainer.register("InraidSaveLoadRouter", { useClass: InraidSaveLoadRouter }); - depContainer.register("InsuranceSaveLoadRouter", { + con.register("HealthSaveLoadRouter", { useClass: HealthSaveLoadRouter }); + con.register("InraidSaveLoadRouter", { useClass: InraidSaveLoadRouter }); + con.register("InsuranceSaveLoadRouter", { useClass: InsuranceSaveLoadRouter }); useClass: InsuranceSaveLoadRouter, }); - depContainer.register("ProfileSaveLoadRouter", { useClass: ProfileSaveLoadRouter }); + con.register("ProfileSaveLoadRouter", { useClass: ProfileSaveLoadRouter }); // Route serializers - depContainer.register("BundleSerializer", { useClass: BundleSerializer }); - depContainer.register("ImageSerializer", { useClass: ImageSerializer }); - depContainer.register("NotifySerializer", { useClass: NotifySerializer }); + con.register("BundleSerializer", { useClass: BundleSerializer }); + con.register("ImageSerializer", { useClass: ImageSerializer }); + con.register("NotifySerializer", { useClass: NotifySerializer }); // Static routes - depContainer.register("BotStaticRouter", { useClass: BotStaticRouter }); - depContainer.register("BundleStaticRouter", { useClass: BundleStaticRouter }); - depContainer.register("ClientLogStaticRouter", { useClass: ClientLogStaticRouter }); - depContainer.register("CustomizationStaticRouter", { + con.register("BotStaticRouter", { useClass: BotStaticRouter }); + con.register("BundleStaticRouter", { useClass: BundleStaticRouter }); + con.register("ClientLogStaticRouter", { useClass: ClientLogStaticRouter }); + con.register("CustomizationStaticRouter", { useClass: CustomizationStaticRouter }); useClass: CustomizationStaticRouter, }); - depContainer.register("DataStaticRouter", { useClass: DataStaticRouter }); - depContainer.register("DialogStaticRouter", { useClass: DialogStaticRouter }); - depContainer.register("GameStaticRouter", { useClass: GameStaticRouter }); - depContainer.register("HealthStaticRouter", { useClass: HealthStaticRouter }); - depContainer.register("InraidStaticRouter", { useClass: InraidStaticRouter }); - depContainer.register("InsuranceStaticRouter", { useClass: InsuranceStaticRouter }); - depContainer.register("ItemEventStaticRouter", { useClass: ItemEventStaticRouter }); - depContainer.register("LauncherStaticRouter", { useClass: LauncherStaticRouter }); - depContainer.register("LocationStaticRouter", { useClass: LocationStaticRouter }); - depContainer.register("MatchStaticRouter", { useClass: MatchStaticRouter }); - depContainer.register("NotifierStaticRouter", { useClass: NotifierStaticRouter }); - depContainer.register("PresetStaticRouter", { useClass: PresetStaticRouter }); - depContainer.register("ProfileStaticRouter", { useClass: ProfileStaticRouter }); - depContainer.register("QuestStaticRouter", { useClass: QuestStaticRouter }); - depContainer.register("RagfairStaticRouter", { useClass: RagfairStaticRouter }); - depContainer.register("TraderStaticRouter", { useClass: TraderStaticRouter }); - depContainer.register("WeatherStaticRouter", { useClass: WeatherStaticRouter }); + con.register("DataStaticRouter", { useClass: DataStaticRouter }); + con.register("DialogStaticRouter", { useClass: DialogStaticRouter }); + con.register("GameStaticRouter", { useClass: GameStaticRouter }); + con.register("HealthStaticRouter", { useClass: HealthStaticRouter }); + con.register("InraidStaticRouter", { useClass: InraidStaticRouter }); + con.register("InsuranceStaticRouter", { useClass: InsuranceStaticRouter }); + con.register("ItemEventStaticRouter", { useClass: ItemEventStaticRouter }); + con.register("LauncherStaticRouter", { useClass: LauncherStaticRouter }); + con.register("LocationStaticRouter", { useClass: LocationStaticRouter }); + con.register("MatchStaticRouter", { useClass: MatchStaticRouter }); + con.register("NotifierStaticRouter", { useClass: NotifierStaticRouter }); + con.register("PresetStaticRouter", { useClass: PresetStaticRouter }); + con.register("ProfileStaticRouter", { useClass: ProfileStaticRouter }); + con.register("QuestStaticRouter", { useClass: QuestStaticRouter }); + con.register("RagfairStaticRouter", { useClass: RagfairStaticRouter }); + con.register("TraderStaticRouter", { useClass: TraderStaticRouter }); + con.register("WeatherStaticRouter", { useClass: WeatherStaticRouter }); } - private static registerGenerators(depContainer: DependencyContainer): void + private static registerGenerators(con: DependencyContainer): void { // Generators - depContainer.register("BotGenerator", BotGenerator); - depContainer.register("BotWeaponGenerator", BotWeaponGenerator); - depContainer.register("BotLootGenerator", BotLootGenerator); - depContainer.register("BotInventoryGenerator", BotInventoryGenerator); - depContainer.register("LocationGenerator", { useClass: LocationGenerator }); - depContainer.register("PMCLootGenerator", PMCLootGenerator, { + con.register("BotGenerator", BotGenerator); + con.register("BotWeaponGenerator", BotWeaponGenerator); + con.register("BotLootGenerator", BotLootGenerator); + con.register("BotInventoryGenerator", BotInventoryGenerator); + con.register("LocationGenerator", { useClass: LocationGenerator }); + con.register("PMCLootGenerator", PMCLootGenerator, { lifecycle: Lifecycle.Singleton }); + con.register("ScavCaseRewardGenerator", ScavCaseRewardGenerator, { lifecycle: Lifecycle.Singleton, }); depContainer.register("ScavCaseRewardGenerator", ScavCaseRewardGenerator, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairAssortGenerator", { useClass: RagfairAssortGenerator }); - depContainer.register("RagfairOfferGenerator", { useClass: RagfairOfferGenerator }); - depContainer.register("WeatherGenerator", { useClass: WeatherGenerator }); - depContainer.register("PlayerScavGenerator", { useClass: PlayerScavGenerator }); - depContainer.register("LootGenerator", { useClass: LootGenerator }); - depContainer.register("FenceBaseAssortGenerator", { + con.register("RagfairAssortGenerator", { useClass: RagfairAssortGenerator }); + con.register("RagfairOfferGenerator", { useClass: RagfairOfferGenerator }); + con.register("WeatherGenerator", { useClass: WeatherGenerator }); + con.register("PlayerScavGenerator", { useClass: PlayerScavGenerator }); + con.register("LootGenerator", { useClass: LootGenerator }); + con.register("FenceBaseAssortGenerator", { useClass: FenceBaseAssortGenerator }); useClass: FenceBaseAssortGenerator, }); - depContainer.register("BotLevelGenerator", { useClass: BotLevelGenerator }); - depContainer.register("BotEquipmentModGenerator", { + con.register("BotLevelGenerator", { useClass: BotLevelGenerator }); + con.register("BotEquipmentModGenerator", { useClass: BotEquipmentModGenerator }); useClass: BotEquipmentModGenerator, }); - depContainer.register("RepeatableQuestGenerator", { - useClass: RepeatableQuestGenerator, - }); + con.register("RepeatableQuestGenerator", { useClass: RepeatableQuestGenerator }); - depContainer.register("BarrelInventoryMagGen", { useClass: BarrelInventoryMagGen }); - depContainer.register("ExternalInventoryMagGen", { + con.register("BarrelInventoryMagGen", { useClass: BarrelInventoryMagGen }); + con.register("ExternalInventoryMagGen", { useClass: ExternalInventoryMagGen }); useClass: ExternalInventoryMagGen, }); - depContainer.register("InternalMagazineInventoryMagGen", { + con.register("InternalMagazineInventoryMagGen", { useClass: InternalMagazineInventoryMagGen, }); - depContainer.register("UbglExternalMagGen", { useClass: UbglExternalMagGen }); + con.register("UbglExternalMagGen", { useClass: UbglExternalMagGen }); - depContainer.registerType("InventoryMagGen", "BarrelInventoryMagGen"); - depContainer.registerType("InventoryMagGen", "ExternalInventoryMagGen"); - depContainer.registerType("InventoryMagGen", "InternalMagazineInventoryMagGen"); - depContainer.registerType("InventoryMagGen", "UbglExternalMagGen"); + con.registerType("InventoryMagGen", "BarrelInventoryMagGen"); + con.registerType("InventoryMagGen", "ExternalInventoryMagGen"); + con.registerType("InventoryMagGen", "InternalMagazineInventoryMagGen"); + con.registerType("InventoryMagGen", "UbglExternalMagGen"); } - private static registerHelpers(depContainer: DependencyContainer): void + private static registerHelpers(con: DependencyContainer): void { // Helpers - depContainer.register("AssortHelper", { useClass: AssortHelper }); - depContainer.register("BotHelper", { useClass: BotHelper }); - depContainer.register("BotGeneratorHelper", { useClass: BotGeneratorHelper }); - depContainer.register("ContainerHelper", ContainerHelper); - depContainer.register("DialogueHelper", { useClass: DialogueHelper }); - depContainer.register("DurabilityLimitsHelper", { useClass: DurabilityLimitsHelper }); - depContainer.register("GameEventHelper", GameEventHelper); - depContainer.register("HandbookHelper", HandbookHelper, { lifecycle: Lifecycle.Singleton }); - depContainer.register("HealthHelper", { useClass: HealthHelper }); - depContainer.register("HideoutHelper", { useClass: HideoutHelper }); - depContainer.register("InRaidHelper", { useClass: InRaidHelper }); - depContainer.register("InventoryHelper", { useClass: InventoryHelper }); - depContainer.register("PaymentHelper", PaymentHelper); - depContainer.register("ItemHelper", { useClass: ItemHelper }); - depContainer.register("PresetHelper", PresetHelper, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ProfileHelper", { useClass: ProfileHelper }); - depContainer.register("QuestHelper", { useClass: QuestHelper }); - depContainer.register("QuestConditionHelper", QuestConditionHelper); - depContainer.register("RagfairHelper", { useClass: RagfairHelper }); - depContainer.register("RagfairSortHelper", { useClass: RagfairSortHelper }); - depContainer.register("RagfairSellHelper", { useClass: RagfairSellHelper }); - depContainer.register("RagfairOfferHelper", { useClass: RagfairOfferHelper }); - depContainer.register("RagfairServerHelper", { useClass: RagfairServerHelper }); - depContainer.register("RepairHelper", { useClass: RepairHelper }); - depContainer.register("TraderHelper", TraderHelper); - depContainer.register("TraderAssortHelper", TraderAssortHelper, { + con.register("AssortHelper", { useClass: AssortHelper }); + con.register("BotHelper", { useClass: BotHelper }); + con.register("BotGeneratorHelper", { useClass: BotGeneratorHelper }); + con.register("ContainerHelper", ContainerHelper); + con.register("DialogueHelper", { useClass: DialogueHelper }); + con.register("DurabilityLimitsHelper", { useClass: DurabilityLimitsHelper }); + con.register("GameEventHelper", GameEventHelper); + con.register("HandbookHelper", HandbookHelper, { lifecycle: Lifecycle.Singleton }); + con.register("HealthHelper", { useClass: HealthHelper }); + con.register("HideoutHelper", { useClass: HideoutHelper }); + con.register("InRaidHelper", { useClass: InRaidHelper }); + con.register("InventoryHelper", { useClass: InventoryHelper }); + con.register("PaymentHelper", PaymentHelper); + con.register("ItemHelper", { useClass: ItemHelper }); + con.register("PresetHelper", PresetHelper, { lifecycle: Lifecycle.Singleton }); + con.register("ProfileHelper", { useClass: ProfileHelper }); + con.register("QuestHelper", { useClass: QuestHelper }); + con.register("QuestConditionHelper", QuestConditionHelper); + con.register("RagfairHelper", { useClass: RagfairHelper }); + con.register("RagfairSortHelper", { useClass: RagfairSortHelper }); + con.register("RagfairSellHelper", { useClass: RagfairSellHelper }); + con.register("RagfairOfferHelper", { useClass: RagfairOfferHelper }); + con.register("RagfairServerHelper", { useClass: RagfairServerHelper }); + con.register("RepairHelper", { useClass: RepairHelper }); + con.register("TraderHelper", TraderHelper); + con.register("TraderAssortHelper", TraderAssortHelper, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("TradeHelper", { useClass: TradeHelper }); - depContainer.register("NotifierHelper", { useClass: NotifierHelper }); - depContainer.register("UtilityHelper", UtilityHelper); - depContainer.register("WeightedRandomHelper", { useClass: WeightedRandomHelper }); - depContainer.register("HttpServerHelper", { useClass: HttpServerHelper }); - depContainer.register("NotificationSendHelper", { useClass: NotificationSendHelper }); - depContainer.register("SecureContainerHelper", { useClass: SecureContainerHelper }); - depContainer.register("ProbabilityHelper", { useClass: ProbabilityHelper }); - depContainer.register("BotWeaponGeneratorHelper", { + con.register("TradeHelper", { useClass: TradeHelper }); + con.register("NotifierHelper", { useClass: NotifierHelper }); + con.register("UtilityHelper", UtilityHelper); + con.register("WeightedRandomHelper", { useClass: WeightedRandomHelper }); + con.register("HttpServerHelper", { useClass: HttpServerHelper }); + con.register("NotificationSendHelper", { useClass: NotificationSendHelper }); + con.register("SecureContainerHelper", { useClass: SecureContainerHelper }); + con.register("ProbabilityHelper", { useClass: ProbabilityHelper }); + con.register("BotWeaponGeneratorHelper", { useClass: BotWeaponGeneratorHelper }); useClass: BotWeaponGeneratorHelper, }); - depContainer.register("BotDifficultyHelper", { useClass: BotDifficultyHelper }); - depContainer.register("RepeatableQuestHelper", { useClass: RepeatableQuestHelper }); + con.register("BotDifficultyHelper", { useClass: BotDifficultyHelper }); + con.register("RepeatableQuestHelper", { useClass: RepeatableQuestHelper }); } - private static registerLoaders(depContainer: DependencyContainer): void + private static registerLoaders(con: DependencyContainer): void { // Loaders - depContainer.register("BundleLoader", BundleLoader, { lifecycle: Lifecycle.Singleton }); - depContainer.register("PreAkiModLoader", PreAkiModLoader, { lifecycle: Lifecycle.Singleton }); - depContainer.register("PostAkiModLoader", PostAkiModLoader, { + con.register("BundleLoader", BundleLoader, { lifecycle: Lifecycle.Singleton }); + con.register("PreAkiModLoader", PreAkiModLoader, { lifecycle: Lifecycle.Singleton }); + con.register("PostAkiModLoader", PostAkiModLoader, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); } - private static registerCallbacks(depContainer: DependencyContainer): void + private static registerCallbacks(con: DependencyContainer): void { // Callbacks - depContainer.register("BotCallbacks", { useClass: BotCallbacks }); - depContainer.register("BundleCallbacks", { useClass: BundleCallbacks }); - depContainer.register("ClientLogCallbacks", { useClass: ClientLogCallbacks }); - depContainer.register("CustomizationCallbacks", { useClass: CustomizationCallbacks }); - depContainer.register("DataCallbacks", { useClass: DataCallbacks }); - depContainer.register("DialogueCallbacks", { useClass: DialogueCallbacks }); - depContainer.register("GameCallbacks", { useClass: GameCallbacks }); - depContainer.register("HandbookCallbacks", { useClass: HandbookCallbacks }); - depContainer.register("HealthCallbacks", { useClass: HealthCallbacks }); - depContainer.register("HideoutCallbacks", { useClass: HideoutCallbacks }); - depContainer.register("HttpCallbacks", { useClass: HttpCallbacks }); - depContainer.register("InraidCallbacks", { useClass: InraidCallbacks }); - depContainer.register("InsuranceCallbacks", { useClass: InsuranceCallbacks }); - depContainer.register("InventoryCallbacks", { useClass: InventoryCallbacks }); - depContainer.register("ItemEventCallbacks", { useClass: ItemEventCallbacks }); - depContainer.register("LauncherCallbacks", { useClass: LauncherCallbacks }); - depContainer.register("LocationCallbacks", { useClass: LocationCallbacks }); - depContainer.register("MatchCallbacks", { useClass: MatchCallbacks }); - depContainer.register("ModCallbacks", { useClass: ModCallbacks }); - depContainer.register("PostDBModLoader", { useClass: PostDBModLoader }); - depContainer.register("NoteCallbacks", { useClass: NoteCallbacks }); - depContainer.register("NotifierCallbacks", { useClass: NotifierCallbacks }); - depContainer.register("PresetBuildCallbacks", { useClass: PresetBuildCallbacks }); - depContainer.register("PresetCallbacks", { useClass: PresetCallbacks }); - depContainer.register("ProfileCallbacks", { useClass: ProfileCallbacks }); - depContainer.register("QuestCallbacks", { useClass: QuestCallbacks }); - depContainer.register("RagfairCallbacks", { useClass: RagfairCallbacks }); - depContainer.register("RepairCallbacks", { useClass: RepairCallbacks }); - depContainer.register("SaveCallbacks", { useClass: SaveCallbacks }); - depContainer.register("TradeCallbacks", { useClass: TradeCallbacks }); - depContainer.register("TraderCallbacks", { useClass: TraderCallbacks }); - depContainer.register("WeatherCallbacks", { useClass: WeatherCallbacks }); - depContainer.register("WishlistCallbacks", { useClass: WishlistCallbacks }); + con.register("BotCallbacks", { useClass: BotCallbacks }); + con.register("BundleCallbacks", { useClass: BundleCallbacks }); + con.register("ClientLogCallbacks", { useClass: ClientLogCallbacks }); + con.register("CustomizationCallbacks", { useClass: CustomizationCallbacks }); + con.register("DataCallbacks", { useClass: DataCallbacks }); + con.register("DialogueCallbacks", { useClass: DialogueCallbacks }); + con.register("GameCallbacks", { useClass: GameCallbacks }); + con.register("HandbookCallbacks", { useClass: HandbookCallbacks }); + con.register("HealthCallbacks", { useClass: HealthCallbacks }); + con.register("HideoutCallbacks", { useClass: HideoutCallbacks }); + con.register("HttpCallbacks", { useClass: HttpCallbacks }); + con.register("InraidCallbacks", { useClass: InraidCallbacks }); + con.register("InsuranceCallbacks", { useClass: InsuranceCallbacks }); + con.register("InventoryCallbacks", { useClass: InventoryCallbacks }); + con.register("ItemEventCallbacks", { useClass: ItemEventCallbacks }); + con.register("LauncherCallbacks", { useClass: LauncherCallbacks }); + con.register("LocationCallbacks", { useClass: LocationCallbacks }); + con.register("MatchCallbacks", { useClass: MatchCallbacks }); + con.register("ModCallbacks", { useClass: ModCallbacks }); + con.register("PostDBModLoader", { useClass: PostDBModLoader }); + con.register("NoteCallbacks", { useClass: NoteCallbacks }); + con.register("NotifierCallbacks", { useClass: NotifierCallbacks }); + con.register("PresetBuildCallbacks", { useClass: PresetBuildCallbacks }); + con.register("PresetCallbacks", { useClass: PresetCallbacks }); + con.register("ProfileCallbacks", { useClass: ProfileCallbacks }); + con.register("QuestCallbacks", { useClass: QuestCallbacks }); + con.register("RagfairCallbacks", { useClass: RagfairCallbacks }); + con.register("RepairCallbacks", { useClass: RepairCallbacks }); + con.register("SaveCallbacks", { useClass: SaveCallbacks }); + con.register("TradeCallbacks", { useClass: TradeCallbacks }); + con.register("TraderCallbacks", { useClass: TraderCallbacks }); + con.register("WeatherCallbacks", { useClass: WeatherCallbacks }); + con.register("WishlistCallbacks", { useClass: WishlistCallbacks }); } - private static registerServices(depContainer: DependencyContainer): void + private static registerServices(con: DependencyContainer): void { // Services - depContainer.register("ImageRouteService", ImageRouteService, { + con.register("ImageRouteService", ImageRouteService, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("FenceService", FenceService, { lifecycle: Lifecycle.Singleton }); - depContainer.register("PlayerService", { useClass: PlayerService }); - depContainer.register("PaymentService", { useClass: PaymentService }); - depContainer.register("InsuranceService", InsuranceService, { + con.register("FenceService", FenceService, { lifecycle: Lifecycle.Singleton }); + con.register("PlayerService", { useClass: PlayerService }); + con.register("PaymentService", { useClass: PaymentService }); + con.register("InsuranceService", InsuranceService, { lifecycle: Lifecycle.Singleton }); lifecycle: Lifecycle.Singleton, }); - depContainer.register("TraderAssortService", TraderAssortService, { + con.register("TraderAssortService", TraderAssortService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairPriceService", RagfairPriceService, { + con.register("RagfairPriceService", RagfairPriceService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairCategoriesService", RagfairCategoriesService, { + con.register("RagfairCategoriesService", RagfairCategoriesService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairOfferService", RagfairOfferService, { + con.register("RagfairOfferService", RagfairOfferService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairLinkedItemService", RagfairLinkedItemService, { + con.register("RagfairLinkedItemService", RagfairLinkedItemService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairRequiredItemsService", RagfairRequiredItemsService, { + con.register("RagfairRequiredItemsService", RagfairRequiredItemsService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("NotificationService", NotificationService, { + con.register("NotificationService", NotificationService, { lifecycle: Lifecycle.Singleton, }); depContainer.register("MatchLocationService", MatchLocationService, { @@ -661,95 +652,105 @@ export class Container depContainer.register("BotLootCacheService", BotLootCacheService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("CustomItemService", CustomItemService); + con.register("MatchLocationService", MatchLocationService, { depContainer.register("BotEquipmentFilterService", BotEquipmentFilterService); depContainer.register("ProfileSnapshotService", ProfileSnapshotService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("ItemFilterService", ItemFilterService, { + con.register("ModCompilerService", ModCompilerService); + con.register("HashCacheService", HashCacheService, { lifecycle: Lifecycle.Singleton }); + con.register("LocaleService", LocaleService, { lifecycle: Lifecycle.Singleton }); + con.register("ProfileFixerService", ProfileFixerService); + con.register("RepairService", RepairService); + con.register("BotLootCacheService", BotLootCacheService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("BotGenerationCacheService", BotGenerationCacheService, { + con.register("CustomItemService", CustomItemService); + con.register("BotEquipmentFilterService", BotEquipmentFilterService); + con.register("ProfileSnapshotService", ProfileSnapshotService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("LocalisationService", LocalisationService, { + con.register("ItemFilterService", ItemFilterService, { lifecycle: Lifecycle.Singleton }); + con.register("BotGenerationCacheService", BotGenerationCacheService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("CustomLocationWaveService", CustomLocationWaveService, { + con.register("LocalisationService", LocalisationService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("OpenZoneService", OpenZoneService, { lifecycle: Lifecycle.Singleton }); + con.register("CustomLocationWaveService", CustomLocationWaveService, { depContainer.register("ItemBaseClassService", ItemBaseClassService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("BotEquipmentModPoolService", BotEquipmentModPoolService, { + con.register("OpenZoneService", OpenZoneService, { lifecycle: Lifecycle.Singleton }); + con.register("ItemBaseClassService", ItemBaseClassService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("BotWeaponModLimitService", BotWeaponModLimitService, { + con.register("BotEquipmentModPoolService", BotEquipmentModPoolService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("SeasonalEventService", SeasonalEventService, { + con.register("BotWeaponModLimitService", BotWeaponModLimitService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("MatchBotDetailsCacheService", MatchBotDetailsCacheService, { + con.register("SeasonalEventService", SeasonalEventService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("RagfairTaxService", RagfairTaxService, { + con.register("MatchBotDetailsCacheService", MatchBotDetailsCacheService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register( + con.register("RagfairTaxService", RagfairTaxService, { lifecycle: Lifecycle.Singleton }); + con.register("TraderPurchasePersisterService", TraderPurchasePersisterService); "TraderPurchasePersisterService", TraderPurchasePersisterService, ); - depContainer.register("PmcChatResponseService", PmcChatResponseService); - depContainer.register("GiftService", GiftService); - depContainer.register("MailSendService", MailSendService); + con.register("PmcChatResponseService", PmcChatResponseService); + con.register("GiftService", GiftService); + con.register("MailSendService", MailSendService); } - private static registerServers(depContainer: DependencyContainer): void + private static registerServers(con: DependencyContainer): void { // Servers - depContainer.register("DatabaseServer", DatabaseServer, { lifecycle: Lifecycle.Singleton }); - depContainer.register("HttpServer", HttpServer, { lifecycle: Lifecycle.Singleton }); - depContainer.register("WebSocketServer", WebSocketServer, { lifecycle: Lifecycle.Singleton }); - depContainer.register("RagfairServer", RagfairServer); - depContainer.register("SaveServer", SaveServer, { lifecycle: Lifecycle.Singleton }); - depContainer.register("ConfigServer", ConfigServer, { lifecycle: Lifecycle.Singleton }); + con.register("DatabaseServer", DatabaseServer, { lifecycle: Lifecycle.Singleton }); + con.register("HttpServer", HttpServer, { lifecycle: Lifecycle.Singleton }); + con.register("WebSocketServer", WebSocketServer, { lifecycle: Lifecycle.Singleton }); + con.register("RagfairServer", RagfairServer); + con.register("SaveServer", SaveServer, { lifecycle: Lifecycle.Singleton }); + con.register("ConfigServer", ConfigServer, { lifecycle: Lifecycle.Singleton }); } - private static registerControllers(depContainer: DependencyContainer): void + private static registerControllers(con: DependencyContainer): void { // Controllers - depContainer.register("BotController", { useClass: BotController }); - depContainer.register("ClientLogController", { useClass: ClientLogController }); - depContainer.register("CustomizationController", { + con.register("BotController", { useClass: BotController }); + con.register("ClientLogController", { useClass: ClientLogController }); + con.register("CustomizationController", { useClass: CustomizationController }); useClass: CustomizationController, }); - depContainer.register("DialogueController", { useClass: DialogueController }); - depContainer.register("GameController", { useClass: GameController }); - depContainer.register("HandbookController", { useClass: HandbookController }); - depContainer.register("HealthController", { useClass: HealthController }); - depContainer.register("HideoutController", { useClass: HideoutController }); - depContainer.register("InraidController", { useClass: InraidController }); - depContainer.register("InsuranceController", { useClass: InsuranceController }); - depContainer.register("InventoryController", { useClass: InventoryController }); - depContainer.register("LauncherController", { useClass: LauncherController }); - depContainer.register("LocationController", { useClass: LocationController }); - depContainer.register("MatchController", MatchController); - depContainer.register("NoteController", { useClass: NoteController }); - depContainer.register("NotifierController", { useClass: NotifierController }); - depContainer.register("PresetBuildController", { useClass: PresetBuildController }); - depContainer.register("PresetController", { useClass: PresetController }); - depContainer.register("ProfileController", { useClass: ProfileController }); - depContainer.register("QuestController", { useClass: QuestController }); - depContainer.register("RagfairController", { useClass: RagfairController }); - depContainer.register("RepairController", { useClass: RepairController }); - depContainer.register("RepeatableQuestController", { + con.register("DialogueController", { useClass: DialogueController }); + con.register("GameController", { useClass: GameController }); + con.register("HandbookController", { useClass: HandbookController }); + con.register("HealthController", { useClass: HealthController }); + con.register("HideoutController", { useClass: HideoutController }); + con.register("InraidController", { useClass: InraidController }); + con.register("InsuranceController", { useClass: InsuranceController }); + con.register("InventoryController", { useClass: InventoryController }); + con.register("LauncherController", { useClass: LauncherController }); + con.register("LocationController", { useClass: LocationController }); + con.register("MatchController", MatchController); + con.register("NoteController", { useClass: NoteController }); + con.register("NotifierController", { useClass: NotifierController }); + con.register("PresetBuildController", { useClass: PresetBuildController }); + con.register("PresetController", { useClass: PresetController }); + con.register("ProfileController", { useClass: ProfileController }); + con.register("QuestController", { useClass: QuestController }); + con.register("RagfairController", { useClass: RagfairController }); + con.register("RepairController", { useClass: RepairController }); + con.register("RepeatableQuestController", { useClass: RepeatableQuestController }); useClass: RepeatableQuestController, }); - depContainer.register("TradeController", { useClass: TradeController }); - depContainer.register("TraderController", { useClass: TraderController }); - depContainer.register("WeatherController", { useClass: WeatherController }); - depContainer.register("WishlistController", WishlistController); + con.register("TradeController", { useClass: TradeController }); + con.register("TraderController", { useClass: TraderController }); + con.register("WeatherController", { useClass: WeatherController }); + con.register("WishlistController", WishlistController); } } diff --git a/project/src/di/OnUpdate.ts b/project/src/di/OnUpdate.ts index 57b20a24..57362acf 100644 --- a/project/src/di/OnUpdate.ts +++ b/project/src/di/OnUpdate.ts @@ -1,6 +1,5 @@ export interface OnUpdate { onUpdate(timeSinceLastRun: number): Promise; - getRoute(): string; } diff --git a/project/src/di/Router.ts b/project/src/di/Router.ts index 3ee49890..c575500f 100644 --- a/project/src/di/Router.ts +++ b/project/src/di/Router.ts @@ -78,10 +78,6 @@ export class DynamicRouter extends Router // So instead I added the definition export class ItemEventRouterDefinition extends Router { - constructor() - { - super(); - } public handleItemEvent(url: string, pmcData: IPmcData, body: any, sessionID: string): IItemEventRouterResponse { throw new Error("This method needs to be overrode by the router classes"); @@ -90,10 +86,6 @@ export class ItemEventRouterDefinition extends Router export class SaveLoadRouter extends Router { - constructor() - { - super(); - } public handleLoad(profile: IAkiProfile): IAkiProfile { throw new Error("This method needs to be overrode by the router classes"); diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index 820ed0f1..d105e602 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -120,7 +120,7 @@ export class BotEquipmentModGenerator } } - // Combatible item not found but slot REQUIRES item, get random item from db + // Compatible item not found but slot REQUIRES item, get random item from db const parentSlot = parentTemplate._props.Slots.find((i) => i._name === modSlot); if (!found && parentSlot !== undefined && parentSlot._required) { @@ -131,7 +131,7 @@ export class BotEquipmentModGenerator // Compatible item not found + not required if (!found && parentSlot !== undefined && !parentSlot._required) { - // Dont add item + // Don't add item continue; } @@ -146,7 +146,7 @@ export class BotEquipmentModGenerator if (Object.keys(modPool).includes(modTpl)) { - // Call self recursivly + // Call self recursively this.generateModsForEquipment( equipment, modPool, @@ -172,8 +172,8 @@ export class BotEquipmentModGenerator * @param modSpawnChances Mod spawn chances * @param ammoTpl Ammo tpl to use when generating magazines/cartridges * @param botRole Role of bot weapon is generated for - * @param botLevel lvel of the bot weapon is being generated for - * @param modLimits limits placed on certian mod types per gun + * @param botLevel Level of the bot weapon is being generated for + * @param modLimits limits placed on certain mod types per gun * @param botEquipmentRole role of bot when accessing bot.json equipment config settings * @returns Weapon + mods array */ @@ -197,11 +197,9 @@ export class BotEquipmentModGenerator const compatibleModsPool = modPool[parentTemplate._id]; // Null guard against bad input weapon - // rome-ignore lint/complexity/useSimplifiedLogicExpression: if ( - !parentTemplate._props.Slots.length - && !parentTemplate._props.Cartridges?.length - && !parentTemplate._props.Chambers?.length + !((parentTemplate._props.Slots.length || parentTemplate._props.Cartridges?.length) + || parentTemplate._props.Chambers?.length) ) { this.logger.error( @@ -346,7 +344,7 @@ export class BotEquipmentModGenerator ); // I first thought we could use the recursive generateModsForItems as previously for cylinder magazines. - // However, the recursion doesnt go over the slots of the parent mod but over the modPool which is given by the bot config + // However, the recursion doesn't go over the slots of the parent mod but over the modPool which is given by the bot config // where we decided to keep cartridges instead of camoras. And since a CylinderMagazine only has one cartridge entry and // this entry is not to be filled, we need a special handling for the CylinderMagazine const modParentItem = this.databaseServer.getTables().templates.items[modToAddTemplate._parent]; @@ -372,7 +370,7 @@ export class BotEquipmentModGenerator } if (containsModInPool) { - // Call self recursivly to add mods to this mod + // Call self recursively to add mods to this mod this.generateModsForWeapon( sessionId, weapon, @@ -707,7 +705,7 @@ export class BotEquipmentModGenerator * @param modTpl _tpl * @param parentId parentId * @param modSlot slotId - * @param modTemplate Used to add additional properites in the upd object + * @param modTemplate Used to add additional properties in the upd object * @returns Item object */ protected createModItem( @@ -741,14 +739,14 @@ export class BotEquipmentModGenerator /** * Get a random mod from an items compatible mods Filter array * @param modTpl ???? default value to return if nothing found - * @param parentSlot item mod will go into, used to get combatible items + * @param parentSlot item mod will go into, used to get compatible items * @param modSlot Slot to get mod to fill * @param items items to ensure picked mod is compatible with * @returns item tpl */ protected getModTplFromItemDb(modTpl: string, parentSlot: Slot, modSlot: string, items: Item[]): string { - // Find combatible mods and make an array of them + // Find compatible mods and make an array of them const allowedItems = parentSlot._props.filters[0].Filter; // Find mod item that fits slot from sorted mod array @@ -814,7 +812,7 @@ export class BotEquipmentModGenerator return false; } - // If mod id doesnt exist in slots filter list and mod id doesnt have any of the slots filters as a base class, mod isn't valid for the slot + // If mod id doesn't exist in slots filter list and mod id doesn't have any of the slots filters as a base class, mod isn't valid for the slot if ( !(itemSlot._props.filters[0].Filter.includes(modToAdd[1]._id) || this.itemHelper.isOfBaseclasses(modToAdd[1]._id, itemSlot._props.filters[0].Filter)) @@ -929,7 +927,7 @@ export class BotEquipmentModGenerator let result: string[] = []; - // Get item blacklist and mod equipmet blackist as one array + // Get item blacklist and mod equipment blacklist as one array const blacklist = this.itemFilterService.getBlacklistedItems().concat( botEquipBlacklist.equipment[modSlot] || [], ); @@ -1021,9 +1019,9 @@ export class BotEquipmentModGenerator } /** - * Take a record of camoras and merge the compatable shells into one array + * Take a record of camoras and merge the compatible shells into one array * @param camorasWithShells camoras we want to merge into one array - * @returns string array of shells fro luitple camora sources + * @returns string array of shells for multiple camora sources */ protected mergeCamoraPoolsTogether(camorasWithShells: Record): string[] { @@ -1113,7 +1111,7 @@ export class BotEquipmentModGenerator } } - // No mods added to return list after filtering has occured, send back the original mod list + // No mods added to return list after filtering has occurred, send back the original mod list if (!filteredScopesAndMods || filteredScopesAndMods.length === 0) { this.logger.debug( diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index bd38ed76..df914f37 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -8,11 +8,11 @@ import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { Common, + Health as PmcHealth, IBaseJsonSkills, IBaseSkill, IBotBase, Info, - Health as PmcHealth, Skills as botSkills, } from "@spt-aki/models/eft/common/tables/IBotBase"; import { Appearance, Health, IBotType } from "@spt-aki/models/eft/common/tables/IBotType"; @@ -277,8 +277,8 @@ export class BotGenerator } const pmcNames = [ - ...this.databaseServer.getTables().bots.types["usec"].firstName, - ...this.databaseServer.getTables().bots.types["bear"].firstName, + ...this.databaseServer.getTables().bots.types.usec.firstName, + ...this.databaseServer.getTables().bots.types.bear.firstName, ]; return `${name} (${this.randomUtil.getArrayValue(pmcNames)})`; diff --git a/project/src/generators/BotInventoryGenerator.ts b/project/src/generators/BotInventoryGenerator.ts index 592d9d67..482c4497 100644 --- a/project/src/generators/BotInventoryGenerator.ts +++ b/project/src/generators/BotInventoryGenerator.ts @@ -161,7 +161,7 @@ export class BotInventoryGenerator for (const equipmentSlot in templateInventory.equipment) { - // Weapons have special generation and will be generated seperately; ArmorVest should be generated after TactivalVest + // Weapons have special generation and will be generated separately; ArmorVest should be generated after TactivalVest if (excludedSlots.includes(equipmentSlot)) { continue; @@ -331,7 +331,7 @@ export class BotInventoryGenerator /** * Get all possible mods for item and filter down based on equipment blacklist from bot.json config - * @param itemTpl Item mod pool is being retreived and filtered + * @param itemTpl Item mod pool is being retrieved and filtered * @param equipmentBlacklist blacklist to filter mod pool with * @returns Filtered pool of mods */ diff --git a/project/src/generators/BotLevelGenerator.ts b/project/src/generators/BotLevelGenerator.ts index 5ec345b7..38778504 100644 --- a/project/src/generators/BotLevelGenerator.ts +++ b/project/src/generators/BotLevelGenerator.ts @@ -59,7 +59,7 @@ export class BotLevelGenerator } /** - * Get the highest level a bot can be relative to the players level, but no futher than the max size from globals.exp_table + * Get the highest level a bot can be relative to the players level, but no further than the max size from globals.exp_table * @param playerLevel Players current level * @param relativeDeltaMax max delta above player level to go * @returns highest level possible for bot diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 37b0c40d..8bd4d68f 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -466,7 +466,7 @@ export class BotLootGenerator { this.logger.warning(this.localisationService.getText("bot-unable_to_find_loot_n_value_for_bot", botRole)); - return this.botConfig.lootNValue["scav"]; + return this.botConfig.lootNValue.scav; } return result; @@ -606,7 +606,7 @@ export class BotLootGenerator { if (isPmc) { - return this.botConfig.itemSpawnLimits["pmc"]; + return this.botConfig.itemSpawnLimits.pmc; } if (this.botConfig.itemSpawnLimits[botRole.toLowerCase()]) @@ -618,7 +618,7 @@ export class BotLootGenerator this.localisationService.getText("bot-unable_to_find_spawn_limits_fallback_to_defaults", botRole), ); - return this.botConfig.itemSpawnLimits["default"]; + return this.botConfig.itemSpawnLimits.default; } /** diff --git a/project/src/generators/BotWeaponGenerator.ts b/project/src/generators/BotWeaponGenerator.ts index 1a8d044a..43a8e1ef 100644 --- a/project/src/generators/BotWeaponGenerator.ts +++ b/project/src/generators/BotWeaponGenerator.ts @@ -1,4 +1,4 @@ -import { inject, injectable, injectAll } from "tsyringe"; +import { inject, injectAll, injectable } from "tsyringe"; import { BotEquipmentModGenerator } from "@spt-aki/generators/BotEquipmentModGenerator"; import { IInventoryMagGen } from "@spt-aki/generators/weapongen/IInventoryMagGen"; diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 028770e5..a05df10b 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -133,8 +133,8 @@ export class LocationGenerator // randomisation is turned off globally or just turned off for this map if ( - !this.locationConfig.containerRandomisationSettings.enabled - || !this.locationConfig.containerRandomisationSettings.maps[locationId] + !(this.locationConfig.containerRandomisationSettings.enabled + && this.locationConfig.containerRandomisationSettings.maps[locationId]) ) { this.logger.debug( @@ -271,7 +271,7 @@ export class LocationGenerator } /** - * Choose a number of containers based on their probabilty value to fulfil the desired count in containerData.chosenCount + * Choose a number of containers based on their probability value to fulfil the desired count in containerData.chosenCount * @param groupId Name of the group the containers are being collected for * @param containerData Containers and probability values for a groupId * @returns List of chosen container Ids @@ -289,11 +289,14 @@ export class LocationGenerator return containerIds; } - // Create probability array with all possible container ids in this group and their relataive probability of spawning + // Create probability array with all possible container ids in this group and their relative probability of spawning const containerDistribution = new ProbabilityObjectArray(this.mathUtil, this.jsonUtil); - containerIds.forEach((x) => - containerDistribution.push(new ProbabilityObject(x, containerData.containerIdsWithProbability[x])) - ); + for (const containerId of containerIds) + { + containerDistribution.push( + new ProbabilityObject(containerId, containerData.containerIdsWithProbability[containerId]), + ); + } chosenContainerIds.push(...containerDistribution.draw(containerData.chosenCount)); @@ -489,7 +492,7 @@ export class LocationGenerator locationName: string, ): number { - // Create probability array to calcualte the total count of lootable items inside container + // Create probability array to calculate the total count of lootable items inside container const itemCountArray = new ProbabilityObjectArray(this.mathUtil, this.jsonUtil); for (const itemCountDistribution of staticLootDist[containerTypeId].itemcountDistribution) { @@ -505,9 +508,9 @@ export class LocationGenerator /** * Get all possible loot items that can be placed into a container * Do not add seasonal items if found + current date is inside seasonal event - * @param containerTypeId Contianer to get possible loot for + * @param containerTypeId Container to get possible loot for * @param staticLootDist staticLoot.json - * @returns ProbabilityObjectArray of item tpls + probabilty + * @returns ProbabilityObjectArray of item tpls + probability */ protected getPossibleLootItemsForContainer( containerTypeId: string, @@ -576,7 +579,7 @@ export class LocationGenerator for (const spawnpoint of allDynamicSpawnpoints) { - // Point is blacklsited, skip + // Point is blacklisted, skip if (blacklistedSpawnpoints?.includes(spawnpoint.template.Id)) { this.logger.debug(`Ignoring loose loot location: ${spawnpoint.template.Id}`); @@ -923,7 +926,7 @@ export class LocationGenerator } else { - // RSP30 (62178be9d0050232da3485d9/624c0b3340357b5f566e8766/6217726288ed9f0845317459) doesnt have any default presets and kills this code below as it has no chidren to reparent + // RSP30 (62178be9d0050232da3485d9/624c0b3340357b5f566e8766/6217726288ed9f0845317459) doesn't have any default presets and kills this code below as it has no children to reparent this.logger.debug(`createItem() No preset found for weapon: ${tpl}`); } diff --git a/project/src/generators/LootGenerator.ts b/project/src/generators/LootGenerator.ts index 5851ca17..a7b8621f 100644 --- a/project/src/generators/LootGenerator.ts +++ b/project/src/generators/LootGenerator.ts @@ -51,13 +51,16 @@ export class LootGenerator const itemTypeCounts = this.initItemLimitCounter(options.itemLimits); const tables = this.databaseServer.getTables(); - const itemBlacklist = new Set(this.itemFilterService.getBlacklistedItems()); - - options.itemBlacklist.forEach(itemBlacklist.add, itemBlacklist); - + const itemBlacklist = new Set([ + ...this.itemFilterService.getBlacklistedItems(), + ...options.itemBlacklist, + ]); if (!options.allowBossItems) { - this.itemFilterService.getBossItems().forEach(itemBlacklist.add, itemBlacklist); + for (const bossItem of this.itemFilterService.getBossItems()) + { + itemBlacklist.add(bossItem); + } } // Handle sealed weapon containers @@ -391,7 +394,7 @@ export class LootGenerator x._parent === rewardTypeId && x._type.toLowerCase() === "item" && !this.itemFilterService.isItemBlacklisted(x._id) - && (!containerSettings.allowBossItems && !this.itemFilterService.isBossItem(x._id)) + && (!(containerSettings.allowBossItems || this.itemFilterService.isBossItem(x._id))) && !x._props.QuestItem ); @@ -438,7 +441,7 @@ export class LootGenerator continue; } - // Get items that fulfil reward type critera from items that fit on gun + // Get items that fulfil reward type criteria from items that fit on gun const relatedItems = linkedItemsToWeapon.filter((x) => x._parent === rewardTypeId && !this.itemFilterService.isItemBlacklisted(x._id) ); diff --git a/project/src/generators/RepeatableQuestGenerator.ts b/project/src/generators/RepeatableQuestGenerator.ts index 5d161e9d..aa65f9ff 100644 --- a/project/src/generators/RepeatableQuestGenerator.ts +++ b/project/src/generators/RepeatableQuestGenerator.ts @@ -157,10 +157,10 @@ export class RepeatableQuestGenerator // a random combination of listed conditions can be required // possible conditions elements and their relative probability can be defined in QuestConfig.js // We use ProbabilityObjectArray to draw by relative probability. e.g. for targets: - // "targets": { - // "Savage": 7, - // "AnyPmc": 2, - // "bossBully": 0.5 + // targets: { + // Savage: 7, + // AnyPmc: 2, + // bossBully: 0.5 // } // higher is more likely. We define the difficulty to be the inverse of the relative probability. @@ -517,7 +517,7 @@ export class RepeatableQuestGenerator itemSelection = itemSelection.filter((x) => this.itemHelper.getItemPrice(x[0]) < roublesBudget); // We also have the option to use whitelist and/or blacklist which is defined in repeatableQuests.json as - // [{"minPlayerLevel": 1, "itemIds": ["id1",...]}, {"minPlayerLevel": 15, "itemIds": ["id3",...]}] + // [{minPlayerLevel: 1, itemIds: ["id1",...]}, {minPlayerLevel: 15, itemIds: ["id3",...]}] if (repeatableConfig.questConfig.Completion.useWhitelist) { const itemWhitelist = @@ -1042,18 +1042,16 @@ export class RepeatableQuestGenerator // check for specific baseclasses which don't make sense as reward item // also check if the price is greater than 0; there are some items whose price can not be found // those are not in the game yet (e.g. AGS grenade launcher) - return Object.entries(this.databaseServer.getTables().templates.items).filter( - ([tpl, itemTemplate]) => + return Object.entries(this.databaseServer.getTables().templates.items).filter(([tpl, itemTemplate]) => + { + // Base "Item" item has no parent, ignore it + if (itemTemplate._parent === "") { - // Base "Item" item has no parent, ignore it - if (itemTemplate._parent === "") - { - return false; - } + return false; + } - return this.isValidRewardItem(tpl, repeatableQuestConfig); - }, - ); + return this.isValidRewardItem(tpl, repeatableQuestConfig); + }); } /** @@ -1096,7 +1094,7 @@ export class RepeatableQuestGenerator } // Skip globally blacklisted items + boss items - // rome-ignore lint/complexity/useSimplifiedLogicExpression: + // biome-ignore lint/complexity/useSimplifiedLogicExpression: valid = !this.itemFilterService.isItemBlacklisted(tpl) && !this.itemFilterService.isBossItem(tpl); return valid; diff --git a/project/src/generators/weapongen/InventoryMagGen.ts b/project/src/generators/weapongen/InventoryMagGen.ts index c3ac5898..21ae076f 100644 --- a/project/src/generators/weapongen/InventoryMagGen.ts +++ b/project/src/generators/weapongen/InventoryMagGen.ts @@ -11,8 +11,7 @@ export class InventoryMagGen private ammoTemplate: ITemplateItem, private pmcInventory: Inventory, ) - { - } + {} public getMagCount(): GenerationData { diff --git a/project/src/generators/weapongen/implementations/BarrelInventoryMagGen.ts b/project/src/generators/weapongen/implementations/BarrelInventoryMagGen.ts index d289081b..2628d5f5 100644 --- a/project/src/generators/weapongen/implementations/BarrelInventoryMagGen.ts +++ b/project/src/generators/weapongen/implementations/BarrelInventoryMagGen.ts @@ -29,7 +29,8 @@ export class BarrelInventoryMagGen implements IInventoryMagGen // Can't be done by _props.ammoType as grenade launcher shoots grenades with ammoType of "buckshot" let randomisedAmmoStackSize: number; if (inventoryMagGen.getAmmoTemplate()._props.StackMaxRandom === 1) - { // doesnt stack + { + // doesnt stack randomisedAmmoStackSize = this.randomUtil.getInt(3, 6); } else diff --git a/project/src/generators/weapongen/implementations/ExternalInventoryMagGen.ts b/project/src/generators/weapongen/implementations/ExternalInventoryMagGen.ts index 6bfb9864..c3df2544 100644 --- a/project/src/generators/weapongen/implementations/ExternalInventoryMagGen.ts +++ b/project/src/generators/weapongen/implementations/ExternalInventoryMagGen.ts @@ -55,10 +55,9 @@ export class ExternalInventoryMagGen implements IInventoryMagGen if (ableToFitMagazinesIntoBotInventory === ItemAddedResult.NO_SPACE && i < randomizedMagazineCount) { - /* We were unable to fit at least the minimum amount of magazines, - * so we fallback to default magazine and try again. - * Temporary workaround to Killa spawning with no extras if he spawns with a drum mag */ - + // We were unable to fit at least the minimum amount of magazines, so we fallback to default magazine + // and try again. Temporary workaround to Killa spawning with no extras if he spawns with a drum mag. + // TODO: Fix this properly if ( magazineTpl === this.botWeaponGeneratorHelper.getWeaponsDefaultMagazineTpl( diff --git a/project/src/helpers/AssortHelper.ts b/project/src/helpers/AssortHelper.ts index 19efc015..83fa16a3 100644 --- a/project/src/helpers/AssortHelper.ts +++ b/project/src/helpers/AssortHelper.ts @@ -22,7 +22,7 @@ export class AssortHelper {} /** - * Remove assorts from a trader that have not been unlocked yet (via player completing corrisponding quest) + * Remove assorts from a trader that have not been unlocked yet (via player completing corresponding quest) * @param pmcProfile Player profile * @param traderId Traders id the assort belongs to * @param traderAssorts All assort items from same trader @@ -138,7 +138,13 @@ export class AssortHelper if (assort.barter_scheme[itemID] && flea) { - assort.barter_scheme[itemID].forEach((b) => b.forEach((br) => br.sptQuestLocked = true)); + for (const barterSchemes of assort.barter_scheme[itemID]) + { + for (const barterScheme of barterSchemes) + { + barterScheme.sptQuestLocked = true; + } + } return assort; } delete assort.barter_scheme[itemID]; diff --git a/project/src/helpers/BotGeneratorHelper.ts b/project/src/helpers/BotGeneratorHelper.ts index e0300992..2263d6bb 100644 --- a/project/src/helpers/BotGeneratorHelper.ts +++ b/project/src/helpers/BotGeneratorHelper.ts @@ -46,7 +46,7 @@ export class BotGeneratorHelper * @param botRole Used by weapons to randomize the durability values. Null for non-equipped items * @returns Item Upd object with extra properties */ - public generateExtraPropertiesForItem(itemTemplate: ITemplateItem, botRole: string = null): { upd?: Upd; } + public generateExtraPropertiesForItem(itemTemplate: ITemplateItem, botRole?: string): { upd?: Upd; } { // Get raid settings, if no raid, default to day const raidSettings = this.applicationContext.getLatestValue(ContextVariableType.RAID_CONFIGURATION)?.getValue< diff --git a/project/src/helpers/BotHelper.ts b/project/src/helpers/BotHelper.ts index 51fb64ee..d7c1991d 100644 --- a/project/src/helpers/BotHelper.ts +++ b/project/src/helpers/BotHelper.ts @@ -50,10 +50,10 @@ export class BotHelper { if (this.randomUtil.getChance100(this.pmcConfig.chanceSameSideIsHostilePercent)) { - difficultySettings.Mind["CAN_RECEIVE_PLAYER_REQUESTS_BEAR"] = false; - difficultySettings.Mind["CAN_RECEIVE_PLAYER_REQUESTS_USEC"] = false; - difficultySettings.Mind["DEFAULT_USEC_BEHAVIOUR"] = "Attack"; - difficultySettings.Mind["DEFAULT_BEAR_BEHAVIOUR"] = "Attack"; + difficultySettings.Mind.CAN_RECEIVE_PLAYER_REQUESTS_BEAR = false; + difficultySettings.Mind.CAN_RECEIVE_PLAYER_REQUESTS_USEC = false; + difficultySettings.Mind.DEFAULT_USEC_BEHAVIOUR = "Attack"; + difficultySettings.Mind.DEFAULT_BEAR_BEHAVIOUR = "Attack"; } } diff --git a/project/src/helpers/DurabilityLimitsHelper.ts b/project/src/helpers/DurabilityLimitsHelper.ts index 4757636a..45d2abcb 100644 --- a/project/src/helpers/DurabilityLimitsHelper.ts +++ b/project/src/helpers/DurabilityLimitsHelper.ts @@ -139,8 +139,8 @@ export class DurabilityLimitsHelper protected generateMaxPmcArmorDurability(itemMaxDurability: number): number { - const lowestMaxPercent = this.botConfig.durability["pmc"].armor.lowestMaxPercent; - const highestMaxPercent = this.botConfig.durability["pmc"].armor.highestMaxPercent; + const lowestMaxPercent = this.botConfig.durability.pmc.armor.lowestMaxPercent; + const highestMaxPercent = this.botConfig.durability.pmc.armor.highestMaxPercent; const multiplier = this.randomUtil.getInt(lowestMaxPercent, highestMaxPercent); return itemMaxDurability * (multiplier / 100); diff --git a/project/src/helpers/HttpServerHelper.ts b/project/src/helpers/HttpServerHelper.ts index cfc4482a..0d20a236 100644 --- a/project/src/helpers/HttpServerHelper.ts +++ b/project/src/helpers/HttpServerHelper.ts @@ -57,7 +57,7 @@ export class HttpServerHelper public sendTextJson(resp: any, output: any): void { - resp.writeHead(200, "OK", { "Content-Type": this.mime["json"] }); + resp.writeHead(200, "OK", { "Content-Type": this.mime.json }); resp.end(output); } } diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index 3d52775c..891f4f74 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -385,10 +385,10 @@ export class InRaidHelper && this.itemHelper.itemIsInsideContainer(x, "SecuredContainer", postRaidProfile.Inventory.items)); }); - itemsToRemovePropertyFrom.forEach((item) => + for (const item of itemsToRemovePropertyFrom) { delete item.upd.SpawnedInSession; - }); + } return postRaidProfile; } @@ -431,10 +431,10 @@ export class InRaidHelper { // Get inventory item ids to remove from players profile const itemIdsToDeleteFromProfile = this.getInventoryItemsLostOnDeath(pmcData).map((x) => x._id); - itemIdsToDeleteFromProfile.forEach((x) => + for (const itemId of itemIdsToDeleteFromProfile) { - this.inventoryHelper.removeItem(pmcData, x, sessionID); - }); + this.inventoryHelper.removeItem(pmcData, itemId, sessionID); + } // Remove contents of fast panel pmcData.Inventory.fastPanel = {}; diff --git a/project/src/helpers/InventoryHelper.ts b/project/src/helpers/InventoryHelper.ts index 6e374525..66b98fa0 100644 --- a/project/src/helpers/InventoryHelper.ts +++ b/project/src/helpers/InventoryHelper.ts @@ -315,9 +315,9 @@ export class InventoryHelper const itemLocation = {}; // Item already has location property, use it - if (itemLib[tmpKey]["location"] !== undefined) + if (itemLib[tmpKey].location !== undefined) { - itemLocation["location"] = itemLib[tmpKey]["location"]; + itemLocation.location = itemLib[tmpKey].location; } output.profileChanges[sessionID].items.new.push({ @@ -887,9 +887,8 @@ export class InventoryHelper { const inventoryItemHash: InventoryHelper.InventoryItemHash = { byItemId: {}, byParentId: {} }; - for (let i = 0; i < inventoryItem.length; i++) + for (const item of inventoryItem) { - const item = inventoryItem[i]; inventoryItemHash.byItemId[item._id] = item; if (!("parentId" in item)) diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 3aa9dd36..fa076340 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -190,27 +190,27 @@ class ItemHelper * AmmoBoxes contain StackSlots which need to be filled for the AmmoBox to have content. * Here's what a filled AmmoBox looks like: * { - * "_id": "b1bbe982daa00ac841d4ae4d", - * "_tpl": "57372c89245977685d4159b1", - * "parentId": "5fe49a0e2694b0755a504876", - * "slotId": "hideout", - * "location": { - * "x": 3, - * "y": 4, - * "r": 0 + * _id: "b1bbe982daa00ac841d4ae4d", + * _tpl: "57372c89245977685d4159b1", + * parentId: "5fe49a0e2694b0755a504876", + * slotId: "hideout", + * location: { + * x: 3, + * y: 4, + * r: 0 * }, - * "upd": { - * "StackObjectsCount": 1 + * upd: { + * StackObjectsCount: 1 * } * }, * { - * "_id": "b997b4117199033afd274a06", - * "_tpl": "56dff061d2720bb5668b4567", - * "parentId": "b1bbe982daa00ac841d4ae4d", - * "slotId": "cartridges", - * "location": 0, - * "upd": { - * "StackObjectsCount": 30 + * _id: "b997b4117199033afd274a06", + * _tpl: "56dff061d2720bb5668b4567", + * parentId: "b1bbe982daa00ac841d4ae4d", + * slotId: "cartridges", + * location: 0, + * upd: { + * StackObjectsCount: 30 * } * } * Given the AmmoBox Item (first object) this function generates the StackSlot (second object) and returns it. @@ -850,7 +850,7 @@ class ItemHelper */ public isAttachmentAttached(item: Item): boolean { - return item.slotId !== "hideout" && item.slotId !== "main" && isNaN(Number(item.slotId)); + return item.slotId !== "hideout" && item.slotId !== "main" && Number.isNaN(Number(item.slotId)); } /** diff --git a/project/src/helpers/RagfairHelper.ts b/project/src/helpers/RagfairHelper.ts index 284a46b0..105cecfb 100644 --- a/project/src/helpers/RagfairHelper.ts +++ b/project/src/helpers/RagfairHelper.ts @@ -54,7 +54,6 @@ export class RagfairHelper case "5449016a4bdc2d6f028b456f": return "RUB"; - default: return ""; } @@ -214,12 +213,9 @@ export class RagfairHelper { case Money.EUROS: return "€"; - case Money.DOLLARS: return "$"; - - case Money.ROUBLES: - default: + default: // Money.ROUBLES return "₽"; } } diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index cd172679..1c09f087 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -318,7 +318,7 @@ export class RagfairOfferHelper public increaseProfileRagfairRating(profile: IAkiProfile, amountToIncrementBy: number): void { profile.characters.pmc.RagfairInfo.isRatingGrowing = true; - if (isNaN(amountToIncrementBy)) + if (Number.isNaN(amountToIncrementBy)) { this.logger.warning(`Unable to increment ragfair rating, value was not a number: ${amountToIncrementBy}`); @@ -635,7 +635,7 @@ export class RagfairOfferHelper return false; } - if (isNaN(offer.requirementsCost)) + if (Number.isNaN(offer.requirementsCost)) { // don't include offers with null or NaN in it return false; diff --git a/project/src/helpers/RagfairSellHelper.ts b/project/src/helpers/RagfairSellHelper.ts index b8e705a7..8cbf6545 100644 --- a/project/src/helpers/RagfairSellHelper.ts +++ b/project/src/helpers/RagfairSellHelper.ts @@ -85,7 +85,7 @@ export class RagfairSellHelper const result: SellResult[] = []; // Value can sometimes be NaN for whatever reason, default to base chance if that happens - if (isNaN(sellChancePercent)) + if (Number.isNaN(sellChancePercent)) { this.logger.warning( `Sell chance was not a number: ${sellChancePercent}, defaulting to ${this.ragfairConfig.sell.chance.base} %`, diff --git a/project/src/helpers/TradeHelper.ts b/project/src/helpers/TradeHelper.ts index 0619b8df..11750a18 100644 --- a/project/src/helpers/TradeHelper.ts +++ b/project/src/helpers/TradeHelper.ts @@ -61,6 +61,7 @@ export class TradeHelper const newReq = { items: [{ + // eslint-disable-next-line @typescript-eslint/naming-convention item_id: buyRequestData.item_id, count: buyRequestData.count, }], diff --git a/project/src/loaders/ModLoadOrder.ts b/project/src/loaders/ModLoadOrder.ts index ba20273b..c874ac01 100644 --- a/project/src/loaders/ModLoadOrder.ts +++ b/project/src/loaders/ModLoadOrder.ts @@ -95,7 +95,7 @@ export class ModLoadOrder for (const loadBeforeMod of loadBefore) { - const loadBeforeModConfig = this.modsAvailable.get(loadBeforeMod)!; + const loadBeforeModConfig = this.modsAvailable.get(loadBeforeMod); loadBeforeModConfig.loadAfter ??= []; loadBeforeModConfig.loadAfter.push(mod); diff --git a/project/src/loaders/PostDBModLoader.ts b/project/src/loaders/PostDBModLoader.ts index 27f20248..86e80e0c 100644 --- a/project/src/loaders/PostDBModLoader.ts +++ b/project/src/loaders/PostDBModLoader.ts @@ -42,7 +42,7 @@ export class PostDBModLoader implements OnLoad const mods = this.preAkiModLoader.sortModsLoadOrder(); for (const modName of mods) { - // // import class + // import class const filepath = `${this.preAkiModLoader.getModPath(modName)}${ this.preAkiModLoader.getImportedModDetails()[modName].main }`; diff --git a/project/src/loaders/PreAkiModLoader.ts b/project/src/loaders/PreAkiModLoader.ts index 25cf6bca..94917fb5 100644 --- a/project/src/loaders/PreAkiModLoader.ts +++ b/project/src/loaders/PreAkiModLoader.ts @@ -146,10 +146,10 @@ export class PreAkiModLoader implements IModLoader const modOrder = this.vfs.readFile(this.modOrderPath, { encoding: "utf8" }); try { - this.jsonUtil.deserialize(modOrder).order.forEach((mod: string, index: number) => + for (const [index, mod] of (this.jsonUtil.deserialize(modOrder).order as string[]).entries()) { this.order[mod] = index; - }); + } } catch (error) { diff --git a/project/src/models/eft/dialog/IAcceptFriendRequestData.ts b/project/src/models/eft/dialog/IAcceptFriendRequestData.ts index 20c1c1b3..d12bd838 100644 --- a/project/src/models/eft/dialog/IAcceptFriendRequestData.ts +++ b/project/src/models/eft/dialog/IAcceptFriendRequestData.ts @@ -1,9 +1,7 @@ -// rome-ignore lint/suspicious/noEmptyInterface: export interface IAcceptFriendRequestData extends IBaseFriendRequest { } -// rome-ignore lint/suspicious/noEmptyInterface: export interface ICancelFriendRequestData extends IBaseFriendRequest { } diff --git a/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts b/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts index 59a34fae..6633df3d 100644 --- a/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts +++ b/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts @@ -13,32 +13,32 @@ export interface IGetRaidConfigurationRequestData } // { -// "keyId": "", -// "side": "Pmc", -// "location": "factory4_day", -// "timeVariant": "CURR", or "PAST" -// "raidMode": "Local", -// "metabolismDisabled": false, -// "playersSpawnPlace": "SamePlace", -// "timeAndWeatherSettings": { -// "isRandomTime": false, -// "isRandomWeather": false, -// "cloudinessType": "Clear", -// "rainType": "NoRain", -// "windType": "Light", -// "fogType": "NoFog", -// "timeFlowType": "x1", -// "hourOfDay": -1 +// keyId: "", +// side: "Pmc", +// location: "factory4_day", +// timeVariant: "CURR", or "PAST" +// raidMode: "Local", +// metabolismDisabled: false, +// playersSpawnPlace: "SamePlace", +// timeAndWeatherSettings: { +// isRandomTime: false, +// isRandomWeather: false, +// cloudinessType: "Clear", +// rainType: "NoRain", +// windType: "Light", +// fogType: "NoFog", +// timeFlowType: "x1", +// hourOfDay: -1 // }, -// "botSettings": { -// "isScavWars": false, -// "botAmount": "AsOnline" +// botSettings: { +// isScavWars: false, +// botAmount: "AsOnline" // }, -// "wavesSettings": { -// "botAmount": "AsOnline", -// "botDifficulty": "AsOnline", -// "isBosses": true, -// "isTaggedAndCursed": false +// wavesSettings: { +// botAmount: "AsOnline", +// botDifficulty: "AsOnline", +// isBosses: true, +// isTaggedAndCursed: false // } // } diff --git a/project/src/models/external/HttpFramework.ts b/project/src/models/external/HttpFramework.ts index b70c2ed4..9ac9db8b 100644 --- a/project/src/models/external/HttpFramework.ts +++ b/project/src/models/external/HttpFramework.ts @@ -28,14 +28,14 @@ export const Listen = (basePath: string) => this.handlers = {}; // Retrieve all handlers - const handlersArray = Base.prototype["handlers"]; + const handlersArray = Base.prototype.handlers; if (!handlersArray) { return; } // Add each flagged handler to the Record - handlersArray.forEach(({ handlerName, path, httpMethod }) => + for (const { handlerName, path, httpMethod } of handlersArray) { if (!this.handlers[httpMethod]) { @@ -50,10 +50,10 @@ export const Listen = (basePath: string) => } this.handlers[httpMethod][`/${basePath}/${path}`] = this[handlerName]; } - }); + } // Cleanup the handlers list - Base.prototype["handlers"] = []; + Base.prototype.handlers = []; } // The canHandle method is used to check if the Listener handles a request @@ -105,13 +105,13 @@ const createHttpDecorator = (httpMethod: HttpMethods) => return (target: any, propertyKey: string) => { // If the handlers array has not been initialized yet - if (!target["handlers"]) + if (!target.handlers) { - target["handlers"] = []; + target.handlers = []; } // Flag the method as a HTTP handler - target["handlers"].push({ handlerName: propertyKey, path, httpMethod }); + target.handlers.push({ handlerName: propertyKey, path, httpMethod }); }; }; }; diff --git a/project/src/models/external/IPostAkiLoadMod.ts b/project/src/models/external/IPostAkiLoadMod.ts index 77c999fc..d88e8e3d 100644 --- a/project/src/models/external/IPostAkiLoadMod.ts +++ b/project/src/models/external/IPostAkiLoadMod.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPostAkiLoadMod { diff --git a/project/src/models/external/IPostAkiLoadModAsync.ts b/project/src/models/external/IPostAkiLoadModAsync.ts index 5cc456af..3bfb37e7 100644 --- a/project/src/models/external/IPostAkiLoadModAsync.ts +++ b/project/src/models/external/IPostAkiLoadModAsync.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPostAkiLoadModAsync { diff --git a/project/src/models/external/IPostDBLoadMod.ts b/project/src/models/external/IPostDBLoadMod.ts index 18e2c949..d5af8f9a 100644 --- a/project/src/models/external/IPostDBLoadMod.ts +++ b/project/src/models/external/IPostDBLoadMod.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPostDBLoadMod { diff --git a/project/src/models/external/IPostDBLoadModAsync.ts b/project/src/models/external/IPostDBLoadModAsync.ts index 9b273a45..14297c3e 100644 --- a/project/src/models/external/IPostDBLoadModAsync.ts +++ b/project/src/models/external/IPostDBLoadModAsync.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPostDBLoadModAsync { diff --git a/project/src/models/external/IPreAkiLoadMod.ts b/project/src/models/external/IPreAkiLoadMod.ts index 9934e181..9d5532a1 100644 --- a/project/src/models/external/IPreAkiLoadMod.ts +++ b/project/src/models/external/IPreAkiLoadMod.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPreAkiLoadMod { diff --git a/project/src/models/external/IPreAkiLoadModAsync.ts b/project/src/models/external/IPreAkiLoadModAsync.ts index 72931dcf..2b15db36 100644 --- a/project/src/models/external/IPreAkiLoadModAsync.ts +++ b/project/src/models/external/IPreAkiLoadModAsync.ts @@ -1,4 +1,4 @@ -import { DependencyContainer } from "@spt-aki/models/external/tsyringe"; +import type { DependencyContainer } from "tsyringe"; export interface IPreAkiLoadModAsync { diff --git a/project/src/routers/HttpRouter.ts b/project/src/routers/HttpRouter.ts index 8468139e..a507f3c8 100644 --- a/project/src/routers/HttpRouter.ts +++ b/project/src/routers/HttpRouter.ts @@ -1,5 +1,5 @@ import { IncomingMessage } from "node:http"; -import { injectable, injectAll } from "tsyringe"; +import { injectAll, injectable } from "tsyringe"; import { DynamicRouter, Router, StaticRouter } from "@spt-aki/di/Router"; @@ -15,7 +15,7 @@ export class HttpRouter protected groupBy(list: T[], keyGetter: (t: T) => string): Map { const map: Map = new Map(); - list.forEach((item) => + for (const item of list) { const key = keyGetter(item); const collection = map.get(key); @@ -27,7 +27,7 @@ export class HttpRouter { collection.push(item); } - }); + } return map; } diff --git a/project/src/routers/ItemEventRouter.ts b/project/src/routers/ItemEventRouter.ts index bd1fd158..a1bf45fb 100644 --- a/project/src/routers/ItemEventRouter.ts +++ b/project/src/routers/ItemEventRouter.ts @@ -1,4 +1,4 @@ -import { inject, injectable, injectAll } from "tsyringe"; +import { inject, injectAll, injectable } from "tsyringe"; import { ItemEventRouterDefinition } from "@spt-aki/di/Router"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; diff --git a/project/src/routers/dynamic/BundleDynamicRouter.ts b/project/src/routers/dynamic/BundleDynamicRouter.ts index e11e0d89..929eba50 100644 --- a/project/src/routers/dynamic/BundleDynamicRouter.ts +++ b/project/src/routers/dynamic/BundleDynamicRouter.ts @@ -9,13 +9,10 @@ export class BundleDynamicRouter extends DynamicRouter constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) { super([ - new RouteAction( - ".bundle", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.bundleCallbacks.getBundle(url, info, sessionID); - }, - ), + new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any => + { + return this.bundleCallbacks.getBundle(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/dynamic/DataDynamicRouter.ts b/project/src/routers/dynamic/DataDynamicRouter.ts index 7a57d890..82ab4860 100644 --- a/project/src/routers/dynamic/DataDynamicRouter.ts +++ b/project/src/routers/dynamic/DataDynamicRouter.ts @@ -9,27 +9,18 @@ export class DataDynamicRouter extends DynamicRouter constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) { super([ - new RouteAction( - "/client/menu/locale/", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getLocalesMenu(url, info, sessionID); - }, - ), - new RouteAction( - "/client/locale/", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); - }, - ), - new RouteAction( - "/client/items/prices/", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getItemPrices(url, info, sessionID); - }, - ), + new RouteAction("/client/menu/locale/", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getLocalesMenu(url, info, sessionID); + }), + new RouteAction("/client/locale/", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); + }), + new RouteAction("/client/items/prices/", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getItemPrices(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/dynamic/HttpDynamicRouter.ts b/project/src/routers/dynamic/HttpDynamicRouter.ts index 383ad8d6..c7e677ec 100644 --- a/project/src/routers/dynamic/HttpDynamicRouter.ts +++ b/project/src/routers/dynamic/HttpDynamicRouter.ts @@ -9,27 +9,18 @@ export class HttpDynamicRouter extends DynamicRouter constructor(@inject("ImageRouter") protected imageRouter: ImageRouter) { super([ - new RouteAction( - ".jpg", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }, - ), - new RouteAction( - ".png", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }, - ), - new RouteAction( - ".ico", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }, - ), + new RouteAction(".jpg", (url: string, info: any, sessionID: string, output: string): any => + { + return this.imageRouter.getImage(); + }), + new RouteAction(".png", (url: string, info: any, sessionID: string, output: string): any => + { + return this.imageRouter.getImage(); + }), + new RouteAction(".ico", (url: string, info: any, sessionID: string, output: string): any => + { + return this.imageRouter.getImage(); + }), ]); } } diff --git a/project/src/routers/dynamic/NotifierDynamicRouter.ts b/project/src/routers/dynamic/NotifierDynamicRouter.ts index a8947535..cf8c86b8 100644 --- a/project/src/routers/dynamic/NotifierDynamicRouter.ts +++ b/project/src/routers/dynamic/NotifierDynamicRouter.ts @@ -9,27 +9,18 @@ export class NotifierDynamicRouter extends DynamicRouter constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks) { super([ - new RouteAction( - "/?last_id", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.notify(url, info, sessionID); - }, - ), - new RouteAction( - "/notifierServer", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.notify(url, info, sessionID); - }, - ), - new RouteAction( - "/push/notifier/get/", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.getNotifier(url, info, sessionID); - }, - ), + new RouteAction("/?last_id", (url: string, info: any, sessionID: string, output: string): any => + { + return this.notifierCallbacks.notify(url, info, sessionID); + }), + new RouteAction("/notifierServer", (url: string, info: any, sessionID: string, output: string): any => + { + return this.notifierCallbacks.notify(url, info, sessionID); + }), + new RouteAction("/push/notifier/get/", (url: string, info: any, sessionID: string, output: string): any => + { + return this.notifierCallbacks.getNotifier(url, info, sessionID); + }), new RouteAction( "/push/notifier/getwebsocket/", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/save_load/HealthSaveLoadRouter.ts b/project/src/routers/save_load/HealthSaveLoadRouter.ts index 3bddd854..b32f49ce 100644 --- a/project/src/routers/save_load/HealthSaveLoadRouter.ts +++ b/project/src/routers/save_load/HealthSaveLoadRouter.ts @@ -6,11 +6,6 @@ import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; @injectable() export class HealthSaveLoadRouter extends SaveLoadRouter { - constructor() - { - super(); - } - public override getHandledRoutes(): HandledRoute[] { return [new HandledRoute("aki-health", false)]; diff --git a/project/src/routers/static/BundleStaticRouter.ts b/project/src/routers/static/BundleStaticRouter.ts index 4074e3cc..a982835c 100644 --- a/project/src/routers/static/BundleStaticRouter.ts +++ b/project/src/routers/static/BundleStaticRouter.ts @@ -9,13 +9,10 @@ export class BundleStaticRouter extends StaticRouter constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) { super([ - new RouteAction( - "/singleplayer/bundles", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.bundleCallbacks.getBundles(url, info, sessionID); - }, - ), + new RouteAction("/singleplayer/bundles", (url: string, info: any, sessionID: string, output: string): any => + { + return this.bundleCallbacks.getBundles(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/static/ClientLogStaticRouter.ts b/project/src/routers/static/ClientLogStaticRouter.ts index c4205937..4c183531 100644 --- a/project/src/routers/static/ClientLogStaticRouter.ts +++ b/project/src/routers/static/ClientLogStaticRouter.ts @@ -9,13 +9,10 @@ export class ClientLogStaticRouter extends StaticRouter constructor(@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks) { super([ - new RouteAction( - "/singleplayer/log", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.clientLogCallbacks.clientLog(url, info, sessionID); - }, - ), + new RouteAction("/singleplayer/log", (url: string, info: any, sessionID: string, output: string): any => + { + return this.clientLogCallbacks.clientLog(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/static/DataStaticRouter.ts b/project/src/routers/static/DataStaticRouter.ts index 579e17d0..422910cc 100644 --- a/project/src/routers/static/DataStaticRouter.ts +++ b/project/src/routers/static/DataStaticRouter.ts @@ -9,27 +9,18 @@ export class DataStaticRouter extends StaticRouter constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) { super([ - new RouteAction( - "/client/settings", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getSettings(url, info, sessionID); - }, - ), - new RouteAction( - "/client/globals", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getGlobals(url, info, sessionID); - }, - ), - new RouteAction( - "/client/items", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getTemplateItems(url, info, sessionID); - }, - ), + new RouteAction("/client/settings", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getSettings(url, info, sessionID); + }), + new RouteAction("/client/globals", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getGlobals(url, info, sessionID); + }), + new RouteAction("/client/items", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getTemplateItems(url, info, sessionID); + }), new RouteAction( "/client/handbook/templates", (url: string, info: any, sessionID: string, output: string): any => @@ -37,13 +28,10 @@ export class DataStaticRouter extends StaticRouter return this.dataCallbacks.getTemplateHandbook(url, info, sessionID); }, ), - new RouteAction( - "/client/customization", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getTemplateSuits(url, info, sessionID); - }, - ), + new RouteAction("/client/customization", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getTemplateSuits(url, info, sessionID); + }), new RouteAction( "/client/account/customization", (url: string, info: any, sessionID: string, output: string): any => @@ -65,13 +53,10 @@ export class DataStaticRouter extends StaticRouter return this.dataCallbacks.getHideoutSettings(url, info, sessionID); }, ), - new RouteAction( - "/client/hideout/areas", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getHideoutAreas(url, info, sessionID); - }, - ), + new RouteAction("/client/hideout/areas", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getHideoutAreas(url, info, sessionID); + }), new RouteAction( "/client/hideout/production/scavcase/recipes", (url: string, info: any, sessionID: string, output: string): any => @@ -79,13 +64,13 @@ export class DataStaticRouter extends StaticRouter return this.dataCallbacks.getHideoutScavcase(url, info, sessionID); }, ), - new RouteAction( - "/client/languages", + new RouteAction("/client/languages", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dataCallbacks.getLocalesLanguages(url, info, sessionID); (url: string, info: any, sessionID: string, output: string): any => { return this.dataCallbacks.getLocalesLanguages(url, info, sessionID); - }, - ), + }), new RouteAction( "/client/hideout/qte/list", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/DialogStaticRouter.ts b/project/src/routers/static/DialogStaticRouter.ts index 040d65ff..a22acc6d 100644 --- a/project/src/routers/static/DialogStaticRouter.ts +++ b/project/src/routers/static/DialogStaticRouter.ts @@ -79,13 +79,10 @@ export class DialogStaticRouter extends StaticRouter return this.dialogueCallbacks.getAllAttachments(url, info, sessionID); }, ), - new RouteAction( - "/client/mail/msg/send", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.sendMessage(url, info, sessionID); - }, - ), + new RouteAction("/client/mail/msg/send", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dialogueCallbacks.sendMessage(url, info, sessionID); + }), new RouteAction( "/client/mail/dialog/clear", (url: string, info: any, sessionID: string, output: string): any => @@ -93,13 +90,10 @@ export class DialogStaticRouter extends StaticRouter return this.dialogueCallbacks.clearMail(url, info, sessionID); }, ), - new RouteAction( - "/client/friend/list", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.getFriendList(url, info, sessionID); - }, - ), + new RouteAction("/client/friend/list", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dialogueCallbacks.getFriendList(url, info, sessionID); + }), new RouteAction( "/client/friend/request/list/outbox", (url: string, info: any, sessionID: string, output: string): any => @@ -135,13 +129,10 @@ export class DialogStaticRouter extends StaticRouter return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID); }, ), - new RouteAction( - "/client/friend/delete", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.deleteFriend(url, info, sessionID); - }, - ), + new RouteAction("/client/friend/delete", (url: string, info: any, sessionID: string, output: string): any => + { + return this.dialogueCallbacks.deleteFriend(url, info, sessionID); + }), new RouteAction( "/client/friend/ignore/set", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/GameStaticRouter.ts b/project/src/routers/static/GameStaticRouter.ts index b17d89bb..04c89a6c 100644 --- a/project/src/routers/static/GameStaticRouter.ts +++ b/project/src/routers/static/GameStaticRouter.ts @@ -9,20 +9,14 @@ export class GameStaticRouter extends StaticRouter constructor(@inject("GameCallbacks") protected gameCallbacks: GameCallbacks) { super([ - new RouteAction( - "/client/game/config", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.getGameConfig(url, info, sessionID); - }, - ), - new RouteAction( - "/client/server/list", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.getServer(url, info, sessionID); - }, - ), + new RouteAction("/client/game/config", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.getGameConfig(url, info, sessionID); + }), + new RouteAction("/client/server/list", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.getServer(url, info, sessionID); + }), new RouteAction( "/client/match/group/current", (url: string, info: any, sessionID: string, output: string): any => @@ -37,27 +31,18 @@ export class GameStaticRouter extends StaticRouter return this.gameCallbacks.versionValidate(url, info, sessionID); }, ), - new RouteAction( - "/client/game/start", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.gameStart(url, info, sessionID); - }, - ), - new RouteAction( - "/client/game/logout", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.gameLogout(url, info, sessionID); - }, - ), - new RouteAction( - "/client/checkVersion", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.validateGameVersion(url, info, sessionID); - }, - ), + new RouteAction("/client/game/start", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.gameStart(url, info, sessionID); + }), + new RouteAction("/client/game/logout", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.gameLogout(url, info, sessionID); + }), + new RouteAction("/client/checkVersion", (url: string, info: any, sessionID: string, output: string): any => + { + return this.gameCallbacks.validateGameVersion(url, info, sessionID); + }), new RouteAction( "/client/game/keepalive", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/HealthStaticRouter.ts b/project/src/routers/static/HealthStaticRouter.ts index 9117b1a9..f20da993 100644 --- a/project/src/routers/static/HealthStaticRouter.ts +++ b/project/src/routers/static/HealthStaticRouter.ts @@ -9,13 +9,10 @@ export class HealthStaticRouter extends StaticRouter constructor(@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks) { super([ - new RouteAction( - "/player/health/sync", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.healthCallbacks.syncHealth(url, info, sessionID); - }, - ), + new RouteAction("/player/health/sync", (url: string, info: any, sessionID: string, output: string): any => + { + return this.healthCallbacks.syncHealth(url, info, sessionID); + }), new RouteAction( "/client/hideout/workout", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/InraidStaticRouter.ts b/project/src/routers/static/InraidStaticRouter.ts index f06eb3d1..3d3eda8d 100644 --- a/project/src/routers/static/InraidStaticRouter.ts +++ b/project/src/routers/static/InraidStaticRouter.ts @@ -9,13 +9,10 @@ export class InraidStaticRouter extends StaticRouter constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks) { super([ - new RouteAction( - "/raid/profile/save", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.inraidCallbacks.saveProgress(url, info, sessionID); - }, - ), + new RouteAction("/raid/profile/save", (url: string, info: any, sessionID: string, output: string): any => + { + return this.inraidCallbacks.saveProgress(url, info, sessionID); + }), new RouteAction( "/singleplayer/settings/raid/endstate", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/LauncherStaticRouter.ts b/project/src/routers/static/LauncherStaticRouter.ts index e402e850..0cdae88c 100644 --- a/project/src/routers/static/LauncherStaticRouter.ts +++ b/project/src/routers/static/LauncherStaticRouter.ts @@ -9,13 +9,10 @@ export class LauncherStaticRouter extends StaticRouter constructor(@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks) { super([ - new RouteAction( - "/launcher/ping", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.launcherCallbacks.ping(url, info, sessionID); - }, - ), + new RouteAction("/launcher/ping", (url: string, info: any, sessionID: string, output: string): any => + { + return this.launcherCallbacks.ping(url, info, sessionID); + }), new RouteAction( "/launcher/server/connect", (url: string, info: any, sessionID: string, output: string): any => @@ -37,13 +34,10 @@ export class LauncherStaticRouter extends StaticRouter return this.launcherCallbacks.register(url, info, sessionID); }, ), - new RouteAction( - "/launcher/profile/get", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.launcherCallbacks.get(url, info, sessionID); - }, - ), + new RouteAction("/launcher/profile/get", (url: string, info: any, sessionID: string, output: string): any => + { + return this.launcherCallbacks.get(url, info, sessionID); + }), new RouteAction( "/launcher/profile/change/username", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/LocationStaticRouter.ts b/project/src/routers/static/LocationStaticRouter.ts index f1dc5a50..a2bff938 100644 --- a/project/src/routers/static/LocationStaticRouter.ts +++ b/project/src/routers/static/LocationStaticRouter.ts @@ -9,13 +9,10 @@ export class LocationStaticRouter extends StaticRouter constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks) { super([ - new RouteAction( - "/client/locations", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.locationCallbacks.getLocationData(url, info, sessionID); - }, - ), + new RouteAction("/client/locations", (url: string, info: any, sessionID: string, output: string): any => + { + return this.locationCallbacks.getLocationData(url, info, sessionID); + }), new RouteAction( "/client/location/getAirdropLoot", (url: string, info: any, sessionID: string, _output: string): any => diff --git a/project/src/routers/static/MatchStaticRouter.ts b/project/src/routers/static/MatchStaticRouter.ts index 63f2b13a..22ce8bb3 100644 --- a/project/src/routers/static/MatchStaticRouter.ts +++ b/project/src/routers/static/MatchStaticRouter.ts @@ -9,13 +9,10 @@ export class MatchStaticRouter extends StaticRouter constructor(@inject("MatchCallbacks") protected matchCallbacks: MatchCallbacks) { super([ - new RouteAction( - "/raid/profile/list", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.getProfile(url, info, sessionID); - }, - ), + new RouteAction("/raid/profile/list", (url: string, info: any, sessionID: string, output: string): any => + { + return this.matchCallbacks.getProfile(url, info, sessionID); + }), new RouteAction( "/client/match/available", (url: string, info: any, sessionID: string, output: string): any => @@ -30,20 +27,14 @@ export class MatchStaticRouter extends StaticRouter return this.matchCallbacks.updatePing(url, info, sessionID); }, ), - new RouteAction( - "/client/match/join", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.joinMatch(url, info, sessionID); - }, - ), - new RouteAction( - "/client/match/exit", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.exitMatch(url, info, sessionID); - }, - ), + new RouteAction("/client/match/join", (url: string, info: any, sessionID: string, output: string): any => + { + return this.matchCallbacks.joinMatch(url, info, sessionID); + }), + new RouteAction("/client/match/exit", (url: string, info: any, sessionID: string, output: string): any => + { + return this.matchCallbacks.exitMatch(url, info, sessionID); + }), new RouteAction( "/client/match/group/create", (url: string, info: any, sessionID: string, output: string): any => @@ -142,13 +133,10 @@ export class MatchStaticRouter extends StaticRouter return this.matchCallbacks.endOfflineRaid(url, info, sessionID); }, ), - new RouteAction( - "/client/putMetrics", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.putMetrics(url, info, sessionID); - }, - ), + new RouteAction("/client/putMetrics", (url: string, info: any, sessionID: string, output: string): any => + { + return this.matchCallbacks.putMetrics(url, info, sessionID); + }), new RouteAction( "/client/getMetricsConfig", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/ProfileStaticRouter.ts b/project/src/routers/static/ProfileStaticRouter.ts index 894da683..4ab84e5f 100644 --- a/project/src/routers/static/ProfileStaticRouter.ts +++ b/project/src/routers/static/ProfileStaticRouter.ts @@ -86,13 +86,10 @@ export class ProfileStaticRouter extends StaticRouter return this.profileCallbacks.getMiniProfile(url, info, sessionID); }, ), - new RouteAction( - "/launcher/profiles", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID); - }, - ), + new RouteAction("/launcher/profiles", (url: string, info: any, sessionID: string, output: string): any => + { + return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/static/QuestStaticRouter.ts b/project/src/routers/static/QuestStaticRouter.ts index 76b57c6a..e56f51ac 100644 --- a/project/src/routers/static/QuestStaticRouter.ts +++ b/project/src/routers/static/QuestStaticRouter.ts @@ -9,13 +9,10 @@ export class QuestStaticRouter extends StaticRouter constructor(@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks) { super([ - new RouteAction( - "/client/quest/list", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.questCallbacks.listQuests(url, info, sessionID); - }, - ), + new RouteAction("/client/quest/list", (url: string, info: any, sessionID: string, output: string): any => + { + return this.questCallbacks.listQuests(url, info, sessionID); + }), new RouteAction( "/client/repeatalbeQuests/activityPeriods", (url: string, info: any, sessionID: string, output: string): any => diff --git a/project/src/routers/static/RagfairStaticRouter.ts b/project/src/routers/static/RagfairStaticRouter.ts index 7cd69575..376b8c6d 100644 --- a/project/src/routers/static/RagfairStaticRouter.ts +++ b/project/src/routers/static/RagfairStaticRouter.ts @@ -16,13 +16,10 @@ export class RagfairStaticRouter extends StaticRouter return this.ragfairCallbacks.search(url, info, sessionID); }, ), - new RouteAction( - "/client/ragfair/find", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.ragfairCallbacks.search(url, info, sessionID); - }, - ), + new RouteAction("/client/ragfair/find", (url: string, info: any, sessionID: string, output: string): any => + { + return this.ragfairCallbacks.search(url, info, sessionID); + }), new RouteAction( "/client/ragfair/itemMarketPrice", (url: string, info: any, sessionID: string, output: string): any => @@ -44,13 +41,10 @@ export class RagfairStaticRouter extends StaticRouter return this.ragfairCallbacks.sendReport(url, info, sessionID); }, ), - new RouteAction( - "/client/items/prices", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.ragfairCallbacks.getFleaPrices(url, info, sessionID); - }, - ), + new RouteAction("/client/items/prices", (url: string, info: any, sessionID: string, output: string): any => + { + return this.ragfairCallbacks.getFleaPrices(url, info, sessionID); + }), ]); } } diff --git a/project/src/routers/static/WeatherStaticRouter.ts b/project/src/routers/static/WeatherStaticRouter.ts index 83ef0f90..28504cc1 100644 --- a/project/src/routers/static/WeatherStaticRouter.ts +++ b/project/src/routers/static/WeatherStaticRouter.ts @@ -9,13 +9,10 @@ export class WeatherStaticRouter extends StaticRouter constructor(@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks) { super([ - new RouteAction( - "/client/weather", - (url: string, info: any, sessionID: string, output: string): any => - { - return this.weatherCallbacks.getWeather(url, info, sessionID); - }, - ), + new RouteAction("/client/weather", (url: string, info: any, sessionID: string, output: string): any => + { + return this.weatherCallbacks.getWeather(url, info, sessionID); + }), ]); } } diff --git a/project/src/servers/HttpServer.ts b/project/src/servers/HttpServer.ts index ae163092..9aabff8c 100644 --- a/project/src/servers/HttpServer.ts +++ b/project/src/servers/HttpServer.ts @@ -74,7 +74,7 @@ export class HttpServer protected handleRequest(req: IncomingMessage, resp: ServerResponse): void { // Pull sessionId out of cookies and store inside app context - const sessionId = this.getCookies(req)["PHPSESSID"]; + const sessionId = this.getCookies(req).PHPSESSID; this.applicationContext.addValue(ContextVariableType.SESSION_ID, sessionId); // http.json logRequests boolean option to allow the user/server to choose to not log requests diff --git a/project/src/servers/SaveServer.ts b/project/src/servers/SaveServer.ts index adccbb3b..95152dee 100644 --- a/project/src/servers/SaveServer.ts +++ b/project/src/servers/SaveServer.ts @@ -1,4 +1,4 @@ -import { inject, injectable, injectAll } from "tsyringe"; +import { inject, injectAll, injectable } from "tsyringe"; import { SaveLoadRouter } from "@spt-aki/di/Router"; import { IAkiProfile, Info } from "@spt-aki/models/eft/profile/IAkiProfile"; diff --git a/project/src/servers/http/AkiHttpListener.ts b/project/src/servers/http/AkiHttpListener.ts index ed88dcf4..f2605086 100644 --- a/project/src/servers/http/AkiHttpListener.ts +++ b/project/src/servers/http/AkiHttpListener.ts @@ -64,10 +64,10 @@ export class AkiHttpListener implements IHttpListener // determine if the payload is compressed. All PUT requests are, and POST requests without // debug = 1 are as well. This should be fixed. // let compressed = req.headers["content-encoding"] === "deflate"; - const compressed = req.method === "PUT" || req.headers["debug"] !== "1"; + const compressed = req.method === "PUT" || req.headers.debug !== "1"; const value = compressed ? zlib.inflateSync(buffer) : buffer; - if (req.headers["debug"] === "1") + if (req.headers.debug === "1") { this.logger.debug(value.toString(), true); } @@ -107,7 +107,7 @@ export class AkiHttpListener implements IHttpListener let handled = false; // Check if this is a debug request, if so just send the raw response without transformation - if (req.headers["debug"] === "1") + if (req.headers.debug === "1") { this.sendJson(resp, output, sessionID); } diff --git a/project/src/services/BotGenerationCacheService.ts b/project/src/services/BotGenerationCacheService.ts index d108db22..4445c1c4 100644 --- a/project/src/services/BotGenerationCacheService.ts +++ b/project/src/services/BotGenerationCacheService.ts @@ -27,17 +27,17 @@ export class BotGenerationCacheService */ public storeBots(key: string, botsToStore: IBotBase[]): void { - botsToStore.forEach((e) => + for (const bot of botsToStore) { if (this.storedBots.has(key)) { - this.storedBots.get(key).unshift(e); + this.storedBots.get(key).unshift(bot); } else { - this.storedBots.set(key, [e]); + this.storedBots.set(key, [bot]); } - }); + } } /** diff --git a/project/src/services/BotLootCacheService.ts b/project/src/services/BotLootCacheService.ts index 3cec14d0..f24ba9ff 100644 --- a/project/src/services/BotLootCacheService.ts +++ b/project/src/services/BotLootCacheService.ts @@ -197,14 +197,14 @@ export class BotLootCacheService // Get loot items (excluding magazines, bullets, grenades and healing items) const backpackLootItems = backpackLootTemplates.filter((template) => - // rome-ignore lint/complexity/useSimplifiedLogicExpression: + // biome-ignore lint/complexity/useSimplifiedLogicExpression: !this.isBulletOrGrenade(template._props) && !this.isMagazine(template._props) // && !this.isMedicalItem(template._props) // Disabled for now as followSanitar has a lot of med items as loot && !this.isGrenade(template._props) ); // Get pocket loot const pocketLootItems = pocketLootTemplates.filter((template) => - // rome-ignore lint/complexity/useSimplifiedLogicExpression: + // biome-ignore lint/complexity/useSimplifiedLogicExpression: !this.isBulletOrGrenade(template._props) && !this.isMagazine(template._props) && !this.isMedicalItem(template._props) @@ -215,7 +215,7 @@ export class BotLootCacheService // Get vest loot items const vestLootItems = vestLootTemplates.filter((template) => - // rome-ignore lint/complexity/useSimplifiedLogicExpression: + // biome-ignore lint/complexity/useSimplifiedLogicExpression: !this.isBulletOrGrenade(template._props) && !this.isMagazine(template._props) && !this.isMedicalItem(template._props) diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index a438c8d6..c7ac6a21 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -148,8 +148,8 @@ export class InsuranceService { const dialogueTemplates = this.databaseServer.getTables().traders[Traders.PRAPOR].dialogue; // todo: get trader id instead of hard coded prapor const randomResponseId = locationName?.toLowerCase() === "laboratory" - ? this.randomUtil.getArrayValue(dialogueTemplates["insuranceFailedLabs"]) - : this.randomUtil.getArrayValue(dialogueTemplates["insuranceFailed"]); + ? this.randomUtil.getArrayValue(dialogueTemplates.insuranceFailedLabs) + : this.randomUtil.getArrayValue(dialogueTemplates.insuranceFailed); this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionId, diff --git a/project/src/services/LocaleService.ts b/project/src/services/LocaleService.ts index 25bf76d7..c9bc8263 100644 --- a/project/src/services/LocaleService.ts +++ b/project/src/services/LocaleService.ts @@ -39,7 +39,7 @@ export class LocaleService `Unable to find desired locale file using locale ${this.getDesiredGameLocale()} from config/locale.json, falling back to 'en'`, ); - return this.databaseServer.getTables().locales.global["en"]; + return this.databaseServer.getTables().locales.global.en; } /** diff --git a/project/src/services/LocalisationService.ts b/project/src/services/LocalisationService.ts index e402fae3..73859227 100644 --- a/project/src/services/LocalisationService.ts +++ b/project/src/services/LocalisationService.ts @@ -1,5 +1,5 @@ -import { I18n } from "i18n"; import path from "node:path"; +import { I18n } from "i18n"; import { inject, injectable } from "tsyringe"; import { ILocaleConfig } from "@spt-aki/models/spt/config/ILocaleConfig"; @@ -57,7 +57,7 @@ export class LocalisationService */ public getKeys(): string[] { - return Object.keys(this.databaseServer.getTables().locales.server["en"]); + return Object.keys(this.databaseServer.getTables().locales.server.en); } /** @@ -67,7 +67,7 @@ export class LocalisationService */ public getRandomTextThatMatchesPartialKey(partialKey: string): string { - const filteredKeys = Object.keys(this.databaseServer.getTables().locales.server["en"]).filter((x) => + const filteredKeys = Object.keys(this.databaseServer.getTables().locales.server.en).filter((x) => x.startsWith(partialKey) ); const chosenKey = this.randomUtil.getArrayValue(filteredKeys); diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 358da3bd..59731787 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -417,7 +417,7 @@ export class ProfileFixerService const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.qid); // if BackendCounter's quest is neither in activeQuests nor Quests it's stale - if (!existsInActiveRepeatableQuests && !existsInQuests) + if (!(existsInActiveRepeatableQuests || existsInQuests)) { counterKeysToRemove.push(key); } @@ -435,14 +435,14 @@ export class ProfileFixerService protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[] { let activeQuests = []; - repeatableQuests?.forEach((x) => + for (const repeatableQuest of repeatableQuests) { - if (x.activeQuests.length > 0) + if (repeatableQuest.activeQuests.length > 0) { // daily/weekly collection has active quests in them, add to array and return - activeQuests = activeQuests.concat(x.activeQuests); + activeQuests = activeQuests.concat(repeatableQuest.activeQuests); } - }); + } return activeQuests; } @@ -462,9 +462,9 @@ export class ProfileFixerService protected addMissingBonusesProperty(pmcProfile: IPmcData): void { - if (typeof pmcProfile["Bonuses"] === "undefined") + if (typeof pmcProfile.Bonuses === "undefined") { - pmcProfile["Bonuses"] = []; + pmcProfile.Bonuses = []; this.logger.debug("Missing Bonuses property added to profile"); } } @@ -1006,7 +1006,7 @@ export class ProfileFixerService */ public addMissingHideoutAreasToProfile(fullProfile: IAkiProfile): void { - const pmcProfile = fullProfile.characters["pmc"]; + const pmcProfile = fullProfile.characters.pmc; // No profile, probably new account being created if (!pmcProfile?.Hideout) { @@ -1059,7 +1059,7 @@ export class ProfileFixerService public fixIncorrectAidValue(fullProfile: IAkiProfile): void { // Not a number, regenerate - if (isNaN(fullProfile.characters.pmc.aid)) + if (Number.isNaN(fullProfile.characters.pmc.aid)) { fullProfile.characters.pmc.sessionId = fullProfile.characters.pmc.aid; fullProfile.characters.pmc.aid = this.hashUtil.generateAccountId(); @@ -1145,11 +1145,11 @@ export class ProfileFixerService */ protected migrateImprovements(pmcProfile: IPmcData): void { - if (pmcProfile.Hideout["Improvements"]) + if (pmcProfile.Hideout.Improvements) { // Correct name is `Improvement` - pmcProfile.Hideout.Improvement = this.jsonUtil.clone(pmcProfile.Hideout["Improvements"]); - delete pmcProfile.Hideout["Improvements"]; + pmcProfile.Hideout.Improvement = this.jsonUtil.clone(pmcProfile.Hideout.Improvements); + delete pmcProfile.Hideout.Improvements; this.logger.success("Successfully migrated hideout Improvements data to new location, deleted old data"); } } diff --git a/project/src/services/RagfairOfferService.ts b/project/src/services/RagfairOfferService.ts index efed6fe9..c38e2973 100644 --- a/project/src/services/RagfairOfferService.ts +++ b/project/src/services/RagfairOfferService.ts @@ -189,7 +189,10 @@ export class RagfairOfferService public expireStaleOffers(): void { const time = this.timeUtil.getTimestamp(); - this.ragfairOfferHandler.getStaleOffers(time).forEach((o) => this.processStaleOffer(o)); + for (const staleOffer of this.ragfairOfferHandler.getStaleOffers(time)) + { + this.processStaleOffer(staleOffer); + } } /** diff --git a/project/src/services/RagfairTaxService.ts b/project/src/services/RagfairTaxService.ts index 0e4b1018..084b5fe0 100644 --- a/project/src/services/RagfairTaxService.ts +++ b/project/src/services/RagfairTaxService.ts @@ -70,15 +70,15 @@ export class RagfairTaxService if (requirementsPrice >= itemWorth) { - requirementPriceMult = Math.pow(requirementPriceMult, 1.08); + requirementPriceMult = requirementPriceMult ** 1.08; } else { - itemPriceMult = Math.pow(itemPriceMult, 1.08); + itemPriceMult = itemPriceMult ** 1.08; } - itemPriceMult = Math.pow(4, itemPriceMult); - requirementPriceMult = Math.pow(4, requirementPriceMult); + itemPriceMult = 4 ** itemPriceMult; + requirementPriceMult = 4 ** requirementPriceMult; const hideoutFleaTaxDiscountBonus = pmcData.Bonuses.find((b) => b.type === "RagfairCommission"); const taxDiscountPercent = hideoutFleaTaxDiscountBonus ? Math.abs(hideoutFleaTaxDiscountBonus.value) : 0; @@ -170,7 +170,7 @@ export class RagfairTaxService if ("Repairable" in item.upd && itemTemplate._props.armorClass > 0) { - const num2 = 0.01 * Math.pow(0.0, item.upd.Repairable.MaxDurability); + const num2 = 0.01 * (0.0 ** item.upd.Repairable.MaxDurability); worth = worth * ((item.upd.Repairable.MaxDurability / itemTemplate._props.Durability) - num2) - Math.floor( itemTemplate._props.RepairCost diff --git a/project/src/services/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index 80301aef..2601fb90 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -415,10 +415,10 @@ export class SeasonalEventService */ protected addLootItemsToGifterDropItemsList(): void { - const gifterBot = this.databaseServer.getTables().bots.types["gifter"]; + const gifterBot = this.databaseServer.getTables().bots.types.gifter; for (const difficulty in gifterBot.difficulty) { - gifterBot.difficulty[difficulty].Patrol["ITEMS_TO_DROP"] = gifterBot.inventory.items.Backpack.join(", "); + gifterBot.difficulty[difficulty].Patrol.ITEMS_TO_DROP = gifterBot.inventory.items.Backpack.join(", "); } } @@ -468,7 +468,7 @@ export class SeasonalEventService protected addPumpkinsToScavBackpacks(): void { - const assaultBackpack = this.databaseServer.getTables().bots.types["assault"].inventory.items.Backpack; + const assaultBackpack = this.databaseServer.getTables().bots.types.assault.inventory.items.Backpack; assaultBackpack.push("634959225289190e5e773b3b"); assaultBackpack.push("634959225289190e5e773b3b"); assaultBackpack.push("634959225289190e5e773b3b"); diff --git a/project/src/utils/DatabaseImporter.ts b/project/src/utils/DatabaseImporter.ts index 2dbc674c..c348e6d5 100644 --- a/project/src/utils/DatabaseImporter.ts +++ b/project/src/utils/DatabaseImporter.ts @@ -206,8 +206,8 @@ export class DatabaseImporter implements OnLoad enum VaildationResult { - SUCCESS, - FAILED, - NOT_FOUND, - UNDEFINED, + SUCCESS = 0, + FAILED = 1, + NOT_FOUND = 2, + UNDEFINED = 3, } diff --git a/project/src/utils/ImporterUtil.ts b/project/src/utils/ImporterUtil.ts index 28e4c06f..51173cec 100644 --- a/project/src/utils/ImporterUtil.ts +++ b/project/src/utils/ImporterUtil.ts @@ -1,8 +1,8 @@ import { inject, injectable } from "tsyringe"; -import { Queue } from "@spt-aki/utils/collections/queue/Queue"; import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { VFS } from "@spt-aki/utils/VFS"; +import { Queue } from "@spt-aki/utils/collections/queue/Queue"; /* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/brace-style */ diff --git a/project/src/utils/RagfairOfferHolder.ts b/project/src/utils/RagfairOfferHolder.ts index 3dcb9926..fc772c8e 100644 --- a/project/src/utils/RagfairOfferHolder.ts +++ b/project/src/utils/RagfairOfferHolder.ts @@ -51,7 +51,10 @@ export class RagfairOfferHolder public addOffers(offers: Array): void { - offers.forEach((o) => this.addOffer(o)); + for (const offer of offers) + { + this.addOffer(offer); + } } public addOffer(offer: IRagfairOffer): void @@ -76,7 +79,10 @@ export class RagfairOfferHolder public removeOffers(offers: Array): void { - offers.forEach((o) => this.removeOffer(o)); + for (const offer of offers) + { + this.removeOffer(offer); + } } public removeOfferByTrader(traderId: string): void diff --git a/project/src/utils/TimeUtil.ts b/project/src/utils/TimeUtil.ts index 12b9f7ce..a74cc943 100644 --- a/project/src/utils/TimeUtil.ts +++ b/project/src/utils/TimeUtil.ts @@ -1,5 +1,5 @@ -import { injectable } from "tsyringe"; import { formatInTimeZone } from "date-fns-tz"; +import { injectable } from "tsyringe"; /** * Utility class to handle time related operations. diff --git a/project/src/utils/VFS.ts b/project/src/utils/VFS.ts index d095e29b..fa24c8ce 100644 --- a/project/src/utils/VFS.ts +++ b/project/src/utils/VFS.ts @@ -1,13 +1,13 @@ import "reflect-metadata"; import { inject, injectable } from "tsyringe"; -import fs from "node:fs"; import crypto from "node:crypto"; -import { promisify } from "node:util"; +import fs from "node:fs"; import path, { resolve } from "node:path"; +import { promisify } from "node:util"; +import { IAsyncQueue } from "@spt-aki/models/spt/utils/IAsyncQueue"; import { writeFileSync } from "atomically"; import lockfile from "proper-lockfile"; -import { IAsyncQueue } from "@spt-aki/models/spt/utils/IAsyncQueue"; @injectable() export class VFS diff --git a/project/src/utils/collections/queue/Queue.ts b/project/src/utils/collections/queue/Queue.ts index d6224e6a..5bce00e4 100644 --- a/project/src/utils/collections/queue/Queue.ts +++ b/project/src/utils/collections/queue/Queue.ts @@ -18,7 +18,10 @@ export class Queue public enqueueAll(elements: T[]): void { - elements.forEach((e) => this.enqueue(e)); + for (const element of elements) + { + this.enqueue(element); + } } public dequeue(): T diff --git a/project/src/utils/logging/AbstractWinstonLogger.ts b/project/src/utils/logging/AbstractWinstonLogger.ts index a9112893..51a744ef 100644 --- a/project/src/utils/logging/AbstractWinstonLogger.ts +++ b/project/src/utils/logging/AbstractWinstonLogger.ts @@ -1,5 +1,5 @@ -import fs from "node:fs"; import crypto from "node:crypto"; +import fs from "node:fs"; import { promisify } from "node:util"; import winston, { createLogger, format, transports } from "winston"; import DailyRotateFile from "winston-daily-rotate-file"; diff --git a/project/tests/CustomEnvironment.ts b/project/tests/CustomEnvironment.ts index 3d1cd93e..e295b1aa 100644 --- a/project/tests/CustomEnvironment.ts +++ b/project/tests/CustomEnvironment.ts @@ -1,17 +1,14 @@ import "reflect-metadata"; -import { container, DependencyContainer, Lifecycle } from "tsyringe"; +import { DependencyContainer, Lifecycle, container } from "tsyringe"; -// For the Vitest Custom Environment. -import type { Environment } from "vitest"; -import { Container } from "@spt-aki/di/Container"; - -// Required for importing the database. import path from "node:path"; +import { Container } from "@spt-aki/di/Container"; import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; +import type { Environment } from "vitest"; -// Manually mock for the logger. +// Manually mock the logger. import { WinstonLogger } from "@tests/__mocks__/WinstonLogger.mock"; export default { diff --git a/project/tests/__factories__/ProfileInsurance.factory.ts b/project/tests/__factories__/ProfileInsurance.factory.ts index 20addde2..83ea5629 100644 --- a/project/tests/__factories__/ProfileInsurance.factory.ts +++ b/project/tests/__factories__/ProfileInsurance.factory.ts @@ -1,9 +1,10 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { format } from "date-fns"; -import { profileInsuranceFixture } from "@tests/__fixture__/profileInsurance.fixture"; -import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile"; + import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile"; +import { profileInsuranceFixture } from "@tests/__fixture__/profileInsurance.fixture"; +import { format } from "date-fns"; type DateInput = number | number[] | { [index: number]: number; }; @@ -79,7 +80,6 @@ export class ProfileInsuranceFactory this.profileInsuranceFixture = this.profileInsuranceFixture.map((insurance) => { insurance.items = insurance.items.filter((item) => itemHelper.isAttachmentAttached(item)); - return insurance; }); diff --git a/project/tests/controllers/InsuranceController.test.ts b/project/tests/controllers/InsuranceController.test.ts index c543172c..4f2cd9e1 100644 --- a/project/tests/controllers/InsuranceController.test.ts +++ b/project/tests/controllers/InsuranceController.test.ts @@ -1,16 +1,16 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, afterEach, describe, expect, it, beforeEach } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { InsuranceController } from "@spt-aki/controllers/InsuranceController"; import { ProfileInsuranceFactory } from "@tests/__factories__/ProfileInsurance.factory"; -import { MessageType } from "@spt-aki/models/enums/MessageType"; +import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile"; -import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { MessageType } from "@spt-aki/models/enums/MessageType"; describe("InsuranceController", () => { @@ -1382,13 +1382,13 @@ describe("InsuranceController", () => describe("insure", () => { - let pmcData: any, - body: any, - sessionId: string, - insuranceController: any, - mockGetPremium: any, - mockPayMoney: any, - mockGetOutput: any; + let pmcData: any; + let body: any; + let sessionId: string; + let insuranceController: any; + let mockGetPremium: any; + let mockPayMoney: any; + let mockGetOutput: any; beforeEach(() => { diff --git a/project/tests/generators/BotGenerator.test.ts b/project/tests/generators/BotGenerator.test.ts index 55869f85..05d9f402 100644 --- a/project/tests/generators/BotGenerator.test.ts +++ b/project/tests/generators/BotGenerator.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + import { BotGenerator } from "@spt-aki/generators/BotGenerator"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; @@ -129,8 +129,8 @@ describe("BotGenerator", () => it("should return name `test (usec)` for player scav bot", () => { botGenerator.botConfig.chanceAssaultScavHasPlayerScavName = 100; - botGenerator.databaseServer.getTables().bots.types["usec"].firstName = ["usec"]; - botGenerator.databaseServer.getTables().bots.types["bear"].firstName = []; + botGenerator.databaseServer.getTables().bots.types.usec.firstName = ["usec"]; + botGenerator.databaseServer.getTables().bots.types.bear.firstName = []; const mockPlayerProfile = { Info: { Nickname: "Player", Level: 1 } }; vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(mockPlayerProfile); diff --git a/project/tests/generators/BotLevelGenerator.test.ts b/project/tests/generators/BotLevelGenerator.test.ts index 2bfe3cc8..8d8815a6 100644 --- a/project/tests/generators/BotLevelGenerator.test.ts +++ b/project/tests/generators/BotLevelGenerator.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { BotLevelGenerator } from "@spt-aki/generators/BotLevelGenerator"; import { MinMax } from "@spt-aki/models/common/MinMax"; diff --git a/project/tests/helpers/BotHelper.test.ts b/project/tests/helpers/BotHelper.test.ts index f9a12537..9e48473b 100644 --- a/project/tests/helpers/BotHelper.test.ts +++ b/project/tests/helpers/BotHelper.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { BotHelper } from "@spt-aki/helpers/BotHelper"; diff --git a/project/tests/helpers/HandbookHelper.test.ts b/project/tests/helpers/HandbookHelper.test.ts index bf1cb7bc..0747f1a7 100644 --- a/project/tests/helpers/HandbookHelper.test.ts +++ b/project/tests/helpers/HandbookHelper.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper"; import { Money } from "@spt-aki/models/enums/Money"; diff --git a/project/tests/helpers/InRaidHelper.test.ts b/project/tests/helpers/InRaidHelper.test.ts index 457bb4a0..d13f2e91 100644 --- a/project/tests/helpers/InRaidHelper.test.ts +++ b/project/tests/helpers/InRaidHelper.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; diff --git a/project/tests/helpers/ItemHelper.test.ts b/project/tests/helpers/ItemHelper.test.ts index d555d0a6..8e875727 100644 --- a/project/tests/helpers/ItemHelper.test.ts +++ b/project/tests/helpers/ItemHelper.test.ts @@ -1,12 +1,12 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { HashUtil } from "@spt-aki/utils/HashUtil"; -import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; describe("ItemHelper", () => { @@ -253,7 +253,7 @@ describe("ItemHelper", () => const fixedItem = itemHelper.fixItemStackCount(initialItem); expect(fixedItem.upd).toBeDefined(); - expect(fixedItem.upd!.StackObjectsCount).toBe(1); + expect(fixedItem.upd?.StackObjectsCount).toBe(1); }); it("should set upd.StackObjectsCount to 1 if upd.StackObjectsCount is undefined", () => @@ -262,7 +262,7 @@ describe("ItemHelper", () => const fixedItem = itemHelper.fixItemStackCount(initialItem); expect(fixedItem.upd).toBeDefined(); - expect(fixedItem.upd!.StackObjectsCount).toBe(1); + expect(fixedItem.upd?.StackObjectsCount).toBe(1); }); it("should not change upd.StackObjectsCount if it is already defined", () => @@ -271,7 +271,7 @@ describe("ItemHelper", () => const fixedItem = itemHelper.fixItemStackCount(initialItem); expect(fixedItem.upd).toBeDefined(); - expect(fixedItem.upd!.StackObjectsCount).toBe(5); + expect(fixedItem.upd?.StackObjectsCount).toBe(5); }); }); @@ -446,7 +446,7 @@ describe("ItemHelper", () => expect(result).toBe(0.5); }); - it("should return correct value for a reparable helmet", () => + it("should return correct value for a repairable helmet", () => { const itemId = container.resolve("HashUtil").generate(); const item: Item = { @@ -815,7 +815,7 @@ describe("ItemHelper", () => describe("addCartridgesToAmmoBox", () => { - it("should return an array with 1xammoBox and 1xcartridge item", () => + it("should return an array with 1x ammoBox and 1x cartridge item", () => { const itemId = container.resolve("HashUtil").generate(); const ammoBox: Item[] = [{ @@ -831,7 +831,7 @@ describe("ItemHelper", () => expect(ammoBox[1].upd.StackObjectsCount).toBe(8); }); - it("should return an array with 1xammoBox and 2xcartridge items", () => + it("should return an array with 1x ammoBox and 2x cartridge items", () => { const itemId = container.resolve("HashUtil").generate(); const ammoBox: Item[] = [{ diff --git a/project/tests/services/ItemBaseClassService.test.ts b/project/tests/services/ItemBaseClassService.test.ts index 83c3c71e..eee0d619 100644 --- a/project/tests/services/ItemBaseClassService.test.ts +++ b/project/tests/services/ItemBaseClassService.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + import { ItemBaseClassService } from "@spt-aki/services/ItemBaseClassService"; describe("ItemBaseClassService", () => diff --git a/project/tests/services/PaymentService.test.ts b/project/tests/services/PaymentService.test.ts index 397e3a53..cea1dae3 100644 --- a/project/tests/services/PaymentService.test.ts +++ b/project/tests/services/PaymentService.test.ts @@ -1,16 +1,16 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; -import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; -import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; -import { HashUtil } from "@spt-aki/utils/HashUtil"; -import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; +import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader"; +import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; +import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; +import { HashUtil } from "@spt-aki/utils/HashUtil"; describe("PaymentService", () => { diff --git a/project/tests/services/PlayerService.test.ts b/project/tests/services/PlayerService.test.ts index 24b1f294..6c731861 100644 --- a/project/tests/services/PlayerService.test.ts +++ b/project/tests/services/PlayerService.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { PlayerService } from "@spt-aki/services/PlayerService"; diff --git a/project/tests/utils/TimeUtil.test.ts b/project/tests/utils/TimeUtil.test.ts index 112b0aa9..03e026b5 100644 --- a/project/tests/utils/TimeUtil.test.ts +++ b/project/tests/utils/TimeUtil.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, afterEach, describe, expect, it, beforeEach } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; diff --git a/project/vitest.config.ts b/project/vitest.config.ts index fffd33aa..d3290ec2 100644 --- a/project/vitest.config.ts +++ b/project/vitest.config.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import path from "node:path"; import { defineConfig } from "vitest/config";