Esempio n. 1
0
        private static void MS_InitPkLoop_Update(DateTime now)
        {
            ZhanDuiZhengBaMatchConfig matchConfig = ZhanDuiZhengBa_K._Config.MatchConfigList.Find((ZhanDuiZhengBaMatchConfig _m) => _m.ID == ZhanDuiZhengBa_K.SyncData.RealActID);
            List <ZhanDuiZhengBa_K.JoinRolePkData> tmpRoleDatas = new List <ZhanDuiZhengBa_K.JoinRolePkData>();

            using (List <RangeKey> .Enumerator enumerator = ZhanDuiZhengBaUtils.GetDayPkGroupRange(ZhanDuiZhengBa_K.SyncData.RealActID).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    RangeKey range = enumerator.Current;
                    List <ZhanDuiZhengBa_K.JoinRolePkData> groupRoles = ZhanDuiZhengBa_K.TodayJoinRoleDatas.FindAll((ZhanDuiZhengBa_K.JoinRolePkData _r) => _r.Group >= range.Left && _r.Group <= range.Right);
                    if (groupRoles != null && groupRoles.Count == 2)
                    {
                        ZhanDuiZhengBa_K.JoinRolePkData joinRole  = groupRoles[0];
                        ZhanDuiZhengBa_K.JoinRolePkData joinRole2 = groupRoles[1];
                        if (joinRole.CurrGameID <= 0)
                        {
                            if (!ZhanDuiZhengBa_K.CreateGameFuBen(now, matchConfig, joinRole, joinRole2))
                            {
                                return;
                            }
                        }
                    }
                    else if (groupRoles != null && groupRoles.Count == 1)
                    {
                        if (!Consts.TestMode)
                        {
                            ZhanDuiZhengBa_K.JoinRolePkData joinRole3 = groupRoles[0];
                            joinRole3.ToServerID   = 0;
                            joinRole3.CurrGameID   = 0;
                            joinRole3.WaitReqEnter = false;
                        }
                        else
                        {
                            ZhanDuiZhengBa_K.JoinRolePkData joinRole  = groupRoles[0];
                            ZhanDuiZhengBa_K.JoinRolePkData joinRole2 = groupRoles[0];
                            if (joinRole.CurrGameID <= 0)
                            {
                                if (!ZhanDuiZhengBa_K.CreateGameFuBen(now, matchConfig, joinRole, joinRole2))
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            ZhanDuiZhengBa_K.StateMachine.SetCurrState(5, now);
        }
Esempio n. 2
0
        private static bool FixSyncData_State(DateTime now)
        {
            bool bForceModify = false;
            int  endID        = 0;

            lock (ZhanDuiZhengBa_K.Mutex)
            {
                if (now.Day > ZhanDuiZhengBaConsts.StartMonthDay)
                {
                    endID = ZhanDuiZhengBa_K._Config.MatchConfigList[ZhanDuiZhengBa_K._Config.MatchConfigList.Count - 1].ID;
                }
                else if (now.Day == ZhanDuiZhengBaConsts.StartMonthDay)
                {
                    for (int i = 0; i < ZhanDuiZhengBa_K._Config.MatchConfigList.Count; i++)
                    {
                        ZhanDuiZhengBaMatchConfig c0 = ZhanDuiZhengBa_K._Config.MatchConfigList[i];
                        if (now.TimeOfDay.Ticks < c0.DayBeginTick)
                        {
                            break;
                        }
                        if (now.TimeOfDay.Ticks >= c0.ResultTick)
                        {
                            endID = c0.ID;
                        }
                    }
                }
                if (endID == ZhanDuiZhengBaUtils.WhichDayResultByGrade(EZhengBaGrade.Grade1))
                {
                    ZhanDuiZhengBa_K.SyncData.HasSeasonEnd = true;
                    ZhanDuiZhengBa_K.SyncData.TopZhanDui   = ZhanDuiZhengBa_K.Persistence.GetLastTopZhanDui(ZhanDuiZhengBa_K.SyncData.Month);
                }
                else
                {
                    ZhanDuiZhengBa_K.SyncData.HasSeasonEnd = false;
                    ZhanDuiZhengBa_K.SyncData.TopZhanDui   = ZhanDuiZhengBa_K.Persistence.GetLastTopZhanDui(ZhengBaUtils.MakeMonth(now.AddMonths(-1)));
                }
                int id;
                for (id = 1; id <= endID; id++)
                {
                    ZhanDuiZhengBaMatchConfig        config      = ZhanDuiZhengBa_K._Config.MatchConfigList.Find((ZhanDuiZhengBaMatchConfig _m) => _m.ID == id);
                    EZhengBaGrade                    preGrade    = config.JoinGrade;
                    EZhengBaGrade                    willUpGrade = config.WillUpGrade;
                    List <ZhanDuiZhengBaZhanDuiData> roleList    = ZhanDuiZhengBa_K.SyncData.ZhanDuiList.FindAll((ZhanDuiZhengBaZhanDuiData _r) => _r.Grade > (int)willUpGrade);
                    if (roleList.Count > 0)
                    {
                        List <ZhanDuiZhengBaZhanDuiData> upGradeList = new List <ZhanDuiZhengBaZhanDuiData>();
                        using (List <RangeKey> .Enumerator enumerator = ZhanDuiZhengBaUtils.GetDayPkGroupRange(id).GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                RangeKey range = enumerator.Current;
                                List <ZhanDuiZhengBaZhanDuiData> groupRoleList = ZhanDuiZhengBa_K.SyncData.ZhanDuiList.FindAll((ZhanDuiZhengBaZhanDuiData _r) => _r.Group >= range.Left && _r.Group <= range.Right && _r.Grade <= (int)preGrade);
                                if (groupRoleList.Count != 0)
                                {
                                    if (!groupRoleList.Exists((ZhanDuiZhengBaZhanDuiData _r) => _r.Grade <= (int)willUpGrade))
                                    {
                                        groupRoleList.Sort(delegate(ZhanDuiZhengBaZhanDuiData _l, ZhanDuiZhengBaZhanDuiData _r)
                                        {
                                            int result;
                                            if (_l.Grade != _r.Grade)
                                            {
                                                result = _l.Grade - _r.Grade;
                                            }
                                            else
                                            {
                                                result = _l.DuanWeiRank - _r.DuanWeiRank;
                                            }
                                            return(result);
                                        });
                                        ZhanDuiZhengBaZhanDuiData selectRole = groupRoleList[0];
                                        LogManager.WriteLog(LogTypes.Error, string.Format("战队争霸::晋级补位 [s{0}.{1}] {2}->{3}", new object[]
                                        {
                                            selectRole.ZoneId,
                                            selectRole.ZhanDuiID,
                                            selectRole.Grade,
                                            (int)willUpGrade
                                        }), null, true);
                                        selectRole.Grade = (int)willUpGrade;
                                        bForceModify     = true;
                                        upGradeList.Add(selectRole);
                                        if (groupRoleList.Count >= 2)
                                        {
                                            ZhanDuiZhengBaZhanDuiData faildRole = groupRoleList[1];
                                            faildRole.Grade = (int)preGrade;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ZhanDuiZhengBa_K.SyncData.RealActID = endID;
                foreach (ZhanDuiZhengBaZhanDuiData role in ZhanDuiZhengBa_K.SyncData.ZhanDuiList)
                {
                    if (endID <= 0)
                    {
                        if (role.Grade != 64 || role.State != 0)
                        {
                            role.Grade   = 64;
                            role.State   = 0;
                            bForceModify = true;
                        }
                    }
                    else
                    {
                        EZhengBaGrade upGrade = ZhanDuiZhengBa_K._Config.MatchConfigList.Find((ZhanDuiZhengBaMatchConfig _m) => _m.ID == endID).WillUpGrade;
                        if (role.Grade <= (int)upGrade && role.State != 1)
                        {
                            role.State   = 1;
                            bForceModify = true;
                        }
                        if (role.Grade > (int)upGrade && role.State != 2)
                        {
                            role.State   = 2;
                            bForceModify = true;
                        }
                        if (role.Grade == 1)
                        {
                            ZhanDuiZhengBa_K.SyncData.TopZhanDui = role.ZhanDuiID;
                        }
                    }
                }
            }
            return(bForceModify);
        }