Exemple #1
0
        /// <summary>
        /// 创建竞技场数据
        /// 用于玩家到达一定等级开启竞技场功能时,初始化竞技场数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool createRobotData(PlayerJingJiData data)
        {
            lock (changeRankingLock)
            {
                if (playerJingJiDatas.ContainsKey(data.roleId))
                {
                    return(false);
                }

                data.isOnline = true;
                playerJingJiDatas.Add(data.roleId, data);
                challengeInfos.Add(data.roleId, new List <JingJiChallengeInfoData>());

                if (rankingDatas.Count >= RankingList_Max_Num)
                {
                    data.ranking = -1;
                }
                else
                {
                    data.ranking = rankingDatas.Count + 1;
                    rankingDatas.Add(data.getPlayerJingJiRankingData());
                }
            }

            return(JingJiChangDBController.getInstance().insertJingJiData(data));
        }
Exemple #2
0
        public void onPlayerLogin(int roleId)
        {
            PlayerJingJiData data = null;

            lock (this.changeRankingLock)
            {
                if (this.playerJingJiDatas.TryGetValue(roleId, out data))
                {
                    data.isOnline = true;
                }
                else
                {
                    data = JingJiChangDBController.getInstance().getPlayerJingJiDataById(roleId);
                    if (null != data)
                    {
                        data.convertObject();
                        data.isOnline = true;
                        this.playerJingJiDatas.Add(data.roleId, data);
                    }
                }
                if (null != data)
                {
                    List <JingJiChallengeInfoData> zhanBaoList = null;
                    if (!this.challengeInfos.TryGetValue(roleId, out zhanBaoList))
                    {
                        zhanBaoList = JingJiChangZhaoBaoDBController.getInstnace().getChallengeInfoListByRoleId(roleId);
                        if (null == zhanBaoList)
                        {
                            zhanBaoList = new List <JingJiChallengeInfoData>();
                        }
                        this.challengeInfos.Add(roleId, zhanBaoList);
                    }
                }
            }
        }
Exemple #3
0
        public bool removeCD(int roleId)
        {
            PlayerJingJiData data = null;

            lock (this.changeRankingLock)
            {
                this.playerJingJiDatas.TryGetValue(roleId, out data);
            }
            if (null != data)
            {
                data.nextChallengeTime = 0L;
            }
            return(JingJiChangDBController.getInstance().updateNextChallengeTime(roleId, 0L));
        }
Exemple #4
0
        public int onChallengeEnd(JingJiChallengeResultData result)
        {
            PlayerJingJiData challenger   = null;
            PlayerJingJiData beChallenger = null;
            int ranking;

            lock (this.changeRankingLock)
            {
                this.playerJingJiDatas.TryGetValue(result.playerId, out challenger);
                this.playerJingJiDatas.TryGetValue(result.robotId, out beChallenger);
                BeChallengerCount beChallengerCount = null;
                this.lockPlayerJingJiDatas.TryGetValue(result.robotId, out beChallengerCount);
                if (null != beChallengerCount)
                {
                    beChallengerCount.nBeChallengerCount--;
                }
                if (result.isWin)
                {
                    int playerRanking = challenger.ranking;
                    int robotRanking  = beChallenger.ranking;
                    if (robotRanking < 1 || playerRanking == robotRanking)
                    {
                        return(challenger.ranking);
                    }
                    if (playerRanking == -1)
                    {
                        challenger.ranking   = robotRanking;
                        beChallenger.ranking = playerRanking;
                        this.rankingDatas.Remove(beChallenger.getPlayerJingJiRankingData());
                        this.rankingDatas.Add(challenger.getPlayerJingJiRankingData());
                        this.rankingDatas.Sort();
                        JingJiChangDBController.getInstance().updateJingJiRanking(challenger.roleId, challenger.ranking);
                        JingJiChangDBController.getInstance().updateJingJiRanking(beChallenger.roleId, beChallenger.ranking);
                    }
                    else if (playerRanking > robotRanking)
                    {
                        challenger.ranking   = robotRanking;
                        beChallenger.ranking = playerRanking;
                        beChallenger.getPlayerJingJiRankingData();
                        challenger.getPlayerJingJiRankingData();
                        this.rankingDatas.Sort();
                        JingJiChangDBController.getInstance().updateJingJiRanking(challenger.roleId, challenger.ranking);
                        JingJiChangDBController.getInstance().updateJingJiRanking(beChallenger.roleId, beChallenger.ranking);
                    }
                }
                ranking = challenger.ranking;
            }
            return(ranking);
        }
