Ejemplo n.º 1
0
        internal static int CalculateHKChange(Player _Player, PlayerHistory _PlayerHistory)
        {
            DateTime beforeLastRankUpdate = CalculateLastRankUpdadeDateUTC(_Player.Realm, _Player.LastSeen).AddHours(-1.0);
            var      lastweekHonorEntry   = _PlayerHistory.GetHonorItemAtTime(beforeLastRankUpdate);

            var lastweekHonorData = lastweekHonorEntry.Data;

            if (lastweekHonorEntry.Uploader.GetTime() < CalculateLastRankUpdadeDateUTC(_Player.Realm, _Player.LastSeen).AddDays(-6.5))
            {
                return(-1);
            }

            return((_Player.Honor.LifetimeHK - _Player.Honor.ThisWeekHK) - (lastweekHonorData.LifetimeHK - lastweekHonorData.ThisWeekHK));
        }
Ejemplo n.º 2
0
        public static float CalculateRankChange(Player _Player, PlayerHistory _PlayerHistory)
        {
            DateTime beforeLastRankUpdate = CalculateLastRankUpdadeDateUTC(_Player.Realm, _Player.LastSeen).AddHours(-1.0);
            var      lastweekHonorData    = _PlayerHistory.GetHonorItemAtTime(beforeLastRankUpdate).Data;

            if (lastweekHonorData != null)
            {
                return(_Player.GetRankTotal() - lastweekHonorData.GetRankTotal());
            }
            else
            {
                return(_Player.GetRankTotal());
            }
        }
Ejemplo n.º 3
0
        public static List <HonorHKDay> GeneratePlayerHonor(PlayerHistory _PlayerHistory)
        {
            DateTime dayAccuracyLoggingDate = DateTime.Parse("2013-08-02 01:00:00");
            DateTime firstTime = _PlayerHistory.HonorHistory.First().Uploader.GetTime().ToLocalTime();
            DateTime lastTime  = _PlayerHistory.HonorHistory.Last().Uploader.GetTime().ToLocalTime();

            firstTime = firstTime.AddHours(-firstTime.Hour);
            firstTime = firstTime.AddMinutes(-firstTime.Minute);
            //firstTime = firstTime.ToLocalTime();

            //lastTime = lastTime.AddHours(-lastTime.Hour);
            //lastTime = lastTime.AddMinutes(-lastTime.Minute);
            //lastTime = lastTime.ToLocalTime();

            List <HonorHKDay> dataList = new List <HonorHKDay>();
            int      totalDays         = (int)((lastTime - firstTime).TotalDays + 1);
            DateTime currentDate       = firstTime;

            for (int i = 0; i < totalDays; ++i)
            {
                bool     todayAddedHKDay = false;
                DateTime researchDate    = currentDate.AddHours(23.59);
                var      honorItem       = _PlayerHistory.GetHonorItemAtTime(researchDate);
                if ((researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalHours < 23.59)
                {
                    dataList.Add(new HonorHKDay
                    {
                        m_DateTime     = currentDate
                        , m_BasedOn    = BasedOn.TodayHK
                        , m_Accuracy   = (int)(researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalHours
                        , m_HonorValue = -1
                        , m_HKValue    = honorItem.Data.TodayHK
                    });
                    todayAddedHKDay = true;
                }
                researchDate = researchDate.AddHours(24.0);
                honorItem    = _PlayerHistory.GetHonorItemAtTime(researchDate);
                if ((researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalHours < 23.59)
                {
                    if (todayAddedHKDay == true)
                    {
                        var dataLast = dataList.Last();
                        if (dataLast.m_HKValue == honorItem.Data.YesterdayHK)
                        {
                            dataLast.m_HonorValue        = honorItem.Data.YesterdayHonor;
                            dataLast.m_BasedOn           = BasedOn.TodayHK_And_YesterdayHK;
                            dataLast.m_Accuracy          = (int)(researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalHours;
                            dataList[dataList.Count - 1] = dataLast;
                        }
                    }
                    dataList.Add(new HonorHKDay
                    {
                        m_DateTime     = currentDate
                        , m_BasedOn    = BasedOn.YesterdayHK
                        , m_Accuracy   = (int)(researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalHours
                        , m_HonorValue = honorItem.Data.YesterdayHonor
                        , m_HKValue    = honorItem.Data.YesterdayHK
                    });
                    todayAddedHKDay = true;
                }
                if (todayAddedHKDay == false)
                {
                    dataList.Add(new HonorHKDay
                    {
                        m_DateTime     = currentDate
                        , m_BasedOn    = BasedOn.Nothing
                        , m_Accuracy   = 0
                        , m_HonorValue = 0
                        , m_HKValue    = 0
                    });
                }
                currentDate = currentDate.AddDays(1.0);
            }
            for (int i = 0; i < dataList.Count; ++i)
            {
                var currData = dataList[i];
                if (currData.m_BasedOn == BasedOn.Nothing || (currData.m_DateTime < dayAccuracyLoggingDate && currData.m_HKValue == 0))
                {
                    DateTime weekUpdateDate = DateTime_GotoSunday(currData.m_DateTime.AddDays(7));
                    DateTime researchDate   = weekUpdateDate.AddDays(6.95);
                    var      honorItem      = _PlayerHistory.GetHonorItemAtTime(researchDate);
                    if ((researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalDays < 6.95)
                    {
                        currData.m_Accuracy   = (int)(researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalDays;
                        currData.m_HKValue    = honorItem.Data.LastWeekHK / 7;
                        currData.m_HonorValue = honorItem.Data.LastWeekHonor / 7;
                        currData.m_BasedOn    = BasedOn.LastWeekHK;
                        dataList[i]           = currData;
                    }
                    else
                    {
                        double currentDaysInThisWeek = (honorItem.Uploader.GetTime().ToLocalTime() - DateTime_GotoSunday(currData.m_DateTime)).TotalDays;
                        if (currentDaysInThisWeek < 1.0)
                        {
                            currentDaysInThisWeek = 1.0;
                        }
                        currData.m_Accuracy   = (int)(researchDate - honorItem.Uploader.GetTime().ToLocalTime()).TotalDays;
                        currData.m_HKValue    = (int)(honorItem.Data.ThisWeekHK / currentDaysInThisWeek);
                        currData.m_HonorValue = (int)(honorItem.Data.ThisWeekHonor / currentDaysInThisWeek);
                        currData.m_BasedOn    = BasedOn.ThisWeekHK;
                        dataList[i]           = currData;
                    }
                }
                if (currData.m_HonorValue == -1)
                {
                    DateTime weekUpdateDate        = DateTime_GotoSunday(currData.m_DateTime.AddDays(7));
                    DateTime researchDate          = weekUpdateDate.AddDays(6.95);
                    var      honorItem             = _PlayerHistory.GetHonorItemAtTime(researchDate);
                    double   currentDaysInThisWeek = (honorItem.Uploader.GetTime().ToLocalTime() - DateTime_GotoSunday(currData.m_DateTime)).TotalDays;
                    if (currentDaysInThisWeek < 1.0)
                    {
                        currentDaysInThisWeek = 1.0;
                    }
                    currData.m_HonorValue = (int)(honorItem.Data.ThisWeekHonor / currentDaysInThisWeek);
                    currData.m_BasedOn    = BasedOn.ThisWeekHK;
                    dataList[i]           = currData;
                }
            }
            //dataList.Distinct();
            return(dataList.Distinct().ToList());
        }