Exemple #1
0
        void SavePrize(CrosscrowdMatchEntity crowdMatch)
        {
            try
            {
                crowdMatch.HomePrizeScore = CacheFactory.CrowdCache.GetCrowdScore(crowdMatch.HomeScore);
                var costMorale  = CacheFactory.CrowdCache.GetCostMorela(crowdMatch.AwayScore);
                var winType     = ShareUtil.CalWinType(crowdMatch.HomeScore, crowdMatch.AwayScore);
                var matchPrize  = CacheFactory.CrowdCache.GetMatchPrize(winType);
                var homeManager = _managerDic[crowdMatch.HomeId];
                homeManager.Morale -= costMorale;
                if (homeManager.Morale < 0)
                {
                    homeManager.Morale = 0;
                }

                int homecoin  = matchPrize.Coin;
                int homehonor = matchPrize.Honor;
                OnlineCore.Instance.CalIndulgePrize(crowdMatch.HomeId, ref homecoin, ref homehonor, crowdMatch.HomeSiteId);
                crowdMatch.HomeMorale     = homeManager.Morale;
                crowdMatch.HomePrizeCoin  = homecoin;
                crowdMatch.HomePrizeHonor = homehonor;
                crowdMatch.HomeCostMorale = costMorale;

                crowdMatch.AwayPrizeScore = CacheFactory.CrowdCache.GetCrowdScore(crowdMatch.AwayScore);
                costMorale = CacheFactory.CrowdCache.GetCostMorela(crowdMatch.HomeScore);
                winType    = ShareUtil.CalWinType(crowdMatch.AwayScore, crowdMatch.HomeScore);
                matchPrize = CacheFactory.CrowdCache.GetMatchPrize(winType);
                var awayManager = _managerDic[crowdMatch.AwayId];
                awayManager.Morale -= costMorale;
                if (awayManager.Morale < 0)
                {
                    awayManager.Morale = 0;
                }
                int awaycoin  = matchPrize.Coin;
                int awayhonor = matchPrize.Honor;
                OnlineCore.Instance.CalIndulgePrize(crowdMatch.AwayId, ref awaycoin, ref awayhonor, crowdMatch.AwaySiteId);
                crowdMatch.AwayMorale     = awayManager.Morale;
                crowdMatch.AwayPrizeCoin  = awaycoin;
                crowdMatch.AwayPrizeHonor = awayhonor;
                crowdMatch.AwayCostMorale = costMorale;

                DateTime resurrectionTime = DateTime.Now.AddSeconds(_crowdResurrectionCd);
                DateTime nextMatchTime    = DateTime.Now.AddSeconds(_crowdCd);
                CrosscrowdMatchMgr.Save(crowdMatch, resurrectionTime, nextMatchTime);

                SavePrizeAfter(crowdMatch, homeManager, awayManager);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("CrossCrowdProcess-SavePrize", ex);
            }
        }
Exemple #2
0
        public LadderMatchEntityListResponse GetMatchList(Guid managerId)
        {
            var response = ResponseHelper.CreateSuccess <LadderMatchEntityListResponse>();

            response.Data = new LadderMatchEntityList();
            var list = LadderMatchMgr.GetFiveMatch(managerId);

            if (list != null)
            {
                response.Data.Matchs = new List <LadderMatchEntityView>(list.Count);
                foreach (var match in list)
                {
                    string      awayName = "";
                    EnumWinType winType;    //0:负; 1:胜;2:平
                    int         prizeScore;
                    string      score = ""; //比分 2:3
                    if (managerId == match.HomeId && match.HomeIsBot == false)
                    {
                        awayName   = match.AwayName;
                        prizeScore = match.PrizeHomeScore;
                        score      = string.Format("{0}:{1}", match.HomeScore, match.AwayScore);
                        winType    = ShareUtil.CalWinType(match.HomeScore, match.AwayScore);
                    }
                    else
                    {
                        if (match.AwayIsBot)
                        {
                            continue;
                        }
                        awayName   = match.HomeName;
                        prizeScore = match.PrizeAwayScore;
                        score      = string.Format("{0}:{1}", match.AwayScore, match.HomeScore);
                        winType    = ShareUtil.CalWinType(match.AwayScore, match.HomeScore);
                    }
                    response.Data.Matchs.Add(BuildMatchView(match.Idx, awayName, prizeScore, score, winType));
                }
            }
            return(response);
        }
