diff --git a/Common/Database/Character/CharacterData.cs b/Common/Database/Character/CharacterData.cs index 6e314d0..aeadf46 100644 --- a/Common/Database/Character/CharacterData.cs +++ b/Common/Database/Character/CharacterData.cs @@ -19,6 +19,7 @@ public class CharacterInfo public int Exp { get; set; } public uint Break { get; set; } public int Evolue { get; set; } + public uint ProLevel { get; set; } public int Trust { get; set; } public uint WeaponUniqueId { get; set; } public uint SkinId { get; set; } @@ -45,6 +46,7 @@ public class CharacterInfo Exp = ToUInt32(Exp), Break = Break, Evolue = ToUInt32(Evolue), + ProLevel = ProLevel, Trust = ToUInt32(Trust) } }; diff --git a/GameServer/Server/CallGS/Handlers/Girl/GirlCard_ProLevelPromote.cs b/GameServer/Server/CallGS/Handlers/Girl/GirlCard_ProLevelPromote.cs new file mode 100644 index 0000000..05472ff --- /dev/null +++ b/GameServer/Server/CallGS/Handlers/Girl/GirlCard_ProLevelPromote.cs @@ -0,0 +1,52 @@ +using MikuSB.Database; +using MikuSB.Proto; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl; + +[CallGSApi("GirlCard_ProLevelPromote")] +public class GirlCard_ProLevelPromote : ICallGSHandler +{ + private const uint MaxProLevel = 3; + + public async Task Handle(Connection connection, string param, ushort seqNo) + { + var player = connection.Player!; + var req = JsonSerializer.Deserialize(param); + if (req == null || req.CardId == 0) + { + await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}"); + return; + } + + var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId); + if (card == null) + { + await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}"); + return; + } + + if (card.ProLevel >= MaxProLevel) + { + await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}"); + return; + } + + card.ProLevel++; + + DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData); + + var sync = new NtfSyncPlayer(); + sync.Items.Add(card.ToProto()); + + // s2c callback takes no params — return empty arg + await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{}", sync); + } +} + +internal sealed class ProLevelPromoteParam +{ + [JsonPropertyName("nID")] + public int CardId { get; set; } +} diff --git a/version.txt b/version.txt index 8e4423b..9cbc9bf 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v=0.9 \ No newline at end of file +v=1.0 \ No newline at end of file