Ejemplo n.º 1
0
        public static List <PopMessageEntity> SaveManagerAfter(NbManagerEntity manager, NbManagerextraEntity extra, DbTransaction transaction)
        {
            if (manager == null)
            {
                return(null);
            }
            List <PopMessageEntity> popList = new List <PopMessageEntity>();

            if (manager.AddCoin > 0 || manager.AddExp > 0)
            {
                //ShadowMgr.SaveCoinCharge(manager.Idx, manager.AddCoin, manager.AddExp, manager.IsLevelup, manager.Level, manager.CoinSourceType, manager.CoinOrderId);
            }
            if (manager.IsLevelup)
            {
                // ChatHelper.SendOpenLevelGiftPop(manager);
                if (extra == null)
                {
                    extra = ManagerCore.Instance.GetManagerExtra(manager.Idx);
                }
                CalCurrentStamina(extra, manager.Level, manager.VipLevel);
                if (extra.Stamina < extra.StaminaMax)
                {
                    extra.Stamina = extra.StaminaMax;
                    // extra.Stamina += ManagerLevelupAddStamina;
                    //if (extra.Stamina > extra.StaminaMax)
                    //    extra.Stamina = extra.StaminaMax;
                    extra.ResumeStaminaTime = DateTime.Now;
                    NbManagerextraMgr.Update(extra, transaction);
                }
            }
            DeleteOpenFunctionCache(manager.Idx);
            manager.IsLevelup = false;
            return(popList);
        }
