From 665da256d98143a04a6f8050280dfc00b15133ce Mon Sep 17 00:00:00 2001 From: Kei-Luna Date: Sun, 26 Apr 2026 09:53:57 +0900 Subject: [PATCH] Chapter can end --- .../Chapter/Chapter_DealLevelSettlement.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 GameServer/Server/CallGS/Handlers/Chapter/Chapter_DealLevelSettlement.cs diff --git a/GameServer/Server/CallGS/Handlers/Chapter/Chapter_DealLevelSettlement.cs b/GameServer/Server/CallGS/Handlers/Chapter/Chapter_DealLevelSettlement.cs new file mode 100644 index 0000000..5237ae1 --- /dev/null +++ b/GameServer/Server/CallGS/Handlers/Chapter/Chapter_DealLevelSettlement.cs @@ -0,0 +1,51 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; + +namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter; + +[CallGSApi("Chapter_DealLevelSettlement")] +public class Chapter_DealLevelSettlement : ICallGSHandler +{ + public async Task Handle(Connection connection, string param, ushort seqNo) + { + var req = JsonSerializer.Deserialize(param); + var response = new JsonObject + { + ["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement", + ["tbParam"] = BuildSettlementPayload(req?.SCmd, req?.TbParam) + }; + + await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString()); + } + + private static JsonNode BuildSettlementPayload(string? sCmd, JsonNode? tbParam) + { + if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal)) + { + return new JsonArray(); + } + + if (string.Equals(sCmd, "Chapter_NewPrologueSettlement", StringComparison.Ordinal)) + { + var result = new JsonObject(); + if (tbParam is JsonObject source && source.TryGetPropertyValue("bWaitServer", out var bWaitServer)) + { + result["bWaitServer"] = bWaitServer?.DeepClone(); + } + result["tbShowAward"] = new JsonArray(); + return result; + } + + return tbParam?.DeepClone() ?? new JsonObject(); + } +} + +internal sealed class DealLevelSettlementParam +{ + [JsonPropertyName("sCmd")] + public string? SCmd { get; set; } + + [JsonPropertyName("tbParam")] + public JsonNode? TbParam { get; set; } +}