namespace Supercell.Laser.Server.Handler { using Supercell.Laser.Logic.Avatar; using Supercell.Laser.Logic.Data; using Supercell.Laser.Logic.Home; using Supercell.Laser.Logic.Message.Account; using Supercell.Laser.Logic.Message.Account.Auth; using Supercell.Laser.Logic.Util; using Supercell.Laser.Server.Database; using Supercell.Laser.Server.Database.Cache; using Supercell.Laser.Server.Database.Models; using Supercell.Laser.Server.Networking.Session; using Supercell.Laser.Server.Logic.Game; using System.Reflection; using System.Linq; public static class CmdHandler { public static void Start() { while (true) { try { string cmd = Console.ReadLine(); if (cmd == null) continue; if (!cmd.StartsWith("/")) continue; cmd = cmd.Substring(1); string[] args = cmd.Split(" "); if (args.Length < 1) continue; switch (args[0]) { case "premium": ExecuteGivePremiumToAccount(args); break; case "ban": ExecuteBanAccount(args); break; case "unban": ExecuteUnbanAccount(args); break; case "changename": ExecuteChangeNameForAccount(args); break; case "getvalue": ExecuteGetFieldValue(args); break; case "changevalue": ExecuteChangeValueForAccount(args); break; case "unlockall": ExecuteUnlockAllForAccount(args); break; case "giveskin": ExecuteGiveSkin(args); break; case "notify": ExecuteNotify(args); break; case "givegold": ExecuteGiveGold(args); break; case "givediamonds": ExecuteGiveDiamonds(args); break; case "info": ExecuteInfo(args); break; case "kick": ExecuteKick(args); break; case "addpowerpoints": ExecuteAddPowerPoints(args); break; case "transferaccount": ExecuteTransferAccount(args); break; case "wipe": ExecuteWipe(args); break; case "serverstats": ExecuteServerStats(); break; case "givestarpoints": ExecuteGiveStarPoints(args); break; case "givebrawler": ExecuteGiveBrawler(args); break; case "resetbrawler": ExecuteResetBrawler(args); break; case "settrophies": ExecuteSetTrophies(args); break; case "resettrophies": ExecuteResetTrophies(args); break; case "online": ExecuteOnline(); break; case "broadcast": ExecuteBroadcast(args); break; case "help": ExecuteHelp(); break; case "maintenance": Console.WriteLine("Starting maintenance..."); ExecuteShutdown(); Console.WriteLine("Maintenance started!"); break; } } catch (Exception) { } } } private static void ExecuteUnlockAllForAccount(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /unlockall [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } for (int i = 0; i < HomeMode.UNLOCKABLE_HEROES_COUNT; i++) { if (!account.Avatar.HasHero(16000000 + i)) { CharacterData character = DataTables.Get(16).GetDataWithId(i); CardData card = DataTables.Get(23).GetData(character.Name + "_unlock"); account.Avatar.UnlockHero(character.GetGlobalId(), card.GetGlobalId()); } } Logger.Print($"Successfully unlocked all brawlers for account {account.AccountId.GetHigherInt()}-{account.AccountId.GetLowerInt()} ({args[1]})"); if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteGivePremiumToAccount(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /premium [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.IsPremium = true; if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteUnbanAccount(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /unban [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.Banned = false; if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteBanAccount(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /ban [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.Banned = true; account.Avatar.ResetTrophies(); account.Avatar.Name = "Brawler"; if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteChangeNameForAccount(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /changevalue [TAG] [NewName]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.Name = args[2]; if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteGetFieldValue(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /changevalue [TAG] [FieldName]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } Type type = typeof(ClientAvatar); FieldInfo field = type.GetField(args[2]); if (field == null) { Console.WriteLine($"Fail: LogicClientAvatar::{args[2]} not found!"); return; } int value = (int)field.GetValue(account.Avatar); Console.WriteLine($"LogicClientAvatar::{args[2]} = {value}"); } private static void ExecuteChangeValueForAccount(string[] args) { if (args.Length != 4) { Console.WriteLine("Usage: /changevalue [TAG] [FieldName] [Value]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } Type type = typeof(ClientAvatar); FieldInfo field = type.GetField(args[2]); if (field == null) { Console.WriteLine($"Fail: LogicClientAvatar::{args[2]} not found!"); return; } field.SetValue(account.Avatar, int.Parse(args[3])); if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Your account updated!" }); Sessions.Remove(id); } } private static void ExecuteAddPowerPoints(string[] args) { if (args.Length != 4) { Console.WriteLine("Usage: /addpowerpoints [TAG] [BrawlerName] [Amount]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } CharacterData character = FindCharacter(args[2]); if (character == null) { Console.WriteLine($"Fail: боец '{args[2]}' не найден."); return; } var hero = account.Avatar.GetHero(character.GetGlobalId()); if (hero == null) { Console.WriteLine($"Fail: у игрока нет бойца {args[2]}."); return; } if (!int.TryParse(args[3], out int amount) || amount <= 0) { Console.WriteLine("Fail: Amount должен быть > 0."); return; } hero.PowerPoints += amount; int[] ppPerLevel = { 20, 30, 50, 80, 130, 210, 340, 550, 890 }; for (int lvl = hero.PowerLevel; lvl < 9; lvl++) { int needed = ppPerLevel[lvl]; if (hero.PowerPoints >= needed) { hero.PowerPoints -= needed; hero.PowerLevel++; } else break; } Console.WriteLine($"Боец {character.Name} у {account.Avatar.Name}: уровень {hero.PowerLevel + 1}, PP {hero.PowerPoints}."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Боец {character.Name} прокачан! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteTransferAccount(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /transferaccount [TAG_from] [TAG_to]"); return; } long fromId = LogicLongCodeGenerator.ToId(args[1]); long toId = LogicLongCodeGenerator.ToId(args[2]); Account from = Accounts.Load(fromId); Account to = Accounts.Load(toId); if (from == null) { Console.WriteLine("Fail: аккаунт FROM не найден!"); return; } if (to == null) { Console.WriteLine("Fail: аккаунт TO не найден!"); return; } // Берём свежие копии из БД напрямую (без кэша) чтобы избежать проблем со ссылками Account fromFresh = Accounts.LoadNoChache(fromId); Account toFresh = Accounts.LoadNoChache(toId); if (fromFresh == null) { Console.WriteLine("Fail: FROM не удалось загрузить из БД!"); return; } if (toFresh == null) { Console.WriteLine("Fail: TO не удалось загрузить из БД!"); return; } long toAccountId = toFresh.Avatar.AccountId; string toPassToken = toFresh.PassToken; string toName = toFresh.Avatar.Name; toFresh.Avatar = fromFresh.Avatar; toFresh.Avatar.AccountId = toAccountId; toFresh.Avatar.Name = toName; toFresh.PassToken = toPassToken; toFresh.Home = fromFresh.Home; // Обновляем кэш и сохраняем в БД AccountCache.Cache(toFresh); Accounts.Save(toFresh); Console.WriteLine($"Прогресс перенесён с {args[1]} на {args[2]} ({toName})."); if (Sessions.IsSessionActive(toId)) { Sessions.GetSession(toId).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Ваш аккаунт обновлён. Переподключитесь." }); Sessions.Remove(toId); } if (Sessions.IsSessionActive(fromId)) { Sessions.GetSession(fromId).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Ваш аккаунт был перенесён администратором." }); Sessions.Remove(fromId); } } private static void ExecuteWipe(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /wipe [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.Gold = 0; account.Avatar.Diamonds = 0; account.Avatar.StarPoints = 0; account.Avatar.StarTokens = 0; account.Avatar.IsPremium = false; account.Avatar.PremiumLevel = 0; account.Avatar.ResetTrophies(); foreach (var hero in account.Avatar.Heroes) { hero.PowerLevel = 0; hero.PowerPoints = 0; hero.SelectedSkinId = 0; } account.Home.BrawlPassProgress = 0; account.Home.BrawlPassTokens = 0; Console.WriteLine($"Аккаунт {account.Avatar.Name} ({args[1]}) полностью сброшен."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { ErrorCode = 8, Message = "Ваш аккаунт был сброшен администратором." }); Sessions.Remove(id); } } private static void ExecuteServerStats() { int online = Sessions.ActiveSessions.Count; int battles = Supercell.Laser.Server.Logic.Game.Battles.GetBattlesCount(); int teams = Teams.Count; long accounts = Accounts.GetTotalAccounts(); Console.WriteLine("=== Статистика сервера ==="); Console.WriteLine($" Онлайн игроков: {online}"); Console.WriteLine($" Активных боёв: {battles}"); Console.WriteLine($" Открытых румов: {teams}"); Console.WriteLine($" Аккаунтов в БД: {accounts}"); } private static void ExecuteGiveStarPoints(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /givestarpoints [TAG] [Amount]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!int.TryParse(args[2], out int amount) || amount <= 0) { Console.WriteLine("Fail: Amount должен быть > 0."); return; } account.Avatar.StarPoints += amount; Console.WriteLine($"Выдано {amount} звёздных очков {account.Avatar.Name} ({args[1]}). Итого: {account.Avatar.StarPoints}."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Вам выдано {amount} звёздных очков! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteGiveBrawler(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /givebrawler [TAG] [BrawlerName]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } CharacterData character = DataTables.Get(16).GetData(args[2]); if (character == null) { Console.WriteLine($"Fail: боец '{args[2]}' не найден."); return; } if (account.Avatar.HasHero(character.GetGlobalId())) { Console.WriteLine($"У игрока уже есть {args[2]}."); return; } CardData card = DataTables.Get(DataType.Card).GetData(character.Name + "_unlock"); if (card == null) { Console.WriteLine($"Fail: карточка для {args[2]} не найдена."); return; } account.Avatar.UnlockHero(character.GetGlobalId(), card.GetGlobalId()); Console.WriteLine($"Боец {character.Name} выдан игроку {account.Avatar.Name} ({args[1]})."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Вам выдан боец: {character.Name}! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteResetBrawler(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /resetbrawler [TAG] [BrawlerName]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } CharacterData character = FindCharacter(args[2]); if (character == null) { Console.WriteLine($"Fail: боец '{args[2]}' не найден."); return; } var hero = account.Avatar.GetHero(character.GetGlobalId()); if (hero == null) { Console.WriteLine($"Fail: у игрока нет бойца {args[2]}."); return; } hero.Trophies = 0; hero.HighestTrophies = 0; hero.PowerLevel = 0; hero.PowerPoints = 0; hero.SelectedSkinId = 0; Console.WriteLine($"Боец {character.Name} сброшен у {account.Avatar.Name} ({args[1]})."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Данные бойца сброшены. Переподключитесь." }); Sessions.Remove(id); } } private static CharacterData FindCharacter(string nameOrId) { // По GlobalId (например "16000000" или "0") if (int.TryParse(nameOrId, out int globalIdOrIndex)) { // Если маленькое число — это индекс (0 = Shelly) int globalId = globalIdOrIndex < 1000 ? 16000000 + globalIdOrIndex : globalIdOrIndex; var byId = DataTables.Get(16).GetDataByGlobalId(globalId); if (byId != null) return byId; } // Точное совпадение var exact = DataTables.Get(16).GetData(nameOrId); if (exact != null) return exact; // Без учёта регистра string lower = nameOrId.ToLower(); for (int i = 0; i < DataTables.Get(16).Count; i++) { var c = DataTables.Get(16).GetDataWithId(i); if (c != null && c.Name.ToLower() == lower) return c; } return null; } private static void ExecuteSetTrophies(string[] args) { if (args.Length != 4) { Console.WriteLine("Usage: /settrophies [TAG] [BrawlerName/Id] [Amount]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } CharacterData character = FindCharacter(args[2]); if (character == null) { Console.WriteLine($"Fail: боец '{args[2]}' не найден."); return; } var hero = account.Avatar.GetHero(character.GetGlobalId()); if (hero == null) { Console.WriteLine($"Fail: у игрока нет бойца {character.Name}."); return; } if (!int.TryParse(args[3], out int amount) || amount < 0) { Console.WriteLine("Fail: Amount должен быть >= 0."); return; } hero.Trophies = amount; hero.HighestTrophies = Math.Max(hero.HighestTrophies, amount); Console.WriteLine($"Трофеи {character.Name} установлены на {amount} у {account.Avatar.Name} ({args[1]})."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Трофеи обновлены. Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteResetTrophies(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /resettrophies [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } account.Avatar.ResetTrophies(); Console.WriteLine($"Все трофеи сброшены у {account.Avatar.Name} ({args[1]})."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = "Ваши трофеи были сброшены. Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteOnline() { var sessions = Sessions.ActiveSessions; Console.WriteLine($"=== Онлайн игроков: {sessions.Count} ==="); int i = 1; foreach (var session in sessions.Values) { if (session?.Home?.Avatar == null) continue; string tag = LogicLongCodeGenerator.ToCode(session.Home.Avatar.AccountId); Console.WriteLine($" {i++}. {session.Home.Avatar.Name} [{tag}] - трофеи: {session.Home.Avatar.Trophies}"); } } private static void ExecuteBroadcast(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: /broadcast [Text...]"); return; } string text = string.Join(" ", args.Skip(1)); var sessions = Sessions.ActiveSessions; int count = 0; foreach (var session in sessions.Values) { if (session?.GameListener == null || session.Home == null) continue; try { string key = $"broadcast_{DateTime.UtcNow.Ticks}_{count}"; session.Home.Home.SendNotification(key, 79, $"[Сервер]: {text}"); count++; } catch { } } Console.WriteLine($"Сообщение отправлено {count} игрокам: {text}"); } private static void ExecuteHelp() { Console.WriteLine("=== Команды сервера ==="); Console.WriteLine("/ban [TAG] - Забанить игрока"); Console.WriteLine("/unban [TAG] - Разбанить игрока"); Console.WriteLine("/kick [TAG] - Выкинуть из сессии"); Console.WriteLine("/info [TAG] - Инфо об аккаунте"); Console.WriteLine("/online - Список онлайн игроков"); Console.WriteLine("/broadcast [Text...] - Сообщение всем онлайн"); Console.WriteLine("/serverstats - Статистика сервера"); Console.WriteLine("/premium [TAG] - Выдать премиум"); Console.WriteLine("/givebrawler [TAG] [BrawlerName] - Выдать бойца"); Console.WriteLine("/giveskin [TAG] [SkinId] - Выдать скин по Id"); Console.WriteLine("/givegold [TAG] [Amount] - Выдать золото"); Console.WriteLine("/givediamonds [TAG] [Amount] - Выдать кристаллы"); Console.WriteLine("/givestarpoints [TAG] [Amount] - Выдать звёздные очки"); Console.WriteLine("/addpowerpoints [TAG] [Name] [Amt] - Добавить PP бойцу"); Console.WriteLine("/settrophies [TAG] [Name] [Amt] - Установить трофеи бойцу"); Console.WriteLine("/resettrophies [TAG] - Сбросить все трофеи"); Console.WriteLine("/resetbrawler [TAG] [BrawlerName] - Сбросить бойца"); Console.WriteLine("/wipe [TAG] - Полный вайп аккаунта"); Console.WriteLine("/transferaccount [TAG_from] [TAG_to] - Перенос прогресса"); Console.WriteLine("/notify [TAG] [NotifId] [Text...] - Уведомление на акк"); Console.WriteLine("/unlockall [TAG] - Разблокировать всех бойцов"); Console.WriteLine("/changename [TAG] [Name] - Сменить ник"); Console.WriteLine("/getvalue [TAG] [Field] - Получить поле аватара"); Console.WriteLine("/changevalue [TAG] [Field] [Val] - Изменить поле аватара"); Console.WriteLine("/maintenance - Остановить сервер"); } private static void ExecuteInfo(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /info [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } var a = account.Avatar; Console.WriteLine($"=== {a.Name} ({args[1]}) ==="); Console.WriteLine($"ID: {account.AccountId}"); Console.WriteLine($"Трофеи: {a.Trophies}"); Console.WriteLine($"Золото: {a.Gold}"); Console.WriteLine($"Кристаллы: {a.Diamonds}"); Console.WriteLine($"Бойцов: {a.Heroes.Count}"); Console.WriteLine($"Забанен: {a.Banned}"); Console.WriteLine($"Премиум: {a.IsPremium}"); Console.WriteLine($"Онлайн: {(Sessions.IsSessionActive(id) ? "Да" : "Нет")}"); Console.WriteLine($"LastOnline: {a.LastOnline}"); } private static void ExecuteKick(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: /kick [TAG]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!Sessions.IsSessionActive(id)) { Console.WriteLine("Игрок не онлайн."); return; } var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { ErrorCode = 7, Message = "Вы были отключены администратором." }); Sessions.Remove(id); Console.WriteLine($"Игрок {account.Avatar.Name} ({args[1]}) кикнут."); } private static void ExecuteGiveSkin(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /giveskin [TAG] [SkinId]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!int.TryParse(args[2], out int skinId)) { Console.WriteLine("Fail: SkinId должен быть числом."); return; } SkinData skin = DataTables.Get(DataType.Skin).GetDataByGlobalId(skinId); if (skin == null) { Console.WriteLine($"Fail: скин с Id {skinId} не найден."); return; } SkinConfData skinConf = DataTables.Get(DataType.SkinConf).GetData(skin.Name); if (skinConf == null) { Console.WriteLine($"Fail: SkinConf для скина '{skin.Name}' не найден."); return; } CharacterData character = DataTables.Get(DataType.Character).GetData(skinConf.Character); if (character == null) { Console.WriteLine($"Fail: боец '{skinConf.Character}' для скина '{skin.Name}' не найден."); return; } var hero = account.Avatar.GetHero(character.GetGlobalId()); if (hero == null) { Console.WriteLine($"Fail: у игрока нет бойца {character.Name}."); return; } hero.SelectedSkinId = skin.GetInstanceId(); Console.WriteLine($"Скин {skin.Name} (Id={skinId}) выдан игроку {account.Avatar.Name} ({args[1]})."); if (Sessions.IsSessionActive(id)) { Sessions.GetSession(id).GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Вам выдан скин: {skin.Name}! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteGiveGold(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /givegold [TAG] [Amount]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!int.TryParse(args[2], out int amount) || amount <= 0) { Console.WriteLine("Fail: Amount должен быть положительным числом."); return; } account.Avatar.AddGold(amount); Console.WriteLine($"Выдано {amount} золота игроку {account.Avatar.Name} ({args[1]}). Итого: {account.Avatar.Gold}."); if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Вам выдано {amount} золота! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteGiveDiamonds(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: /givediamonds [TAG] [Amount]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!int.TryParse(args[2], out int amount) || amount <= 0) { Console.WriteLine("Fail: Amount должен быть положительным числом."); return; } account.Avatar.AddDiamonds(amount); Console.WriteLine($"Выдано {amount} кристаллов игроку {account.Avatar.Name} ({args[1]}). Итого: {account.Avatar.Diamonds}."); if (Sessions.IsSessionActive(id)) { var session = Sessions.GetSession(id); session.GameListener.SendTCPMessage(new AuthenticationFailedMessage() { Message = $"Вам выдано {amount} кристаллов! Переподключитесь." }); Sessions.Remove(id); } } private static void ExecuteNotify(string[] args) { if (args.Length < 4) { Console.WriteLine("Usage: /notify [TAG] [NotifId] [Text...]"); return; } long id = LogicLongCodeGenerator.ToId(args[1]); Account account = Accounts.Load(id); if (account == null) { Console.WriteLine("Fail: account not found!"); return; } if (!int.TryParse(args[2], out int notifId)) { Console.WriteLine("Fail: NotifId должен быть числом (например 79)."); return; } string text = string.Join(" ", args.Skip(3)); string key = $"admin_notify_{notifId}_{id}_{DateTime.UtcNow.Ticks}"; account.Home.SendNotification(key, notifId, text); Console.WriteLine($"Уведомление (Id={notifId}) отправлено игроку {account.Avatar.Name} ({args[1]}): {text}"); } private static void ExecuteShutdown() { Sessions.StartShutdown(); AccountCache.SaveAll(); AllianceCache.SaveAll(); AccountCache.Started = false; AllianceCache.Started = false; } } }