Ejemplo n.º 2
0
        MessageCode Tran_SaveMatch(DbTransaction transaction, NbManagerEntity manager, NbManagerextraEntity managerex, BaseMatchData pkmatchData,
                                   Guid lotteryMatchId, int win, int lose, int draw, int prizeExp, int prizeCoin, int prizeItemCode, string prizeItemString
                                   , bool isrevenge, long revengeRecordId, ref long outRevengeRecordId, PlayerkillInfoEntity info, int prizeItemCount)
        {
            if (prizeCoin > 0 || prizeExp > 0)
            {
                if (!ManagerUtil.SaveManagerData(manager, managerex, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
                else
                {
                    ManagerUtil.SaveManagerAfter(manager, managerex, transaction);
                }
                if (!NbManagerextraMgr.Update(managerex, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            PlayerkillInfoMgr.Update(info);
            PlayerkillInfoMgr.SaveFightResult(pkmatchData.Home.ManagerId, manager.Logo, pkmatchData.Away.ManagerId, lotteryMatchId,
                                              win, lose, draw, DateTime.Now,
                                              pkmatchData.MatchId, pkmatchData.Home.Name, pkmatchData.Away.Name,
                                              pkmatchData.Home.Score, pkmatchData.Away.Score, prizeExp, prizeCoin,
                                              prizeItemCode
                                              , prizeItemString, isrevenge, revengeRecordId, prizeItemCount, ref outRevengeRecordId, transaction);

            return(MessageCode.Success);
        }
Ejemplo n.º 3
0
 private MessageCode SaveMatchConfirm(NbManagerEntity manager, ItemPackageFrame package, LeagueRecordEntity leagueRecordInfo,
                                      LeagueManagerrecordEntity nextManagerRecord, LeagueManagerrecordEntity leagueManagerRecord, int point,
                                      bool isUpdatenextManagerRecord, LaegueManagerinfoEntity leagueManagerInfo, LeagueFightMapFrame fightMap, NbManagerextraEntity managerExtra, LeagueWincountrecordEntity leagueWinCount, DbTransaction trans)
 {
     if (!ManagerUtil.SaveManagerData(manager, managerExtra, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!NbManagerextraMgr.Update(managerExtra, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (package != null)
     {
         if (!package.Save(trans))
         {
             return(MessageCode.NbUpdateFail);
         }
         package.Shadow.Save();
     }
     if (!LeagueRecordMgr.Update(leagueRecordInfo, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (isUpdatenextManagerRecord)
     {
         if (nextManagerRecord != null)
         {
             if (!LeagueManagerrecordMgr.Update(nextManagerRecord, trans))
             {
                 return(MessageCode.NbUpdateFail);
             }
         }
     }
     if (!LaegueManagerinfoMgr.Update(leagueManagerInfo, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueManagerrecordMgr.Update(leagueManagerRecord, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (point > 0)
     {
         var code = PayCore.Instance.AddBonus(manager.Idx, point, EnumChargeSourceType.LeaguePrize,
                                              ShareUtil.GenerateComb().ToString(), trans);
         return(code);
     }
     if (!fightMap.SaveFIghtMap(trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueWincountrecordMgr.Update(leagueWinCount, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     return(MessageCode.Success);
 }
Ejemplo n.º 4
0
        public static List <PopMessageEntity> SaveManagerAfter(NbManagerEntity manager, bool sendByChat, NbManagerextraEntity extra = null, int currentPoint = -1, int tourLeagueId = -1)
        {
            if (manager == null)
            {
                return(null);
            }
            List <PopMessageEntity> popList = new List <PopMessageEntity>();

            if (manager.AddCoin > 0 || manager.AddExp > 0)
            {
                //ShadowMgr.SaveCoinCharge(manager.Idx, manager.AddCoin, manager.AddExp, manager.IsLevelup, manager.Level, manager.CoinSourceType, manager.CoinOrderId);
            }
            if (manager.IsLevelup)
            {
                // ChatHelper.SendOpenLevelGiftPop(manager);
                if (extra == null)
                {
                    extra = ManagerCore.Instance.GetManagerExtra(manager.Idx);
                }
                CalCurrentStamina(extra, manager.Level, manager.VipLevel);
                if (extra.Stamina < extra.StaminaMax)
                {
                    extra.Stamina = extra.StaminaMax;
                    //extra.Stamina += ManagerLevelupAddStamina;
                    //if (extra.Stamina > extra.StaminaMax)
                    //    extra.Stamina = extra.StaminaMax;
                    NbManagerextraMgr.Update(extra);
                }
            }

            //var pop1 = ChatHelper.SendUpdateManagerInfoPop(manager, extra, sendByChat, currentPoint, tourLeagueId);
            //if (pop1 != null)
            //    popList.Add(pop1);
            //var pop2 = ChatHelper.SendOpenFuncPop(manager, sendByChat);
            //if (pop2 != null)
            //    popList.Add(pop2);
            //var pop3 = ChatHelper.SendOpenTaskPop(manager, sendByChat);
            //if (pop3 != null)
            //    popList.Add(pop3);

            DeleteOpenFunctionCache(manager.Idx);
            manager.IsLevelup = false;
            return(popList);
        }
Ejemplo n.º 5
0
        public static bool SaveManagerData(NbManagerEntity manager, NbManagerextraEntity extra, bool openTask = true,
                                           DbTransaction transaction = null, string zoneId = "")
        {
            try
            {
                var functionList = manager.FunctionList;
                if (manager.IsLevelup)
                {
                    var function = CacheFactory.ManagerDataCache.GetFunctionList(manager.Level);
                    if (function != null)
                    {
                        if (function.FunctionId > 0)
                        {
                            manager.AddOpenFunc(function.FunctionId);
                        }
                        functionList = function.FunctionList;
                        if (extra != null)
                        {
                            extra.FunctionList = functionList;
                        }
                    }
                }
                int returnCode        = -2;
                var levelGiftExpired  = ShareUtil.BaseTime;
                var levelGiftExpired2 = ShareUtil.BaseTime;
                var levelGiftExpired3 = ShareUtil.BaseTime;
                int step = 0;
                if (manager.IsLevelup)
                {
                    step = CacheFactory.ManagerDataCache.GetLevelgiftStep(manager.Level);
                    if (step > 0)
                    {
                        manager.OpenLevelGift = true;
                        switch (step)
                        {
                        case 1:
                            levelGiftExpired = DateTime.Now.AddHours(72);
                            break;

                        case 2:
                            levelGiftExpired2 = DateTime.Now.AddHours(72);
                            break;

                        case 3:
                            levelGiftExpired3 = DateTime.Now.AddHours(72);
                            break;
                        }
                        if (extra != null)
                        {
                            extra.LevelGiftExpired  = levelGiftExpired;
                            extra.LevelGiftExpired2 = levelGiftExpired2;
                            extra.LevelGiftExpired3 = levelGiftExpired3;
                            extra.LevelGiftStep     = step;
                        }
                    }
                }
                NbManagerMgr.Save(manager.Idx, manager.Level, manager.EXP, manager.Sophisticate, manager.Score, manager.Coin,
                                  manager.Reiki, manager.TeammemberMax, manager.TrainSeatMax, manager.VipLevel,
                                  functionList, levelGiftExpired, levelGiftExpired2, levelGiftExpired3, step, manager.RowVersion, ref returnCode, transaction, zoneId);
                if (returnCode != 0)
                {
                    return(false);
                }
                manager.FunctionList = functionList;

                try
                {
                    if (manager.IsLevelup)
                    {
                        var code = SkillCardRules.SetSkillMapByManagerLevel(manager, transaction);
                        if (code != MessageCode.Success)
                        {
                            return(false);
                        }

                        var addSkillPoint = CacheFactory.ManagerDataCache.GetAddSkillPointByLevel(manager.Level);
                        if (extra != null)
                        {
                            extra.SkillPoint += addSkillPoint;
                        }
                        else
                        {
                            if (!NbManagerextraMgr.AddSkillPoint(manager.Idx, addSkillPoint, transaction))
                            {
                                return(false);
                            }
                        }

                        CalCurrentStamina(extra, manager.Level, manager.VipLevel);
                        if (extra == null)
                        {
                            extra = ManagerCore.Instance.GetManagerExtra(manager.Idx);
                            if (extra.Stamina < extra.StaminaMax)
                            {
                                extra.Stamina = extra.StaminaMax;
                                // extra.Stamina += ManagerLevelupAddStamina;
                                //if (extra.Stamina > extra.StaminaMax)
                                //    extra.Stamina = extra.StaminaMax;
                                extra.ResumeStaminaTime = DateTime.Now;
                                NbManagerextraMgr.Update(extra, transaction);
                            }
                        }
                        else
                        {
                            if (extra.Stamina < extra.StaminaMax)
                            {
                                extra.Stamina           = extra.StaminaMax;
                                extra.ResumeStaminaTime = DateTime.Now;
                            }
                        }

                        //if (TaskCore.Instance.CheckOpenDailyTask(manager.Level))
                        //{
                        //    var daily = TaskDailyrecordMgr.GetById(manager.Idx, zoneId);
                        //    if (daily == null)
                        //    {
                        //        var entity = TaskCore.Instance.CreateDailyTask(manager.Idx);
                        //        if (!TaskDailyrecordMgr.Insert(entity, transaction, zoneId))
                        //            return false;
                        //    }
                        //}
                        if (openTask)
                        {
                            List <TaskRecordEntity> newTasks = new List <TaskRecordEntity>();
                            TaskCore.Instance.GetLevelOpenTasks(manager.Idx, manager.Level, ref newTasks, zoneId);
                            if (newTasks.Count > 0)
                            {
                                foreach (var entity in newTasks)
                                {
                                    TaskCore.Instance.HandleOpenTaskStatus(entity, zoneId);
                                    if (!TaskRecordMgr.Add(entity, transaction, zoneId))
                                    {
                                        return(false);
                                    }
                                }
                                manager.HasOpenTask = true;
                            }
                        }
                        //如果等级为15级 向竞技场注册用户
                        //获取竞技场等级限制
                        //if (manager.Level == level.Values)
                        //{

                        //}
                    }
                }
                catch (Exception ex)
                {
                    SystemlogMgr.ErrorByZone("SaveManagerData Task pending", ex, zoneId);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                SystemlogMgr.ErrorByZone("SaveManagerData", ex, zoneId);
                return(false);
            }
            finally
            {
                ManagerCore.Instance.DeleteCache(manager.Idx);
            }
        }