Exemple #5
0
        /// <summary>
        /// 更新下次领取奖励时间
        /// </summary>
        public bool updateNextRewardTime(int roleId, long nextRewardTime)
        {
            PlayerJingJiData data = null;

            lock (changeRankingLock)
            {
                playerJingJiDatas.TryGetValue(roleId, out data);
            }

            if (null != data)
            {
                data.nextRewardTime = nextRewardTime;
                return(JingJiChangDBController.getInstance().updateNextRewardTime(roleId, nextRewardTime));
            }

            return(false);
        }
Exemple #6
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void initData()
        {
            //初始化竞技场机器人数据,排行榜数据
            List <PlayerJingJiData> playerJingJiDataList = JingJiChangDBController.getInstance().getPlayerJingJiDataList();

            if (null == playerJingJiDataList)
            {
                return;
            }

            foreach (PlayerJingJiData data in playerJingJiDataList)
            {
                data.convertObject();
                playerJingJiDatas.Add(data.roleId, data);
                rankingDatas.Add(data.getPlayerJingJiRankingData());
            }
        }
Exemple #7
0
        /// <summary>
        /// 消除挑战CD
        /// </summary>
        public bool removeCD(int roleId)
        {
            PlayerJingJiData data = null;

            lock (changeRankingLock)
            {
                playerJingJiDatas.TryGetValue(roleId, out data);
            }

            if (null != data)
            {
                //更新内存
                data.nextChallengeTime = 0;
            }

            //更新数据库
            return(JingJiChangDBController.getInstance().updateNextChallengeTime(roleId, 0));
        }
Exemple #8
0
        public bool updateNextRewardTime(int roleId, long nextRewardTime)
        {
            PlayerJingJiData data = null;

            lock (this.changeRankingLock)
            {
                this.playerJingJiDatas.TryGetValue(roleId, out data);
            }
            bool result;

            if (null != data)
            {
                data.nextRewardTime = nextRewardTime;
                result = JingJiChangDBController.getInstance().updateNextRewardTime(roleId, nextRewardTime);
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemple #9
0
        private void initData()
        {
            List <PlayerJingJiData> playerJingJiDataList = JingJiChangDBController.getInstance().getPlayerJingJiDataList();

            if (null != playerJingJiDataList)
            {
                foreach (PlayerJingJiData data in playerJingJiDataList)
                {
                    data.convertObject();
                    this.playerJingJiDatas.Add(data.roleId, data);
                    this.rankingDatas.Add(data.getPlayerJingJiRankingData());
                }
                for (int rankLoop = 0; rankLoop < this.rankingDatas.Count; rankLoop++)
                {
                    if (this.rankingDatas[rankLoop].ranking != rankLoop + 1)
                    {
                        this.rankingDatas[rankLoop].ranking = rankLoop + 1;
                        JingJiChangDBController.getInstance().updateJingJiRanking(this.rankingDatas[rankLoop].roleId, this.rankingDatas[rankLoop].ranking);
                    }
                }
            }
        }
Exemple #10
0
 public void OnChangeName(int roleId, string oldName, string newName)
 {
     if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName))
     {
         try
         {
             lock (this.changeRankingLock)
             {
                 PlayerJingJiData data = null;
                 if (!this.playerJingJiDatas.TryGetValue(roleId, out data) || data == null)
                 {
                     return;
                 }
                 data.roleName = newName;
                 data.name     = newName;
             }
         }
         catch (Exception)
         {
         }
         JingJiChangDBController.getInstance().OnChangeName(roleId, oldName, newName);
     }
 }
