add rarity option for shipcommand

This commit is contained in:
raphaeIl
2024-04-03 06:03:45 -04:00
parent cea1a22103
commit 91042d06eb
2 changed files with 17 additions and 6 deletions

View File

@@ -159,7 +159,7 @@ namespace BLHX.Server.Common.Database {
public string Name { get; set; } public string Name { get; set; }
// Aka. manifesto // Aka. manifesto
public string Adv { get; set; } = string.Empty; public string Adv { get; set; } = string.Empty;
public uint ShipBagMax { get; set; } = 9990; public uint ShipBagMax { get; set; } = 9854938;
public uint Level { get; set; } public uint Level { get; set; }
// TODO: Exp add setter to recalculate cap and set level // TODO: Exp add setter to recalculate cap and set level
public uint Exp { get; set; } public uint Exp { get; set; }

View File

@@ -5,23 +5,33 @@ using BLHX.Server.Common.Utils;
using BLHX.Server.Game.Handlers; using BLHX.Server.Game.Handlers;
namespace BLHX.Server.Game.Commands { 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 { public class ShipCommand : Command {
[Argument("unlock")] [Argument("unlock")]
public string? Unlock { get; set; } public string? Unlock { get; set; }
[Argument("rarity")]
public string? Rarity { get; set; }
public override void Execute(Dictionary<string, string> args, Connection connection) { public override void Execute(Dictionary<string, string> args, Connection connection) {
base.Execute(args); base.Execute(args);
if (Unlock is null) { if (Unlock is null) {
Logger.c.Log($"Usage: /ship unlock=<all|clear|shipId>"); Logger.c.Log($"Usage: /ship unlock=<all|clear|shipId> rarity=1-6");
return; return;
} }
if (Unlock.Equals("all", StringComparison.CurrentCultureIgnoreCase)) { if (Unlock.Equals("all", StringComparison.CurrentCultureIgnoreCase)) {
int amount = 585; // not sure why but if you add more than this amount the client crashes int amount = 585; // adding more than this currently causes the client to crash since too much data is sent in a single packet
List<int> all_ship_ids = Data.ShipDataTemplate.Where(x => x.Value.Star == x.Value.StarMax && x.Value.Star >= 5).ToDictionary().Keys.ToList(); Dictionary<int, ShipDataTemplate> ship_ids_filter = Data.ShipDataTemplate.Where(x => x.Value.Star == x.Value.StarMax && x.Value.Star >= 5).ToDictionary();
List<PlayerShip> all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).ToList();
List<int> 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<PlayerShip> 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 all_ships.AddRange(GetDefaultShips(connection.player.Ships)); // add the defaults
connection.player.Ships = all_ships; connection.player.Ships = all_ships;
@@ -39,6 +49,7 @@ namespace BLHX.Server.Game.Commands {
return; return;
} }
Rarity = null;
DBManager.PlayerContext.Save(); DBManager.PlayerContext.Save();
connection.NotifyShipData(); connection.NotifyShipData();
base.NotifySuccess(connection); base.NotifySuccess(connection);