Esempio n. 1
0
 /// <summary>
 /// 移除Buff,自动提交事务
 /// </summary>
 /// <param name="managerId">经理Id</param>
 /// <param name="srcType">来源类型</param>
 /// <param name="skillCode">技能Code</param>
 /// <param name="srcId">来源Id</param>
 /// <param name="tranMgr">事务对象</param>
 /// <returns></returns>
 public bool RemovePools(Guid managerId, EnumSkillSrcType srcType, string skillCode = "", string srcId = "", TransactionManager tranMgr = null)
 {
     try
     {
         int managerHash = ShareUtil.GetTableMod(managerId);
         if (null == tranMgr)
         {
             tranMgr = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault());
         }
         using (tranMgr)
         {
             if (!tranMgr.IsOpen)
             {
                 tranMgr.BeginTransaction();
             }
             NbManagerbuffpoolMgr.Exclude(managerId, managerHash, (int)srcType, srcId, skillCode, tranMgr.TransactionObject);
             tranMgr.Commit();
         }
         s_buffSync.SyncBuffPools(managerId);
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.Insert(ex, "BuffPoolCore:AddBuffPools");
         throw ex;
     }
 }
Esempio n. 2
0
        internal DTOBuffPoolView ReqRawPools(Guid managerId, string siteId = "", bool syncFlag = true)
        {
            int managerHash = ShareUtil.GetTableMod(managerId);

            byte[] verDb     = null;
            var    data      = CreateBuffView();
            var    pools     = NbManagerbuffpoolMgr.GetByMid(managerId, managerHash, siteId);
            var    teamPools = CheckTeamBuffPools(managerId, siteId);

            if (null != teamPools)
            {
                pools.AddRange(teamPools);
            }
            NbManagerbuffpoolMgr.GetVersionByMid(managerId, managerHash, ref verDb, null, siteId);
            ulong verNo = 0;

            if (null != verDb)
            {
                verNo = BitConverter.ToUInt64(verDb, 0);
            }
            DateTime      dtNow      = DateTime.Now;
            DateTime      dtSync     = DATEInfi;
            List <string> liveSkills = null;

            foreach (var item in pools)
            {
                if (dtNow < item.ExpiryTime && item.ExpiryTime < dtSync)
                {
                    dtSync = item.ExpiryTime;
                }
                if (item.LiveFlag != 2)
                {
                    continue;
                }
                if (null == liveSkills)
                {
                    liveSkills = new List <string>();
                }
                liveSkills.Add(BuffCache.Instance().CastSkillKey(item.SkillCode, item.SkillLevel));
            }
            data.BuffPools   = pools;
            data.LiveSkills  = liveSkills;
            data.SyncTime    = dtSync;
            data.SyncVersion = verNo;
            if (syncFlag)
            {
                s_memBuffPool.Set(managerId.ToString(), data);
            }
            return(data);
        }
Esempio n. 3
0
 /// <summary>
 /// 添加技能Buff,自动提交事务
 /// </summary>
 /// <param name="managerId">经理Id</param>
 /// <param name="srcId">来源Id</param>
 /// <param name="skillCode">技能Code</param>
 /// <param name="skillLevel">技能等级</param>
 /// <param name="tranMgr">事务对象</param>
 /// <returns></returns>
 public bool PostAddPools(Guid managerId, string srcId, string skillCode, int skillLevel = 0, TransactionManager tranMgr = null)
 {
     try
     {
         int  managerHash = ShareUtil.GetTableMod(managerId);
         var  incPools    = BuffCache.Instance().GetPoolIncBuffList(skillCode, skillLevel);
         var  flows       = BuffCache.Instance().GetFirmBuffList(skillCode, skillLevel);
         bool syncFlow    = (null != flows && flows.Count > 0);
         if (null == incPools || incPools.Count == 0)
         {
             if (null != tranMgr && tranMgr.IsOpen)
             {
                 tranMgr.Commit();
             }
             if (syncFlow)
             {
                 s_buffSync.SetBuffMembers(managerId);
             }
             return(true);
         }
         string[] excSkills;
         int[]    excBuffs;
         GetExcSkillBuffs(out excSkills, out excBuffs, skillCode, skillLevel);
         if (null == tranMgr)
         {
             tranMgr = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault());
         }
         using (tranMgr)
         {
             if (!tranMgr.IsOpen)
             {
                 tranMgr.BeginTransaction();
             }
             if (excSkills[0] != string.Empty)
             {
                 NbManagerbuffpoolMgr.ExcludeMulti(managerId, managerHash,
                                                   excSkills[0], excBuffs[0], excSkills[1], excBuffs[1], excSkills[2], excBuffs[2], excSkills[3], excBuffs[3], excSkills[4], excBuffs[4],
                                                   tranMgr.TransactionObject);
             }
             foreach (var cfg in incPools)
             {
                 NbManagerbuffpoolMgr.Include(managerId, managerHash, cfg.SkillCode, cfg.SkillLevel, cfg.BuffSrcType, srcId,
                                              (int)cfg.AsBuffUnitType, cfg.LiveFlag, cfg.BuffNo,
                                              cfg.DstDir, cfg.DstMode, cfg.DstKey, cfg.BuffMap, cfg.BuffVal, cfg.BuffPer,
                                              cfg.ExpiryMinutes, cfg.LimitTimes, cfg.TotalTimes, cfg.RepeatBuffFlag, cfg.RepeatTimeFlag, cfg.RepeatTimesFlag,
                                              tranMgr.TransactionObject);
             }
             tranMgr.Commit();
         }
         s_buffSync.SyncBuffPools(managerId);
         if (syncFlow)
         {
             s_buffSync.SetBuffMembers(managerId);
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.Insert(ex, "BuffPoolCore:PostAddPools");
         throw ex;
     }
 }
Esempio n. 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);
        }