From 0a3ac15ed438b84ae2afebcbaca29eb0a52959e9 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 13 Jan 2025 19:33:52 +0000 Subject: [PATCH 1/2] Implemented `SaveActiveModsToProfile` with TODO --- Core/Controllers/GameController.cs | 79 ++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/Core/Controllers/GameController.cs b/Core/Controllers/GameController.cs index d4a58705..db7a86ec 100644 --- a/Core/Controllers/GameController.cs +++ b/Core/Controllers/GameController.cs @@ -3,9 +3,9 @@ using Core.Context; using Core.Helpers; using Core.Models.Eft.Common; using Core.Models.Eft.Game; -using Core.Models.Eft.Health; using Core.Models.Eft.Profile; using Core.Models.Enums; +using Core.Models.External; using Core.Models.Spt.Config; using Core.Servers; using Core.Services; @@ -41,6 +41,7 @@ public class GameController private readonly RaidTimeAdjustmentService _raidTimeAdjustmentService; private readonly ProfileActivityService _profileActivityService; private readonly ApplicationContext _applicationContext; + //private readonly PreSptModLoader preSptModLoader private readonly ICloner _cloner; private readonly CoreConfig _coreConfig; @@ -470,7 +471,21 @@ public class GameController /// Profile to add gifts to private void SendPraporGiftsToNewProfiles(PmcData pmcProfile) { - throw new NotImplementedException(); + var timeStampProfileCreated = pmcProfile.Info.RegistrationDate; + var oneDaySeconds = _timeUtil.GetHoursAsSeconds(24); + var currentTimeStamp = _timeUtil.GetTimeStamp(); + + // One day post-profile creation + if (currentTimeStamp > timeStampProfileCreated + oneDaySeconds) + { + _giftService.SendPraporStartingGift(pmcProfile.SessionId, 1); + } + + // Two day post-profile creation + if (currentTimeStamp > timeStampProfileCreated + oneDaySeconds * 2) + { + _giftService.SendPraporStartingGift(pmcProfile.SessionId, 2); + } } /// @@ -479,7 +494,36 @@ public class GameController /// Profile to add mod details to private void SaveActiveModsToProfile(SptProfile fullProfile) { - throw new NotImplementedException(); + // Add empty mod array if undefined + if (fullProfile.SptData.Mods is null) + { + fullProfile.SptData.Mods = []; + } + + // Get active mods + //var activeMods = _preSptModLoader.GetImportedModDetails(); //TODO IMPLEMENT _preSptModLoader + var activeMods = new Dictionary(); + foreach (var modKvP in activeMods) { + var modDetails = modKvP.Value; + if ( + fullProfile.SptData.Mods.Any( + (mod) => + mod.Author == modDetails.Author && + mod.Name == modDetails.Name && + mod.Version == modDetails.Version)) + { + // Exists already, skip + continue; + } + + fullProfile.SptData.Mods.Add( new ModDetails{ + Author = modDetails.Author, + DateAdded = _timeUtil.GetTimeStamp(), + Name = modDetails.Name, + Version = modDetails.Version, + Url = modDetails.Url, + }); + } } /// @@ -488,7 +532,34 @@ public class GameController /// Profile of player to get name from private void AddPlayerToPmcNames(PmcData pmcProfile) { - throw new NotImplementedException(); + var playerName = pmcProfile.Info.Nickname; + if (playerName is not null) + { + var bots = _databaseService.GetBots().Types; + + // Official names can only be 15 chars in length + if (playerName.Length > _botConfig.BotNameLengthLimit) + { + return; + } + + // Skip if player name exists already + if (bots.TryGetValue("bear", out var bearBot)) + { + if (bearBot is not null && bearBot.FirstNames.Any(x => x == playerName)) + { + bearBot.FirstNames.Add(playerName); + } + } + + if (bots.TryGetValue("bear", out var usecBot)) + { + if (usecBot is not null && usecBot.FirstNames.Any(x => x == playerName)) + { + usecBot.FirstNames.Add(playerName); + } + } + } } /// From 2a875b2566dab2a71962c8f3cac71b1e762e9cf6 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 13 Jan 2025 19:35:42 +0000 Subject: [PATCH 2/2] Fixed build --- Core/Helpers/HealthHelper.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Helpers/HealthHelper.cs b/Core/Helpers/HealthHelper.cs index 863a8d08..989d8a91 100644 --- a/Core/Helpers/HealthHelper.cs +++ b/Core/Helpers/HealthHelper.cs @@ -1,8 +1,9 @@ -using Core.Annotations; +using Core.Annotations; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Health; using Core.Models.Eft.Profile; +using BodyPartHealth = Core.Models.Eft.Common.Tables.BodyPartHealth; using Effects = Core.Models.Eft.Profile.Effects; using Health = Core.Models.Eft.Profile.Health; @@ -53,7 +54,7 @@ public class HealthHelper /// /// Post-raid body part data /// Player profile on server - protected void TransferPostRaidLimbEffectsToProfile(BodyPartsHealth postRaidBodyParts, PmcData profileData) + protected void TransferPostRaidLimbEffectsToProfile(Dictionary postRaidBodyParts, PmcData profileData) { throw new NotImplementedException(); }