public static CurrentLobbyStats GetLobbyStats()
        {
            if (DateTime.UtcNow.Subtract(lastStatsCheck).TotalMinutes < 2) return cachedStats;
            else
            {
                lastStatsCheck = DateTime.UtcNow;
                try
                {
                    cachedStats = Global.Nightwatch.Auth.GetCurrentStats();
                    var lastMonth = DateTime.Now.AddDays(-31);
                    cachedStats.UsersLastMonth = new ZkDataContext().SpringBattlePlayers.Where(x=>x.SpringBattle.StartTime > lastMonth).GroupBy(x=>x.AccountID).Count();
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error getting lobby stats: {0}", ex);
                }

                return cachedStats;
            }
        }
Exemplo n.º 2
0
        public static CurrentLobbyStats GetLobbyStats()
        {
            if (DateTime.UtcNow.Subtract(lastStatsCheck).TotalMinutes < 2)
            {
                return(cachedStats);
            }
            else
            {
                lastStatsCheck = DateTime.UtcNow;
                try
                {
                    cachedStats = Global.Nightwatch.Auth.GetCurrentStats();
                    cachedStats.UsersLastMonth = new ZkDataContext().SpringBattlePlayers.Where(x => x.SpringBattle.StartTime > DateTime.Now.AddDays(-31)).GroupBy(x => x.AccountID).Count();
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error getting lobby stats: {0}", ex);
                }

                return(cachedStats);
            }
        }
        static CurrentLobbyStats GetCurrentLobbyStats()
        {
            var ret = new CurrentLobbyStats();
            if (Global.Server != null)
            {
                ret.UsersIdle = Global.Server.ConnectedUsers.Values.Count(x => !x.User.IsBot && !x.User.IsInGame && !x.User.IsInBattleRoom);

                foreach (var b in Global.Server.Battles.Values)
                {
                    foreach (var u in b.Users.Values.Select(x => x.LobbyUser))
                    {
                        if (u.IsBot) continue;
                        if (u.IsInGame) ret.UsersFighting++;
                        else if (u.IsInBattleRoom) ret.UsersWaiting++;
                    }
                    if (b.IsInGame) ret.BattlesRunning++;
                    else ret.BattlesWaiting++;
                }
            }

            var lastMonth = DateTime.Now.AddDays(-31);
            ret.UsersLastMonth = new ZkDataContext().SpringBattlePlayers.Where(x => x.SpringBattle.StartTime > lastMonth).GroupBy(x => x.AccountID).Count();
            return ret;
        }
        static CurrentLobbyStats GetCurrentLobbyStats()
        {
            var ret = new CurrentLobbyStats();
            if (Global.Server != null)
            {
                ret.UsersOnline = Global.Server.ConnectedUsers.Count;

                foreach (var b in Global.Server.Battles.Values)
                {
                    if (b.IsInGame)
                    {
                        ret.BattlesRunning++;
                        ret.UsersFighting += b.NonSpectatorCount;
                    }
                    else
                    {
                        ret.UsersWaiting += b.NonSpectatorCount;
                    }
                }

                ret.UsersWaiting += Global.Server.MatchMaker.GetTotalWaiting();
            }

            var lastMonth = DateTime.Now.AddDays(-31);
            ret.UsersLastMonth = new ZkDataContext().SpringBattlePlayers.Where(x => x.SpringBattle.StartTime > lastMonth).Select(x => x.AccountID).Distinct().Count();
            return ret;
        }
        public CurrentLobbyStats GetCurrentStats()
        {
            var ret = new CurrentLobbyStats();
            foreach (var u in client.ExistingUsers.Values) if (!u.IsBot && !u.IsInGame && !u.IsInBattleRoom) ret.UsersIdle++;

            foreach (var b in client.ExistingBattles.Values)
            {
                foreach (var u in b.Users.Values.Select(x => x.LobbyUser))
                {
                    if (u.IsBot) continue;
                    if (u.IsInGame) ret.UsersFighting++;
                    else if (u.IsInBattleRoom) ret.UsersWaiting++;
                }
                if (b.IsInGame) ret.BattlesRunning++;
                else ret.BattlesWaiting++;
            }
            return ret;
        }