mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 17:44:42 +01:00
chat cmd & hopefully proper avatar level up
This commit is contained in:
@@ -25,13 +25,33 @@ namespace PemukulPaku.GameServer.Game.Chatrooms
|
||||
{
|
||||
string? StringMsg = chatMsg.Content.Items.Where(item => item.MsgStr != null).FirstOrDefault()?.MsgStr;
|
||||
|
||||
if (StringMsg != null)
|
||||
{
|
||||
if (StringMsg != null)
|
||||
{
|
||||
// do we need cmds?
|
||||
Command? Cmd = CommandFactory.Commands.Find(cmd => StringMsg.Split(' ').ToList()[0] == cmd.Name.ToLower());
|
||||
List<string> args = StringMsg.Split(' ').ToList();
|
||||
Command? Cmd = CommandFactory.Commands.Find(cmd => args[0] == cmd.Name.ToLower());
|
||||
if (Cmd != null)
|
||||
{
|
||||
args.RemoveAt(0);
|
||||
|
||||
try
|
||||
{
|
||||
if (Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Player)
|
||||
{
|
||||
Cmd.Run(session, args.ToArray());
|
||||
if (Cmd.CmdType == CommandType.Player)
|
||||
SendAiMsg("Command executed", session);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendAiMsg("Invalid usage", session);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SendAiMsg(ex.Message, session);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
chatMsg.CheckResult = new()
|
||||
@@ -67,6 +87,40 @@ namespace PemukulPaku.GameServer.Game.Chatrooms
|
||||
session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAiMsg(string msg, Session? session)
|
||||
{
|
||||
if(session == null)
|
||||
{
|
||||
foreach (Session valSession in Members)
|
||||
{
|
||||
SendAiMsg(msg, valSession);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RecvChatMsgNotify notify = new() { };
|
||||
ChatMsg AiMsg = new()
|
||||
{
|
||||
Uid = 0,
|
||||
Nickname = "Ai-chan",
|
||||
Time = (uint)Global.GetUnixInSeconds(),
|
||||
Msg = msg,
|
||||
Content = new() { },
|
||||
Channel = ChatMsg.MsgChannel.World,
|
||||
AvatarId = 3201,
|
||||
DressId = 593201,
|
||||
FrameId = 200001,
|
||||
CustomHeadId = 161080,
|
||||
CheckResult = new() { NumberCheck = 0, ShieldType = 0, RewriteText = msg }
|
||||
};
|
||||
AiMsg.Content.Items.Add(new() { MsgStr = msg });
|
||||
|
||||
notify.ChatMsgLists.Add(AiMsg);
|
||||
|
||||
session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseChatroom<TSelf> where TSelf : BaseChatroom<TSelf>
|
||||
|
||||
41
GameServer/Handlers/AddAvatarExpByMaterialReqHandler.cs
Normal file
41
GameServer/Handlers/AddAvatarExpByMaterialReqHandler.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Common.Database;
|
||||
using Common.Resources.Proto;
|
||||
using Common.Utils.ExcelReader;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
{
|
||||
[PacketCmdId(CmdId.AddAvatarExpByMaterialReq)]
|
||||
internal class AddAvatarExpByMaterialReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
AddAvatarExpByMaterialReq Data = packet.GetDecodedBody<AddAvatarExpByMaterialReq>();
|
||||
MaterialDataExcel? materialData = MaterialData.GetInstance().FromId(Data.MaterialId);
|
||||
AvatarScheme? avatar = session.Player.AvatarList.FirstOrDefault(avatar => avatar.AvatarId == Data.AvatarId);
|
||||
|
||||
AddAvatarExpByMaterialRsp Rsp = new() { retcode = AddAvatarExpByMaterialRsp.Retcode.Succ };
|
||||
|
||||
if (avatar is not null && materialData is not null)
|
||||
{
|
||||
session.Player.Equipment.AddMaterial(materialData.Id, -(int)Data.MaterialNum);
|
||||
GetEquipmentDataRsp EquipmentRsp = new()
|
||||
{
|
||||
retcode = GetEquipmentDataRsp.Retcode.Succ,
|
||||
VitalityValue = 0,
|
||||
IsAll = true
|
||||
};
|
||||
EquipmentRsp.MaterialLists.Add(session.Player.Equipment.MaterialList.First(mat => mat.Id == materialData.Id));
|
||||
|
||||
avatar.AddExp((uint)materialData.CharacterExpProvide * Data.MaterialNum);
|
||||
|
||||
session.Send(Packet.FromProto(EquipmentRsp, CmdId.GetEquipmentDataRsp));
|
||||
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = new uint[] { avatar.AvatarId } }, CmdId.GetAvatarDataReq));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rsp.retcode = AddAvatarExpByMaterialRsp.Retcode.AvatarNotExist;
|
||||
}
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.AddAvatarExpByMaterialRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user