mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 08:54:36 +01:00
avatar cmd & update assistant
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Common.Database
|
|||||||
EquipmentScheme Equipment = new()
|
EquipmentScheme Equipment = new()
|
||||||
{
|
{
|
||||||
OwnerUid = uid,
|
OwnerUid = uid,
|
||||||
MaterialList = Array.Empty<Resources.Proto.Material>(),
|
MaterialList = new Resources.Proto.Material[] { new Resources.Proto.Material { Id = 100, Num = 750 }, new Resources.Proto.Material { Id = 119107, Num = 6 } },
|
||||||
WeaponList = Array.Empty<Weapon>(),
|
WeaponList = Array.Empty<Weapon>(),
|
||||||
StigmataList = Array.Empty<Stigmata>(),
|
StigmataList = Array.Empty<Stigmata>(),
|
||||||
MechaList = Array.Empty<Mecha>(),
|
MechaList = Array.Empty<Mecha>(),
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ namespace Common.Utils.ExcelReader
|
|||||||
int level = 1;
|
int level = 1;
|
||||||
int expRemain = exp;
|
int expRemain = exp;
|
||||||
|
|
||||||
foreach (var levelData in All)
|
foreach (PlayerLevelDataExcel levelData in All)
|
||||||
{
|
{
|
||||||
if(expRemain < 1)
|
if(expRemain < 1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(expRemain > levelData.Exp)
|
else if(expRemain >= levelData.Exp)
|
||||||
{
|
{
|
||||||
level++;
|
level++;
|
||||||
expRemain -= levelData.Exp;
|
expRemain -= levelData.Exp;
|
||||||
@@ -42,6 +42,26 @@ namespace Common.Utils.ExcelReader
|
|||||||
|
|
||||||
return new LevelData(level, expRemain);
|
return new LevelData(level, expRemain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LevelData CalculateExpForLevel(int level)
|
||||||
|
{
|
||||||
|
int exp = 0;
|
||||||
|
|
||||||
|
foreach (PlayerLevelDataExcel levelData in All)
|
||||||
|
{
|
||||||
|
if (levelData.Level >= level)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
exp += levelData.Exp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LevelData(level, exp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||||
|
|||||||
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
GameServer/Commands/LevelCommand.cs
Normal file
30
GameServer/Commands/LevelCommand.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Common.Utils.ExcelReader;
|
||||||
|
using PemukulPaku.GameServer.Game;
|
||||||
|
using Common.Resources.Proto;
|
||||||
|
|
||||||
|
namespace PemukulPaku.GameServer.Commands
|
||||||
|
{
|
||||||
|
[CommandHandler("level", "Modify the player captain level", CommandType.Player)]
|
||||||
|
internal class LevelCommand : Command
|
||||||
|
{
|
||||||
|
public override void Run(Session session, string[] args)
|
||||||
|
{
|
||||||
|
Run(session.Player, args);
|
||||||
|
|
||||||
|
GetMainDataRsp Rsp = new()
|
||||||
|
{
|
||||||
|
retcode = GetMainDataRsp.Retcode.Succ,
|
||||||
|
Level = (uint)PlayerLevelData.GetInstance().CalculateLevel(session.Player.User.Exp).Level,
|
||||||
|
Exp = (uint)PlayerLevelData.GetInstance().CalculateLevel(session.Player.User.Exp).Exp
|
||||||
|
};
|
||||||
|
session.Send(Packet.FromProto(Rsp, CmdId.GetMainDataRsp), Packet.FromProto(new PlayerLevelUpNotify() { NewLevel = Rsp.Level }, CmdId.PlayerLevelUpNotify));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Run(Player player, string[] args)
|
||||||
|
{
|
||||||
|
int level = int.Parse(args[0]);
|
||||||
|
player.User.Exp = PlayerLevelData.GetInstance().CalculateExpForLevel(level).Exp;
|
||||||
|
player.User.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,19 +25,25 @@
|
|||||||
{
|
{
|
||||||
args.RemoveAt(0);
|
args.RemoveAt(0);
|
||||||
|
|
||||||
if (Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Console)
|
try
|
||||||
{
|
{
|
||||||
Cmd.Run(args.ToArray());
|
if (Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Console)
|
||||||
|
{
|
||||||
|
Cmd.Run(args.ToArray());
|
||||||
|
}
|
||||||
|
else if(session != null)
|
||||||
|
{
|
||||||
|
Cmd.Run(session, args.ToArray());
|
||||||
|
Command.c.Log("Command executed");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Command.c.Error("Invalid usage, try selecting session first with target");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(session != null)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Command.c.Error(ex.Message);
|
||||||
Command.c.Log("Command executed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Command.c.Error("Invalid usage, try selecting session first with target");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
19
GameServer/Handlers/UpdateAssistantAvatarIdReqHandler.cs
Normal file
19
GameServer/Handlers/UpdateAssistantAvatarIdReqHandler.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Common.Resources.Proto;
|
||||||
|
|
||||||
|
namespace PemukulPaku.GameServer.Handlers
|
||||||
|
{
|
||||||
|
[PacketCmdId(CmdId.UpdateAssistantAvatarIdReq)]
|
||||||
|
public class UpdateAssistantAvatarIdReqHandler : IPacketHandler
|
||||||
|
{
|
||||||
|
public void Handle(Session session, Packet packet)
|
||||||
|
{
|
||||||
|
UpdateAssistantAvatarIdReq Data = packet.GetDecodedBody<UpdateAssistantAvatarIdReq>();
|
||||||
|
session.Player.User.AssistantAvatarId = (int)Data.AvatarId;
|
||||||
|
|
||||||
|
UpdateAssistantAvatarIdRsp Rsp = new() { retcode = UpdateAssistantAvatarIdRsp.Retcode.Succ };
|
||||||
|
GetMainDataRsp MainDataRsp = new() { retcode = GetMainDataRsp.Retcode.Succ, AssistantAvatarId = (uint)session.Player.User.AssistantAvatarId };
|
||||||
|
|
||||||
|
session.Send(Packet.FromProto(MainDataRsp, CmdId.GetMainDataRsp), Packet.FromProto(Rsp, CmdId.UpdateAssistantAvatarIdRsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user