Пример #1
0
        NbManagerbuffpoolEntity CreateManagerPool(ConfigBuffpoolEntity src, string srcId = "")
        {
            var obj = new NbManagerbuffpoolEntity()
            {
                ManagerId    = Guid.Empty,
                SkillCode    = src.SkillCode,
                SkillLevel   = src.SkillLevel,
                BuffSrcType  = src.BuffSrcType,
                BuffSrcId    = srcId,
                BuffUnitType = src.BuffUnitType,
                LiveFlag     = src.LiveFlag,
                BuffNo       = src.BuffNo,
                DstDir       = src.DstDir,
                DstMode      = src.DstMode,
                DstKey       = src.DstKey,
                BuffMap      = src.BuffMap,
                BuffVal      = src.BuffVal,
                BuffPer      = src.BuffPer,
            };

            if (src.ExpiryMinutes <= 0)
            {
                obj.ExpiryTime = DATEInfi;
            }
            else
            {
                obj.ExpiryTime = DateTime.Now.AddMinutes(src.ExpiryMinutes);
            }
            return(obj);
        }
        /// <summary>
        /// 将IDataReader的当前记录读取到NbManagerbuffpoolEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public NbManagerbuffpoolEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new NbManagerbuffpoolEntity();

            obj.Id           = (System.Int64)reader["Id"];
            obj.ManagerId    = (System.Guid)reader["ManagerId"];
            obj.SkillCode    = (System.String)reader["SkillCode"];
            obj.SkillLevel   = (System.Int32)reader["SkillLevel"];
            obj.BuffSrcType  = (System.Int32)reader["BuffSrcType"];
            obj.BuffSrcId    = (System.String)reader["BuffSrcId"];
            obj.BuffUnitType = (System.Int32)reader["BuffUnitType"];
            obj.LiveFlag     = (System.Int32)reader["LiveFlag"];
            obj.BuffNo       = (System.Int32)reader["BuffNo"];
            obj.DstDir       = (System.Int32)reader["DstDir"];
            obj.DstMode      = (System.Int32)reader["DstMode"];
            obj.DstKey       = (System.String)reader["DstKey"];
            obj.BuffMap      = (System.String)reader["BuffMap"];
            obj.BuffVal      = (System.Decimal)reader["BuffVal"];
            obj.BuffPer      = (System.Decimal)reader["BuffPer"];
            obj.ExpiryTime   = (System.DateTime)reader["ExpiryTime"];
            obj.LimitTimes   = (System.Int32)reader["LimitTimes"];
            obj.RemainTimes  = (System.Int32)reader["RemainTimes"];
            obj.RowTime      = (System.DateTime)reader["RowTime"];
            obj.RowVersion   = (System.Byte[])reader["RowVersion"];

            return(obj);
        }
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/2/23 17:06:02</remarks>
        public bool Update(NbManagerbuffpoolEntity entity, DbTransaction trans = null)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_NbManagerbuffpool_Update");

            database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id);
            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId);
            database.AddInParameter(commandWrapper, "@SkillCode", DbType.AnsiString, entity.SkillCode);
            database.AddInParameter(commandWrapper, "@SkillLevel", DbType.Int32, entity.SkillLevel);
            database.AddInParameter(commandWrapper, "@BuffSrcType", DbType.Int32, entity.BuffSrcType);
            database.AddInParameter(commandWrapper, "@BuffSrcId", DbType.AnsiString, entity.BuffSrcId);
            database.AddInParameter(commandWrapper, "@BuffUnitType", DbType.Int32, entity.BuffUnitType);
            database.AddInParameter(commandWrapper, "@LiveFlag", DbType.Int32, entity.LiveFlag);
            database.AddInParameter(commandWrapper, "@BuffNo", DbType.Int32, entity.BuffNo);
            database.AddInParameter(commandWrapper, "@DstDir", DbType.Int32, entity.DstDir);
            database.AddInParameter(commandWrapper, "@DstMode", DbType.Int32, entity.DstMode);
            database.AddInParameter(commandWrapper, "@DstKey", DbType.AnsiString, entity.DstKey);
            database.AddInParameter(commandWrapper, "@BuffMap", DbType.AnsiString, entity.BuffMap);
            database.AddInParameter(commandWrapper, "@BuffVal", DbType.Currency, entity.BuffVal);
            database.AddInParameter(commandWrapper, "@BuffPer", DbType.Currency, entity.BuffPer);
            database.AddInParameter(commandWrapper, "@ExpiryTime", DbType.DateTime, entity.ExpiryTime);
            database.AddInParameter(commandWrapper, "@LimitTimes", DbType.Int32, entity.LimitTimes);
            database.AddInParameter(commandWrapper, "@RemainTimes", DbType.Int32, entity.RemainTimes);
            database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime);
            database.AddInParameter(commandWrapper, "@RowVersion", DbType.Binary, entity.RowVersion);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            entity.Id = (System.Int64)database.GetParameterValue(commandWrapper, "@Id");

            return(Convert.ToBoolean(results));
        }
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>NbManagerbuffpoolEntity</returns>
        /// <remarks>2016/2/23 17:06:02</remarks>
        public NbManagerbuffpoolEntity GetById(System.Int64 id)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_NbManagerbuffpool_GetById");

            database.AddInParameter(commandWrapper, "@Id", DbType.Int64, id);


            NbManagerbuffpoolEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Пример #5
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);
        }
Пример #6
0
        public static bool Insert(NbManagerbuffpoolEntity nbManagerbuffpoolEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new NbManagerbuffpoolProvider(zoneId);

            return(provider.Insert(nbManagerbuffpoolEntity, trans));
        }