This commit is contained in:
rafi1212122
2023-06-12 20:06:29 +07:00
4 changed files with 188 additions and 103 deletions

View File

@@ -7,7 +7,7 @@ namespace PemukulPaku.GameServer.Commands
{
[CommandHandler("give", "<sel> [#] [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)
{
@@ -56,7 +56,7 @@ namespace PemukulPaku.GameServer.Commands
if (weaponData.EvoId == 0)
{
Weapon weapon = player.Equipment.AddWeapon(weaponData.Id);
weapon.Level = value <= 0 ? (uint)weaponData.MaxLv : (uint)value;
weapon.Level = value is not null && value <= 0 ? (uint)weaponData.MaxLv : value is not null ? (uint)value : (uint)weaponData.MaxLv;
}
}
break;
@@ -65,7 +65,7 @@ namespace PemukulPaku.GameServer.Commands
foreach (WeaponDataExcel weaponData in WeaponData.GetInstance().All)
{
Weapon weapon = player.Equipment.AddWeapon(weaponData.Id);
weapon.Level = value <= 0 ? (uint)weaponData.MaxLv : (uint)value;
weapon.Level = value is not null && value <= 0 ? (uint)weaponData.MaxLv : value is not null ? (uint)value : (uint)weaponData.MaxLv;
}
break;
case "stigmata":
@@ -75,7 +75,7 @@ namespace PemukulPaku.GameServer.Commands
if (stigmataData.EvoId == 0)
{
Stigmata stigmata = player.Equipment.AddStigmata(stigmataData.Id);
stigmata.Level = value <= 0 ? (uint)stigmataData.MaxLv : (uint)value;
stigmata.Level = value is not null && value <= 0 ? (uint)stigmataData.MaxLv : value is not null ? (uint)value : (uint)stigmataData.MaxLv;
}
}
break;
@@ -84,21 +84,25 @@ namespace PemukulPaku.GameServer.Commands
foreach (StigmataDataExcel stigmataData in StigmataData.GetInstance().All)
{
Stigmata stigmata = player.Equipment.AddStigmata(stigmataData.Id);
stigmata.Level = value <= 0 ? (uint)stigmataData.MaxLv : (uint)value;
stigmata.Level = value is not null && value <= 0 ? (uint)stigmataData.MaxLv : value is not null ? (uint)value : (uint)stigmataData.MaxLv;
}
break;
case "materials":
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":

View File

@@ -1,5 +1,6 @@
using Common.Resources.Proto;
using Common;
using System.Text;
namespace PemukulPaku.GameServer.Commands
{
@@ -9,26 +10,26 @@ namespace PemukulPaku.GameServer.Commands
{
public override void Run(Session session, string[] args)
{
RecvChatMsgNotify notify = new() { };
RecvChatMsgNotify notify = new();
//hardcoding values is fun AND easy!
string msg = "<color=#B00B><size=26>Commands</size></color><size=16><color=#555>\n";
msg += "command <required> [optional]\n";
//msg += "┌\n";
StringBuilder msg = new("<color=#B00B><size=26>Commands</size></color><size=16><color=#555>\n");
msg.Append("command <required> [optional]\n");
//msg.Append("┌\n");
foreach (Command Cmd in CommandFactory.Commands)
{
if(Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Player)
if (Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Player)
{
msg += "┝<size=22>" + Cmd.Name + " " + Cmd.Description + "</size>\n";
msg.Append("┝<size=22>" + Cmd.Name + " " + Cmd.Description + "</size>\n");
if (Cmd.Examples is not null)
{
foreach (string Example in Cmd.Examples)
{
msg += "│┕" + Example + "\n";
msg.Append("│┕" + Example + "\n");
}
}
}
}
}
msg += "</color></size>";
msg.Append("</color></size>");
//I really want to figure out how to grab from Chatroom.cs instead, but oh well.
ChatMsg AiMsg = new()
@@ -36,16 +37,16 @@ namespace PemukulPaku.GameServer.Commands
Uid = 0,
Nickname = "Ai-chan",
Time = (uint)Global.GetUnixInSeconds(),
Msg = msg,
Content = new() { },
Msg = msg.ToString(),
Content = new(),
Channel = ChatMsg.MsgChannel.World,
AvatarId = 3201,
DressId = 593201,
FrameId = 200001,
CustomHeadId = 161080,
CheckResult = new() { NumberCheck = 0, ShieldType = 0, RewriteText = msg }
CheckResult = new() { NumberCheck = 0, ShieldType = 0, RewriteText = msg.ToString() }
};
AiMsg.Content.Items.Add(new() { MsgStr = msg });
AiMsg.Content.Items.Add(new() { MsgStr = msg.ToString() });
notify.ChatMsgLists.Add(AiMsg);
session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
}
@@ -54,7 +55,7 @@ namespace PemukulPaku.GameServer.Commands
{
foreach (Command Cmd in CommandFactory.Commands)
{
Console.ForegroundColor= ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" " + Cmd.Name);
Console.ResetColor();
c.Trail(Cmd.Description);