From 2e8eee09776f89031854e088c3b45bf45e87ccc7 Mon Sep 17 00:00:00 2001 From: rfi Date: Mon, 18 Dec 2023 21:20:02 +0700 Subject: [PATCH] very primitive gacha display --- AscNet.Common/MsgPack/Types.cs | 2 +- AscNet.GameServer/Handlers/AccountModule.cs | 10 +++ AscNet.GameServer/Handlers/DrawModule.cs | 75 ++++++++++++++++++++- AscNet.GameServer/Handlers/TRPGModule.cs | 75 +++++++++++++++++++++ 4 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 AscNet.GameServer/Handlers/TRPGModule.cs diff --git a/AscNet.Common/MsgPack/Types.cs b/AscNet.Common/MsgPack/Types.cs index f0d8828c..12d18616 100644 --- a/AscNet.Common/MsgPack/Types.cs +++ b/AscNet.Common/MsgPack/Types.cs @@ -1647,7 +1647,7 @@ namespace AscNet.Common.MsgPack public NotifyTRPGDataBossInfo BossInfo { get; set; } public List TargetList { get; set; } = new(); public List RewardList { get; set; } = new(); - public List FuncList { get; set; } = new(); + public List FuncList { get; set; } = new(); public List Characters { get; set; } = new(); [global::MessagePack.MessagePackObject(true)] public class NotifyTRPGDataShopInfo diff --git a/AscNet.GameServer/Handlers/AccountModule.cs b/AscNet.GameServer/Handlers/AccountModule.cs index 5b6b0f65..0e1bacbb 100644 --- a/AscNet.GameServer/Handlers/AccountModule.cs +++ b/AscNet.GameServer/Handlers/AccountModule.cs @@ -4,6 +4,7 @@ using AscNet.Common.Util; using AscNet.Table.V2.share.chat; using AscNet.Table.V2.share.guide; using AscNet.Table.V2.share.photomode; +using AscNet.Table.V2.share.trpg; using MessagePack; using System.Diagnostics; @@ -224,6 +225,15 @@ namespace AscNet.GameServer.Handlers session.SendPush(notifyChatLoginData); session.SendPush(notifyItemDataList); session.SendPush(notifyBackground); + session.SendPush(new NotifyTRPGData() + { + CurTargetLink = 10001, + BaseInfo = new() + { + Level = 1 + }, + BossInfo = new() + }); #region DisclamerMail NotifyMails notifyMails = new(); diff --git a/AscNet.GameServer/Handlers/DrawModule.cs b/AscNet.GameServer/Handlers/DrawModule.cs index 0211c9aa..9d6117ef 100644 --- a/AscNet.GameServer/Handlers/DrawModule.cs +++ b/AscNet.GameServer/Handlers/DrawModule.cs @@ -4,11 +4,52 @@ namespace AscNet.GameServer.Handlers { #region MsgPackScheme #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + [MessagePackObject(true)] + public class DrawGetDrawInfoListResponse + { + public int Code { get; set; } + public List DrawInfoList { get; set; } = new(); + } + [MessagePackObject(true)] public class DrawGetDrawGroupListResponse { public int Code { get; set; } - public List DrawGroupInfoList { get; set; } = new(); + public List DrawGroupInfoList { get; set; } = new(); + } + + [MessagePackObject(true)] + public class DrawGroupInfo + { + public int Id { get; set; } + public int SwitchDrawIdCount { get; set; } + public int UseDrawId { get; set; } + public int MaxSwitchDrawIdCount { get; set; } + public int Tag { get; set; } + public int Order { get; set; } + public int Priority { get; set; } + public int BottomTimes { get; set; } + public int MaxBottomTimes { get; set; } + public long BannerBeginTime { get; set; } + public long BannerEndTime { get; set; } + public long StartTime { get; set; } + public long EndTime { get; set; } + } + + [MessagePackObject(true)] + public class DrawInfo + { + public int Id { get; set; } + public string Banner { get; set; } + public int UseItemId { get; set; } + public int GroupId { get; set; } + public List BtnDrawCount { get; set; } = new(); + public List PurchaseId { get; set; } = new(); + public int UseItemCount { get; set; } + public int BottomTimes { get; set; } + public int MaxBottomTimes { get; set; } + public long StartTime { get; set; } + public long EndTime { get; set; } } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. #endregion @@ -18,7 +59,37 @@ namespace AscNet.GameServer.Handlers [RequestPacketHandler("DrawGetDrawGroupListRequest")] public static void DrawGetDrawGroupListRequestHandler(Session session, Packet.Request packet) { - session.SendResponse(new DrawGetDrawGroupListResponse(), packet.Id); + var rsp = new DrawGetDrawGroupListResponse(); + rsp.DrawGroupInfoList.Add(new() + { + Id = 1, + SwitchDrawIdCount = 1, + UseDrawId = 1, + Order = 1, + Tag = 1, + EndTime = DateTimeOffset.Now.ToUnixTimeSeconds() * 2, + BannerEndTime = DateTimeOffset.Now.ToUnixTimeSeconds() * 2 + }); + + session.SendResponse(rsp, packet.Id); + } + + [RequestPacketHandler("DrawGetDrawInfoListRequest")] + public static void DrawGetDrawInfoListRequestHandler(Session session, Packet.Request packet) + { + DrawGetDrawInfoListResponse rsp = new(); + rsp.DrawInfoList.Add(new() + { + Id = 101, + UseItemId = 1, + UseItemCount = 10, + GroupId = 1, + BtnDrawCount = { 1, 10 }, + Banner = "Assets/Product/Ui/Scene3DPrefab/UiMain3dWuqi.prefab", + EndTime = DateTimeOffset.Now.ToUnixTimeSeconds() * 2 + }); + + session.SendResponse(rsp, packet.Id); } } } diff --git a/AscNet.GameServer/Handlers/TRPGModule.cs b/AscNet.GameServer/Handlers/TRPGModule.cs new file mode 100644 index 00000000..eca9483b --- /dev/null +++ b/AscNet.GameServer/Handlers/TRPGModule.cs @@ -0,0 +1,75 @@ +using AscNet.Common.MsgPack; +using AscNet.Common.Util; +using AscNet.Table.V2.share.reward; +using AscNet.Table.V2.share.trpg; +using MessagePack; + +namespace AscNet.GameServer.Handlers +{ + #region MsgPackScheme +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + [MessagePackObject(true)] + public class TRPGFunctionFinishRequest + { + public int FunctionId { get; set; } + } + + [MessagePackObject(true)] + public class TRPGFunctionFinishResponse + { + public int Code { get; set; } + public List RewardList { get; set; } = new(); + } + + [MessagePackObject(true)] + public class TRPGChangePageStatusRequest + { + public bool Status { get; set; } + } + + [MessagePackObject(true)] + public class TRPGChangePageStatusResponse + { + public int Code { get; set; } + } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + #endregion + + internal class TRPGModule + { + [RequestPacketHandler("TRPGFunctionFinishRequest")] + public static void TRPGFunctionFinishRequestHandler(Session session, Packet.Request packet) + { + TRPGFunctionFinishRequest request = MessagePackSerializer.Deserialize(packet.Content); + TRPGFunctionTable? trpgFunction = TableReaderV2.Parse().Find(x => x.Id == request.FunctionId); + + var response = new TRPGFunctionFinishResponse(); + + // TODO: Implement rewards + /*if (trpgFunction?.RewardId is not null) + { + var rewardGoods = TableReaderV2.Parse().Where(x => TableReaderV2.Parse().Find(x => x.Id == trpgFunction.RewardId)?.SubIds.Contains(x.Id) ?? false); + + foreach (var goods in rewardGoods) + { + response.RewardList.Add(new() + { + Id = goods.Id, + TemplateId = goods.TemplateId, + Count = goods.Count + }); + } + }*/ + + session.SendResponse(response, packet.Id); + } + + [RequestPacketHandler("TRPGChangePageStatusRequest")] + public static void TRPGChangePageStatusRequestHandler(Session session, Packet.Request packet) + { + TRPGChangePageStatusRequest request = MessagePackSerializer.Deserialize(packet.Content); + + session.SendResponse(new TRPGChangePageStatusResponse(), packet.Id); + } + } +}