From f6ce7d06be0773917b48726bc8794915a68aef45 Mon Sep 17 00:00:00 2001 From: SELEKCJONER Date: Sun, 15 Sep 2024 22:36:41 +0200 Subject: [PATCH] Add all event and favorite item wallpapers --- EpinelPS/Database/JsonDb.cs | 1 - EpinelPS/GameData/GameData.cs | 10 ++++- EpinelPS/GameData/JsonStaticData.cs | 11 +++++ .../LobbyServer/Msgs/Character/UpgradeCore.cs | 43 +++++++++++++++++++ EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs | 7 ++- .../Msgs/User/GetWallpaperInventory.cs | 11 ++++- 6 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 EpinelPS/LobbyServer/Msgs/Character/UpgradeCore.cs diff --git a/EpinelPS/Database/JsonDb.cs b/EpinelPS/Database/JsonDb.cs index ef4af45..ef703ee 100644 --- a/EpinelPS/Database/JsonDb.cs +++ b/EpinelPS/Database/JsonDb.cs @@ -28,7 +28,6 @@ namespace EpinelPS.Database public int Csn = 0; public int Tid = 0; public int CostumeId = 0; - public int Level = 1; public int UltimateLevel = 1; public int Skill1Lvl = 1; diff --git a/EpinelPS/GameData/GameData.cs b/EpinelPS/GameData/GameData.cs index 1199ffe..874769a 100644 --- a/EpinelPS/GameData/GameData.cs +++ b/EpinelPS/GameData/GameData.cs @@ -45,6 +45,8 @@ namespace EpinelPS.StaticInfo private Dictionary jukeboxThemeDataRecords; public Dictionary gachaTypes = new Dictionary(); // Fixed initialization public Dictionary eventManagers = new Dictionary(); + public Dictionary lwptablemgrs = new Dictionary(); // Fixed initialization + public byte[] Sha256Hash; @@ -387,7 +389,13 @@ namespace EpinelPS.StaticInfo eventManagers.Add(obj.id, obj); // Use obj.id as the key and obj (the EventManager) as the value } - + var lwptable = await LoadZip("LiveWallpaperTable.json", progress); + + // Add the records to the dictionary + foreach (var obj in lwptable.records) + { + lwptablemgrs.Add(obj.id, obj); // Use obj.id as the key and obj (the LiveWallpaperRecord) as the value + } // Load Jukebox data await LoadJukeboxListData(progress); await LoadJukeboxThemeData(progress); diff --git a/EpinelPS/GameData/JsonStaticData.cs b/EpinelPS/GameData/JsonStaticData.cs index 6276d47..2cc4d8d 100644 --- a/EpinelPS/GameData/JsonStaticData.cs +++ b/EpinelPS/GameData/JsonStaticData.cs @@ -135,6 +135,7 @@ public string corporation; public string grade_core_id; public string name_code; + public string grow_grade; } public class CharacterTable { @@ -271,5 +272,15 @@ { public List records; } + + public class LiveWallpaperRecord + { + public int id; + public string livewallpaper_type; + } + public class LiveWallpaperTable + { + public List records; + } } diff --git a/EpinelPS/LobbyServer/Msgs/Character/UpgradeCore.cs b/EpinelPS/LobbyServer/Msgs/Character/UpgradeCore.cs new file mode 100644 index 0000000..7ec9efa --- /dev/null +++ b/EpinelPS/LobbyServer/Msgs/Character/UpgradeCore.cs @@ -0,0 +1,43 @@ +using EpinelPS.Database; +using EpinelPS.Utils; +using EpinelPS.StaticInfo; +//this file is work in progress and currently its fucked +namespace EpinelPS.LobbyServer.Msgs.Character +{ + [PacketPath("/character/coreupgrade")] + public class CoreUpgrade : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + // Read the incoming request that contains the current CSN and ISN + var req = await ReadData(); // Contains csn and isn (read-only) + var response = new ResCharacterCoreUpgrade(); + + // Get all character data from the game's character table + var fullchardata = GameData.Instance.characterTable.Values.ToList(); + + // Find the element with the current csn from the request + var currentCharacter = fullchardata.FirstOrDefault(c => c.id == req.Csn); + + if (currentCharacter != null) + { + // Find a new CSN based on the `name_code` of the current character and `grade_core_id + 1` + var newCharacter = fullchardata.FirstOrDefault(c => c.name_code == currentCharacter.name_code && c.grade_core_id == currentCharacter.grade_core_id + 1); + + if (newCharacter != null) + { + // Update the characterData with the new CSN + var characterData = new NetUserCharacterDefaultData + { + Csn = newCharacter.id + // Add any other required data here + }; + + } + + } + // Send the response back to the client + await WriteDataAsync(response); + } + } +} \ No newline at end of file diff --git a/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs b/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs index e473b4c..89726ba 100644 --- a/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs +++ b/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs @@ -25,10 +25,9 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha var entireallCharacterData = GameData.Instance.characterTable.Values.ToList(); // Remove the .Values part since it's already a list. - var allCharacterData = entireallCharacterData - .GroupBy(c => c.name_code) // Group by name_code to treat same name_code as one character - .SelectMany(g => g.Where(c => c.grade_core_id == "11" || c.grade_core_id == "103" || c.grade_core_id == "201" || c.name_code == "3999")) // Always add characters with grade_core_id == 11 and 103 - .ToList(); + // Group by name_code to treat same name_code as one character + // Always add characters with grade_core_id == 11 and 103 + var allCharacterData = entireallCharacterData.GroupBy(c => c.name_code).SelectMany(g => g.Where(c => c.grade_core_id == "11" || c.grade_core_id == "103" || c.grade_core_id == "201" || c.name_code == "3999")).ToList(); // Separate characters by rarity categories var rCharacters = allCharacterData.Where(c => c.original_rare == "R").ToList(); diff --git a/EpinelPS/LobbyServer/Msgs/User/GetWallpaperInventory.cs b/EpinelPS/LobbyServer/Msgs/User/GetWallpaperInventory.cs index bf50f5c..cbbeb6f 100644 --- a/EpinelPS/LobbyServer/Msgs/User/GetWallpaperInventory.cs +++ b/EpinelPS/LobbyServer/Msgs/User/GetWallpaperInventory.cs @@ -1,5 +1,5 @@ using EpinelPS.Utils; - +using EpinelPS.StaticInfo; namespace EpinelPS.LobbyServer.Msgs.User { [PacketPath("/user/getwallpaperinventory")] @@ -9,8 +9,17 @@ namespace EpinelPS.LobbyServer.Msgs.User { var req = await ReadData(); + // Prepare the response var r = new ResGetWallpaperInventory(); + // Fetch all the wallpaper IDs from the LiveWallpaperTable, + // excluding records where livewallpaper_type is "SkillCutScene" + var wallpaperIds = GameData.Instance.lwptablemgrs.Where(w => w.Value.livewallpaper_type != "SkillCutScene").Select(w => w.Key).ToList(); + + // Add the filtered wallpaper IDs to the LivewallpaperIds field + r.LivewallpaperIds.AddRange(wallpaperIds); + + // Send the response back await WriteDataAsync(r); } }