Example #1
0
        public int ZhanDuiDataCompare(TianTi5v5ZhanDuiData x, TianTi5v5ZhanDuiData y)
        {
            int result;

            if (x.LastFightTime < this.MonthStartDateTime)
            {
                if (y.LastFightTime < this.MonthStartDateTime)
                {
                    int ret = y.DuanWeiJiFen - x.DuanWeiJiFen;
                    result = ((ret != 0) ? ret : (x.ZhanDuiID - y.ZhanDuiID));
                }
                else
                {
                    result = 1;
                }
            }
            else if (y.LastFightTime < this.MonthStartDateTime)
            {
                result = -1;
            }
            else
            {
                int ret = y.DuanWeiJiFen - x.DuanWeiJiFen;
                result = ((ret != 0) ? ret : (x.ZhanDuiID - y.ZhanDuiID));
            }
            return(result);
        }
Example #2
0
 public void UpdateZhanDuiRankData(List <TianTi5v5ZhanDuiData> list, int dayId, int maxRankCount, bool updateMonthRank)
 {
     try
     {
         if (updateMonthRank)
         {
             this.AddDelayWriteSql(string.Format("update t_kf_5v5_zhandui set `duanweirank`={0},`monthduanweirank`={1}", maxRankCount + 1, maxRankCount + 1), null, null);
             int i = 0;
             while (i < maxRankCount && i < list.Count)
             {
                 TianTi5v5ZhanDuiData data = list[i];
                 string sql = string.Format("update t_kf_5v5_zhandui set `duanweirank`={1},`monthduanweirank`={2}", data.ZhanDuiID, data.DuanWeiRank, data.MonthDuanWeiRank);
                 this.AddDelayWriteSql(sql, null, null);
                 i++;
             }
         }
         else
         {
             this.AddDelayWriteSql(string.Format("update t_kf_5v5_zhandui set `duanweirank`={0}", maxRankCount + 1), null, null);
             int i = 0;
             while (i < maxRankCount && i < list.Count)
             {
                 TianTi5v5ZhanDuiData data = list[i];
                 string sql = string.Format("update t_kf_5v5_zhandui set `duanweirank`={1} where zhanduiid={0}", data.ZhanDuiID, data.DuanWeiRank);
                 this.AddDelayWriteSql(sql, null, null);
                 i++;
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Example #3
0
        public int UpdateZhanDui(TianTi5v5ZhanDuiData data)
        {
            string sql = string.Format("update t_kf_5v5_zhandui set `leaderid`={1},`xuanyan`='{2}',`zhanduiname`='{3}',`duanweiid`='{4}',`zhanli`='{5}',`data1`=@data1,leaderrolename='{6}',`liansheng`='{7}',`fightcount`='{8}',`successcount`='{9}',lastfighttime='{10}',`duanweijifen`='{11}',`duanweirank`='{12}',`monthduanweirank`='{13}' where `zhanduiid`={0};", new object[]
            {
                data.ZhanDuiID,
                data.LeaderRoleID,
                data.XuanYan,
                data.ZhanDuiName,
                data.DuanWeiId,
                data.ZhanDouLi,
                data.LeaderRoleName,
                data.LianSheng,
                data.FightCount,
                data.SuccessCount,
                data.LastFightTime,
                data.DuanWeiJiFen,
                data.DuanWeiRank,
                data.MonthDuanWeiRank
            });
            int result;

            if (!this.AddDelayWriteSql(sql, new List <Tuple <string, byte[]> >
            {
                new Tuple <string, byte[]>("@data1", DataHelper2.ObjectToBytes <List <TianTi5v5ZhanDuiRoleData> >(data.teamerList))
            }, null))
            {
                result = -11000;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Example #4
0
        public static int UpdateZhanDuiData(TianTi5v5ZhanDuiData data, ZhanDuiDataModeTypes modeType)
        {
            int result = 0;

            lock (TianTi5v5Service.Mutex)
            {
                TianTi5v5ZhanDuiData curZhanDui;
                if (TianTi5v5Service.ZhanDuiDict.TryGetValue(data.ZhanDuiID, out curZhanDui))
                {
                    if (modeType == ZhanDuiDataModeTypes.ZhanDuiInfo)
                    {
                        curZhanDui.ZhanDuiID      = data.ZhanDuiID;
                        curZhanDui.XuanYan        = data.XuanYan;
                        curZhanDui.ZhanDuiName    = data.ZhanDuiName;
                        curZhanDui.LeaderRoleID   = data.LeaderRoleID;
                        curZhanDui.ZhanDouLi      = data.ZhanDouLi;
                        curZhanDui.teamerList     = data.teamerList;
                        curZhanDui.TeamerRidList  = data.TeamerRidList;
                        curZhanDui.LeaderRoleName = data.LeaderRoleName;
                        curZhanDui.ZoneID         = data.ZoneID;
                    }
                    else if (modeType == ZhanDuiDataModeTypes.TianTiFightData)
                    {
                        curZhanDui.DuanWeiId        = data.DuanWeiId;
                        curZhanDui.DuanWeiJiFen     = data.DuanWeiJiFen;
                        curZhanDui.DuanWeiRank      = data.DuanWeiRank;
                        curZhanDui.ZhanDouLi        = data.ZhanDouLi;
                        curZhanDui.LianSheng        = data.LianSheng;
                        curZhanDui.SuccessCount     = data.SuccessCount;
                        curZhanDui.FightCount       = data.FightCount;
                        curZhanDui.MonthDuanWeiRank = data.MonthDuanWeiRank;
                        curZhanDui.LastFightTime    = data.LastFightTime;
                        using (List <TianTi5v5ZhanDuiRoleData> .Enumerator enumerator = curZhanDui.teamerList.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                TianTi5v5ZhanDuiRoleData role        = enumerator.Current;
                                TianTi5v5ZhanDuiRoleData newRoleInfo = data.teamerList.Find((TianTi5v5ZhanDuiRoleData x) => x.RoleID == role.RoleID);
                                if (null != newRoleInfo)
                                {
                                    role.MonthFightCounts = newRoleInfo.MonthFightCounts;
                                    role.TodayFightCount  = newRoleInfo.TodayFightCount;
                                    role.MonthFigntCount  = newRoleInfo.MonthFigntCount;
                                    role.ZhanLi           = newRoleInfo.ZhanLi;
                                    role.RoleOcc          = newRoleInfo.RoleOcc;
                                    role.ZhuanSheng       = newRoleInfo.ZhuanSheng;
                                    role.Level            = newRoleInfo.Level;
                                    role.RebornLevel      = newRoleInfo.RebornLevel;
                                    role.ModelData        = newRoleInfo.ModelData;
                                }
                            }
                        }
                    }
                    result = TianTi5v5Service.Persistence.UpdateZhanDui(curZhanDui);
                }
            }
            return(result);
        }
Example #5
0
        public static void UpdateZhanDuiRankData(DateTime now, bool forceUpdateMonthRank = false)
        {
            bool     updateMonthRank    = now.Day == 1 || forceUpdateMonthRank;
            int      dayID              = TimeUtil.GetOffsetDay(now);
            DateTime monthStartDateTime = new DateTime(now.Year, now.Month, 1);

            if (now.Day == 1)
            {
                monthStartDateTime = monthStartDateTime.AddMonths(-1);
            }
            List <TianTi5v5ZhanDuiData> list = TianTi5v5Service.ZhanDuiDict.Values.ToList <TianTi5v5ZhanDuiData>();

            list.RemoveAll((TianTi5v5ZhanDuiData x) => x.LastFightTime < monthStartDateTime || x.DuanWeiJiFen == 0);
            list.Sort(new Comparison <TianTi5v5ZhanDuiData>(TianTi5v5Service.ZhanDuiDataSortCompare));
            int maxRankCount = TianTi5v5Service.RankData.MaxPaiMingRank;
            List <TianTi5v5ZhanDuiData> rankList = new List <TianTi5v5ZhanDuiData>();

            for (int i = 0; i < list.Count; i++)
            {
                TianTi5v5ZhanDuiData data = list[i];
                if (i < maxRankCount)
                {
                    data.DuanWeiRank = i + 1;
                    if (updateMonthRank)
                    {
                        data.MonthDuanWeiRank = data.DuanWeiRank;
                    }
                    rankList.Add(data.Clone());
                    if (updateMonthRank)
                    {
                        data.DuanWeiRank = maxRankCount + 1;
                    }
                }
                else
                {
                    data.DuanWeiRank = maxRankCount + 1;
                    if (updateMonthRank)
                    {
                        data.MonthDuanWeiRank = data.DuanWeiRank;
                    }
                }
            }
            TianTi5v5Service.Persistence.UpdateZhanDuiRankData(list, dayID, TianTi5v5Service.RankData.MaxPaiMingRank, updateMonthRank);
            TianTi5v5Service.Persistence.UpdateZhanDuiDayRank(rankList, dayID, TianTi5v5Service.RankData.MaxPaiMingRank, updateMonthRank);
            lock (TianTi5v5Service.Mutex)
            {
                TianTi5v5Service.RankData.ModifyTime = now;
                if (now.Day == 1)
                {
                    TianTi5v5Service.RankData.MonthPaiHangList = rankList;
                    TianTi5v5Service.RankData.DayPaiHangList   = new List <TianTi5v5ZhanDuiData>();
                }
                else
                {
                    TianTi5v5Service.RankData.DayPaiHangList = list;
                }
            }
        }
Example #6
0
        public static TianTi5v5ZhanDuiData GetZhanDuiData(int zhanDuiID)
        {
            TianTi5v5ZhanDuiData data = null;

            lock (TianTi5v5Service.Mutex)
            {
                TianTi5v5Service.ZhanDuiDict.TryGetValue(zhanDuiID, out data);
            }
            return(data);
        }
Example #7
0
        public int GameFuBenComplete_ZorkBattle(ZorkBattleStatisticalData data)
        {
            int result = 0;

            try
            {
                lock (this.Mutex)
                {
                    KuaFu5v5FuBenData fubenData;
                    if (!this.FuBenDataDict.TryGetValue(data.GameId, out fubenData))
                    {
                        result = -4000;
                        return(result);
                    }
                    ClientAgentManager.Instance().RemoveKfFuben(this.GameType, fubenData.ServerId, (long)data.GameId);
                    this.FuBenDataDict.Remove(data.GameId);
                    foreach (KeyValuePair <int, int> item in fubenData.ZhanDuiDict)
                    {
                        this.ZhanDuiIDVsGameIDDict.Remove(item.Key);
                    }
                    foreach (KeyValuePair <int, TianTi5v5ZhanDuiData> item2 in data.ZhanDuiDict)
                    {
                        TianTi5v5ZhanDuiData zhanduiData = item2.Value;
                        TianTi5v5Service.UpdateZorkZhanDuiData(zhanduiData);
                    }
                    foreach (ZorkBattleRoleInfo client in data.ClientContextDataList)
                    {
                        this.Persistence.UpdateZorkBattleRoleData(client, true);
                    }
                    string zhanduiIdArray = string.Join <int>("|", data.ZhanDuiDict.Keys.ToArray <int>());
                    string strLog         = string.Format("Zork::GameFuBenComplete_ZorkBattle SeasonID:{0} GameID:{1} ZhanDuiIDWin:{2} ZhanDuiID:{3} Round:{2} ZhanDuiInfo:", new object[]
                    {
                        this.CurrentSeasonID,
                        data.GameId,
                        data.ZhanDuiIDWin,
                        zhanduiIdArray,
                        this.CurrentRound
                    });
                    foreach (KeyValuePair <int, TianTi5v5ZhanDuiData> item2 in data.ZhanDuiDict)
                    {
                        TianTi5v5ZhanDuiData zhanduiData = item2.Value;
                        strLog += string.Format(" [ZhanDuiID:{0} JiFen:{1}]", item2.Key, zhanduiData.ZorkJiFen);
                    }
                    LogManager.WriteLog(LogTypes.Analysis, strLog, null, true);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result = -11;
                LogManager.WriteLog(LogTypes.Error, "Zork5v5Service.GameFuBenComplete_ZorkBattle failed!", ex, true);
            }
            return(result);
        }
Example #8
0
 private void UpdateTopZhanDuiInfo()
 {
     this.TopZhanDuiName = "";
     if (this.TopZhanDui > 0)
     {
         TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(this.TopZhanDui);
         if (null != zhanduiData)
         {
             this.TopZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName);
         }
     }
 }
Example #9
0
 public static void UpdateZorkZhanDuiData(TianTi5v5ZhanDuiData data)
 {
     TianTi5v5Service.Persistence.UpdateZorkZhanDui(data);
     lock (TianTi5v5Service.Mutex)
     {
         TianTi5v5ZhanDuiData curZhanDui;
         if (TianTi5v5Service.ZhanDuiDict.TryGetValue(data.ZhanDuiID, out curZhanDui))
         {
             curZhanDui.ZorkJiFen         = data.ZorkJiFen;
             curZhanDui.ZorkLastFightTime = data.ZorkLastFightTime;
         }
     }
 }
Example #10
0
        public int SignUp_ZorkBattle(int zhanduiID, int serverID)
        {
            int result = 0;

            try
            {
                lock (this.Mutex)
                {
                    DateTime now = TimeUtil.NowDateTime();
                    if (!this.CheckOpenState(now))
                    {
                        result = -11004;
                        return(result);
                    }
                    if (this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.SignUp && this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.RankAnalyse)
                    {
                        result = -2001;
                        return(result);
                    }
                    TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(zhanduiID);
                    if (null == zhanduiData)
                    {
                        result = -5;
                        return(result);
                    }
                    if (this.PiPeiDict.ContainsKey(zhanduiID))
                    {
                        result = -5;
                        return(result);
                    }
                    KF5v5PiPeiTeam pipeiTeam = new KF5v5PiPeiTeam
                    {
                        TeamID      = zhanduiID,
                        ServerID    = serverID,
                        GroupIndex  = this.CalDuanWeiByJiFen(zhanduiData.ZorkJiFen),
                        ZhanDouLi   = zhanduiData.ZhanDouLi,
                        ZorkJiFen   = zhanduiData.ZorkJiFen,
                        ZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName)
                    };
                    this.PiPeiDict[zhanduiID] = pipeiTeam;
                    LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::比赛报名 SeasonID:{0} Round:{1} ZhanDuiID:{2}", this.CurrentSeasonID, this.CurrentRound, zhanduiID), null, true);
                }
                return(result);
            }
            catch (Exception ex)
            {
                result = -11;
                LogManager.WriteLog(LogTypes.Error, "Zork5v5Service.SignUp_ZorkBattle failed!", ex, true);
            }
            return(result);
        }
Example #11
0
        public bool LoadZhanDuiData()
        {
            bool result = false;

            lock (this.Mutex)
            {
                string sql = "select`zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`duanweijifen`,`duanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`,`monthduanweirank`,leaderrolename,zoneid,zorkjifen,zorkwin,zorkwinstreak,zorkbossinjure,zorklastfighttime,escapejifen,escapelastfighttime from t_kf_5v5_zhandui";
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    using (MySQLDataReader reader = conn.ExecuteReader(sql, new MySQLParameter[0]))
                    {
                        result = true;
                        this.ZhanDuiDataList.Age = 1L;
                        this.ZhanDuiDataList.V   = new List <TianTi5v5ZhanDuiData>();
                        while (reader.Read())
                        {
                            TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                            data.ZhanDuiID    = Convert.ToInt32(reader[0].ToString());
                            data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                            data.XuanYan      = reader["xuanyan"].ToString();
                            data.ZhanDuiName  = reader["zhanduiname"].ToString();
                            data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                            data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                            byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                            data.teamerList                      = DataHelper.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                            data.DuanWeiJiFen                    = Convert.ToInt32(reader["duanweijifen"].ToString());
                            data.DuanWeiRank                     = Convert.ToInt32(reader["duanweirank"].ToString());
                            data.LianSheng                       = Convert.ToInt32(reader["liansheng"].ToString());
                            data.FightCount                      = Convert.ToInt32(reader["fightcount"].ToString());
                            data.SuccessCount                    = Convert.ToInt32(reader["successcount"].ToString());
                            data.LastFightTime                   = Convert.ToDateTime(reader["lastfighttime"].ToString());
                            data.MonthDuanWeiRank                = Convert.ToInt32(reader["monthduanweirank"].ToString());
                            data.LeaderRoleName                  = reader["leaderrolename"].ToString();
                            data.ZoneID                          = Convert.ToInt32(reader["zoneid"].ToString());
                            data.ZorkJiFen                       = Convert.ToInt32(reader["zorkjifen"].ToString());
                            data.ZorkWin                         = Convert.ToInt32(reader["zorkwin"].ToString());
                            data.ZorkWinStreak                   = Convert.ToInt32(reader["zorkwinstreak"].ToString());
                            data.ZorkBossInjure                  = Convert.ToInt32(reader["zorkbossinjure"].ToString());
                            data.ZorkLastFightTime               = Convert.ToDateTime(reader["zorklastfighttime"].ToString());
                            data.EscapeJiFen                     = Convert.ToInt32(reader["escapejifen"].ToString());
                            data.EscapeLastFightTime             = Convert.ToDateTime(reader["escapelastfighttime"].ToString());
                            this.ZhanDuiDataDict[data.ZhanDuiID] = new AgeDataT <TianTi5v5ZhanDuiData>(1L, data);
                            this.ZhanDuiDataList.V.Add(data);
                        }
                    }
                }
                this.ZhanDuiDataList.V.Sort(new Comparison <TianTi5v5ZhanDuiData>(this.ZhanDuiDataCompare));
            }
            return(result);
        }
Example #12
0
        private static int ZhanDuiDataSortCompare(TianTi5v5ZhanDuiData x, TianTi5v5ZhanDuiData y)
        {
            int ret = y.DuanWeiJiFen - x.DuanWeiJiFen;
            int result;

            if (ret != 0)
            {
                result = ret;
            }
            else
            {
                result = x.ZhanDuiID - y.ZhanDuiID;
            }
            return(result);
        }
Example #13
0
        public int UpdateEscapeZhanDui(TianTi5v5ZhanDuiData data)
        {
            string sql = string.Format("update t_kf_5v5_zhandui set escapejifen={1}, escapelastfighttime='{2}' where `zhanduiid`={0};", data.ZhanDuiID, data.EscapeJiFen, data.EscapeLastFightTime.ToString("yyyy-MM-dd HH:mm:ss"));
            int    result;

            if (!this.AddDelayWriteSql(sql, null, null))
            {
                result = -11000;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Example #14
0
        public static int ZhanDuiJoin(int zhanDuiID, int jiFen, int readyNum)
        {
            DateTime now = TimeUtil.NowDateTime();
            int      result;

            if (!EscapeBattleConsts.CheckOpenState(now))
            {
                result = -11004;
            }
            else
            {
                TianTi5v5ZhanDuiData zhanDuiData = TianTi5v5Service.GetZhanDuiData(zhanDuiID);
                if (null == zhanDuiData)
                {
                    result = -4031;
                }
                else
                {
                    lock (EscapeBattle_K.Mutex)
                    {
                        EscapeBattle_K.JoinPkData joinData;
                        if (!EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out joinData))
                        {
                            joinData = new EscapeBattle_K.JoinPkData
                            {
                                ZhanDuiID = zhanDuiID
                            };
                            EscapeBattle_K.JoinDict[zhanDuiID] = joinData;
                        }
                        joinData.DuanWeiJiFen = zhanDuiData.EscapeJiFen;
                        joinData.ZhanDuiName  = zhanDuiData.ZhanDuiName;
                        joinData.ZoneId       = zhanDuiData.ZoneID;
                        joinData.ReadyNum     = readyNum;
                        if (readyNum > 0)
                        {
                            joinData.ReadyState = true;
                            joinData.State      = 2;
                        }
                        else if (readyNum == 0)
                        {
                            joinData.ReadyState = false;
                        }
                    }
                    result = 0;
                }
            }
            return(result);
        }
Example #15
0
        public bool LoadZhanDuiData(Dictionary <int, TianTi5v5ZhanDuiData> dict)
        {
            bool   result = false;
            string sql    = "select `zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`duanweijifen`,`duanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`,`monthduanweirank`,leaderrolename,zoneid,zorkjifen,zorklastfighttime,escapejifen,escapelastfighttime from t_kf_5v5_zhandui";

            using (MySqlDataReader reader = DbHelperMySQL.ExecuteReader(sql, false))
            {
                result = true;
                while (reader.Read())
                {
                    try
                    {
                        TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                        data.ZhanDuiID    = Convert.ToInt32(reader[0].ToString());
                        data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                        data.XuanYan      = reader["xuanyan"].ToString();
                        data.ZhanDuiName  = reader["zhanduiname"].ToString();
                        data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                        data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                        byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                        data.teamerList          = DataHelper2.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                        data.DuanWeiJiFen        = Convert.ToInt32(reader["duanweijifen"].ToString());
                        data.DuanWeiRank         = Convert.ToInt32(reader["duanweirank"].ToString());
                        data.LianSheng           = Convert.ToInt32(reader["liansheng"].ToString());
                        data.FightCount          = Convert.ToInt32(reader["fightcount"].ToString());
                        data.SuccessCount        = Convert.ToInt32(reader["successcount"].ToString());
                        data.LastFightTime       = Convert.ToDateTime(reader["lastfighttime"].ToString());
                        data.MonthDuanWeiRank    = Convert.ToInt32(reader["monthduanweirank"].ToString());
                        data.LeaderRoleName      = reader["leaderrolename"].ToString();
                        data.ZoneID              = Convert.ToInt32(reader["zoneid"].ToString());
                        data.ZorkJiFen           = Convert.ToInt32(reader["zorkjifen"].ToString());
                        data.ZorkLastFightTime   = Convert.ToDateTime(reader["zorklastfighttime"].ToString());
                        data.EscapeJiFen         = Convert.ToInt32(reader["escapejifen"].ToString());
                        data.EscapeLastFightTime = Convert.ToDateTime(reader["escapelastfighttime"].ToString());
                        dict[data.ZhanDuiID]     = data;
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteException(ex.ToString());
                    }
                }
            }
            return(result);
        }
Example #16
0
        public int InitZhanDui(TianTi5v5ZhanDuiData data)
        {
            string sql = string.Format("INSERT INTO t_kf_5v5_zhandui(`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`leaderrolename`,zoneid) VALUES('{1}','{2}','{3}','{4}','{5}',@content,'{6}',{7});", new object[]
            {
                data.ZhanDuiID,
                data.LeaderRoleID,
                data.XuanYan,
                data.ZhanDuiName,
                data.DuanWeiId,
                data.ZhanDouLi,
                data.LeaderRoleName,
                data.ZoneID
            });
            List <Tuple <string, byte[]> > imgList = new List <Tuple <string, byte[]> >();

            imgList.Add(new Tuple <string, byte[]>("@content", DataHelper2.ObjectToBytes <List <TianTi5v5ZhanDuiRoleData> >(data.teamerList)));
            LogManager.WriteLog(LogTypes.SQL, sql, null, true);
            return((int)DbHelperMySQL.ExecuteSqlGetIncrement(sql, imgList));
        }
Example #17
0
 public void UpdateZhanDuiDayRank(List <TianTi5v5ZhanDuiData> list, int dayId, int maxRankCount, bool updateMonthRank)
 {
     try
     {
         this.AddDelayWriteSql("delete from t_kf_5v5_zhandui_paihang where dayid=" + dayId, null, null);
         int i = 0;
         while (i < maxRankCount && i < list.Count)
         {
             TianTi5v5ZhanDuiData data = list[i];
             string sql = string.Format("REPLACE INTO t_kf_5v5_zhandui_paihang (`dayid`,`zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`leaderrolename`,`zoneid`,`zhanli`,`data1`,`data2`,`duanweiid`,`duanweijifen`,`duanweirank`,`monthduanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`) VALUES({15},{0},{1},'{2}','{3}','{4}',{5},{6},@data1,@data2,{7},{8},{9},{10},{11},{12},{13},'{14}');", new object[]
             {
                 data.ZhanDuiID,
                 data.LeaderRoleID,
                 data.XuanYan,
                 data.ZhanDuiName,
                 data.LeaderRoleName,
                 data.ZoneID,
                 data.ZhanDouLi,
                 data.DuanWeiId,
                 data.DuanWeiJiFen,
                 data.DuanWeiRank,
                 data.MonthDuanWeiRank,
                 data.LianSheng,
                 data.FightCount,
                 data.SuccessCount,
                 data.LastFightTime,
                 dayId
             });
             this.AddDelayWriteSql(sql, new List <Tuple <string, byte[]> >
             {
                 new Tuple <string, byte[]>("@data1", DataHelper2.ObjectToBytes <List <TianTi5v5ZhanDuiRoleData> >(data.teamerList)),
                 new Tuple <string, byte[]>("@data2", null)
             }, null);
             i++;
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Example #18
0
        public static int UpdateEscapeZhanDui(int zhanDuiID, int jiFen, DateTime fightTime)
        {
            TianTi5v5ZhanDuiData zhanDuiData = TianTi5v5Service.GetZhanDuiData(zhanDuiID);
            int result;

            if (zhanDuiData != null)
            {
                if (jiFen != -2147483648)
                {
                    zhanDuiData.EscapeJiFen = jiFen;
                }
                zhanDuiData.EscapeLastFightTime = fightTime;
                TianTi5v5Service.Persistence.UpdateEscapeZhanDui(zhanDuiData);
                result = zhanDuiData.EscapeJiFen;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Example #19
0
        public int LoadZhanDuiRankList(List <TianTi5v5ZhanDuiData> list, int dayID)
        {
            int    result = 0;
            string sql    = string.Format("select `zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`duanweijifen`,`duanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`,`monthduanweirank`,leaderrolename,zoneid from t_kf_5v5_zhandui_paihang where dayid={0} order by duanweirank", dayID);

            using (MySqlDataReader reader = DbHelperMySQL.ExecuteReader(sql, false))
            {
                result = 1;
                while (reader.Read())
                {
                    try
                    {
                        TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                        data.ZhanDuiID    = Convert.ToInt32(reader[0].ToString());
                        data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                        data.XuanYan      = reader["xuanyan"].ToString();
                        data.ZhanDuiName  = reader["zhanduiname"].ToString();
                        data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                        data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                        byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                        data.teamerList       = DataHelper2.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                        data.DuanWeiJiFen     = Convert.ToInt32(reader["duanweijifen"].ToString());
                        data.DuanWeiRank      = Convert.ToInt32(reader["duanweirank"].ToString());
                        data.LianSheng        = Convert.ToInt32(reader["liansheng"].ToString());
                        data.FightCount       = Convert.ToInt32(reader["fightcount"].ToString());
                        data.SuccessCount     = Convert.ToInt32(reader["successcount"].ToString());
                        data.LastFightTime    = Convert.ToDateTime(reader["lastfighttime"].ToString());
                        data.MonthDuanWeiRank = Convert.ToInt32(reader["monthduanweirank"].ToString());
                        data.LeaderRoleName   = reader["leaderrolename"].ToString();
                        data.ZoneID           = Convert.ToInt32(reader["zoneid"].ToString());
                        list.Add(data);
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteException(ex.ToString());
                    }
                }
            }
            return(result);
        }
Example #20
0
        public bool QueryZhanDuiRoleInfo(TianTi5v5ZhanDuiData data)
        {
            bool modify = false;

            if (data != null && null != data.teamerList)
            {
                foreach (TianTi5v5ZhanDuiRoleData role in data.teamerList)
                {
                    try
                    {
                        int        roleID   = role.RoleID;
                        DBRoleInfo roleInfo = DBManager.getInstance().GetDBRoleInfo(ref roleID);
                        if (null != roleInfo)
                        {
                            int RebornLevel = Global.GetRoleParamsInt32(roleInfo, "10241");
                            if (role.RoleName != roleInfo.RoleName || role.RoleOcc != roleInfo.Occupation || role.ZhanLi != (long)roleInfo.CombatForce || role.RebornLevel != RebornLevel)
                            {
                                modify = true;
                            }
                            role.RoleName    = roleInfo.RoleName;
                            role.RoleOcc     = roleInfo.Occupation;
                            role.ZhanLi      = (long)roleInfo.CombatForce;
                            role.ZhuanSheng  = roleInfo.ChangeLifeCount;
                            role.Level       = roleInfo.Level;
                            role.RebornLevel = RebornLevel;
                            if (role.RoleID == data.LeaderRoleID)
                            {
                                data.LeaderRoleName = roleInfo.RoleName;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteException(ex.ToString());
                    }
                }
                data.ZhanDouLi = data.teamerList.Sum((TianTi5v5ZhanDuiRoleData x) => x.ZhanLi);
            }
            return(modify);
        }
Example #21
0
        public static int CreateZhanDui(int serverID, TianTi5v5ZhanDuiData pData)
        {
            int ret2 = pData.ZhanDuiID;
            int result;

            if (!TianTi5v5Service.ThreadInit)
            {
                result = -3;
            }
            else
            {
                lock (TianTi5v5Service.Mutex)
                {
                    if (pData.ZhanDuiID == 0)
                    {
                        if (TianTi5v5Service.ZhanDuiDict.Values.Any((TianTi5v5ZhanDuiData x) => StringComparer.CurrentCultureIgnoreCase.Compare(x.ZhanDuiName, pData.ZhanDuiName) == 0))
                        {
                            return(-4023);
                        }
                        ret2 = TianTi5v5Service.Persistence.InitZhanDui(pData);
                        if (ret2 <= 0)
                        {
                            return(-15);
                        }
                        pData.ZhanDuiID = ret2;
                        TianTi5v5Service.ZhanDuiDict[pData.ZhanDuiID] = pData;
                        return(ret2);
                    }
                    else
                    {
                        TianTi5v5Service.Persistence.UpdateZhanDui(pData);
                        TianTi5v5Service.ZhanDuiDict[pData.ZhanDuiID] = pData;
                    }
                }
                result = ret2;
            }
            return(result);
        }
Example #22
0
        public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            DBManager dbMgr  = DBManager.getInstance();
            int       result = 0;

            if (nID <= 3688)
            {
                if (nID != 969)
                {
                    if (nID != 3670)
                    {
                        if (nID == 3688)
                        {
                            AgeDataT <int> requestData = DataHelper.BytesToObject <AgeDataT <int> >(cmdParams, 0, count);
                            AgeDataT <List <TianTi5v5ZhanDuiMiniData> > resultData = new AgeDataT <List <TianTi5v5ZhanDuiMiniData> >(requestData.Age, null);
                            int maxCount = requestData.V;
                            lock (this.Mutex)
                            {
                                if (this.ZhanDuiDataListNeedUpdate)
                                {
                                    List <TianTi5v5ZhanDuiData> list = new List <TianTi5v5ZhanDuiData>();
                                    foreach (AgeDataT <TianTi5v5ZhanDuiData> item in this.ZhanDuiDataDict.Values)
                                    {
                                        if (null != item.V)
                                        {
                                            list.Add(item.V);
                                        }
                                    }
                                    DateTime now = DateTime.Now;
                                    this.MonthStartDateTime = new DateTime(now.Year, now.Month, 1).AddMonths(-1);
                                    list.Sort(new Comparison <TianTi5v5ZhanDuiData>(this.ZhanDuiDataCompare));
                                    this.ZhanDuiDataList.V         = list;
                                    this.ZhanDuiDataListNeedUpdate = false;
                                    TimeUtil.AgeByNow(ref this.ZhanDuiDataList.Age);
                                }
                                if (requestData.Age < this.ZhanDuiDataList.Age)
                                {
                                    resultData.Age = this.ZhanDuiDataList.Age;
                                    resultData.V   = new List <TianTi5v5ZhanDuiMiniData>();
                                    int i = 0;
                                    while (i < this.ZhanDuiDataList.V.Count && i < maxCount)
                                    {
                                        TianTi5v5ZhanDuiData     pData    = this.ZhanDuiDataList.V[i];
                                        TianTi5v5ZhanDuiMiniData miniData = new TianTi5v5ZhanDuiMiniData();
                                        miniData.ZhanDuiID    = pData.ZhanDuiID;
                                        miniData.DuanWeiID    = pData.DuanWeiId;
                                        miniData.DuiZhangName = pData.ZhanDuiName;
                                        miniData.XuanYan      = pData.XuanYan;
                                        miniData.ZhanDouLi    = pData.ZhanDouLi;
                                        miniData.Name         = pData.LeaderRoleName;
                                        miniData.MemberList   = new List <RoleNameLevelData>();
                                        foreach (TianTi5v5ZhanDuiRoleData role2 in pData.teamerList)
                                        {
                                            miniData.MemberList.Add(new RoleNameLevelData(role2.ZhuanSheng, role2.Level, role2.RoleName, role2.RoleID == pData.LeaderRoleID, role2.RoleOcc));
                                        }
                                        resultData.V.Add(miniData);
                                        i++;
                                    }
                                }
                            }
                            client.sendCmd <AgeDataT <List <TianTi5v5ZhanDuiMiniData> > >(nID, resultData);
                        }
                    }
                    else
                    {
                        TianTiLogItemData kf5V5LogItemData = DataHelper.BytesToObject <TianTiLogItemData>(cmdParams, 0, count);
                        if (kf5V5LogItemData != null && kf5V5LogItemData.RoleId > 0)
                        {
                            lock (this.Mutex)
                            {
                                KF5V5RoleLogData pKF5VRoleLogData;
                                if (this.KF5V5RoleLogDataDict.TryGetValue(kf5V5LogItemData.RoleId, out pKF5VRoleLogData))
                                {
                                    pKF5VRoleLogData.LogItemList.Insert(0, kf5V5LogItemData);
                                }
                            }
                            DBWriter.InsertKF5v5ItemLog(DBManager.getInstance(), kf5V5LogItemData);
                        }
                        client.sendCmd <int>(nID, result);
                    }
                }
                else
                {
                    int  roleId   = DataHelper.BytesToObject <int>(cmdParams, 0, count);
                    bool needLoad = false;
                    TianTiRoleLogData tianTiRoleLogData;
                    lock (this.Mutex)
                    {
                        if (!this.TianTiRoleLogDataDict.TryGetValue(roleId, out tianTiRoleLogData))
                        {
                            tianTiRoleLogData = new TianTiRoleLogData();
                            this.TianTiRoleLogDataDict.Add(roleId, tianTiRoleLogData);
                            needLoad = true;
                        }
                    }
                    if (needLoad)
                    {
                        tianTiRoleLogData.LogItemList = DBQuery.GetTianTiLogItemDataList(dbMgr, roleId, 100);
                    }
                    lock (this.Mutex)
                    {
                        if (null != tianTiRoleLogData.LogItemList)
                        {
                            if (tianTiRoleLogData.LogItemList.Count > 0)
                            {
                                if (tianTiRoleLogData.LogItemList.Count > 100)
                                {
                                    int c = tianTiRoleLogData.LogItemList.Count - 100;
                                    if (c > 0)
                                    {
                                        tianTiRoleLogData.LogItemList.RemoveRange(100, c);
                                    }
                                }
                            }
                        }
                    }
                    client.sendCmd <List <TianTiLogItemData> >(nID, tianTiRoleLogData.LogItemList);
                }
            }
            else if (nID <= 3709)
            {
                if (nID != 3699)
                {
                    if (nID == 3709)
                    {
                        int              roleId   = DataHelper.BytesToObject <int>(cmdParams, 0, count);
                        bool             needLoad = false;
                        KF5V5RoleLogData kf5v5RoleLogData;
                        lock (this.Mutex)
                        {
                            if (!this.KF5V5RoleLogDataDict.TryGetValue(roleId, out kf5v5RoleLogData))
                            {
                                kf5v5RoleLogData = new KF5V5RoleLogData();
                                this.KF5V5RoleLogDataDict.Add(roleId, kf5v5RoleLogData);
                                needLoad = true;
                            }
                        }
                        if (needLoad)
                        {
                            kf5v5RoleLogData.LogItemList = DBQuery.GetT5v5ItemDataList(dbMgr, roleId, 100);
                        }
                        lock (this.Mutex)
                        {
                            if (null != kf5v5RoleLogData.LogItemList)
                            {
                                if (kf5v5RoleLogData.LogItemList.Count > 0)
                                {
                                    if (kf5v5RoleLogData.LogItemList.Count > 100)
                                    {
                                        int c = kf5v5RoleLogData.LogItemList.Count - 100;
                                        if (c > 0)
                                        {
                                            kf5v5RoleLogData.LogItemList.RemoveRange(100, c);
                                        }
                                    }
                                }
                            }
                        }
                        client.sendCmd <List <TianTiLogItemData> >(nID, kf5v5RoleLogData.LogItemList);
                    }
                }
                else
                {
                    int zhanDuiID = DataHelper.BytesToObject <int>(cmdParams, 0, count);
                    lock (this.Mutex)
                    {
                        AgeDataT <TianTi5v5ZhanDuiData> zhanDuiData;
                        if (this.ZhanDuiDataDict.TryGetValue(zhanDuiID, out zhanDuiData))
                        {
                            TimeUtil.AgeByNow(ref zhanDuiData.Age);
                            zhanDuiData.V = null;
                            this.ZhanDuiDataListNeedUpdate = true;
                            using (MyDbConnection3 conn = new MyDbConnection3(false))
                            {
                                string cmdText = string.Format("delete from t_kf_5v5_zhandui where zhanduiid={0}", zhanDuiID);
                                result = conn.ExecuteSql(cmdText, new MySQLParameter[0]);
                            }
                        }
                    }
                    client.sendCmd <int>(nID, result);
                }
            }
            else
            {
                switch (nID)
                {
                case 3715:
                {
                    AgeDataT <int> requestData = DataHelper.BytesToObject <AgeDataT <int> >(cmdParams, 0, count);
                    int            zhanDuiID   = requestData.V;
                    AgeDataT <TianTi5v5ZhanDuiData> zhanDuiData;
                    lock (this.Mutex)
                    {
                        if (this.ZhanDuiDataDict.TryGetValue(requestData.V, out zhanDuiData))
                        {
                            if (this.QueryZhanDuiRoleInfo(zhanDuiData.V))
                            {
                                TimeUtil.AgeByNow(ref zhanDuiData.Age);
                            }
                            if (requestData.Age == zhanDuiData.Age || zhanDuiData.V == null)
                            {
                                zhanDuiData = new AgeDataT <TianTi5v5ZhanDuiData>(zhanDuiData.Age, null);
                            }
                            goto IL_91C;
                        }
                    }
                    TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                    using (MyDbConnection3 conn = new MyDbConnection3(false))
                    {
                        string sql = string.Format("select zhanduiname,xuanyan,`leaderid`,duanweiid,duanweijifen,duanweirank,liansheng,fightcount,successcount,lastfighttime,monthduanweirank,zhanli,data1,leaderrolename,zoneid,zorkjifen,zorkwin,zorkwinstreak,zorkbossinjure,zorklastfighttime,escapejifen,escapelastfighttime from t_kf_5v5_zhandui where zhanduiid={0}", zhanDuiID);
                        using (MySQLDataReader reader = conn.ExecuteReader(sql, new MySQLParameter[0]))
                        {
                            if (reader.Read())
                            {
                                data.ZhanDuiID    = zhanDuiID;
                                data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                                data.XuanYan      = reader["xuanyan"].ToString();
                                data.ZhanDuiName  = reader["zhanduiname"].ToString();
                                data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                                data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                                byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                                data.teamerList          = DataHelper.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                                data.DuanWeiJiFen        = Convert.ToInt32(reader["duanweijifen"].ToString());
                                data.DuanWeiRank         = Convert.ToInt32(reader["duanweirank"].ToString());
                                data.LianSheng           = Convert.ToInt32(reader["liansheng"].ToString());
                                data.FightCount          = Convert.ToInt32(reader["fightcount"].ToString());
                                data.SuccessCount        = Convert.ToInt32(reader["successcount"].ToString());
                                data.LastFightTime       = Convert.ToDateTime(reader["lastfighttime"].ToString());
                                data.MonthDuanWeiRank    = Convert.ToInt32(reader["monthduanweirank"].ToString());
                                data.LeaderRoleName      = reader["leaderrolename"].ToString();
                                data.ZoneID              = Convert.ToInt32(reader["zoneid"].ToString());
                                data.ZorkJiFen           = Convert.ToInt32(reader["zorkjifen"].ToString());
                                data.ZorkWin             = Convert.ToInt32(reader["zorkwin"].ToString());
                                data.ZorkWinStreak       = Convert.ToInt32(reader["zorkwinstreak"].ToString());
                                data.ZorkBossInjure      = Convert.ToInt32(reader["zorkbossinjure"].ToString());
                                data.ZorkLastFightTime   = Convert.ToDateTime(reader["zorklastfighttime"].ToString());
                                data.EscapeJiFen         = Convert.ToInt32(reader["escapejifen"].ToString());
                                data.EscapeLastFightTime = Convert.ToDateTime(reader["escapelastfighttime"].ToString());
                            }
                        }
                    }
                    lock (this.Mutex)
                    {
                        if (data.ZhanDuiID > 0)
                        {
                            if (!this.ZhanDuiDataDict.TryGetValue(requestData.V, out zhanDuiData) || zhanDuiData.V == null)
                            {
                                zhanDuiData = new AgeDataT <TianTi5v5ZhanDuiData>(1L, data);
                                this.ZhanDuiDataDict[requestData.V] = zhanDuiData;
                            }
                        }
                        else
                        {
                            zhanDuiData = new AgeDataT <TianTi5v5ZhanDuiData>(requestData.Age + 1L, null);
                            this.ZhanDuiDataDict[requestData.V] = zhanDuiData;
                        }
                        if (this.QueryZhanDuiRoleInfo(zhanDuiData.V))
                        {
                            TimeUtil.AgeByNow(ref zhanDuiData.Age);
                        }
                    }
IL_91C:
                    client.sendCmd <AgeDataT <TianTi5v5ZhanDuiData> >(nID, zhanDuiData);
                    break;
                }

                case 3716:
                {
                    AgeDataT <TianTi5v5ZhanDuiData> zhanDuiData  = null;
                    AgeDataT <TianTi5v5ZhanDuiData> requestData2 = DataHelper.BytesToObject <AgeDataT <TianTi5v5ZhanDuiData> >(cmdParams, 0, count);
                    if (requestData2 != null && requestData2.V != null)
                    {
                        lock (this.Mutex)
                        {
                            TianTi5v5ZhanDuiData data = requestData2.V;
                            if (!this.ZhanDuiDataDict.TryGetValue(data.ZhanDuiID, out zhanDuiData))
                            {
                                zhanDuiData = new AgeDataT <TianTi5v5ZhanDuiData>(0L, data);
                                this.ZhanDuiDataDict[data.ZhanDuiID] = zhanDuiData;
                                this.ZhanDuiDataListNeedUpdate       = true;
                            }
                            else
                            {
                                if (zhanDuiData.V == null || zhanDuiData.V.LeaderRoleID != requestData2.V.LeaderRoleID || zhanDuiData.V.LeaderRoleName != requestData2.V.LeaderRoleName || zhanDuiData.V.DuanWeiId != requestData2.V.DuanWeiId)
                                {
                                    this.ZhanDuiDataListNeedUpdate = true;
                                }
                                if (requestData2.V.ZhanDuiDataModeType == 1)
                                {
                                    zhanDuiData.V.ZhanDuiID      = data.ZhanDuiID;
                                    zhanDuiData.V.XuanYan        = data.XuanYan;
                                    zhanDuiData.V.ZhanDuiName    = data.ZhanDuiName;
                                    zhanDuiData.V.LeaderRoleID   = data.LeaderRoleID;
                                    zhanDuiData.V.ZhanDouLi      = data.ZhanDouLi;
                                    zhanDuiData.V.teamerList     = data.teamerList;
                                    zhanDuiData.V.TeamerRidList  = data.TeamerRidList;
                                    zhanDuiData.V.LeaderRoleName = data.LeaderRoleName;
                                    zhanDuiData.V.ZoneID         = data.ZoneID;
                                }
                                else if (requestData2.V.ZhanDuiDataModeType == 0)
                                {
                                    zhanDuiData.V.DuanWeiId        = data.DuanWeiId;
                                    zhanDuiData.V.DuanWeiJiFen     = data.DuanWeiJiFen;
                                    zhanDuiData.V.DuanWeiRank      = data.DuanWeiRank;
                                    zhanDuiData.V.ZhanDouLi        = data.ZhanDouLi;
                                    zhanDuiData.V.LianSheng        = data.LianSheng;
                                    zhanDuiData.V.SuccessCount     = data.SuccessCount;
                                    zhanDuiData.V.FightCount       = data.FightCount;
                                    zhanDuiData.V.MonthDuanWeiRank = data.MonthDuanWeiRank;
                                    zhanDuiData.V.LastFightTime    = data.LastFightTime;
                                    using (List <TianTi5v5ZhanDuiRoleData> .Enumerator enumerator2 = zhanDuiData.V.teamerList.GetEnumerator())
                                    {
                                        while (enumerator2.MoveNext())
                                        {
                                            TianTi5v5ZhanDuiRoleData role        = enumerator2.Current;
                                            TianTi5v5ZhanDuiRoleData newRoleInfo = data.teamerList.Find((TianTi5v5ZhanDuiRoleData x) => x.RoleID == role.RoleID);
                                            if (null != newRoleInfo)
                                            {
                                                role.MonthFightCounts = newRoleInfo.MonthFightCounts;
                                                role.TodayFightCount  = newRoleInfo.TodayFightCount;
                                                role.MonthFigntCount  = newRoleInfo.MonthFigntCount;
                                                role.ZhanLi           = newRoleInfo.ZhanLi;
                                                role.RoleOcc          = newRoleInfo.RoleOcc;
                                                role.ZhuanSheng       = newRoleInfo.ZhuanSheng;
                                                role.Level            = newRoleInfo.Level;
                                                role.RebornLevel      = newRoleInfo.RebornLevel;
                                                role.ModelData        = newRoleInfo.ModelData;
                                            }
                                        }
                                    }
                                }
                            }
                            requestData2.Age = TimeUtil.AgeByNow(ref zhanDuiData.Age);
                            using (MyDbConnection3 conn = new MyDbConnection3(false))
                            {
                                data = zhanDuiData.V;
                                if (null != data)
                                {
                                    MySQLParameter p          = new MySQLParameter("@p1", data.ZhanDuiName);
                                    MySQLParameter p2         = new MySQLParameter("@p2", data.XuanYan);
                                    string         teamerList = DataHelper.ObjectToHexString <List <TianTi5v5ZhanDuiRoleData> >(data.teamerList);
                                    string         cmdText    = string.Format("INSERT INTO t_kf_5v5_zhandui (zhanduiid,zhanduiname,xuanyan,`leaderid`,duanweiid,duanweijifen,duanweirank,liansheng,fightcount,successcount,lastfighttime,monthduanweirank,zhanli,data1,leaderrolename,zoneid) VALUES({0},@p1,@p2,{3},{4},{5},{6},{7},{8},{9},'{10}',{11},{12},{14},'{13}',{15}) ON DUPLICATE KEY UPDATE zhanduiname=@p1,xuanyan=@p2,leaderid={3},duanweiid={4},duanweijifen={5},duanweirank={6},liansheng={7},fightcount={8},successcount={9},lastfighttime='{10}',monthduanweirank={11},zhanli={12},data1={14},leaderrolename='{13}',zoneid={15}", new object[]
                                        {
                                            data.ZhanDuiID,
                                            data.ZhanDuiName,
                                            data.XuanYan,
                                            data.LeaderRoleID,
                                            data.DuanWeiId,
                                            data.DuanWeiJiFen,
                                            data.DuanWeiRank,
                                            data.LianSheng,
                                            data.FightCount,
                                            data.SuccessCount,
                                            data.LastFightTime,
                                            data.MonthDuanWeiRank,
                                            data.ZhanDouLi,
                                            data.LeaderRoleName,
                                            teamerList,
                                            data.ZoneID
                                        });
                                    int ret = conn.ExecuteSql(cmdText, new MySQLParameter[]
                                        {
                                            p,
                                            p2
                                        });
                                }
                            }
                        }
                    }
                    client.sendCmd <AgeDataT <TianTi5v5ZhanDuiData> >(nID, zhanDuiData);
                    break;
                }

                case 3717:
                {
                    int[]      args     = DataHelper.BytesToObject <int[]>(cmdParams, 0, count);
                    DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref args[0]);
                    if (null != roleInfo)
                    {
                        roleInfo.ZhanDuiID    = args[1];
                        roleInfo.ZhanDuiZhiWu = args[2];
                        using (MyDbConnection3 conn = new MyDbConnection3(false))
                        {
                            string cmdText = string.Format("update t_roles set zhanduiid={1},zhanduizhiwu={2} where rid={0}", roleInfo.RoleID, roleInfo.ZhanDuiID, roleInfo.ZhanDuiZhiWu);
                            result = conn.ExecuteSql(cmdText, new MySQLParameter[0]);
                        }
                    }
                    client.sendCmd <int>(nID, result);
                    break;
                }

                case 3718:
                case 3719:
                case 3720:
                case 3721:
                    break;

                case 3722:
                {
                    AgeDataT <TianTi5v5ZhanDuiData> zhanDuiData  = null;
                    AgeDataT <TianTi5v5ZhanDuiData> requestData2 = DataHelper.BytesToObject <AgeDataT <TianTi5v5ZhanDuiData> >(cmdParams, 0, count);
                    if (requestData2 != null && requestData2.V != null)
                    {
                        lock (this.Mutex)
                        {
                            TianTi5v5ZhanDuiData data = requestData2.V;
                            if (!this.ZhanDuiDataDict.TryGetValue(data.ZhanDuiID, out zhanDuiData))
                            {
                                client.sendCmd(30767, "0");
                                break;
                            }
                            zhanDuiData.V.ZorkJiFen         = data.ZorkJiFen;
                            zhanDuiData.V.ZorkWin           = data.ZorkWin;
                            zhanDuiData.V.ZorkWinStreak     = data.ZorkWinStreak;
                            zhanDuiData.V.ZorkBossInjure    = data.ZorkBossInjure;
                            zhanDuiData.V.ZorkLastFightTime = data.ZorkLastFightTime;
                            requestData2.Age = TimeUtil.AgeByNow(ref zhanDuiData.Age);
                            using (MyDbConnection3 conn = new MyDbConnection3(false))
                            {
                                string cmdText = string.Format("UPDATE t_kf_5v5_zhandui SET zorkjifen={1}, zorkwin={2}, zorkwinstreak={3}, zorkbossinjure={4}, zorklastfighttime='{5}' WHERE zhanduiid={0}; ", new object[]
                                    {
                                        data.ZhanDuiID,
                                        data.ZorkJiFen,
                                        data.ZorkWin,
                                        data.ZorkWinStreak,
                                        data.ZorkBossInjure,
                                        data.ZorkLastFightTime
                                    });
                                int ret = conn.ExecuteSql(cmdText, new MySQLParameter[0]);
                            }
                        }
                    }
                    client.sendCmd <AgeDataT <TianTi5v5ZhanDuiData> >(nID, zhanDuiData);
                    break;
                }

                case 3723:
                {
                    AgeDataT <TianTi5v5ZhanDuiData> zhanDuiData  = null;
                    AgeDataT <TianTi5v5ZhanDuiData> requestData2 = DataHelper.BytesToObject <AgeDataT <TianTi5v5ZhanDuiData> >(cmdParams, 0, count);
                    if (requestData2 != null && requestData2.V != null)
                    {
                        lock (this.Mutex)
                        {
                            TianTi5v5ZhanDuiData data = requestData2.V;
                            if (!this.ZhanDuiDataDict.TryGetValue(data.ZhanDuiID, out zhanDuiData))
                            {
                                client.sendCmd(30767, "0");
                                break;
                            }
                            zhanDuiData.V.EscapeJiFen         = data.EscapeJiFen;
                            zhanDuiData.V.EscapeLastFightTime = data.EscapeLastFightTime;
                            requestData2.Age = TimeUtil.AgeByNow(ref zhanDuiData.Age);
                            using (MyDbConnection3 conn = new MyDbConnection3(false))
                            {
                                string cmdText = string.Format("UPDATE t_kf_5v5_zhandui SET escapejifen={1}, escapelastfighttime='{2}' WHERE zhanduiid={0}; ", data.ZhanDuiID, data.EscapeJiFen, data.EscapeLastFightTime);
                                int    ret     = conn.ExecuteSql(cmdText, new MySQLParameter[0]);
                            }
                        }
                    }
                    client.sendCmd <AgeDataT <TianTi5v5ZhanDuiData> >(nID, zhanDuiData);
                    break;
                }

                default:
                    switch (nID)
                    {
                    case 10200:
                    {
                        TianTiLogItemData tianTiLogItemData = DataHelper.BytesToObject <TianTiLogItemData>(cmdParams, 0, count);
                        if (tianTiLogItemData != null && tianTiLogItemData.RoleId > 0)
                        {
                            lock (this.Mutex)
                            {
                                TianTiRoleLogData tianTiRoleLogData;
                                if (this.TianTiRoleLogDataDict.TryGetValue(tianTiLogItemData.RoleId, out tianTiRoleLogData))
                                {
                                    tianTiRoleLogData.LogItemList.Insert(0, tianTiLogItemData);
                                }
                            }
                            DBWriter.InsertTianTiItemLog(DBManager.getInstance(), tianTiLogItemData);
                        }
                        client.sendCmd <int>(nID, result);
                        break;
                    }

                    case 10201:
                    {
                        RoleTianTiData roleTianTiData = DataHelper.BytesToObject <RoleTianTiData>(cmdParams, 0, count);
                        if (null != roleTianTiData)
                        {
                            DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleTianTiData.RoleId);
                            if (null != dbRoleInfo)
                            {
                                lock (dbRoleInfo)
                                {
                                    dbRoleInfo.TianTiData = roleTianTiData;
                                    DBWriter.UpdateTianTiRoleData(dbMgr, roleTianTiData);
                                }
                            }
                        }
                        client.sendCmd <int>(nID, result);
                        break;
                    }

                    case 10202:
                    {
                        int[] dataArray = DataHelper.BytesToObject <int[]>(cmdParams, 0, count);
                        if (dataArray != null && dataArray.Length == 2)
                        {
                            DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref dataArray[0]);
                            if (null != dbRoleInfo)
                            {
                                lock (dbRoleInfo)
                                {
                                    dbRoleInfo.TianTiData.RongYao = dataArray[1];
                                    if (dbRoleInfo.TianTiData.LastFightDayId > 0)
                                    {
                                        result = DBWriter.UpdateTianTiRoleRongYao(dbMgr, dataArray[0], dataArray[1]);
                                    }
                                    else
                                    {
                                        result = DBWriter.UpdateTianTiRoleData(dbMgr, dbRoleInfo.TianTiData);
                                    }
                                }
                            }
                        }
                        client.sendCmd <int>(nID, result);
                        break;
                    }
                    }
                    break;
                }
            }
        }
Example #23
0
        private void MS_PrepareGame_Update(DateTime now, int param)
        {
            ZorkBattleSceneInfo   matchConfig    = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
            List <KF5v5PiPeiTeam> SignUpTeamList = this.PiPeiDict.Values.ToList <KF5v5PiPeiTeam>();

            if (SignUpTeamList.Count < matchConfig.MaxEnterNum - 1)
            {
                this.StateMachine.SetCurrState(Zork5v5StateMachine.StateType.NotifyEnter, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_PrepareGame_Update To:{0} SeasonID:{1} Round:{2}", Zork5v5StateMachine.StateType.NotifyEnter, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
            else
            {
                List <KF5v5PiPeiTeam> TeamStandByList = new List <KF5v5PiPeiTeam>(SignUpTeamList);
                if (TeamStandByList.Count > 0)
                {
                    Random r = new Random((int)now.Ticks);
                    int    i = 0;
                    while (TeamStandByList.Count > 0 && i < TeamStandByList.Count * 2)
                    {
                        int            idx  = r.Next(0, TeamStandByList.Count);
                        int            idx2 = r.Next(0, TeamStandByList.Count);
                        KF5v5PiPeiTeam tmp  = TeamStandByList[idx];
                        TeamStandByList[idx]  = TeamStandByList[idx2];
                        TeamStandByList[idx2] = tmp;
                        i++;
                    }
                }
                int currIdx = 0;
                for (int i = 0; i < TeamStandByList.Count / matchConfig.MaxEnterNum; i++)
                {
                    int zhanduiCount = 0;
                    int side         = 0;
                    KuaFu5v5FuBenData ZorkFuBenData = new KuaFu5v5FuBenData();
                    for (int teamIdx = currIdx; teamIdx < currIdx + matchConfig.MaxEnterNum; teamIdx++)
                    {
                        KF5v5PiPeiTeam team = TeamStandByList[teamIdx];
                        if (ZorkFuBenData.AddZhanDuiWithName(team.TeamID, team.ZhanDuiName, ref zhanduiCount, ref side))
                        {
                            TianTi5v5ZhanDuiData teamData = TianTi5v5Service.GetZhanDuiData(team.TeamID);
                            if (null != teamData)
                            {
                                foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList)
                                {
                                    KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
                                    {
                                        ServerId = team.ServerID,
                                        RoleId   = role.RoleID,
                                        Side     = side
                                    };
                                    ZorkFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID);
                                }
                            }
                        }
                    }
                    currIdx += matchConfig.MaxEnterNum;
                    this.AssginKfFuben(ZorkFuBenData);
                }
                if (currIdx > 0)
                {
                    TeamStandByList.RemoveRange(0, currIdx);
                }
                if (TeamStandByList.Count >= matchConfig.MaxEnterNum - 1)
                {
                    int zhanduiCount = 0;
                    int side         = 0;
                    KuaFu5v5FuBenData ZorkFuBenData = new KuaFu5v5FuBenData();
                    for (int i = 0; i < TeamStandByList.Count; i++)
                    {
                        KF5v5PiPeiTeam team = TeamStandByList[i];
                        if (ZorkFuBenData.AddZhanDuiWithName(team.TeamID, team.ZhanDuiName, ref zhanduiCount, ref side))
                        {
                            TianTi5v5ZhanDuiData teamData = TianTi5v5Service.GetZhanDuiData(team.TeamID);
                            if (null != teamData)
                            {
                                foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList)
                                {
                                    KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
                                    {
                                        ServerId = team.ServerID,
                                        RoleId   = role.RoleID,
                                        Side     = side
                                    };
                                    ZorkFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID);
                                }
                            }
                        }
                    }
                    this.AssginKfFuben(ZorkFuBenData);
                }
                else if (TeamStandByList.Count > 0)
                {
                    foreach (KF5v5PiPeiTeam item in TeamStandByList)
                    {
                        this.BybZhanDuiIDSet.Add(item.TeamID);
                    }
                    string zhanduiIdArray = string.Join <int>("|", this.BybZhanDuiIDSet.ToArray <int>());
                    LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::轮空 SeasonID:{0} Round:{1} zhanduiId:{2} ", this.CurrentSeasonID, this.CurrentRound, zhanduiIdArray), null, true);
                }
                this.StateMachine.SetCurrState(Zork5v5StateMachine.StateType.NotifyEnter, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_PrepareGame_Update To:{0} SeasonID:{1} Round:{2}", Zork5v5StateMachine.StateType.NotifyEnter, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
        }
Example #24
0
 public int CreateZhanDui(int serverID, TianTi5v5ZhanDuiData pData)
 {
     return(TianTi5v5Service.CreateZhanDui(serverID, pData));
 }
Example #25
0
 public int UpdateZhanDuiData(TianTi5v5ZhanDuiData data, ZhanDuiDataModeTypes modeType)
 {
     return(TianTi5v5Service.UpdateZhanDuiData(data, modeType));
 }
        public ZhanDuiZhengBaSyncData LoadZhengBaSyncData(DateTime now, int selectRoleIfNewCreate)
        {
            ZhanDuiZhengBaSyncData syncData = new ZhanDuiZhengBaSyncData();

            syncData.Month = ZhengBaUtils.MakeMonth(now);
            syncData.IsThisMonthInActivity = false;
            List <ZhanDuiZhengBaZhanDuiData> rankList    = new List <ZhanDuiZhengBaZhanDuiData>();
            List <ZhanDuiZhengBaZhanDuiData> zhanDuiList = new List <ZhanDuiZhengBaZhanDuiData>();
            List <ZhanDuiZhengBaPkLogData>   pkLogList   = new List <ZhanDuiZhengBaPkLogData>();

            if (KuaFuServerManager.IsGongNengOpened(113))
            {
                TianTi5v5RankData rankData = TianTi5v5Service.ZhanDuiGetRankingData(DateTime.MinValue);
                bool bMonthFirst           = this.CheckZhengBaRank(selectRoleIfNewCreate, syncData.Month);
                if (bMonthFirst)
                {
                    syncData.IsThisMonthInActivity = true;
                }
                else if (syncData.Month == ZhengBaUtils.MakeMonth(rankData.ModifyTime) && rankData.MonthPaiHangList.Count > ZhanDuiZhengBaConsts.MinZhanDuiNum)
                {
                    syncData.IsThisMonthInActivity = true;
                    int[] groupArray = MathEx.MatchGroupBinary(64);
                    int   i          = 0;
                    while (i < 64 && i < rankData.MonthPaiHangList.Count)
                    {
                        int group = Array.IndexOf <int>(groupArray, i + 1) + 1;
                        TianTi5v5ZhanDuiData      data    = rankData.MonthPaiHangList[i];
                        ZhanDuiZhengBaZhanDuiData zhandui = new ZhanDuiZhengBaZhanDuiData
                        {
                            ZhanDuiName = data.ZhanDuiName,
                            ZhanDuiID   = data.ZhanDuiID,
                            ZhanLi      = (long)((int)data.ZhanDouLi),
                            DuanWeiId   = data.DuanWeiId,
                            DuanWeiRank = data.DuanWeiRank,
                            ZoneId      = data.ZoneID,
                            MemberList  = new List <RoleOccuNameZhanLi>(),
                            Group       = group
                        };
                        foreach (TianTi5v5ZhanDuiRoleData a in data.teamerList)
                        {
                            if (a.RoleID == data.LeaderRoleID)
                            {
                                zhandui.MemberList.Insert(0, new RoleOccuNameZhanLi
                                {
                                    RoleName   = a.RoleName,
                                    Occupation = a.RoleOcc,
                                    ZhanLi     = a.ZhanLi
                                });
                            }
                            else
                            {
                                zhandui.MemberList.Add(new RoleOccuNameZhanLi
                                {
                                    RoleName   = a.RoleName,
                                    Occupation = a.RoleOcc,
                                    ZhanLi     = a.ZhanLi
                                });
                            }
                        }
                        rankList.Add(zhandui);
                        i++;
                    }
                    if (!this.BuildZhengBaRank(syncData.Month, rankList))
                    {
                        LogManager.WriteLog(LogTypes.Fatal, "生成并写入战队争霸64强数据失败!", null, true);
                        syncData.IsThisMonthInActivity = false;
                    }
                }
                if (syncData.IsThisMonthInActivity)
                {
                    zhanDuiList = this.LoadZhengBaRankData(syncData.Month);
                    pkLogList   = this.LoadPkLogList(syncData.Month);
                }
            }
            syncData.ZhanDuiList = zhanDuiList;
            syncData.PKLogList   = pkLogList;
            syncData.RoleModTime = now;
            return(syncData);
        }