Expanded gift system used by spt bot

Gifts can be given multiple times
stash expansions are limited to 5 max by default
dev balaclava can be given 5 times, majority of gifts are 1 use still

Updated data structure to persist gifts received, this will break profiles
This commit is contained in:
Dev 2024-06-08 17:54:05 +01:00
parent f475d4f6f3
commit 75a34f5ca2
9 changed files with 158 additions and 69 deletions

View File

@ -26,7 +26,10 @@
"commandoEnabled": true,
"commandoFeatures": {
"giveCommandEnabled": true
}
},
"commandUseLimits": {
"StashRows": 5
}
}
},
"customWatermarkLocaleKeys": []

View File

@ -219,7 +219,8 @@
"parentId": "658efad286f149afb701c2cc",
"slotId": "Helmet_back"
}
]
],
"maxToSendPlayer": 1
},
"NewYear2021": {
"sender": "System",
@ -447,7 +448,8 @@
"parentId": "64b4473f3b4c4dd8cdf9999",
"slotId": "mod_charge"
}
]
],
"maxToSendPlayer": 1
},
"Christmas2022": {
"items": [
@ -501,7 +503,8 @@
"messageText": "Merry christmas!",
"timestampToSend": 42069,
"associatedEvent": "Christmas",
"collectionTimeHours": 48
"collectionTimeHours": 48,
"maxToSendPlayer": 1
},
"1CLICKDRESSUP": {
"items": [
@ -665,7 +668,8 @@
"messageText": "1CLICKDRESSUP",
"timestampToSend": 42069,
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"BARMALEY": {
"items": [
@ -826,7 +830,8 @@
"messageText": "BARMALEY",
"timestampToSend": 42069,
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"S00NS00N": {
"items": [
@ -907,7 +912,8 @@
"messageText": "S00NS00N",
"timestampToSend": 42069,
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"TRAMBON": {
"items": [
@ -1084,7 +1090,8 @@
"messageText": "TRAMBON",
"timestampToSend": 42069,
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"PINEWOOD": {
"items": [
@ -1173,7 +1180,8 @@
"messageText": "PINEWOOD",
"timestampToSend": 42069,
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"HESOYAM": {
"items": [
@ -1190,7 +1198,8 @@
"sender": "System",
"messageText": "HESOYAM",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"PraporGiftDay1": {
"items": [
@ -1225,7 +1234,8 @@
"sender": "Trader",
"trader": "PRAPOR",
"localeTextId": "5fd4c8b59e4b2a58b34bbd28 0",
"collectionTimeHours": 48
"collectionTimeHours": 48,
"maxToSendPlayer": 1
},
"PraporGiftDay2": {
"items": [
@ -1260,7 +1270,8 @@
"sender": "Trader",
"trader": "PRAPOR",
"localeTextId": "5fd4c8d49e4b2a58b34bbd29 0",
"collectionTimeHours": 48
"collectionTimeHours": 48,
"maxToSendPlayer": 1
},
"KAPPA4U": {
"items": [
@ -1277,7 +1288,8 @@
"sender": "System",
"messageText": "Easy Kappa",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"ENDOFWIPE": {
"items": [
@ -1303,7 +1315,8 @@
"sender": "System",
"localeTextId": "626e5d63bc92c87fd22a943f 0",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"IAMADIRTYLITTLEGOBLIN": {
"items": [
@ -1320,7 +1333,8 @@
"sender": "System",
"messageText": "You dirty little cheating goblin",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 5
},
"CHOMP": {
"items": [
@ -1337,7 +1351,8 @@
"sender": "System",
"messageText": "caw caw",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"CWX": {
"items": [
@ -1354,7 +1369,8 @@
"sender": "System",
"messageText": "un oh stinky",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"VALENS": {
"items": [
@ -1494,7 +1510,8 @@
"sender": "System",
"messageText": "It's time to pew pew.",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"TERKOIZ": {
"items": [
@ -1511,7 +1528,8 @@
"sender": "System",
"messageText": "Out of the way, i'm a motorist",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"WAFFLE": {
"items": [
@ -1537,7 +1555,8 @@
"sender": "System",
"messageText": "JONKLER NO",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"NIGHTWING": {
"items": [
@ -1563,7 +1582,9 @@
"sender": "System",
"messageText": "JONKLER NO",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendToPlayer": 1,
"maxToSendPlayer": 1
},
"BSGBIRTHDAY2023": {
"sender": "System",
@ -1709,7 +1730,8 @@
"parentId": "652a6f5c35258f985804aa0b",
"slotId": "main"
}
]
],
"maxToSendPlayer": 1
},
"GROUNDZERO": {
"items": [
@ -1722,7 +1744,8 @@
"sender": "System",
"messageText": "GROUNDZERO",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"IAMMIGHTY": {
"items": [
@ -1962,7 +1985,8 @@
"sender": "System",
"messageText": "IAMMIGHTY",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"ARMORPLATES": {
"items": [
@ -2096,7 +2120,8 @@
"sender": "System",
"messageText": "ARMORPLATES",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"RICHANDEXPENSIVE": {
"items": [
@ -2164,7 +2189,8 @@
"sender": "System",
"messageText": "RICHANDEXPENSIVE",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"LEFTHANDHEADEYES": {
"items": [
@ -2190,7 +2216,8 @@
"sender": "System",
"messageText": "LEFTHANDHEADEYES",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"EDITPROFILE": {
"items": [
@ -2612,7 +2639,8 @@
"sender": "System",
"localeTextId": "5a2d28f786f77436023be4a5 0",
"collectionTimeHours": 72,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"TWITCHNEWYEARS2023": {
"items": [
@ -3026,7 +3054,8 @@
"sender": "System",
"localeTextId": "5e0653ba86f774478f700632 3",
"collectionTimeHours": 72,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"LUNARNEWYEAR2024": {
"items": [
@ -3219,7 +3248,8 @@
"sender": "System",
"associatedEvent": "Promo",
"collectionTimeHours": 72,
"messageText": "<ch>Thank you for activating the code.</ch><cz>Thank you for activating the code.</cz><en>Thank you for activating the code.</en><fr>Thank you for activating the code.</fr><ge>Thank you for activating the code.</ge><hu>Thank you for activating the code.</hu><it>Thank you for activating the code.</it><jp>Thank you for activating the code.</jp><kr>Thank you for activating the code.</kr><pl>Thank you for activating the code.</pl><po>Thank you for activating the code.</po><sk>Thank you for activating the code.</sk><es>Thank you for activating the code.</es><es-mx>Thank you for activating the code.</es-mx><tu>Thank you for activating the code.</tu><ru>Thank you for activating the code.</ru><ro>Thank you for activating the code.</ro>"
"messageText": "<ch>Thank you for activating the code.</ch><cz>Thank you for activating the code.</cz><en>Thank you for activating the code.</en><fr>Thank you for activating the code.</fr><ge>Thank you for activating the code.</ge><hu>Thank you for activating the code.</hu><it>Thank you for activating the code.</it><jp>Thank you for activating the code.</jp><kr>Thank you for activating the code.</kr><pl>Thank you for activating the code.</pl><po>Thank you for activating the code.</po><sk>Thank you for activating the code.</sk><es>Thank you for activating the code.</es><es-mx>Thank you for activating the code.</es-mx><tu>Thank you for activating the code.</tu><ru>Thank you for activating the code.</ru><ro>Thank you for activating the code.</ro>",
"maxToSendPlayer": 1
},
"ETSREWARD": {
"items": [
@ -3466,7 +3496,8 @@
"sender": "System",
"associatedEvent": "Promo",
"collectionTimeHours": 72,
"messageText": "<ch>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</ch><cz>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</cz><en>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</en><fr>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</fr><ge>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</ge><hu>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</hu><it>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</it><jp>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</jp><kr>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</kr><pl>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</pl><po>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</po><sk>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</sk><es>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</es><es-mx>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</es-mx><tu>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</tu><ru>Привет, боец. Слыхал, ты местным работягам активно помогал, проверял всё на прочность, так сказать. Это дело правильное, молодец, вояка. Ребята сверху тебе за это подарочек передали в знак благодарности. Продолжай в том же духе!</ru><ro>Promo code is activated</ro>"
"messageText": "<ch>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</ch><cz>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</cz><en>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</en><fr>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</fr><ge>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</ge><hu>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</hu><it>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</it><jp>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</jp><kr>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</kr><pl>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</pl><po>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</po><sk>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</sk><es>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</es><es-mx>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</es-mx><tu>Greetings, warrior. I've heard you've been helping out our local hard workers with their stuff, testing everything out, so to speak. That's a good deed, soldier, great job. The higher-ups sent you a little present as a token of gratitude. Keep it up!</tu><ru>Привет, боец. Слыхал, ты местным работягам активно помогал, проверял всё на прочность, так сказать. Это дело правильное, молодец, вояка. Ребята сверху тебе за это подарочек передали в знак благодарности. Продолжай в том же духе!</ru><ro>Promo code is activated</ro>",
"maxToSendPlayer": 1
},
"KONTOROVICH": {
"items": [
@ -3662,7 +3693,8 @@
"sender": "System",
"associatedEvent": "Promo",
"collectionTimeHours": 72,
"messageText": "Thank you for purchasing of the first book in EFT series by A, Kontorovich. We are glad to give you this theme package with ingame items."
"messageText": "Thank you for purchasing of the first book in EFT series by A, Kontorovich. We are glad to give you this theme package with ingame items.",
"maxToSendPlayer": 1
},
"UNHEARD": {
"items": [
@ -3679,7 +3711,8 @@
"sender": "System",
"messageText": "Have a nice 20 minute adventure in the blatant plagiarist game. In and out",
"collectionTimeHours": 72,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"TOURNAMENTGIFT": {
"items": [{
@ -5440,7 +5473,8 @@
"value": 1,
"entity": "5c0647fdd443bc2504c2d371"
}
]
],
"maxToSendPlayer": 1
},
"HIDEOUTCAT": {
"items": [
@ -5457,7 +5491,8 @@
"sender": "System",
"associatedEvent": "Promo",
"collectionTimeHours": 72,
"messageText": "Hideout cat."
"messageText": "Hideout cat.",
"maxToSendPlayer": 1
},
"KILLA": {
"items": [{
@ -5481,7 +5516,8 @@
"sender": "System",
"messageText": "TarkovTV May 2024 gift",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"BITCOIN": {
"items": [{
@ -5709,7 +5745,8 @@
"sender": "System",
"messageText": "TarkovTV May 2024 gift",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"GROUNDZERO2": {
"items": [{
@ -5865,7 +5902,8 @@
"sender": "System",
"messageText": "TarkovTV May 2024 gift",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"OBDOLBOS": {
"items": [{
@ -6001,7 +6039,8 @@
"sender": "System",
"messageText": "TarkovTV May 2024 gift",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
},
"THICC": {
"items": [{
@ -6136,7 +6175,8 @@
"sender": "System",
"messageText": "TarkovTV May 2024 gift",
"collectionTimeHours": 48,
"associatedEvent": "Promo"
"associatedEvent": "Promo",
"maxToSendPlayer": 1
}
}
}

View File

@ -59,6 +59,8 @@ export class SptDialogueChatBot implements IDialogueChatBot
const giftSent = this.giftService.sendGiftToPlayer(sessionId, request.text);
const requestInput = request.text.toLowerCase();
if (giftSent === GiftSentResult.SUCCESS)
{
this.mailSendService.sendUserMessageToPlayer(
@ -85,7 +87,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
return;
}
if (request.text.toLowerCase().includes("love you"))
if (requestInput.includes("love you"))
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
@ -99,7 +101,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
);
}
if (request.text.toLowerCase() === "spt")
if (requestInput === "spt")
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
@ -108,7 +110,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
);
}
if (["hello", "hi", "sup", "yo", "hey"].includes(request.text.toLowerCase()))
if (["hello", "hi", "sup", "yo", "hey"].includes(requestInput))
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
@ -128,7 +130,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
);
}
if (request.text.toLowerCase() === "nikita")
if (requestInput === "nikita")
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
@ -137,12 +139,12 @@ export class SptDialogueChatBot implements IDialogueChatBot
"I know that guy!",
"Cool guy, he made EFT!",
"Legend",
"Remember when he said webel-webel-webel-webel, classic nikita moment",
"Remember when he said webel-webel-webel-webel, classic Nikita moment",
]),
);
}
if (request.text.toLowerCase() === "are you a bot")
if (requestInput === "are you a bot")
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
@ -151,7 +153,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
);
}
if (request.text.toLowerCase() === "itsonlysnowalan")
if (requestInput === "itsonlysnowalan")
{
this.weatherConfig.overrideSeason = Season.WINTER;
@ -162,15 +164,34 @@ export class SptDialogueChatBot implements IDialogueChatBot
);
}
if (request.text.toLowerCase() === "givemespace")
if (requestInput === "givemespace")
{
this.profileHelper.addStashRowsBonusToProfile(sessionId, 2);
const stashRowGiftId = "StashRows";
if (
this.profileHelper.playerHasRecievedMaxNumberOfGift(sessionId, stashRowGiftId))
{
this.mailSendService.sendUserMessageToPlayer(
sessionId,
sptFriendUser,
"You cannot accept any more of this gift",
);
}
else
{
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"]),
);
this.mailSendService.sendUserMessageToPlayer(
sessionId,
sptFriendUser,
this.randomUtil.getArrayValue(["Added 2 rows to stash, please restart your game to see them"]),
);
this.profileHelper.flagGiftReceivedInProfile(
sessionId,
stashRowGiftId,
this.coreConfig.features.chatbotFeatures.commandUseLimits[stashRowGiftId],
);
}
}
return request.dialogId;

View File

@ -367,17 +367,32 @@ export class ProfileHelper
* Store giftid in profile spt object
* @param playerId Player to add gift flag to
* @param giftId Gift player received
* @param maxCount Limit of how many of this gift a player can have
*/
public addGiftReceivedFlagToProfile(playerId: string, giftId: string): void
public flagGiftReceivedInProfile(playerId: string, giftId: string, maxCount: number): void
{
const profileToUpdate = this.getFullProfile(playerId);
const giftHistory = profileToUpdate.spt.receivedGifts;
if (!giftHistory)
{
profileToUpdate.spt.receivedGifts = [];
}
profileToUpdate.spt.receivedGifts.push({ giftId: giftId, timestampAccepted: this.timeUtil.getTimestamp() });
// nullguard receivedGifts
profileToUpdate.spt.receivedGifts ||= [];
const giftData = profileToUpdate.spt.receivedGifts.find((gift) => gift.giftId === giftId);
if (giftData)
{
// Increment counter
giftData.current++;
}
else
{
// Player has never received gift, make a new object
profileToUpdate.spt.receivedGifts.push(
{
giftId: giftId,
timestampLastAccepted: this.timeUtil.getTimestamp(),
max: maxCount,
current: 1,
});
}
}
/**
@ -386,7 +401,7 @@ export class ProfileHelper
* @param giftId Gift to check for
* @returns True if player has recieved gift previously
*/
public playerHasRecievedGift(playerId: string, giftId: string): boolean
public playerHasRecievedMaxNumberOfGift(playerId: string, giftId: string): boolean
{
const profile = this.getFullProfile(playerId);
if (!profile)
@ -400,7 +415,13 @@ export class ProfileHelper
return false;
}
return !!profile.spt.receivedGifts.find((x) => x.giftId === giftId);
const giftDataFromProfile = profile.spt.receivedGifts.find((x) => x.giftId === giftId);
if (!giftDataFromProfile)
{
return false;
}
return giftDataFromProfile.current >= giftDataFromProfile.max;
}
/**

View File

@ -231,7 +231,9 @@ export interface ModDetails
export interface ReceivedGift
{
giftId: string
timestampAccepted: number
timestampLastAccepted: number
current: number
max: number
}
export interface Vitality

View File

@ -94,6 +94,7 @@ export interface IChatbotFeatures
sptFriendEnabled: boolean
commandoEnabled: boolean
commandoFeatures: ICommandoFeatures
commandUseLimits: Record<string, number>
}
export interface ICommandoFeatures

View File

@ -32,4 +32,5 @@ export interface Gift
collectionTimeHours: number
/** Optional, can be used to change profile settings like level/skills */
profileChangeEvents?: IProfileChangeEvent[]
maxToSendPlayer?: number
}

View File

@ -56,7 +56,7 @@ export class GiftService
return GiftSentResult.FAILED_GIFT_DOESNT_EXIST;
}
if (this.profileHelper.playerHasRecievedGift(playerId, giftId))
if (this.profileHelper.playerHasRecievedMaxNumberOfGift(playerId, giftId))
{
this.logger.debug(`Player already recieved gift: ${giftId}`);
@ -154,7 +154,7 @@ export class GiftService
this.mailSendService.sendMessageToPlayer(details);
}
this.profileHelper.addGiftReceivedFlagToProfile(playerId, giftId);
this.profileHelper.flagGiftReceivedInProfile(playerId, giftId, giftData.maxToSendPlayer ?? 1);
return GiftSentResult.SUCCESS;
}
@ -208,13 +208,13 @@ export class GiftService
switch (day)
{
case 1:
if (this.profileHelper.playerHasRecievedGift(sessionId, "PraporGiftDay1"))
if (this.profileHelper.playerHasRecievedMaxNumberOfGift(sessionId, "PraporGiftDay1"))
{
this.sendGiftToPlayer(sessionId, "PraporGiftDay1");
}
break;
case 2:
if (this.profileHelper.playerHasRecievedGift(sessionId, "PraporGiftDay2"))
if (this.profileHelper.playerHasRecievedMaxNumberOfGift(sessionId, "PraporGiftDay2"))
{
this.sendGiftToPlayer(sessionId, "PraporGiftDay2");
}

View File

@ -614,7 +614,7 @@ export class SeasonalEventService
*/
protected giveGift(playerId: string, giftkey: string): void
{
if (!this.profileHelper.playerHasRecievedGift(playerId, giftkey))
if (!this.profileHelper.playerHasRecievedMaxNumberOfGift(playerId, giftkey))
{
this.giftService.sendGiftToPlayer(playerId, giftkey);
}