Exemple #11
0
        public void saveData(JingJiSaveData data, out int winCount)
        {
            winCount = 0;
            PlayerJingJiData playerData = null;
            PlayerJingJiData robotData  = null;

            lock (this.changeRankingLock)
            {
                this.playerJingJiDatas.TryGetValue(data.roleId, out playerData);
                this.playerJingJiDatas.TryGetValue(data.robotId, out robotData);
                if (data.isWin)
                {
                    playerData.level             = data.level;
                    playerData.changeLiveCount   = data.changeLiveCount;
                    playerData.nextChallengeTime = data.nextChallengeTime;
                    playerData.baseProps         = data.baseProps;
                    playerData.extProps          = data.extProps;
                    playerData.equipDatas        = data.equipDatas;
                    playerData.skillDatas        = data.skillDatas;
                    playerData.combatForce       = data.combatForce;
                    playerData.wingData          = data.wingData;
                    playerData.settingFlags      = data.settingFlags;
                    playerData.occupationId      = data.Occupation;
                    playerData.SubOccupation     = data.SubOccupation;
                    playerData.winCount++;
                    playerData.shenShiEquipData = data.ShenShiEuipSkill;
                    if (playerData.winCount > playerData.MaxWinCnt)
                    {
                        playerData.MaxWinCnt = playerData.winCount;
                        JingJiChangDBController.getInstance().updateJingJiMaxWinCount(playerData.roleId, playerData.MaxWinCnt);
                    }
                    playerData.PassiveEffectList = data.PassiveEffectList;
                    playerData.convertString();
                    JingJiChangDBController.getInstance().updateJingJiDataForWin(playerData);
                    JingJiChallengeInfoData playerZhanBaoData;
                    JingJiChallengeInfoData robotZhanBaoData;
                    this.createChallengeWinChallengeInfoData(playerData, robotData, out playerZhanBaoData, out robotZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(playerZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(robotZhanBaoData);
                    JingJiChallengeInfoData lianShengZhanBaoData = null;
                    if (playerData.winCount >= 10 && playerData.winCount % 10 == 0)
                    {
                        winCount = playerData.winCount;
                        this.createLianShengChallengeInfo(playerData, out lianShengZhanBaoData);
                        JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(lianShengZhanBaoData);
                    }
                    List <JingJiChallengeInfoData> playerZhanbaoList = null;
                    this.challengeInfos.TryGetValue(playerData.roleId, out playerZhanbaoList);
                    if (null != lianShengZhanBaoData)
                    {
                        playerZhanbaoList.Insert(0, lianShengZhanBaoData);
                        if (playerZhanbaoList.Count > JingJiChangConstants.ChallengeInfo_Max_Num)
                        {
                            playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                        }
                    }
                    playerZhanbaoList.Insert(0, playerZhanBaoData);
                    if (playerZhanbaoList.Count > JingJiChangConstants.ChallengeInfo_Max_Num)
                    {
                        playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                    }
                    if (robotData.isOnline)
                    {
                        List <JingJiChallengeInfoData> robotZhanbaoList = null;
                        this.challengeInfos.TryGetValue(robotData.roleId, out robotZhanbaoList);
                        robotZhanbaoList.Insert(0, robotZhanBaoData);
                        if (robotZhanbaoList.Count > JingJiChangConstants.ChallengeInfo_Max_Num)
                        {
                            robotZhanbaoList.RemoveAt(robotZhanbaoList.Count - 1);
                        }
                    }
                    if (robotData.winCount > 0)
                    {
                        robotData.winCount = 0;
                        JingJiChangDBController.getInstance().updateJingJiWinCount(robotData.roleId, robotData.winCount);
                    }
                }
                else
                {
                    if (playerData.winCount >= 10)
                    {
                        winCount = playerData.winCount;
                    }
                    playerData.winCount          = 0;
                    playerData.nextChallengeTime = data.nextChallengeTime;
                    JingJiChangDBController.getInstance().updateJingJiDataForFailed(playerData.roleId, playerData.nextChallengeTime);
                    robotData.winCount++;
                    if (robotData.winCount > robotData.MaxWinCnt)
                    {
                        robotData.MaxWinCnt = robotData.winCount;
                        JingJiChangDBController.getInstance().updateJingJiMaxWinCount(robotData.roleId, robotData.MaxWinCnt);
                    }
                    JingJiChangDBController.getInstance().updateJingJiWinCount(robotData.roleId, robotData.winCount);
                    JingJiChallengeInfoData playerZhanBaoData;
                    JingJiChallengeInfoData robotZhanBaoData;
                    this.createChallengeFailedChallengeInfoData(playerData, robotData, out playerZhanBaoData, out robotZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(playerZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(robotZhanBaoData);
                    List <JingJiChallengeInfoData> playerZhanbaoList = null;
                    this.challengeInfos.TryGetValue(playerData.roleId, out playerZhanbaoList);
                    playerZhanbaoList.Insert(0, playerZhanBaoData);
                    if (playerZhanbaoList.Count > JingJiChangConstants.ChallengeInfo_Max_Num)
                    {
                        playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                    }
                    if (robotData.isOnline)
                    {
                        List <JingJiChallengeInfoData> robotZhanbaoList = null;
                        this.challengeInfos.TryGetValue(robotData.roleId, out robotZhanbaoList);
                        robotZhanbaoList.Insert(0, robotZhanBaoData);
                        if (robotZhanbaoList.Count > JingJiChangConstants.ChallengeInfo_Max_Num)
                        {
                            robotZhanbaoList.RemoveAt(robotZhanbaoList.Count - 1);
                        }
                    }
                }
                BeChallengerCount beChallengerCount = null;
                int nBeChallengerCount = 0;
                this.lockPlayerJingJiDatas.TryGetValue(robotData.roleId, out beChallengerCount);
                if (null != beChallengerCount)
                {
                    nBeChallengerCount = beChallengerCount.nBeChallengerCount;
                    if (nBeChallengerCount <= 0)
                    {
                        this.lockPlayerJingJiDatas.Remove(robotData.roleId);
                    }
                }
                if (robotData.ranking == -1 && nBeChallengerCount <= 0 && !robotData.isOnline)
                {
                    this.playerJingJiDatas.Remove(robotData.roleId);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// GS处理完成后保存数据
        /// </summary>
        public void saveData(JingJiSaveData data, out int winCount)
        {
            winCount = 0;

            PlayerJingJiData playerData = null;
            PlayerJingJiData robotData  = null;

            lock (changeRankingLock)
            {
                playerJingJiDatas.TryGetValue(data.roleId, out playerData);
                playerJingJiDatas.TryGetValue(data.robotId, out robotData);

                if (data.isWin)
                {
                    //更新挑战者竞技场数据 begin

                    playerData.level             = data.level;
                    playerData.changeLiveCount   = data.changeLiveCount;
                    playerData.nextChallengeTime = data.nextChallengeTime;
                    playerData.baseProps         = data.baseProps;
                    playerData.extProps          = data.extProps;
                    playerData.equipDatas        = data.equipDatas;
                    playerData.skillDatas        = data.skillDatas;
                    playerData.combatForce       = data.combatForce;
                    playerData.winCount         += 1;

                    playerData.convertString();

                    JingJiChangDBController.getInstance().updateJingJiDataForWin(playerData);

                    //                 //更新被挑战者竞技场数据
                    //                 JingJiChangDBController.getInstance().updateJingJiRanking(robotData.roleId, robotData.ranking);

                    //创建竞技场战报
                    JingJiChallengeInfoData playerZhanBaoData;
                    JingJiChallengeInfoData robotZhanBaoData;

                    this.createChallengeWinChallengeInfoData(playerData, robotData, out playerZhanBaoData, out robotZhanBaoData);

                    //插入数据库
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(playerZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(robotZhanBaoData);

                    JingJiChallengeInfoData lianShengZhanBaoData = null;
                    //创建连胜战报
                    if (playerData.winCount >= 10 && playerData.winCount % 10 == 0)
                    {
                        winCount = playerData.winCount;

                        this.createLianShengChallengeInfo(playerData, out lianShengZhanBaoData);

                        JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(lianShengZhanBaoData);
                    }

                    //更新内存数据
                    List <JingJiChallengeInfoData> playerZhanbaoList = null;
                    challengeInfos.TryGetValue(playerData.roleId, out playerZhanbaoList);

                    if (null != lianShengZhanBaoData)
                    {
                        playerZhanbaoList.Insert(0, lianShengZhanBaoData);
                        //只缓存50条
                        if (playerZhanbaoList.Count > ChallengeInfo_Max_Num)
                        {
                            playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                        }
                    }

                    playerZhanbaoList.Insert(0, playerZhanBaoData);

                    //只缓存50条
                    if (playerZhanbaoList.Count > ChallengeInfo_Max_Num)
                    {
                        playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                    }

                    if (robotData.isOnline)
                    {
                        List <JingJiChallengeInfoData> robotZhanbaoList = null;
                        challengeInfos.TryGetValue(robotData.roleId, out robotZhanbaoList);

                        robotZhanbaoList.Insert(0, robotZhanBaoData);

                        //只缓存50条
                        if (robotZhanbaoList.Count > ChallengeInfo_Max_Num)
                        {
                            robotZhanbaoList.RemoveAt(robotZhanbaoList.Count - 1);
                        }
                    }
                }
                else
                {
                    //连胜清零,重置上次挑战时间,更新声望值

                    if (playerData.winCount >= 10)
                    {
                        winCount = playerData.winCount;
                    }

                    playerData.winCount          = 0;
                    playerData.nextChallengeTime = data.nextChallengeTime;

                    JingJiChangDBController.getInstance().updateJingJiDataForFailed(playerData.roleId, playerData.nextChallengeTime);

                    //创建竞技场战报
                    JingJiChallengeInfoData playerZhanBaoData;
                    JingJiChallengeInfoData robotZhanBaoData;

                    this.createChallengeFailedChallengeInfoData(playerData, robotData, out playerZhanBaoData, out robotZhanBaoData);

                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(playerZhanBaoData);
                    JingJiChangZhaoBaoDBController.getInstnace().insertZhanBao(robotZhanBaoData);

                    //更新内存数据
                    List <JingJiChallengeInfoData> playerZhanbaoList = null;
                    challengeInfos.TryGetValue(playerData.roleId, out playerZhanbaoList);

                    playerZhanbaoList.Insert(0, playerZhanBaoData);

                    //只缓存50条
                    if (playerZhanbaoList.Count > ChallengeInfo_Max_Num)
                    {
                        playerZhanbaoList.RemoveAt(playerZhanbaoList.Count - 1);
                    }

                    if (robotData.isOnline)
                    {
                        List <JingJiChallengeInfoData> robotZhanbaoList = null;
                        challengeInfos.TryGetValue(robotData.roleId, out robotZhanbaoList);

                        robotZhanbaoList.Insert(0, robotZhanBaoData);

                        //只缓存50条
                        if (robotZhanbaoList.Count > ChallengeInfo_Max_Num)
                        {
                            robotZhanbaoList.RemoveAt(robotZhanbaoList.Count - 1);
                        }
                    }
                }

                //解除被挑战者锁定状态
                //lock (lockPlayerJingJiDatas)
                //{
                //    lockPlayerJingJiDatas.Remove(robotData.roleId);
                //}

                BeChallengerCount beChallengerCount = null;
                int nBeChallengerCount = 0;
                lockPlayerJingJiDatas.TryGetValue(robotData.roleId, out beChallengerCount);
                if (null != beChallengerCount)
                {
                    nBeChallengerCount = beChallengerCount.nBeChallengerCount;
                    if (nBeChallengerCount <= 0)
                    {
                        lockPlayerJingJiDatas.Remove(robotData.roleId);
                    }
                }

                //已经不再500名以内了、不在线、没人挑战,就没有必要缓存了
                if (robotData.ranking == -1 && nBeChallengerCount <= 0 && !robotData.isOnline)
                {
                    // lock (playerJingJiDatas)
                    {
                        playerJingJiDatas.Remove(robotData.roleId);
                    }
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// 挑战结束处理
        /// </summary>
        public int onChallengeEnd(JingJiChallengeResultData result)
        {
            PlayerJingJiData challenger   = null;
            PlayerJingJiData beChallenger = null;

            //获取数据
            lock (changeRankingLock)
            {
                playerJingJiDatas.TryGetValue(result.playerId, out challenger);
                playerJingJiDatas.TryGetValue(result.robotId, out beChallenger);

                BeChallengerCount beChallengerCount = null;
                lockPlayerJingJiDatas.TryGetValue(result.robotId, out beChallengerCount);
                if (null != beChallengerCount)
                {
                    beChallengerCount.nBeChallengerCount -= 1;
                }

                //胜利
                if (result.isWin)
                {
                    // lock (rankingDatas)
                    {
                        //记录挑战前排行
                        int playerRanking = challenger.ranking;
                        int robotRanking  = beChallenger.ranking;

                        // 被挑战者500名以后或排名相等,直接返回
                        if (robotRanking < 1 || playerRanking == robotRanking)
                        {
                            return(challenger.ranking);
                        }
                        //挑战者500名以后
                        else if (playerRanking == -1)
                        {
                            //排行互换
                            challenger.ranking   = robotRanking;
                            beChallenger.ranking = playerRanking;

                            //被挑战者排名500名以后,被踢出排行榜
                            rankingDatas.Remove(beChallenger.getPlayerJingJiRankingData());

                            //将挑战者加入排行榜
                            rankingDatas.Add(challenger.getPlayerJingJiRankingData());

                            rankingDatas.Sort();

                            JingJiChangDBController.getInstance().updateJingJiRanking(challenger.roleId, challenger.ranking);
                            JingJiChangDBController.getInstance().updateJingJiRanking(beChallenger.roleId, beChallenger.ranking);
                        }
                        //双方都在榜上
                        else if (playerRanking > robotRanking)
                        {
                            //排行互换
                            challenger.ranking   = robotRanking;
                            beChallenger.ranking = playerRanking;

                            beChallenger.getPlayerJingJiRankingData();
                            challenger.getPlayerJingJiRankingData();

                            rankingDatas.Sort();

                            JingJiChangDBController.getInstance().updateJingJiRanking(challenger.roleId, challenger.ranking);
                            JingJiChangDBController.getInstance().updateJingJiRanking(beChallenger.roleId, beChallenger.ranking);
                        }
                    }
                }

                return(challenger.ranking);
            }
        }