Favours dot object notation whenever possible.
This commit is contained in:
parent
e709b6c111
commit
ce45862e75
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
}),
|
||||
);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)})`;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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({
|
||||
|
10
project/src/models/external/HttpFramework.ts
vendored
10
project/src/models/external/HttpFramework.ts
vendored
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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: {
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user