diff --git a/project/src/callbacks/GameCallbacks.ts b/project/src/callbacks/GameCallbacks.ts index e333a4fc..a47b1129 100644 --- a/project/src/callbacks/GameCallbacks.ts +++ b/project/src/callbacks/GameCallbacks.ts @@ -76,22 +76,30 @@ class GameCallbacks return this.httpResponse.getBody(this.gameController.getGameConfig(sessionID)); } + /** + * Handle client/server/list + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getServer(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { - return this.httpResponse.getBody(this.gameController.getServer()); + return this.httpResponse.getBody(this.gameController.getServer(sessionID)); } - // Handle client/match/group/current + /** + * Handle client/match/group/current + */ public getCurrentGroup(url: string, info: IEmptyRequestData, sessionID: string): any { return this.httpResponse.getBody(this.gameController.getCurrentGroup(sessionID)); } + /** + * Handle client/checkVersion + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public validateGameVersion(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { - return this.httpResponse.getBody(this.gameController.getValidGameVersion()); + return this.httpResponse.getBody(this.gameController.getValidGameVersion(sessionID)); } /** diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 59c949ab..58b7959b 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -65,6 +65,9 @@ export class GameController this.locationConfig = this.configServer.getConfig(ConfigTypes.LOCATION); } + /** + * Handle client/game/start + */ public gameStart(_url: string, _info: IEmptyRequestData, sessionID: string, startTimeStampMS: number): void { // Store start time in app context @@ -152,36 +155,71 @@ export class GameController } } } - - /** Check for any missing assorts inside each traders assort.json data, checking against traders qeustassort.json */ - protected validateQuestAssortUnlocksExist(): void + + /** + * Handle client/game/config + */ + public getGameConfig(sessionID: string): IGameConfigResponse { - const db = this.databaseServer.getTables(); - const traders = db.traders; - const quests = db.templates.quests; - for (const traderId of Object.values(Traders)) - { - const traderData = traders[traderId]; - const traderAssorts = traderData?.assort; - if (!traderAssorts) - { - continue; - } + const config: IGameConfigResponse = { + languages: this.databaseServer.getTables().locales.languages, + ndaFree: false, + reportAvailable: false, + twitchEventMember: false, + lang: "en", + aid: sessionID, + taxonomy: 6, + activeProfileId: `pmc${sessionID}`, + backend: { + Lobby: this.httpServerHelper.getBackendUrl(), + Trading: this.httpServerHelper.getBackendUrl(), + Messaging: this.httpServerHelper.getBackendUrl(), + Main: this.httpServerHelper.getBackendUrl(), + RagFair: this.httpServerHelper.getBackendUrl() + }, + // eslint-disable-next-line @typescript-eslint/naming-convention + utc_time: new Date().getTime() / 1000, + totalInGame: 1 + }; - // Merge started/success/fail quest assorts into one dictionary - const mergedQuestAssorts = Object.assign({}, traderData.questassort["started"], traderData.questassort["success"], traderData.questassort["fail"]); + return config; + } - // loop over all assorts for trader - for (const [assortKey, questKey] of Object.entries(mergedQuestAssorts)) + /** + * Handle client/server/list + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public getServer(sessionId: string): IServerDetails[] + { + return [ { - // Does assort key exist in trader assort file - if (!traderAssorts.loyal_level_items[assortKey]) - { - // reverse lookup of enum key by value - this.logger.warning(this.localisationService.getText("assort-missing_quest_assort_unlock", {traderName: Object.keys(Traders)[Object.values(Traders).indexOf(traderId)], questName: quests[questKey].QuestName})); - } + ip: this.httpConfig.ip, + port: this.httpConfig.port } - } + ]; + } + + /** + * Handle client/match/group/current + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public getCurrentGroup(sessionId: string): ICurrentGroupResponse + { + return { + squad: [] + }; + } + + /** + * Handle client/checkVersion + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public getValidGameVersion(sessionId: string): ICheckVersionResponse + { + return { + isvalid: true, + latestVersion: this.coreConfig.compatibleTarkovVersion + }; } /** @@ -446,6 +484,39 @@ export class GameController } } + /** + * Check for any missing assorts inside each traders assort.json data, checking against traders qeustassort.json + */ + protected validateQuestAssortUnlocksExist(): void + { + const db = this.databaseServer.getTables(); + const traders = db.traders; + const quests = db.templates.quests; + for (const traderId of Object.values(Traders)) + { + const traderData = traders[traderId]; + const traderAssorts = traderData?.assort; + if (!traderAssorts) + { + continue; + } + + // Merge started/success/fail quest assorts into one dictionary + const mergedQuestAssorts = Object.assign({}, traderData.questassort["started"], traderData.questassort["success"], traderData.questassort["fail"]); + + // 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 + this.logger.warning(this.localisationService.getText("assort-missing_quest_assort_unlock", {traderName: Object.keys(Traders)[Object.values(Traders).indexOf(traderId)], questName: quests[questKey].QuestName})); + } + } + } + } + /** * Add the logged in players name to PMC name pool * @param pmcProfile @@ -513,56 +584,4 @@ export class GameController this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.argv[0])}`); this.logger.debug(`PATH: ${this.encodingUtil.toBase64(process.execPath)}`); } - - public getGameConfig(sessionID: string): IGameConfigResponse - { - const config: IGameConfigResponse = { - languages: this.databaseServer.getTables().locales.languages, - ndaFree: false, - reportAvailable: false, - twitchEventMember: false, - lang: "en", - aid: sessionID, - taxonomy: 6, - activeProfileId: `pmc${sessionID}`, - backend: { - Lobby: this.httpServerHelper.getBackendUrl(), - Trading: this.httpServerHelper.getBackendUrl(), - Messaging: this.httpServerHelper.getBackendUrl(), - Main: this.httpServerHelper.getBackendUrl(), - RagFair: this.httpServerHelper.getBackendUrl() - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - utc_time: new Date().getTime() / 1000, - totalInGame: 1 - }; - - return config; - } - - public getServer(): IServerDetails[] - { - return [ - { - ip: this.httpConfig.ip, - port: this.httpConfig.port - } - ]; - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public getCurrentGroup(sessionId: string): ICurrentGroupResponse - { - return { - squad: [] - }; - } - - public getValidGameVersion(): ICheckVersionResponse - { - return { - isvalid: true, - latestVersion: this.coreConfig.compatibleTarkovVersion - }; - } } \ No newline at end of file diff --git a/project/src/controllers/HealthController.ts b/project/src/controllers/HealthController.ts index 0dd0a0a8..b52ada22 100644 --- a/project/src/controllers/HealthController.ts +++ b/project/src/controllers/HealthController.ts @@ -140,6 +140,7 @@ export class HealthController } /** + * Handle RestoreHealth event * Occurs on post-raid healing page * @param pmcData player profile * @param healthTreatmentRequest Request data from client @@ -150,7 +151,7 @@ export class HealthController { let output = this.eventOutputHolder.getOutput(sessionID); const payMoneyRequest: IProcessBuyTradeRequestData = { - Action: "RestoreHealth", + Action: healthTreatmentRequest.Action, tid: Traders.THERAPIST, // eslint-disable-next-line @typescript-eslint/naming-convention scheme_items: healthTreatmentRequest.items,