I have no clue if this works

This commit is contained in:
Kyle Belanger 2023-11-28 07:51:39 -05:00
parent e91b49b07a
commit fe9146e6e4
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
using AscNet.Common.Util;
using AscNet.Table.V2.share.player;
namespace AscNet.GameServer.Commands
{
[CommandName("level")]
internal class LevelCommand : Command
{
public LevelCommand(Session session, string[] args, bool validate = true) : base(session, args, validate) { }
public override string Help => "Command to change the Commandant level";
[Argument(0, @"^[0-9]+$|^max$", "The target level, value is number or 'max'")]
string Level { get; set; } = string.Empty;
public override void Execute()
{
int maxLevel = TableReaderV2.Parse<PlayerTable>().Count;
int level = Miscs.ParseIntOr(Level);
if (Level == "max")
{
session.player.PlayerData.Level = maxLevel;
session.ExpSanityCheck();
}
else if (level > 0)
{
session.player.PlayerData.Level = level;
session.ExpSanityCheck();
}
else
{
throw new ArgumentException("Invalid Level!");
}
}
}
}