mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 21:34:44 +01:00
avatar cmd & update assistant
This commit is contained in:
55
GameServer/Commands/AvatarCommand.cs
Normal file
55
GameServer/Commands/AvatarCommand.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Common.Database;
|
||||
using Common.Resources.Proto;
|
||||
using Common.Utils.ExcelReader;
|
||||
using PemukulPaku.GameServer.Game;
|
||||
|
||||
namespace PemukulPaku.GameServer.Commands
|
||||
{
|
||||
[CommandHandler("avatar", "Add avatar to player account", CommandType.Player)]
|
||||
internal class AvatarCommand : Command
|
||||
{
|
||||
public override void Run(Session session, string[] args)
|
||||
{
|
||||
int avatarId = int.Parse(args[1]);
|
||||
Run(session.Player, args);
|
||||
|
||||
session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
|
||||
if (avatarId == -1)
|
||||
{
|
||||
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = new uint[] { 0 } }, CmdId.GetAvatarDataReq));
|
||||
}
|
||||
else
|
||||
{
|
||||
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = new uint[] { (uint)avatarId } }, CmdId.GetAvatarDataReq));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Run(Player player, string[] args)
|
||||
{
|
||||
string action = args[0];
|
||||
int avatarId = int.Parse(args[1]);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "add":
|
||||
if (avatarId == -1)
|
||||
{
|
||||
foreach (AvatarDataExcel avatarData in AvatarData.GetInstance().All)
|
||||
{
|
||||
AvatarScheme avatar = Common.Database.Avatar.Create(avatarData.AvatarId, player.User.Uid, player.Equipment);
|
||||
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarScheme avatar = Common.Database.Avatar.Create(avatarId, player.User.Uid, player.Equipment);
|
||||
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
||||
}
|
||||
player.Equipment.Save();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unrecognized action");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user