From d2c2a39075a168d53b072e041860cead4c3fb803 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 15 Jul 2023 10:56:00 +0100 Subject: [PATCH] Add comments + improve comment consistency --- project/src/callbacks/BundleCallbacks.ts | 3 ++ .../src/callbacks/CustomizationCallbacks.ts | 12 ++++-- project/src/callbacks/DataCallbacks.ts | 25 +++++++++--- project/src/callbacks/DialogueCallbacks.ts | 11 +++-- project/src/callbacks/InsuranceCallbacks.ts | 2 +- project/src/callbacks/ProfileCallbacks.ts | 40 +++++++++++-------- project/src/callbacks/QuestCallbacks.ts | 19 +++++++-- .../controllers/CustomizationController.ts | 11 +++-- project/src/controllers/DialogueController.ts | 10 +++++ .../src/controllers/InsuranceController.ts | 2 + 10 files changed, 97 insertions(+), 38 deletions(-) diff --git a/project/src/callbacks/BundleCallbacks.ts b/project/src/callbacks/BundleCallbacks.ts index 742e93b1..f5d2d9c9 100644 --- a/project/src/callbacks/BundleCallbacks.ts +++ b/project/src/callbacks/BundleCallbacks.ts @@ -36,6 +36,9 @@ export class BundleCallbacks this.httpFileUtil.sendFile(resp, bundle.path); } + /** + * Handle singleplayer/bundles + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getBundles(url: string, info: any, sessionID: string): string { diff --git a/project/src/callbacks/CustomizationCallbacks.ts b/project/src/callbacks/CustomizationCallbacks.ts index 6cad85b9..06698b91 100644 --- a/project/src/callbacks/CustomizationCallbacks.ts +++ b/project/src/callbacks/CustomizationCallbacks.ts @@ -23,8 +23,8 @@ export class CustomizationCallbacks { } /** - * Handles client/trading/customization/storage - * @returns + * Handle client/trading/customization/storage + * @returns IGetSuitsResponse */ public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { @@ -36,7 +36,7 @@ export class CustomizationCallbacks } /** - * Handles client/trading/customization + * Handle client/trading/customization * @returns ISuit[] */ public getTraderSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData @@ -47,11 +47,17 @@ export class CustomizationCallbacks return this.httpResponse.getBody(this.customizationController.getTraderSuits(traderID, sessionID)); } + /** + * Handle CustomizationWear event + */ public wearClothing(pmcData: IPmcData, body: IWearClothingRequestData, sessionID: string): IItemEventRouterResponse { return this.customizationController.wearClothing(pmcData, body, sessionID); } + /** + * Handle CustomizationBuy event + */ public buyClothing(pmcData: IPmcData, body: IBuyClothingRequestData, sessionID: string): IItemEventRouterResponse { return this.customizationController.buyClothing(pmcData, body, sessionID); diff --git a/project/src/callbacks/DataCallbacks.ts b/project/src/callbacks/DataCallbacks.ts index c45976ba..ac7164b4 100644 --- a/project/src/callbacks/DataCallbacks.ts +++ b/project/src/callbacks/DataCallbacks.ts @@ -33,7 +33,7 @@ export class DataCallbacks { } /** - * Handles client/settings + * Handle client/settings * @returns ISettingsBase */ // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -43,7 +43,7 @@ export class DataCallbacks } /** - * Handles client/globals + * Handle client/globals * @returns IGlobals */ // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -54,7 +54,7 @@ export class DataCallbacks } /** - * Handles client/items + * Handle client/items * @returns string */ // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -64,7 +64,7 @@ export class DataCallbacks } /** - * Handles client/handbook/templates + * Handle client/handbook/templates * @returns IHandbookBase */ // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -74,7 +74,7 @@ export class DataCallbacks } /** - * Handles client/customization + * Handle client/customization * @returns Record { @@ -123,18 +127,27 @@ export class DataCallbacks return this.httpResponse.getBody(this.databaseServer.getTables().hideout.scavcase); } + /** + * Handle client/languages + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getLocalesLanguages(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData> { return this.httpResponse.getBody(this.databaseServer.getTables().locales.languages); } + /** + * Handle client/menu/locale + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getLocalesMenu(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { return this.httpResponse.getBody(this.databaseServer.getTables().locales.menu[url.replace("/client/menu/locale/", "")]); } + /** + * Handle client/locale + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getLocalesGlobal(url: string, info: IEmptyRequestData, sessionID: string): string { diff --git a/project/src/callbacks/DialogueCallbacks.ts b/project/src/callbacks/DialogueCallbacks.ts index f5f42f46..0dfc6487 100644 --- a/project/src/callbacks/DialogueCallbacks.ts +++ b/project/src/callbacks/DialogueCallbacks.ts @@ -44,7 +44,7 @@ export class DialogueCallbacks implements OnUpdate } /** - * Handles client/friend/list + * Handle client/friend/list * @returns IGetFriendListDataResponse */ public getFriendList(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData @@ -53,8 +53,8 @@ export class DialogueCallbacks implements OnUpdate } /** - * Handles client/chatServer/list - * @returns + * Handle client/chatServer/list + * @returns IChatServer[] */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getChatServerList(url: string, info: IGetChatServerListRequestData, sessionID: string): IGetBodyResponseData @@ -106,18 +106,21 @@ export class DialogueCallbacks implements OnUpdate return this.httpResponse.emptyArrayResponse(); } + /** Handle client/mail/dialog/pin */ public pinDialog(url: string, info: IPinDialogRequestData, sessionID: string): IGetBodyResponseData { this.dialogueController.setDialoguePin(info.dialogId, true, sessionID); return this.httpResponse.emptyArrayResponse(); } + /** Handle client/mail/dialog/unpin */ public unpinDialog(url: string, info: IPinDialogRequestData, sessionID: string): IGetBodyResponseData { this.dialogueController.setDialoguePin(info.dialogId, false, sessionID); return this.httpResponse.emptyArrayResponse(); } + /** Handle client/mail/dialog/read */ public setRead(url: string, info: ISetDialogReadRequestData, sessionID: string): IGetBodyResponseData { this.dialogueController.setRead(info.dialogs, sessionID); @@ -125,7 +128,7 @@ export class DialogueCallbacks implements OnUpdate } /** - * Handles client/mail/dialog/getAllAttachments + * Handle client/mail/dialog/getAllAttachments * @returns IGetAllAttachmentsResponse */ public getAllAttachments(url: string, info: IGetAllAttachmentsRequestData, sessionID: string): IGetBodyResponseData diff --git a/project/src/callbacks/InsuranceCallbacks.ts b/project/src/callbacks/InsuranceCallbacks.ts index 2f2a29a9..4ce40a71 100644 --- a/project/src/callbacks/InsuranceCallbacks.ts +++ b/project/src/callbacks/InsuranceCallbacks.ts @@ -40,7 +40,7 @@ export class InsuranceCallbacks implements OnUpdate } /** - * Handle Insure + * Handle Insure event * @returns IItemEventRouterResponse */ public insure(pmcData: IPmcData, body: IInsureRequestData, sessionID: string): IItemEventRouterResponse diff --git a/project/src/callbacks/ProfileCallbacks.ts b/project/src/callbacks/ProfileCallbacks.ts index 8d0ccab0..f3af52e3 100644 --- a/project/src/callbacks/ProfileCallbacks.ts +++ b/project/src/callbacks/ProfileCallbacks.ts @@ -31,6 +31,9 @@ export class ProfileCallbacks @inject("ProfileController") protected profileController: ProfileController) { } + /** + * Handle client/game/profile/create + */ public createProfile(url: string, info: IProfileCreateRequestData, sessionID: string): IGetBodyResponseData { this.profileController.createProfile(info, sessionID); @@ -38,11 +41,8 @@ export class ProfileCallbacks } /** + * Handle client/game/profile/list * Get the complete player profile (scav + pmc character) - * @param url - * @param info Empty - * @param sessionID Session id - * @returns Profile object */ public getProfileData(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { @@ -50,6 +50,7 @@ export class ProfileCallbacks } /** + * Handle client/game/profile/savage/regenerate * Handle the creation of a scav profile for player * Occurs post-raid and when profile first created immediately after character details are confirmed by player * @param url @@ -64,10 +65,6 @@ export class ProfileCallbacks /** * Handle client/game/profile/voice/change event - * @param url - * @param info Change voice request object - * @param sessionID Session id - * @returns Client response */ public changeVoice(url: string, info: IProfileChangeVoiceRequestData, sessionID: string): INullResponseData { @@ -78,10 +75,6 @@ export class ProfileCallbacks /** * Handle client/game/profile/nickname/change event * Client allows player to adjust their profile name - * @param url - * @param info Change nickname request object - * @param sessionID Session id - * @returns client response */ public changeNickname(url: string, info: IProfileChangeNicknameRequestData, sessionID: string): IGetBodyResponseData { @@ -103,6 +96,9 @@ export class ProfileCallbacks }); } + /** + * Handle client/game/profile/nickname/validate + */ public validateNickname(url: string, info: IValidateNicknameRequestData, sessionID: string): IGetBodyResponseData { const output = this.profileController.validateNickname(info, sessionID); @@ -120,6 +116,9 @@ export class ProfileCallbacks return this.httpResponse.getBody({ "status": "ok" }); } + /** + * Handle client/game/profile/nickname/reserved + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getReservedNickname(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { @@ -127,11 +126,8 @@ export class ProfileCallbacks } /** + * Handle client/profile/status * Called when creating a character when choosing a character face/voice - * @param url - * @param info response (empty) - * @param sessionID - * @returns */ public getProfileStatus(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { @@ -166,22 +162,34 @@ export class ProfileCallbacks return this.httpResponse.getBody(response); } + /** + * Handle client/profile/settings + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getProfileSettings(url: string, info: IGetProfileSettingsRequest, sessionId: string): IGetBodyResponseData { return this.httpResponse.emptyResponse(); } + /** + * Handle client/game/profile/search + */ public searchFriend(url: string, info: ISearchFriendRequestData, sessionID: string): IGetBodyResponseData { return this.httpResponse.getBody(this.profileController.getFriends(info, sessionID)); } + /** + * Handle launcher/profile/info + */ public getMiniProfile(url: string, info: IGetMiniProfileRequestData, sessionID: string): string { return this.httpResponse.noBody(this.profileController.getMiniProfile(sessionID)); } + /** + * Handle /launcher/profiles + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getAllMiniProfiles(url: string, info: any, sessionID: string): string { diff --git a/project/src/callbacks/QuestCallbacks.ts b/project/src/callbacks/QuestCallbacks.ts index bba9753f..fc49cf45 100644 --- a/project/src/callbacks/QuestCallbacks.ts +++ b/project/src/callbacks/QuestCallbacks.ts @@ -24,11 +24,17 @@ export class QuestCallbacks @inject("RepeatableQuestController") protected repeatableQuestController: RepeatableQuestController) { } + /** + * Handle RepeatableQuestChange event + */ public changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse { return this.repeatableQuestController.changeRepeatableQuest(pmcData, body, sessionID); } + /** + * Handle QuestAccept event + */ public acceptQuest(pmcData: IPmcData, body: IAcceptQuestRequestData, sessionID: string): IItemEventRouterResponse { if (body.type === "repeatable") @@ -39,11 +45,17 @@ export class QuestCallbacks return this.questController.acceptQuest(pmcData, body, sessionID); } + /** + * Handle QuestComplete event + */ public completeQuest(pmcData: IPmcData, body: ICompleteQuestRequestData, sessionID: string): IItemEventRouterResponse { return this.questController.completeQuest(pmcData, body, sessionID); } + /** + * Handle QuestHandover event + */ public handoverQuest(pmcData: IPmcData, body: IHandoverQuestRequestData, sessionID: string): IItemEventRouterResponse { return this.questController.handoverQuest(pmcData, body, sessionID); @@ -51,16 +63,15 @@ export class QuestCallbacks /** * Handle client/quest/list - * @param url - * @param info - * @param sessionID - * @returns */ public listQuests(url: string, info: IListQuestsRequestData, sessionID: string): IGetBodyResponseData { return this.httpResponse.getBody(this.questController.getClientQuests(sessionID)); } + /** + * Handle client/repeatalbeQuests/activityPeriods + */ public activityPeriods(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { return this.httpResponse.getBody(this.repeatableQuestController.getClientRepeatableQuests(info, sessionID)); diff --git a/project/src/controllers/CustomizationController.ts b/project/src/controllers/CustomizationController.ts index 5c53ce13..963dafc2 100644 --- a/project/src/controllers/CustomizationController.ts +++ b/project/src/controllers/CustomizationController.ts @@ -51,7 +51,10 @@ export class CustomizationController return matchingSuits.filter(x => templates[x.suiteId]._props.Side.includes(pmcData.Info.Side)); } - /** Equip one to many clothing items to player */ + /** + * Handle CustomizationWear event + * Equip one to many clothing items to player + */ public wearClothing(pmcData: IPmcData, wearClothingRequest: IWearClothingRequestData, sessionID: string): IItemEventRouterResponse { for (const suitId of wearClothingRequest.suites) @@ -77,6 +80,7 @@ export class CustomizationController } /** + * Handle CustomizationBuy event * Purchase/unlock a clothing item from a trader * @param pmcData Player profile * @param buyClothingRequest Request object @@ -122,8 +126,8 @@ export class CustomizationController /** * Has an outfit been purchased by a player * @param suitId clothing id - * @param sessionID Session id - * @returns true if purchased already + * @param sessionID Session id of profile to check for clothing in + * @returns true if already purchased */ protected outfitAlreadyPurchased(suitId: string, sessionID: string): boolean { @@ -151,7 +155,6 @@ export class CustomizationController * @param pmcData Player profile * @param clothingItem Clothing item purchased * @param output Client response - * @returns */ protected payForClothingItem(sessionId: string, pmcData: IPmcData, clothingItem: ClothingItem, output: IItemEventRouterResponse): void { diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index dd81d382..7f900efd 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -21,6 +21,7 @@ export class DialogueController ) { } + /** Handle onUpdate spt event */ public update(): void { const profiles = this.saveServer.getProfiles(); @@ -30,6 +31,10 @@ export class DialogueController } } + /** + * Handle client/friend/list + * @returns IGetFriendListDataResponse + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars public getFriendList(sessionID: string): IGetFriendListDataResponse { @@ -41,6 +46,7 @@ export class DialogueController } /** + * Handle client/mail/dialog/list * Create array holding trader dialogs and mail interactions with player * Set the content of the dialogue on the list tab. * @param sessionID Session Id @@ -81,6 +87,7 @@ export class DialogueController } /** + * Handle client/mail/dialog/view * Handle player clicking 'messenger' and seeing all the messages they've recieved * Set the content of the dialogue on the details panel, showing all the messages * for the specified dialogue. @@ -156,6 +163,7 @@ export class DialogueController return messages.some(x => x.items?.data?.length > 0); } + /** Handle client/mail/dialog/remove */ public removeDialogue(dialogueID: string, sessionID: string): void { delete this.saveServer.getProfile(sessionID).dialogues[dialogueID]; @@ -166,6 +174,7 @@ export class DialogueController this.saveServer.getProfile(sessionID).dialogues[dialogueID].pinned = shouldPin; } + /** Handle client/mail/dialog/read */ public setRead(dialogueIDs: string[], sessionID: string): void { const dialogueData = this.saveServer.getProfile(sessionID).dialogues; @@ -177,6 +186,7 @@ export class DialogueController } /** + * Handle client/mail/dialog/getAllAttachments * Get all uncollected items attached to mail in a particular dialog * @param dialogueID Dialog to get mail attachments from * @param sessionID Session id diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index b901d160..cfa27348 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -146,6 +146,7 @@ export class InsuranceController } /** + * Handle Insure event * Add insurance to an item * @param pmcData Player profile * @param body Insurance request @@ -205,6 +206,7 @@ export class InsuranceController } /** + * Handle client/insurance/items/list/cost * Calculate insurance cost * @param info request object * @param sessionID session id