From 6976803f974aa99e27cf643c4e2df49321eaf72c Mon Sep 17 00:00:00 2001 From: rfi Date: Sun, 19 Nov 2023 22:16:36 +0700 Subject: [PATCH] premature chat command + hardcoded stage for chat on any state --- AscNet.GameServer/Handlers/AccountModule.cs | 22 ++++++++++++++++++++- AscNet.GameServer/Handlers/ChatModule.cs | 21 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/AscNet.GameServer/Handlers/AccountModule.cs b/AscNet.GameServer/Handlers/AccountModule.cs index b595e820..7c7c4c72 100644 --- a/AscNet.GameServer/Handlers/AccountModule.cs +++ b/AscNet.GameServer/Handlers/AccountModule.cs @@ -132,7 +132,7 @@ namespace AscNet.GameServer.Handlers BaseEquipLoginData = new(), FubenData = new() { - StageData = session.stage.Stages.ToDictionary(x => x.Key, x => x.Value), + StageData = session.stage.Stages, FubenBaseData = new() }, FubenMainLineData = new(), @@ -147,6 +147,26 @@ namespace AscNet.GameServer.Handlers #if DEBUG notifyLogin.PlayerData.GuideData = GuideGroupTableReader.Instance.All.Select(x => (long)x.Id).ToList(); + + StageDatum stageForChat = new() + { + StageId = 10030201, + StarsMark = 7, + Passed = true, + PassTimesToday = 0, + PassTimesTotal = 1, + BuyCount = 0, + Score = 0, + LastPassTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds(), + BestRecordTime = 0, + LastRecordTime = 0, + BestCardIds = new List { 1021001 }, + LastCardIds = new List { 1021001 } + }; + if (!notifyLogin.FubenData.StageData.ContainsKey(stageForChat.StageId)) + notifyLogin.FubenData.StageData = notifyLogin.FubenData.StageData.Append(new(stageForChat.StageId, stageForChat)).ToDictionary(x => x.Key, x => x.Value); #endif NotifyCharacterDataList notifyCharacterData = new(); diff --git a/AscNet.GameServer/Handlers/ChatModule.cs b/AscNet.GameServer/Handlers/ChatModule.cs index c05af654..10778fb9 100644 --- a/AscNet.GameServer/Handlers/ChatModule.cs +++ b/AscNet.GameServer/Handlers/ChatModule.cs @@ -1,4 +1,5 @@ using AscNet.Common.MsgPack; +using AscNet.GameServer.Commands; using AscNet.Table.share.chat; using MessagePack; @@ -152,6 +153,26 @@ internal class ChatModule request.ChatData.Icon = (int)session.player.PlayerData.CurrHeadPortraitId; request.ChatData.NickName = session.player.PlayerData.Name; + if (request.ChatData.Content is not null && request.ChatData.Content.StartsWith('/')) + { + var cmdStrings = request.ChatData.Content.Split(" "); + + try + { + Command? cmd = CommandFactory.CreateCommand(cmdStrings.First().Split('/').Last(), session, cmdStrings[1..]); + if (cmd is null) + { + // Invalid command + } + + cmd?.Execute(); + } + catch (Exception) + { + // Failed to execute command + } + } + NotifyWorldChat notifyWorldChat = new(); notifyWorldChat.ChatMessages.Add(request.ChatData);