From 5fa8803f8c5d82854a10016328610e404ffd3f61 Mon Sep 17 00:00:00 2001 From: Refringe Date: Fri, 10 Nov 2023 15:23:51 -0500 Subject: [PATCH] Auto-formatting for context classes. --- project/src/context/ApplicationContext.ts | 37 ++++++++++++---------- project/src/context/ContextVariable.ts | 2 +- project/src/context/ContextVariableType.ts | 18 ++++------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/project/src/context/ApplicationContext.ts b/project/src/context/ApplicationContext.ts index bd8dc12f..28850cd5 100644 --- a/project/src/context/ApplicationContext.ts +++ b/project/src/context/ApplicationContext.ts @@ -5,29 +5,29 @@ import { ContextVariableType } from "@spt-aki/context/ContextVariableType"; import { LinkedList } from "@spt-aki/utils/collections/lists/LinkedList"; @injectable() -export class ApplicationContext +export class ApplicationContext { private variables = new Map>(); private static holderMaxSize = 10; /** - * Called like: - * - * const registerPlayerInfo = this.applicationContext.getLatestValue(ContextVariableType.REGISTER_PLAYER_REQUEST).getValue(); - * - * const activePlayerSessionId = this.applicationContext.getLatestValue(ContextVariableType.SESSION_ID).getValue(); - * - * const matchInfo = this.applicationContext.getLatestValue(ContextVariableType.MATCH_INFO).getValue(); - * @param type - * @returns + * @examples + * + * const registerPlayerInfo = this.applicationContext.getLatestValue(ContextVariableType.REGISTER_PLAYER_REQUEST) + * .getValue(); + * + * const activePlayerSessionId = this.applicationContext.getLatestValue(ContextVariableType.SESSION_ID) + * .getValue(); + * + * const matchInfo = this.applicationContext.getLatestValue(ContextVariableType.MATCH_INFO) + * .getValue(); */ - public getLatestValue(type: ContextVariableType): ContextVariable + public getLatestValue(type: ContextVariableType): ContextVariable { - if (this.variables.has(type)) + if (this.variables.has(type)) { return this.variables.get(type)?.getTail()?.getValue(); } - return undefined; } @@ -37,22 +37,27 @@ export class ApplicationContext { return this.variables.get(type).toList(); } - return undefined; } - public addValue(type: ContextVariableType, value: any): void + public addValue(type: ContextVariableType, value: any): void { let list: LinkedList; if (this.variables.has(type)) + { list = this.variables.get(type); + } else + { list = new LinkedList(); + } if (list.getSize() >= ApplicationContext.holderMaxSize) + { list.removeFirst(); + } list.add(new ContextVariable(value, type)); this.variables.set(type, list); } -} \ No newline at end of file +} diff --git a/project/src/context/ContextVariable.ts b/project/src/context/ContextVariable.ts index 8abc00d7..9dd5755d 100644 --- a/project/src/context/ContextVariable.ts +++ b/project/src/context/ContextVariable.ts @@ -27,4 +27,4 @@ export class ContextVariable { return this.type; } -} \ No newline at end of file +} diff --git a/project/src/context/ContextVariableType.ts b/project/src/context/ContextVariableType.ts index 86fea151..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 = 0, - /** Currently acive raid information */ - RAID_CONFIGURATION = 1, - /** Timestamp when client first connected */ - CLIENT_START_TIMESTAMP = 2, - /** When player is loading into map and loot is requested */ - REGISTER_PLAYER_REQUEST = 3 -} \ No newline at end of file +export enum ContextVariableType +{ + 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 +}