From 91042d06ebac3b213a44e3202e534844ba0c2b88 Mon Sep 17 00:00:00 2001 From: raphaeIl Date: Wed, 3 Apr 2024 06:03:45 -0400 Subject: [PATCH] add rarity option for shipcommand --- BLHX.Server.Common/Database/Player.cs | 2 +- BLHX.Server.Game/Commands/ShipCommand.cs | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/BLHX.Server.Common/Database/Player.cs b/BLHX.Server.Common/Database/Player.cs index 60f1b3f..85048eb 100644 --- a/BLHX.Server.Common/Database/Player.cs +++ b/BLHX.Server.Common/Database/Player.cs @@ -159,7 +159,7 @@ namespace BLHX.Server.Common.Database { public string Name { get; set; } // Aka. manifesto public string Adv { get; set; } = string.Empty; - public uint ShipBagMax { get; set; } = 9990; + public uint ShipBagMax { get; set; } = 9854938; public uint Level { get; set; } // TODO: Exp add setter to recalculate cap and set level public uint Exp { get; set; } diff --git a/BLHX.Server.Game/Commands/ShipCommand.cs b/BLHX.Server.Game/Commands/ShipCommand.cs index c5266ba..00d993c 100644 --- a/BLHX.Server.Game/Commands/ShipCommand.cs +++ b/BLHX.Server.Game/Commands/ShipCommand.cs @@ -5,23 +5,33 @@ using BLHX.Server.Common.Utils; using BLHX.Server.Game.Handlers; namespace BLHX.Server.Game.Commands { - [CommandHandler("ship", "Unlock a character or all characters", "ship unlock=all")] + [CommandHandler("ship", "Unlock a character or all characters", "ship unlock=all rarity=6")] public class ShipCommand : Command { [Argument("unlock")] public string? Unlock { get; set; } + [Argument("rarity")] + public string? Rarity { get; set; } + public override void Execute(Dictionary args, Connection connection) { base.Execute(args); if (Unlock is null) { - Logger.c.Log($"Usage: /ship unlock="); + Logger.c.Log($"Usage: /ship unlock= rarity=1-6"); return; } if (Unlock.Equals("all", StringComparison.CurrentCultureIgnoreCase)) { - int amount = 585; // not sure why but if you add more than this amount the client crashes - List all_ship_ids = Data.ShipDataTemplate.Where(x => x.Value.Star == x.Value.StarMax && x.Value.Star >= 5).ToDictionary().Keys.ToList(); - List all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).ToList(); + int amount = 585; // adding more than this currently causes the client to crash since too much data is sent in a single packet + Dictionary ship_ids_filter = Data.ShipDataTemplate.Where(x => x.Value.Star == x.Value.StarMax && x.Value.Star >= 5).ToDictionary(); + + List all_ship_ids = ship_ids_filter.Keys.ToList(); + + if (Rarity is not null && int.TryParse(Rarity, out int rarity)) { + all_ship_ids = Data.ShipDataStatistics.Where(ship_data => all_ship_ids.Contains(ship_data.Key) && ship_data.Value.Rarity == rarity).ToDictionary().Keys.ToList(); + } + + List all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).Take(amount).ToList(); all_ships.AddRange(GetDefaultShips(connection.player.Ships)); // add the defaults connection.player.Ships = all_ships; @@ -39,6 +49,7 @@ namespace BLHX.Server.Game.Commands { return; } + Rarity = null; DBManager.PlayerContext.Save(); connection.NotifyShipData(); base.NotifySuccess(connection);