diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index cef02021..d2684f94 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -651,7 +651,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 @@ -815,9 +815,9 @@ 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 @@ -850,14 +850,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); } } } @@ -868,10 +868,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; } } diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index af7c6b62..9cbe4536 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -374,7 +374,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], @@ -400,7 +400,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, }), ); diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index 3ce39b96..93de5e56 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -410,7 +410,7 @@ export class QuestController ); // 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"]; + const enLocale = this.databaseServer.getTables().locales.global.en; questStartedMessageText = enLocale[repeatableQuestProfile.startedMessageText]; if (!questStartedMessageText) diff --git a/project/src/controllers/RepeatableQuestController.ts b/project/src/controllers/RepeatableQuestController.ts index 531fae50..ec9e30bb 100644 --- a/project/src/controllers/RepeatableQuestController.ts +++ b/project/src/controllers/RepeatableQuestController.ts @@ -305,7 +305,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); diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index f43bf0b3..c0b19da8 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -282,8 +282,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/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 4125fd5c..1c7af16d 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -502,7 +502,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; @@ -642,7 +642,7 @@ export class BotLootGenerator { if (isPmc) { - return this.botConfig.itemSpawnLimits["pmc"]; + return this.botConfig.itemSpawnLimits.pmc; } if (this.botConfig.itemSpawnLimits[botRole.toLowerCase()]) @@ -654,7 +654,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/helpers/BotHelper.ts b/project/src/helpers/BotHelper.ts index 71f718b7..aaae6ebf 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 f888d30c..84e53e73 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 e6db7dee..65b38bcc 100644 --- a/project/src/helpers/HttpServerHelper.ts +++ b/project/src/helpers/HttpServerHelper.ts @@ -60,7 +60,7 @@ export class HttpServerHelper public sendTextJson(resp: any, output: any): void { // eslint-disable-next-line @typescript-eslint/naming-convention - 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/InventoryHelper.ts b/project/src/helpers/InventoryHelper.ts index 793a80b1..724e65fb 100644 --- a/project/src/helpers/InventoryHelper.ts +++ b/project/src/helpers/InventoryHelper.ts @@ -325,9 +325,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({ diff --git a/project/src/models/external/HttpFramework.ts b/project/src/models/external/HttpFramework.ts index 36b69531..fa5fc86a 100644 --- a/project/src/models/external/HttpFramework.ts +++ b/project/src/models/external/HttpFramework.ts @@ -28,7 +28,7 @@ export const Listen = (basePath: string) => this.handlers = {}; // Retrieve all handlers - const handlersArray = Base.prototype["handlers"]; + const handlersArray = Base.prototype.handlers; if (!handlersArray) { return; @@ -53,7 +53,7 @@ export const Listen = (basePath: string) => } // 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({ + target.handlers.push({ handlerName: propertyKey, path, httpMethod, 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/http/AkiHttpListener.ts b/project/src/servers/http/AkiHttpListener.ts index ef795e91..cd481fb6 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/InsuranceService.ts b/project/src/services/InsuranceService.ts index 02cc0ea4..5f0f1724 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 6a75cb7f..df610e64 100644 --- a/project/src/services/LocalisationService.ts +++ b/project/src/services/LocalisationService.ts @@ -59,7 +59,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); } /** @@ -69,7 +69,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 690c4b46..9d672128 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -469,9 +469,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"); } } @@ -1024,7 +1024,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) { @@ -1163,11 +1163,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/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index 51d2a73d..6e97737d 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -418,10 +418,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(", "); } } @@ -471,7 +471,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/tests/generators/BotGenerator.test.ts b/project/tests/generators/BotGenerator.test.ts index a6e781de..2072430e 100644 --- a/project/tests/generators/BotGenerator.test.ts +++ b/project/tests/generators/BotGenerator.test.ts @@ -161,8 +161,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: { diff --git a/project/tests/helpers/ItemHelper.test.ts b/project/tests/helpers/ItemHelper.test.ts index e86ae492..ba98a991 100644 --- a/project/tests/helpers/ItemHelper.test.ts +++ b/project/tests/helpers/ItemHelper.test.ts @@ -256,7 +256,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", () => @@ -269,7 +269,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", () => @@ -284,7 +284,7 @@ describe("ItemHelper", () => const fixedItem = itemHelper.fixItemStackCount(initialItem); expect(fixedItem.upd).toBeDefined(); - expect(fixedItem.upd!.StackObjectsCount).toBe(5); + expect(fixedItem.upd?.StackObjectsCount).toBe(5); }); });