mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2026-02-04 10:55:04 +01:00
avatar modify subcommand
This commit is contained in:
@@ -10,7 +10,9 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
{
|
{
|
||||||
public override void Run(Session session, string[] args)
|
public override void Run(Session session, string[] args)
|
||||||
{
|
{
|
||||||
|
string action = args[0];
|
||||||
int avatarId = int.Parse(args[1]);
|
int avatarId = int.Parse(args[1]);
|
||||||
|
|
||||||
Run(session.Player, args);
|
Run(session.Player, args);
|
||||||
|
|
||||||
session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
|
session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
|
||||||
@@ -22,12 +24,38 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
{
|
{
|
||||||
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = new uint[] { (uint)avatarId } }, CmdId.GetAvatarDataReq));
|
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = new uint[] { (uint)avatarId } }, CmdId.GetAvatarDataReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action == "modify")
|
||||||
|
{
|
||||||
|
List<uint> updatedAvatars = new();
|
||||||
|
|
||||||
|
if (avatarId == -1)
|
||||||
|
{
|
||||||
|
foreach (AvatarScheme av in session.Player.AvatarList)
|
||||||
|
{
|
||||||
|
updatedAvatars.Add(av.AvatarId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AvatarScheme? avatar = session.Player.AvatarList.FirstOrDefault(av => av.AvatarId == avatarId);
|
||||||
|
if (avatar is not null)
|
||||||
|
{
|
||||||
|
updatedAvatars.Add(avatar.AvatarId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.ProcessPacket(Packet.FromProto(new GetAvatarDataReq() { AvatarIdLists = updatedAvatars.ToArray() }, CmdId.GetAvatarDataReq));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Run(Player player, string[] args)
|
public override void Run(Player player, string[] args)
|
||||||
{
|
{
|
||||||
string action = args[0];
|
string action = args[0];
|
||||||
int avatarId = int.Parse(args[1]);
|
int avatarId = int.Parse(args[1]);
|
||||||
|
string modType = args[2];
|
||||||
|
int value = int.Parse(args[3]);
|
||||||
|
AvatarScheme? avatar;
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@@ -38,17 +66,38 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
{
|
{
|
||||||
if (avatarData.AvatarId >= 9000) continue; // Avoid APHO avatars
|
if (avatarData.AvatarId >= 9000) continue; // Avoid APHO avatars
|
||||||
|
|
||||||
AvatarScheme avatar = Common.Database.Avatar.Create(avatarData.AvatarId, player.User.Uid, player.Equipment);
|
avatar = Common.Database.Avatar.Create(avatarData.AvatarId, player.User.Uid, player.Equipment);
|
||||||
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AvatarScheme avatar = Common.Database.Avatar.Create(avatarId, player.User.Uid, player.Equipment);
|
avatar = Common.Database.Avatar.Create(avatarId, player.User.Uid, player.Equipment);
|
||||||
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
player.AvatarList = player.AvatarList.Append(avatar).ToArray();
|
||||||
}
|
}
|
||||||
player.Equipment.Save();
|
player.Equipment.Save();
|
||||||
break;
|
break;
|
||||||
|
case "modify":
|
||||||
|
if (avatarId == -1)
|
||||||
|
{
|
||||||
|
foreach (var av in player.AvatarList)
|
||||||
|
{
|
||||||
|
av.GetType()?.GetProperty(modType)?.SetValue(av, (uint)value, null);
|
||||||
|
av.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
avatar = player.AvatarList.FirstOrDefault(av => av.AvatarId == avatarId);
|
||||||
|
if (avatar is not null)
|
||||||
|
{
|
||||||
|
avatar.GetType()?.GetProperty(modType)?.SetValue(avatar, value, null);
|
||||||
|
avatar.Save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c.Error("Invalid AvatarScheme in avatar modify command");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException("Unrecognized action");
|
throw new ArgumentException("Unrecognized action");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user