mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 05:03:58 +00:00
Compare commits
3 Commits
v3.7
...
331d2dbcaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331d2dbcaa | ||
|
|
85df98c0ae | ||
|
|
a585232045 |
@@ -2,16 +2,15 @@ using MikuSB.Data;
|
||||
using MikuSB.Data.Excel;
|
||||
using MikuSB.Database.Inventory;
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.GameServer.Server.CallGS;
|
||||
using MikuSB.Proto;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
namespace MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
internal static class BossPvpShared
|
||||
internal static class BossPvpService
|
||||
{
|
||||
private const uint GroupId = 51;
|
||||
private const uint ActivitySubId = 0;
|
||||
@@ -27,9 +26,8 @@ internal static class BossPvpShared
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||
};
|
||||
|
||||
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(Connection connection)
|
||||
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(PlayerInstance player)
|
||||
{
|
||||
var player = connection.Player!;
|
||||
await EnsureBossLineupsAsync(player);
|
||||
|
||||
var sync = new NtfSyncPlayer();
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_EnterLevel")]
|
||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_EnterLevel : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var response = BossPvpShared.HandleEnterLevel(param);
|
||||
var response = BossPvpService.HandleEnterLevel(param);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_EnterLevel", System.Text.Json.JsonSerializer.Serialize(response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_GetOpenID")]
|
||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_GetOpenID : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var (response, sync) = await BossPvpShared.HandleGetOpenIdAsync(connection);
|
||||
var (response, sync) = await BossPvpService.HandleGetOpenIdAsync(connection.Player!);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetOpenID", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_GetReward")]
|
||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_GetReward : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var response = BossPvpShared.HandleGetReward(param);
|
||||
var response = BossPvpService.HandleGetReward(param);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetReward", System.Text.Json.JsonSerializer.Serialize(response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_LevelFail")]
|
||||
@@ -6,7 +8,7 @@ public class BossPvpLogic_LevelFail : ICallGSHandler
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||
var (response, sync) = BossPvpShared.HandleFail(connection.Player!, node);
|
||||
var (response, sync) = BossPvpService.HandleFail(connection.Player!, node);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelFail", response.ToJsonString(), sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_LevelMopup")]
|
||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_LevelMopup : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var (response, sync) = BossPvpShared.HandleMopup(connection.Player!, param);
|
||||
var (response, sync) = BossPvpService.HandleMopup(connection.Player!, param);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelMopup", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_LevelSettlement")]
|
||||
@@ -6,7 +8,7 @@ public class BossPvpLogic_LevelSettlement : ICallGSHandler
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||
var (response, sync) = BossPvpShared.HandleSettlement(connection.Player!, node);
|
||||
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, node);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelSettlement", response.ToJsonString(), sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
|
||||
[CallGSApi("BossPvpLogic_Record")]
|
||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_Record : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var (response, sync) = BossPvpShared.HandleRecord(connection.Player!, param);
|
||||
var (response, sync) = BossPvpService.HandleRecord(connection.Player!, param);
|
||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_Record", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.Json.Serialization;
|
||||
using MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||
using MikuSB.GameServer.Game.BossPvp;
|
||||
using MikuSB.Proto;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
||||
@@ -44,14 +44,14 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
||||
|
||||
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
||||
{
|
||||
var (response, sync) = BossPvpShared.HandleSettlement(connection.Player!, tbParam);
|
||||
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, tbParam);
|
||||
extraSync = sync;
|
||||
return response;
|
||||
}
|
||||
|
||||
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
|
||||
{
|
||||
var (response, sync) = BossPvpShared.HandleFail(connection.Player!, tbParam);
|
||||
var (response, sync) = BossPvpService.HandleFail(connection.Player!, tbParam);
|
||||
extraSync = sync;
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using MikuSB.Data;
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Rogue3D;
|
||||
|
||||
// Enters the Rogue3D season level. Returns a random seed used by the client for map generation.
|
||||
// Persists SeasonGameplayId (sid=1006) and SeasonEnterFlag (sid=1008) as player attributes (GroupId=124).
|
||||
// param: {"nDiffId", "nTeamID", "tbTeam", "tbBuffList", "tbLog"}
|
||||
// Response: {"nSeed": int} on success, {"sErr": "key"} on failure
|
||||
[CallGSApi("Rogue3D_EnterSeasonLevel")]
|
||||
public class Rogue3D_EnterSeasonLevel : ICallGSHandler
|
||||
{
|
||||
private const uint GroupId = 124;
|
||||
private const uint SeasonGameplayIdSid = 1006;
|
||||
private const uint SeasonEnterFlagSid = 1008;
|
||||
private static readonly Random Random = new();
|
||||
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<EnterSeasonLevelParam>(param);
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", "{\"nSeed\":0}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GameData.Rogue3DDifficultData.TryGetValue(req.DiffId, out var cfg) || cfg.GameplayGroup.Count == 0)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", "{\"sErr\":\"rogue3.massage_gameProcessError\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
var player = connection.Player!;
|
||||
var sync = new NtfSyncPlayer();
|
||||
|
||||
SetAttr(player, SeasonGameplayIdSid, cfg.GameplayGroup[0], sync);
|
||||
SetAttr(player, SeasonEnterFlagSid, 1, sync);
|
||||
|
||||
var seed = Random.Next(1, 1_000_000_000);
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", $"{{\"nSeed\":{seed}}}", sync);
|
||||
}
|
||||
|
||||
private static void SetAttr(PlayerInstance player, uint sid, uint val, NtfSyncPlayer sync)
|
||||
{
|
||||
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||
if (attr == null)
|
||||
{
|
||||
attr = new PlayerAttr { Gid = GroupId, Sid = sid };
|
||||
player.Data.Attrs.Add(attr);
|
||||
}
|
||||
|
||||
if (attr.Val == val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
attr.Val = val;
|
||||
sync.Custom[player.ToPackedAttrKey(GroupId, sid)] = val;
|
||||
sync.Custom[player.ToShiftedAttrKey(GroupId, sid)] = val;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class EnterSeasonLevelParam
|
||||
{
|
||||
[JsonPropertyName("nDiffId")]
|
||||
public uint DiffId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Rogue3D;
|
||||
|
||||
// Selects the Rogue3D season talent and persists it as player attribute (GroupId=124, TalentId=1007).
|
||||
// param: {"nTalentId": int}
|
||||
// Response: {} on success, {"sErr": "key"} on failure
|
||||
[CallGSApi("Rogue3D_SelectSeasonTalent")]
|
||||
public class Rogue3D_SelectSeasonTalent : ICallGSHandler
|
||||
{
|
||||
private const uint GroupId = 124;
|
||||
private const uint SeasonTalentIdSid = 1007;
|
||||
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<SelectSeasonTalentParam>(param);
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_SelectSeasonTalent", "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
var player = connection.Player!;
|
||||
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == SeasonTalentIdSid);
|
||||
if (attr == null)
|
||||
{
|
||||
attr = new PlayerAttr { Gid = GroupId, Sid = SeasonTalentIdSid };
|
||||
player.Data.Attrs.Add(attr);
|
||||
}
|
||||
attr.Val = req.TalentId;
|
||||
|
||||
var sync = new NtfSyncPlayer();
|
||||
sync.Custom[player.ToPackedAttrKey(GroupId, SeasonTalentIdSid)] = attr.Val;
|
||||
sync.Custom[player.ToShiftedAttrKey(GroupId, SeasonTalentIdSid)] = attr.Val;
|
||||
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_SelectSeasonTalent", "{}", sync);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SelectSeasonTalentParam
|
||||
{
|
||||
[JsonPropertyName("nTalentId")]
|
||||
public uint TalentId { get; set; }
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
v=3.7
|
||||
v=3.8
|
||||
Reference in New Issue
Block a user