Пример #1
0
        private void OnGetGlobalDataRequestReceived(TriviaMessage message, Socket socket)
		{
            Stats stats = new Stats();

            stats.PointsEarnedByHour = StatsAccess.PointsEarnedByHour() ?? new int[0];
            stats.PointsMaximumByHour = StatsAccess.PointsMaxByHour() ?? new int[0];

            GlobalData gd = new GlobalData
            {
                Links = LinkAccess.GetAllLinks(),
                CurrentCaller = "mgncallerhardcoded",
                Stats = stats
            };

			TriviaMessage responseMessage = MessageParser.CreateGetGlobalDataResponse(gd);

			this.mServer.SendMessageToSpecificClient(responseMessage, socket);
		}
Пример #2
0
        private GlobalData CreateGlobalData()
        {
            Stats stats = new Stats();

            stats.PointsEarnedByHour = StatsAccess.PointsEarnedByHour() ?? new int[0];
            stats.PointsMaximumByHour = StatsAccess.PointsMaxByHour() ?? new int[0];

            GlobalData gd = new GlobalData
            {
                Links = LinkAccess.GetAllLinks(),
                CurrentCaller = null,
                Stats = stats
            };

            return gd;
        }
Пример #3
0
        private static void LoadStatsIntoViewModel(Stats stats, TriviaViewModel viewModel)
        {
            if (stats.PointsMaximumByHour == null ||
                                stats.PointsMaximumByHour.Length == 0 ||
                                stats.PointsEarnedByHour == null ||
                                stats.PointsEarnedByHour.Length == 0)
            {
                return;  // No data yet... no questions opened
            }

            int maxPointsPossibleInAnyHour = stats.PointsMaximumByHour.Max();

            for (int i = 0; i < stats.PointsEarnedByHour.Length; ++i)
            {
                int hourNumber = i + 1;

                HourViewModel hour = viewModel.GetHour(hourNumber);

                hour.Stats.MaximumTotalPointsPossibleInAnyHour = maxPointsPossibleInAnyHour;
                hour.Stats.TotalPointsEarned = stats.PointsEarnedByHour[i];
                hour.Stats.TotalPointsPossible = stats.PointsMaximumByHour[i];
            }
        }