mirror of
https://github.com/rafi1212122/BLHX.Server.git
synced 2025-12-14 07:24:50 +01:00
added all params to player database
This commit is contained in:
50
BLHX.Server.Game/Commands/SetPlayerDataCommand.cs
Normal file
50
BLHX.Server.Game/Commands/SetPlayerDataCommand.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using BLHX.Server.Common.Database;
|
||||
using BLHX.Server.Common.Utils;
|
||||
using BLHX.Server.Game.Handlers;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace BLHX.Server.Game.Commands;
|
||||
|
||||
// Chatbox has 40 character limit, original command is setplayerdata shortened -> spd
|
||||
[CommandHandler("spd", "set a player's data", "spd property=level value=20")]
|
||||
public class SetPlayerDataCommand : Command {
|
||||
|
||||
[Argument("property")]
|
||||
public string? Property { get; set; }
|
||||
|
||||
[Argument("value")]
|
||||
public string? Value { get; set; }
|
||||
|
||||
public override void Execute(Dictionary<string, string> args, Connection connection) {
|
||||
base.Execute(args);
|
||||
|
||||
if (Property is null || Value is null) {
|
||||
connection.SendSystemMsg($"Usage: /spd property=<Level|Name|Exp|ShipBagMax|...> value=1");
|
||||
return;
|
||||
}
|
||||
|
||||
PropertyInfo? targetProperty = typeof(Player).GetProperty(Property);
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(targetProperty.PropertyType);
|
||||
|
||||
if (converter != null && converter.CanConvertFrom(typeof(string))) {
|
||||
try {
|
||||
object targetValue = converter.ConvertFromInvariantString(Value);
|
||||
|
||||
targetProperty.SetValue(connection.player, targetValue);
|
||||
} catch (Exception) {
|
||||
connection.SendSystemMsg("Invalid Value");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
connection.SendSystemMsg($"Invalid Player Property!");
|
||||
return;
|
||||
}
|
||||
|
||||
DBManager.PlayerContext.Save();
|
||||
connection.NotifyPlayerData();
|
||||
connection.SendSystemMsg($"Set Player with UID {connection.player.Uid}'s {Property} to {Value}");
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace BLHX.Server.Game.Commands {
|
||||
base.Execute(args);
|
||||
|
||||
if (Unlock is null) {
|
||||
Logger.c.Log($"Usage: /ship unlock=<all|clear|shipId> rarity=1-6");
|
||||
connection.SendSystemMsg($"Usage: /ship unlock=<all|clear|shipId> rarity=1-6");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BLHX.Server.Game.Commands {
|
||||
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)).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
|
||||
connection.player.Ships = all_ships;
|
||||
|
||||
@@ -75,18 +75,45 @@ namespace BLHX.Server.Game.Handlers {
|
||||
Exp = connection.player.Exp,
|
||||
Adv = connection.player.Adv,
|
||||
ResourceLists = connection.player.Resources.Select(x => new Resource() { Num = x.Num, Type = x.Id }).ToList(),
|
||||
Characters = [1],
|
||||
Characters = connection.player.Characters,
|
||||
WinCount = connection.player.WinCount,
|
||||
AttackCount = connection.player.AttackCount,
|
||||
ShipBagMax = connection.player.ShipBagMax,
|
||||
EquipBagMax = 350,
|
||||
GmFlag = 1,
|
||||
Rank = 1,
|
||||
GuideIndex = 1000000,
|
||||
ChatRoomId = 1,
|
||||
EquipBagMax = connection.player.EquipBagMax,
|
||||
GmFlag = connection.player.GmFlag,
|
||||
Rank = connection.player.Rank,
|
||||
PvpAttackCount = connection.player.PvpAttackCount,
|
||||
PvpWinCount = connection.player.PvpWinCount,
|
||||
CollectAttackCount = connection.player.CollectAttackCount,
|
||||
GuideIndex = connection.player.GuideIndex,
|
||||
BuyOilCount = connection.player.BuyOilCount,
|
||||
ChatRoomId = connection.player.ChatRoomId,
|
||||
MaxRank = connection.player.MaxRank,
|
||||
AccPayLv = connection.player.AccPayLv,
|
||||
GuildWaitTime = connection.player.GuildWaitTime,
|
||||
ChatMsgBanTime = connection.player.ChatMsgBanTime,
|
||||
ThemeUploadNotAllowedTime = connection.player.ThemeUploadNotAllowedTime,
|
||||
RandomShipMode = connection.player.RandomShipMode,
|
||||
MarryShip = connection.player.MarryShip,
|
||||
ChildDisplay = connection.player.ChildDisplay,
|
||||
StoryLists = connection.player.StoryLists,
|
||||
FlagLists = connection.player.FlagLists,
|
||||
MedalIds = connection.player.MedalIds,
|
||||
CartoonReadMarks = connection.player.CartoonReadMarks,
|
||||
CartoonCollectMarks = connection.player.CartoonCollectMarks,
|
||||
RandomShipLists = connection.player.RandomShipLists,
|
||||
Soundstories = connection.player.Soundstories,
|
||||
CardLists = connection.player.CardLists,
|
||||
CdLists = connection.player.CdLists,
|
||||
IconFrameLists = connection.player.IconFrameLists,
|
||||
ChatFrameLists = connection.player.ChatFrameLists,
|
||||
RefundShopInfoLists = connection.player.RefundShopInfoLists,
|
||||
TakingShipLists = connection.player.TakingShipLists,
|
||||
RegisterTime = (uint)new DateTimeOffset(connection.player.CreatedAt).ToUnixTimeSeconds(),
|
||||
ShipCount = (uint)connection.player.Ships.Count,
|
||||
CommanderBagMax = 40,
|
||||
ShipCount = connection.player.ShipCount,
|
||||
CommanderBagMax = connection.player.CommanderBagMax,
|
||||
Display = connection.player.DisplayInfo,
|
||||
Appreciation = new()
|
||||
Appreciation = connection.player.Appreciation,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BLHX.Server.Game.Handlers {
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs12002, SaveDataAfterRun = true)]
|
||||
static void UseResourceHandler(Connection connection, Packet packet) {
|
||||
static void BuildHandler(Connection connection, Packet packet) {
|
||||
var req = packet.Decode<Cs12002>();
|
||||
|
||||
Logger.c.Log("Id: " + req.Id);
|
||||
@@ -45,7 +45,7 @@ namespace BLHX.Server.Game.Handlers {
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs12008, SaveDataAfterRun = true)]
|
||||
static void FinishAllBuildHandler(Connection connection, Packet packet) {
|
||||
static void FinishBuildHandler(Connection connection, Packet packet) {
|
||||
var req = packet.Decode<Cs12008>();
|
||||
|
||||
connection.Send(new Sc12009() { PosLists = req.PosLists });
|
||||
|
||||
Reference in New Issue
Block a user