From e58417f4fa0bdf240056521bd2b381b939adb9fc Mon Sep 17 00:00:00 2001 From: Kyle873 Date: Fri, 9 Jun 2023 21:40:00 -0400 Subject: [PATCH] fixes and improvements to give command --- GameServer/Commands/GiveCommand.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/GameServer/Commands/GiveCommand.cs b/GameServer/Commands/GiveCommand.cs index ffaba95..c6c4be0 100644 --- a/GameServer/Commands/GiveCommand.cs +++ b/GameServer/Commands/GiveCommand.cs @@ -7,7 +7,7 @@ namespace PemukulPaku.GameServer.Commands { [CommandHandler("give", " [#] [id]", CommandType.Player, //example commands list - "gold 123456789","stigs 1", "weaps", "mats 999 2008", "valks", "outfits" + "gold 123456789", "stigs 1", "weaps", "mats 999 2008", "valks", "outfits" )] internal class GiveCommand : Command { @@ -22,7 +22,7 @@ namespace PemukulPaku.GameServer.Commands public override void Run(Player player, string[] args) { string action = args[0]; - int value = (args.Length > 1 && args[1] is not null) ? int.Parse(args[1]) : -1; + int? value = (args.Length >= 2 && args[1] is not null) ? int.Parse(args[1]) : null; switch (action) { @@ -91,14 +91,18 @@ namespace PemukulPaku.GameServer.Commands case "mats": case "matz": foreach (MaterialDataExcel materialData in MaterialData.GetInstance().All) - { - player.Equipment.AddMaterial(materialData.Id, value > 0 || value < -1 ? value : 9999); + { + player.Equipment.AddMaterial(materialData.Id, value is not null && value != 0 ? (int)value : materialData.QuantityLimit); } break; case "material-id": case "gold": - int materialId = args[2] is not null ? int.Parse(args[2]) : 100; - player.Equipment.AddMaterial(materialId, value > 0 || value < -1 ? value : 9999); + int materialId = args.Length >= 3 && args[2] is not null ? int.Parse(args[2]) : 100; + int? quantityLimit = MaterialData.GetInstance().All.FirstOrDefault(m => m.Id == materialId)?.QuantityLimit; + if (quantityLimit is not null) + { + player.Equipment.AddMaterial(materialId, value is not null && value != 0 ? (int)value : (int)quantityLimit); + } break; case "dress": case "outfits":