Implement BossPvP logic (I implemented this based on undownding's code. Thank you!)

This commit is contained in:
Kei-Luna
2026-05-19 17:35:08 +09:00
parent 9a9ae13da0
commit cfca2f970c
13 changed files with 668 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
using MikuSB.Proto;
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
@@ -10,17 +12,20 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
public async Task Handle(Connection connection, string param, ushort seqNo)
{
var req = JsonSerializer.Deserialize<DealLevelSettlementParam>(param);
NtfSyncPlayer? extraSync = null;
var response = new JsonObject
{
["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement",
["tbParam"] = BuildSettlementPayload(req?.SCmd, req?.TbParam)
["tbParam"] = BuildSettlementPayload(connection, req?.SCmd, req?.TbParam, out extraSync)
};
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString());
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString(), extraSync!);
}
private static JsonNode BuildSettlementPayload(string? sCmd, JsonNode? tbParam)
private static JsonNode BuildSettlementPayload(Connection connection, string? sCmd, JsonNode? tbParam, out NtfSyncPlayer? extraSync)
{
extraSync = null;
if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal))
{
return new JsonArray();
@@ -37,6 +42,20 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
return result;
}
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
{
var (response, sync) = BossPvpShared.HandleSettlement(connection.Player!, tbParam);
extraSync = sync;
return response;
}
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
{
var (response, sync) = BossPvpShared.HandleFail(connection.Player!, tbParam);
extraSync = sync;
return response;
}
return tbParam?.DeepClone() ?? new JsonObject();
}
}