Пример #1
0
 /// <summary>
 /// 保存金币增加记录
 /// </summary>
 /// <param name="managerId"></param>
 /// <param name="coin"></param>
 /// <param name="chargeSourceType"></param>
 /// <param name="orderId">用于关联源记录参考</param>
 /// <returns></returns>
 public static bool SaveCoinCharge(Guid managerId, int coin, int exp, bool isLevelup, int level, int chargeSourceType, string orderId)
 {
     if (!CacheFactory.AppsettingCache.ShadowCoin)
     {
         return(true);
     }
     try
     {
         //统计金币
         StatisticKpiMgr.UpdateSame(ShareUtil.ZoneId, DateTime.Now.Date, 0, 0, 0, coin);
         var provider = new ShadowProvider();
         return(provider.SaveCoinCharge(managerId, coin, exp, isLevelup, level, chargeSourceType, orderId));
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("SaveCoinCharge", ex);
         return(false);
     }
 }
Пример #2
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);
        }