Send string representation of notification type enum to client to let profile changes work #368
This commit is contained in:
@@ -7,7 +7,6 @@ using SPTarkov.Server.Core.Models.Eft.Inventory;
|
||||
using SPTarkov.Server.Core.Models.Eft.ItemEvent;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Models.Spt.Dialog;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
using SPTarkov.Server.Core.Routers;
|
||||
using SPTarkov.Server.Core.Services;
|
||||
@@ -177,26 +176,26 @@ public class InventoryController(
|
||||
var mail = dialog.Messages.FirstOrDefault(message => message.Id == rewardEvent.MessageId);
|
||||
var mailEvent =
|
||||
mail.ProfileChangeEvents.FirstOrDefault(changeEvent => changeEvent.Id == rewardEvent.EventId);
|
||||
|
||||
|
||||
switch (mailEvent.Type)
|
||||
{
|
||||
case ProfileChangeEventType.TraderSalesSum:
|
||||
case "TraderSalesSum":
|
||||
pmcData.TradersInfo[mailEvent.Entity].SalesSum = mailEvent.Value;
|
||||
_traderHelper.LevelUp(mailEvent.Entity, pmcData);
|
||||
_logger.Success($"Set trader {mailEvent.Entity}: Sales Sum to: {mailEvent.Value}");
|
||||
break;
|
||||
case ProfileChangeEventType.TraderStanding:
|
||||
case "TraderStanding":
|
||||
pmcData.TradersInfo[mailEvent.Entity].Standing = mailEvent.Value;
|
||||
_traderHelper.LevelUp(mailEvent.Entity, pmcData);
|
||||
_logger.Success($"Set trader {mailEvent.Entity}: Standing to: {mailEvent.Value}");
|
||||
break;
|
||||
case ProfileChangeEventType.ProfileLevel:
|
||||
case "ProfileLevel":
|
||||
pmcData.Info.Experience = (int) mailEvent.Value.Value;
|
||||
// Will calculate level below
|
||||
_traderHelper.ValidateTraderStandingsAndPlayerLevelForProfile(sessionId);
|
||||
_logger.Success($"Set profile xp to: {mailEvent.Value}");
|
||||
break;
|
||||
case ProfileChangeEventType.SkillPoints:
|
||||
case "SkillPoints":
|
||||
{
|
||||
var profileSkill = pmcData.Skills.Common.FirstOrDefault(x => x.Id == mailEvent.Entity);
|
||||
if (profileSkill is null)
|
||||
@@ -209,7 +208,7 @@ public class InventoryController(
|
||||
_logger.Success($"Set profile skill: {mailEvent.Entity} to: {mailEvent.Value}");
|
||||
break;
|
||||
}
|
||||
case ProfileChangeEventType.ExamineAllItems:
|
||||
case "ExamineAllItems":
|
||||
{
|
||||
var itemsToInspect = _itemHelper.GetItems().Where(x => x.Type != "Node");
|
||||
FlagItemsAsInspectedAndRewardXp(itemsToInspect.Select(x => x.Id), fullProfile);
|
||||
@@ -217,18 +216,18 @@ public class InventoryController(
|
||||
|
||||
break;
|
||||
}
|
||||
case ProfileChangeEventType.UnlockTrader:
|
||||
case "UnlockTrader":
|
||||
pmcData.TradersInfo[mailEvent.Entity].Unlocked = true;
|
||||
_logger.Success($"Trader {mailEvent.Entity} Unlocked");
|
||||
|
||||
break;
|
||||
case ProfileChangeEventType.AssortmentUnlockRule:
|
||||
case "AssortmentUnlockRule":
|
||||
fullProfile.SptData.BlacklistedItemTemplates ??= [];
|
||||
fullProfile.SptData.BlacklistedItemTemplates.Add(mailEvent.Entity);
|
||||
_logger.Success($"Item {mailEvent.Entity} is now blacklisted");
|
||||
|
||||
break;
|
||||
case ProfileChangeEventType.HideoutAreaLevel:
|
||||
case "HideoutAreaLevel":
|
||||
{
|
||||
var areaName = mailEvent.Entity;
|
||||
var newValue = mailEvent.Value;
|
||||
|
||||
+4
-3
@@ -4,6 +4,7 @@ using SPTarkov.Server.Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.Dialog;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
using SPTarkov.Server.Core.Models.Eft.Ws;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Models.Spt.Dialog;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
@@ -152,7 +153,7 @@ public class ProfileSptCommand(
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.SkillPoints,
|
||||
Type = "SkillPoints",
|
||||
Value = level * 100,
|
||||
Entity = skill.ToString()
|
||||
};
|
||||
@@ -165,7 +166,7 @@ public class ProfileSptCommand(
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.ProfileLevel,
|
||||
Type = "ProfileLevel",
|
||||
Value = exp,
|
||||
Entity = null
|
||||
};
|
||||
@@ -177,7 +178,7 @@ public class ProfileSptCommand(
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.ExamineAllItems,
|
||||
Type = "ExamineAllItems",
|
||||
Value = null,
|
||||
Entity = null
|
||||
};
|
||||
|
||||
+6
-5
@@ -4,6 +4,7 @@ using SPTarkov.Server.Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.Dialog;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
using SPTarkov.Server.Core.Models.Eft.Ws;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Models.Spt.Dialog;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
@@ -64,15 +65,15 @@ public class TraderSptCommand(
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
ProfileChangeEventType profileChangeEventType;
|
||||
NotificationEventType profileChangeEventType;
|
||||
switch (command)
|
||||
{
|
||||
case "rep":
|
||||
quantity /= 100;
|
||||
profileChangeEventType = ProfileChangeEventType.TraderStanding;
|
||||
profileChangeEventType = NotificationEventType.TraderStanding;
|
||||
break;
|
||||
case "spend":
|
||||
profileChangeEventType = ProfileChangeEventType.TraderSalesSum;
|
||||
profileChangeEventType = NotificationEventType.TraderSalesSum;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@@ -109,12 +110,12 @@ public class TraderSptCommand(
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
protected ProfileChangeEvent CreateProfileChangeEvent(ProfileChangeEventType profileChangeEventType, int quantity, string dbTraderId)
|
||||
protected ProfileChangeEvent CreateProfileChangeEvent(NotificationEventType profileChangeEventType, int quantity, string dbTraderId)
|
||||
{
|
||||
return new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = profileChangeEventType,
|
||||
Type = profileChangeEventType.ToString(),
|
||||
Value = quantity,
|
||||
Entity = dbTraderId
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.Profile;
|
||||
using SPTarkov.Server.Core.Models.Eft.Ws;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Utils.Json.Converters;
|
||||
|
||||
namespace SPTarkov.Server.Core.Models.Spt.Dialog;
|
||||
|
||||
@@ -155,7 +155,7 @@ public record ProfileChangeEvent
|
||||
}
|
||||
|
||||
[JsonPropertyName("Type")]
|
||||
public ProfileChangeEventType? Type
|
||||
public string Type
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -182,16 +182,3 @@ public record ProfileChangeEvent
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
[EftEnumConverter]
|
||||
public enum ProfileChangeEventType
|
||||
{
|
||||
TraderSalesSum,
|
||||
TraderStanding,
|
||||
ProfileLevel,
|
||||
SkillPoints,
|
||||
ExamineAllItems,
|
||||
UnlockTrader,
|
||||
AssortmentUnlockRule,
|
||||
HideoutAreaLevel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user