From 7ec5d8960837050056a6c690258a6b4598c0a291 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 26 Feb 2024 23:51:45 +0000 Subject: [PATCH] Add ability to insert stash rows to profile --- .../helpers/Dialogue/SptDialogueChatBot.ts | 11 +++++++++ project/src/helpers/ProfileHelper.ts | 24 +++++++++++++++++++ project/src/models/enums/BonusType.ts | 1 + 3 files changed, 36 insertions(+) diff --git a/project/src/helpers/Dialogue/SptDialogueChatBot.ts b/project/src/helpers/Dialogue/SptDialogueChatBot.ts index 93d8de69..34036ee0 100644 --- a/project/src/helpers/Dialogue/SptDialogueChatBot.ts +++ b/project/src/helpers/Dialogue/SptDialogueChatBot.ts @@ -162,6 +162,17 @@ export class SptDialogueChatBot implements IDialogueChatBot ); } + if (request.text.toLowerCase() === "givemespace") + { + this.profileHelper.addStashRowsBonusToProfile(sessionId, 2); + + this.mailSendService.sendUserMessageToPlayer( + sessionId, + sptFriendUser, + this.randomUtil.getArrayValue(["Added 2 rows to stash, please restart your game to see them"]), + ); + } + return request.dialogId; } } diff --git a/project/src/helpers/ProfileHelper.ts b/project/src/helpers/ProfileHelper.ts index 3e1b6ac3..5142b2cb 100644 --- a/project/src/helpers/ProfileHelper.ts +++ b/project/src/helpers/ProfileHelper.ts @@ -6,12 +6,14 @@ import { Common, CounterKeyValue, Stats } from "@spt-aki/models/eft/common/table import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IValidateNicknameRequestData } from "@spt-aki/models/eft/profile/IValidateNicknameRequestData"; import { AccountTypes } from "@spt-aki/models/enums/AccountTypes"; +import { BonusType } from "@spt-aki/models/enums/BonusType"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { SaveServer } from "@spt-aki/servers/SaveServer"; import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { ProfileSnapshotService } from "@spt-aki/services/ProfileSnapshotService"; +import { HashUtil } from "@spt-aki/utils/HashUtil"; import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; import { Watermark } from "@spt-aki/utils/Watermark"; @@ -22,6 +24,7 @@ export class ProfileHelper constructor( @inject("WinstonLogger") protected logger: ILogger, @inject("JsonUtil") protected jsonUtil: JsonUtil, + @inject("HashUtil") protected hashUtil: HashUtil, @inject("Watermark") protected watermark: Watermark, @inject("TimeUtil") protected timeUtil: TimeUtil, @inject("SaveServer") protected saveServer: SaveServer, @@ -453,4 +456,25 @@ export class ProfileHelper { return this.getFullProfile(sessionID).info.edition.toLowerCase().startsWith(AccountTypes.SPT_DEVELOPER); } + + public addStashRowsBonusToProfile(sessionId: string, rowsToAdd: number): void + { + const profile = this.getPmcProfile(sessionId); + const existingBonus = profile.Bonuses.find((bonus) => bonus.type === BonusType.STASH_ROWS); + if (!existingBonus) + { + profile.Bonuses.push({ + id: this.hashUtil.generate(), + value: rowsToAdd, + type: BonusType.STASH_ROWS, + passive: true, + visible: true, + production: false, + }); + } + else + { + existingBonus.value += rowsToAdd; + } + } } diff --git a/project/src/models/enums/BonusType.ts b/project/src/models/enums/BonusType.ts index 4bab5a04..20a59a2e 100644 --- a/project/src/models/enums/BonusType.ts +++ b/project/src/models/enums/BonusType.ts @@ -30,4 +30,5 @@ export enum BonusType MAXIMUM_ENERGY_RESERVE = "MaximumEnergyReserve", TEXT_BONUS = "TextBonus", SKILL_GROUP_LEVELING_BOOST = "SkillGroupLevelingBoost", + STASH_ROWS = "StashRows", }