namespace Supercell.Laser.Server.Logic { using Supercell.Laser.Logic.Avatar; using Supercell.Laser.Logic.Home; using Supercell.Laser.Logic.Listener; using Supercell.Laser.Server.Database; using Supercell.Laser.Server.Networking.Session; using Supercell.Laser.Logic.Ranked; using Supercell.Laser.Logic.Home.Items; using Supercell.Laser.Server.Logic.Game; using Supercell.Laser.Logic.Battle; public class ServerListener : LogicServerListener { public ClientAvatar GetAvatar(long id) { return Accounts.Load(id).Avatar; } public LogicGameListener GetGameListener(long id) { if (Sessions.IsSessionActive(id)) { return Sessions.GetSession(id).GameListener; } return null; } public HomeMode GetHomeMode(long id) { if (Sessions.IsSessionActive(id)) { return Sessions.GetSession(id).Home; } return null; } public bool IsPlayerOnline(long id) { return Sessions.IsSessionActive(id); } public void StartMatchBattle(List entries, EventData edata, int Location, int id, int round, bool ispig) { foreach (mp_thestealdev ranked in entries) { if (!Sessions.IsSessionActive(ranked.AccountId)) { //Console.WriteLine($"[ServerListener] Предупреждение: Игрок {ranked.AccountId} не в сети, но будет добавлен как оффлайн-игрок."); } } RankedMatchRegulator.StartMatchBattle(entries, edata, Location, id, round, ispig); } public RankedMatch GetRankedMatch(long id) => RankedMatchRegulator.Get(id); public void OnCommunityWin() { CommunityEvent.AddWin(); } public void OnCommunityMilestone(int gems, int winsGoal, string notifKey) { foreach (var session in Sessions.ActiveSessions.Values) { try { if (session?.Home?.Avatar == null) continue; session.Home.Avatar.AddDiamonds(gems); string key = $"{notifKey}_{session.Home.Avatar.AccountId}"; session.Home.Home.SendNotification(key, 89, $"Ивент: сообщество достигло {winsGoal} побед! Вам выдано {gems} 💎", donationCount: gems); } catch { } } Task.Run(() => { try { var allAccounts = Accounts.GetAllAccounts(); foreach (var account in allAccounts) { if (Sessions.IsSessionActive(account.Avatar.AccountId)) continue; string key = $"{notifKey}_{account.Avatar.AccountId}"; if (account.Home.SentNotifications.Contains(key)) continue; account.Avatar.AddDiamonds(gems); account.Home.SendNotification(key, 89, $"Ивент: сообщество достигло {winsGoal} побед! Вам выдано {gems} 💎", donationCount: gems); Accounts.Save(account); } } catch (Exception ex) { Console.WriteLine($"[EVENT] Ошибка: {ex.Message}"); } }); } } }