mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 05:23:59 +00:00
Compare commits
2 Commits
772c272fb4
...
bc399f6afe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc399f6afe | ||
|
|
4fdd093644 |
@@ -45,7 +45,8 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
||||
|
||||
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
||||
{
|
||||
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, tbParam);
|
||||
var normalized = NormalizeBossPvpSettlement(tbParam);
|
||||
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, normalized);
|
||||
extraSync = sync;
|
||||
return response;
|
||||
}
|
||||
@@ -66,6 +67,22 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
||||
|
||||
return tbParam?.DeepClone() ?? new JsonObject();
|
||||
}
|
||||
|
||||
private static JsonNode? NormalizeBossPvpSettlement(JsonNode? tbParam)
|
||||
{
|
||||
if (tbParam is not JsonObject obj)
|
||||
return tbParam;
|
||||
|
||||
var clone = obj.DeepClone() as JsonObject ?? obj;
|
||||
if (clone.TryGetPropertyValue("ResidueTime", out var residueNode) &&
|
||||
residueNode is JsonValue residueValue &&
|
||||
residueValue.TryGetValue<double>(out var residueTime))
|
||||
{
|
||||
clone["ResidueTime"] = (int)Math.Max(0, Math.Round(residueTime, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DealLevelSettlementParam
|
||||
|
||||
43
GameServer/Server/CallGS/Handlers/Lineup/Lineups_Update.cs
Normal file
43
GameServer/Server/CallGS/Handlers/Lineup/Lineups_Update.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using MikuSB.Database;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Lineup;
|
||||
|
||||
[CallGSApi("Lineups_Update")]
|
||||
public class Lineups_Update : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<List<LineupUpdateBatchParam>>(param);
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "UpdateLineup", "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var lineup in req)
|
||||
{
|
||||
if (lineup == null)
|
||||
continue;
|
||||
|
||||
await connection.Player!.LineupManager.UpdateLineup(
|
||||
lineup.Index,
|
||||
lineup.Member1,
|
||||
lineup.Member2,
|
||||
lineup.Member3);
|
||||
}
|
||||
|
||||
DatabaseHelper.SaveDatabaseType(connection.Player!.LineupManager.LineupData);
|
||||
await CallGSRouter.SendScript(connection, "UpdateLineup", "{}");
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class LineupUpdateBatchParam
|
||||
{
|
||||
[JsonPropertyName("name")] public string Name { get; set; } = "";
|
||||
[JsonPropertyName("index")] public int Index { get; set; }
|
||||
[JsonPropertyName("member1")] public uint Member1 { get; set; }
|
||||
[JsonPropertyName("member2")] public uint Member2 { get; set; }
|
||||
[JsonPropertyName("member3")] public uint Member3 { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user