diff --git a/AscNet.GameServer/Commands/Command.cs b/AscNet.GameServer/Commands/Command.cs index 3033475..eb2c142 100644 --- a/AscNet.GameServer/Commands/Command.cs +++ b/AscNet.GameServer/Commands/Command.cs @@ -58,14 +58,19 @@ namespace AscNet.GameServer.Commands public class ArgumentAttribute : Attribute { public int Position { get; } - public Regex Pattern { get; } + public Regex Pattern { get; set; } public string? Description { get; } public ArgumentFlags Flags { get; } public ArgumentAttribute(int position, string pattern, string? description = null, ArgumentFlags flags = ArgumentFlags.None) { Position = position; - Pattern = new(pattern); + + if ((flags & ArgumentFlags.IgnoreCase) != ArgumentFlags.IgnoreCase) + Pattern = new(pattern); + else + Pattern = new(pattern, RegexOptions.IgnoreCase); + Description = description; Flags = flags; } @@ -74,7 +79,8 @@ namespace AscNet.GameServer.Commands public enum ArgumentFlags { None = 0, - Optional = 1 + Optional = 1, + IgnoreCase = 2 } [AttributeUsage(AttributeTargets.Class)] diff --git a/AscNet.GameServer/Commands/ItemCommand.cs b/AscNet.GameServer/Commands/ItemCommand.cs index a1ef14c..0337094 100644 --- a/AscNet.GameServer/Commands/ItemCommand.cs +++ b/AscNet.GameServer/Commands/ItemCommand.cs @@ -11,7 +11,7 @@ namespace AscNet.GameServer.Commands public override string Help => "Command to interact with user's items"; - [Argument(0, @"^add$|^clear$|^reset$", "The operation selected (add, clear, reset)")] + [Argument(0, @"^add$|^clear$|^reset$", "The operation selected (add, clear, reset)", ArgumentFlags.IgnoreCase)] string Op { get; set; } = string.Empty; [Argument(1, @"^[0-9]+$|^all$", "The target item, value is item id or 'all'", ArgumentFlags.Optional)] @@ -22,7 +22,7 @@ namespace AscNet.GameServer.Commands public override void Execute() { - switch (Op) + switch (Op.ToLower()) { case "add": if (Target == "all")