mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 18:43:56 +00:00
Implement BossPvP logic (I implemented this based on undownding's code. Thank you!)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user