Exemple #3
0
        public PlayerkillMatchResponse GetMatchResult(Guid managerId, Guid matchId)
        {
            var match = PlayerkillMatchMgr.GetById(matchId);

            if (match == null)
            {
                return(ResponseHelper.InvalidParameter <PlayerkillMatchResponse>("match is null"));
            }
            if (match.HomeId != managerId)
            {
                return(ResponseHelper.InvalidParameter <PlayerkillMatchResponse>("HomeId!=managerId"));
            }
            if (match.Status == 0)
            {
                match.PrizeItemCode = 0;
            }
            var response = ResponseHelper.CreateSuccess <PlayerkillMatchResponse>();

            response.Data = match;
            var popMsg = MemcachedFactory.MatchPopClient.Get <List <PopMessageEntity> >(matchId);

            if (popMsg != null)
            {
                MemcachedFactory.MatchPopClient.Delete(matchId);
                response.Data.PopMsg = popMsg;
            }
            //是否有vip效果
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager != null)
            {
                var winType = ShareUtil.CalWinType(match.HomeScore, match.AwayScore);
                var prize   = CacheFactory.PlayerKillCache.GetPrize(winType);
                var vipRate = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.PkOrLeagueExpPlus);
                response.Data.VipExp = prize.Exp * vipRate / 100;
            }
            return(response);
        }
