mirror of
https://github.com/rafi1212122/BLHX.Server.git
synced 2025-12-14 23:45:01 +01:00
add item handling and some gacha stuff
This commit is contained in:
@@ -16,38 +16,44 @@ namespace BLHX.Server.Game.Commands {
|
||||
public override void Execute(Dictionary<string, string> args, Connection connection) {
|
||||
base.Execute(args);
|
||||
|
||||
uint amount = 1;
|
||||
//uint amount = 1;
|
||||
|
||||
if (Amount is not null) {
|
||||
uint.TryParse(Amount, out uint parsedAmount);
|
||||
amount = parsedAmount;
|
||||
}
|
||||
//if (Amount is not null) {
|
||||
// uint.TryParse(Amount, out uint parsedAmount);
|
||||
// amount = parsedAmount;
|
||||
//}
|
||||
|
||||
if (Unlock is not null) {
|
||||
if (Unlock.Equals("all", StringComparison.CurrentCultureIgnoreCase)) {
|
||||
// ...
|
||||
} else if (uint.TryParse(Unlock, out uint itemId)) {
|
||||
//connection.player.DoResource(itemId, amount);
|
||||
PlayerResource? item = DBManager.PlayerContext.Resources.Where(res => res.Id == itemId).FirstOrDefault();
|
||||
//if (Unlock is not null) {
|
||||
// if (Unlock.Equals("all", StringComparison.CurrentCultureIgnoreCase)) {
|
||||
// // ...
|
||||
// } else if (uint.TryParse(Unlock, out uint itemId)) {
|
||||
// //connection.player.DoResource(itemId, amount);
|
||||
// PlayerResource? item = DBManager.PlayerContext.Resources.Where(res => res.Id == itemId).FirstOrDefault();
|
||||
|
||||
if (item is null) {
|
||||
DBManager.PlayerContext.Resources.Add(new PlayerResource() { Id = itemId, PlayerUid = connection.player.Uid, Num = 1 });
|
||||
//connection.player.DoResource(itemId, 1);
|
||||
// if (item is null) {
|
||||
// DBManager.PlayerContext.Resources.Add(new PlayerResource() { Id = itemId, PlayerUid = connection.player.Uid, Num = 1 });
|
||||
// //connection.player.DoResource(itemId, 1);
|
||||
|
||||
//item = DBManager.PlayerContext.Resources.Where(res => res.Id == itemId).FirstOrDefault();
|
||||
} else {
|
||||
item.Num += amount;
|
||||
connection.SendSystemMsg($"{amount} item of itemid: {itemId} added!");
|
||||
}
|
||||
// //item = DBManager.PlayerContext.Resources.Where(res => res.Id == itemId).FirstOrDefault();
|
||||
// } else {
|
||||
// item.Num += amount;
|
||||
// connection.SendSystemMsg($"{amount} item of itemid: {itemId} added!");
|
||||
// }
|
||||
|
||||
|
||||
// } else {
|
||||
// connection.SendSystemMsg($"Invalid ItemId: {itemId}");
|
||||
// }
|
||||
//}
|
||||
|
||||
connection.player.DoResource(1, 938493849);
|
||||
connection.player.DoResource(4, 39843294);
|
||||
|
||||
|
||||
} else {
|
||||
connection.SendSystemMsg($"Invalid ItemId: {itemId}");
|
||||
}
|
||||
}
|
||||
|
||||
DBManager.PlayerContext.Save();
|
||||
connection.NotifyPlayerData();
|
||||
connection.NotifyBagData();
|
||||
base.NotifySuccess(connection);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user