Exemple #4
0
        public MessageCode MatchCallback(BaseMatchData matchData, long revengeRecordId, PlayerKillOpponentEntity awayOpp, PlayerkillInfoEntity info)
        {
            var pkmatchData = matchData;

            if (pkmatchData == null || pkmatchData.ErrorCode != (int)MessageCode.Success)
            {
                return(MessageCode.MatchCreateFail);
            }
            bool isrevenge      = false;
            Guid lotteryMatchId = Guid.Empty;

            var winType = ShareUtil.CalWinType(pkmatchData.Home.Score, pkmatchData.Away.Score);

            int win       = 0;
            int lose      = 0;
            int draw      = 0;
            int prizeExp  = 0;
            int prizeCoin = 0;

            if (!isrevenge)
            {
                if (winType == EnumWinType.Win)
                {
                    win = 1;
                }
                if (winType == EnumWinType.Lose)
                {
                    lose = 1;
                }
                if (winType == EnumWinType.Draw)
                {
                    draw = 1;
                }
                var prize = CacheFactory.PlayerKillCache.GetPrize(winType);
                prizeCoin = prize.Coin;
                prizeExp  = prize.Exp;
            }
            int    prizeItemCode   = 0;
            string prizeItemString = "";
            var    manager         = ManagerCore.Instance.GetManager(pkmatchData.Home.ManagerId);
            var    managerex       = ManagerCore.Instance.GetManagerExtra(pkmatchData.Home.ManagerId);

            var subtype = 1;

            if (manager.Level % 10 == 0)
            {
                subtype = manager.Level / 10;
            }
            else
            {
                subtype = manager.Level / 10 + 1;
            }

            int matchTimes = 0;

            PlayerkillInfoMgr.GetMatchTimes(manager.Idx, ref matchTimes);

            //if (winType == EnumWinType.Win)
            //{
            var lotteryEntity = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.PlayerKill, subtype);
            int pointCount    = 0;

            if (lotteryEntity != null)
            {
                //第一场友谊赛固定获得5钻石
                if (matchTimes == 0)
                {
                    prizeItemCode  = 810001;
                    pointCount     = 5;
                    lotteryMatchId = pkmatchData.MatchId;
                }
                else
                {
                    if (winType == EnumWinType.Win)
                    {
                        prizeItemCode   = lotteryEntity.PrizeItemCode;
                        prizeItemString = lotteryEntity.ItemString;
                        if (prizeItemCode == 810001)
                        {
                            var pointConfig = CacheFactory.PlayerKillCache.GetPointConfig(manager.VipLevel);
                            if (pointConfig != null && (info.DayPoint + pointCount) < pointConfig.TotalPoint)
                            {
                                pointCount = pointConfig.PrizePoint;
                                int point = pointCount;
                                //欧洲杯狂欢
                                ActivityExThread.Instance.EuropeCarnival(5, ref point);
                                info.DayPoint = info.DayPoint + point;
                                info.DayPoint = info.DayPoint > pointConfig.TotalPoint ? pointConfig.TotalPoint : info.DayPoint;
                            }
                            else
                            {
                                prizeItemCode = 910001;
                                pointCount    = 5;
                            }
                        }
                        else if (prizeItemCode == 910001)
                        {
                            prizeItemCode = 910001;
                            pointCount    = 5;
                        }
                        var itemcode = ActivityExThread.Instance.SummerGiftBag(4);
                        if (itemcode > 0)
                        {
                            prizeItemCode = itemcode;
                        }
                        else
                        {
                            itemcode = ActivityExThread.Instance.MidAutumnActivity(4, info.SpecialItemNumber);
                            if (itemcode > 0)
                            {
                                info.SpecialItemNumber++;
                                prizeItemCode = itemcode;
                            }
                        }
                        lotteryMatchId = pkmatchData.MatchId;
                    }
                }
            }
            //}



            //LogHelper.Insert("友谊赛比赛结果处理请求:比赛id"+lotteryMatchId+",ManagerId:" + pkmatchData.Home.ManagerId.ToString() + " ,对手Id:" + pkmatchData.Away.ManagerId.ToString(), LogType.Info);

            double totalPlusRate = 0;
            //是否有vip效果
            var vipRate = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.PkOrLeagueExpPlus);

            totalPlusRate += vipRate / 100.00;
            //是否有增加经验的Buff
            var buffExp = BuffPoolCore.Instance().GetBuffValue(manager.Idx, EnumBuffCode.PkMatchExp, true, false);
            NbManagerbuffpoolEntity buffExpEntity = null;

            if (buffExp != null)
            {
                if (buffExp.SrcList != null && buffExp.SrcList.Count > 0)
                {
                    buffExpEntity = NbManagerbuffpoolMgr.GetById(buffExp.SrcList[0].Idx);
                    if (buffExpEntity != null && buffExpEntity.RemainTimes > 0)
                    {
                        totalPlusRate += buffExp.Percent;
                    }
                }
            }
            prizeExp = (int)(prizeExp * (1 + totalPlusRate));

            if (matchData.Home.Score > matchData.Away.Score)
            {
                awayOpp.HasWin    = true;
                info.OpponentInfo = SerializationHelper.ToByte(info.Opponents);
                //PlayerkillInfoMgr.Update(info);
            }

            //欧洲杯狂欢
            ActivityExThread.Instance.EuropeCarnival(1, ref prizeExp);

            LogHelper.Insert(string.Format("revengeId:{0},score1:{1},score2:{2},haswin:{3}", revengeRecordId, matchData.Home.Score, matchData.Away.Score, awayOpp.HasWin), LogType.Info);
            OnlineCore.Instance.CalIndulgePrize(manager, ref prizeExp, ref prizeCoin);
            ManagerUtil.AddManagerData(manager, prizeExp, prizeCoin, 0, EnumCoinChargeSourceType.PlayerKillPrize, pkmatchData.MatchId.ToString());
            long outRevengeRecordId = 0;
            //扣除行动力
            var code = ManagerCore.Instance.SubStamina(managerex, _pkStamina, manager.Level, manager.VipLevel);

            if (code != MessageCode.Success)
            {
                return(code);
            }

            code = SaveMatch(manager, managerex, pkmatchData, lotteryMatchId, win, lose, draw, prizeExp, prizeCoin,
                             prizeItemCode, prizeItemString, isrevenge, revengeRecordId, ref outRevengeRecordId, info, pointCount);
            //统计使用的行动力
            StatisticKpiMgr.UpdateSame(ShareUtil.ZoneId, DateTime.Now.Date, 0, _pkStamina, 0, 0);
            if (code == MessageCode.Success)
            {
                //更新祝福Buff剩余场次数
                if (buffExpEntity != null && buffExpEntity.RemainTimes > 0)
                {
                    buffExpEntity.RemainTimes--;
                    NbManagerbuffpoolMgr.Update(buffExpEntity);
                }
                //记录比赛数据
                MatchCore.SaveMatchStat(pkmatchData.Home.ManagerId, EnumMatchType.PlayerKill, pkmatchData.Home.Score, pkmatchData.Away.Score, pkmatchData.Home.Score);
                //记录成就相关数据
                AchievementTaskCore.Instance.UpdatePkMatchGoals(manager.Idx, pkmatchData.Home.Score);
                TaskHandler.Instance.PkOrFriendMatchCount(manager.Idx);
                var popList = ManagerUtil.SaveManagerAfter(manager, false);
                var taskPop = TaskHandler.Instance.PlayerKillFight(manager.Idx, (int)winType);
                if (matchData.HasTask)
                {
                    //var taskPop = TaskHandler.Instance.PlayerKillFight(manager.Idx, (int)winType);
                    if (taskPop != null && taskPop.Count > 0)
                    {
                        if (popList == null)
                        {
                            popList = taskPop;
                        }
                        else
                        {
                            popList.AddRange(taskPop);
                        }
                    }
                }



                MemcachedFactory.MatchPopClient.Set(matchData.MatchId, popList);
            }
            return(code);
        }