예제 #1
0
        /// <summary>
        /// 更新卡牌收集数量
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public MessageCode UpdatePlayCardCount(ItemPackageFrame package, string zoneId = "")
        {
            if (package == null)
            {
                return(MessageCode.Success);
            }
            var taskRecord = TaskRecordMgr.GetManagerTaskList(package.ManagerId, zoneId);

            if (taskRecord == null || taskRecord.Count == 0)
            {
                return(MessageCode.Success);
            }
            foreach (var item in taskRecord)
            {
                var task = CacheFactory.TaskConfigCache.GetTask(item.TaskId);
                if (task == null)
                {
                    continue;
                }
                var require = CacheFactory.TaskConfigCache.GetTaskByRequire(item.TaskId);
                if (require == null)
                {
                    continue;
                }
                switch (require.RequireType)
                {
                case (int)EnumTaskRequireFunc.PlayerCardStrengthCollection:
                    if (require.RequireSub >= 0 && require.RequireSub <= 4)
                    {
                        if (require.RequireThird >= 2 && require.RequireThird <= 9)
                        {
                            var number2 = package.GetStrengthCardCount(require.RequireSub, require.RequireThird);
                            if (number2 > 0)
                            {
                                SavePackageTask(item, number2, task, zoneId);
                            }
                        }
                    }
                    break;

                case (int)EnumTaskRequireFunc.PlayCardCollection:
                    var number1 = package.GetPlayCountByCardLevel(require.RequireSub);
                    if (number1 > 0)
                    {
                        SavePackageTask(item, number1, task, zoneId);
                    }
                    break;

                case (int)EnumTaskRequireFunc.PlayerCardLevel:
                    int number = package.GetLevelCardCount(require.RequireSub);
                    if (number > 0)
                    {
                        SavePackageTask(item, number, task, zoneId);
                    }
                    break;
                }
            }
            return(MessageCode.Success);
        }
예제 #2
0
        /// <summary>
        /// 更新最高杯赛排名
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="rank"></param>
        /// <returns></returns>
        public MessageCode UpdateDailyCupRank(Guid managerId, int rank)
        {
            if (rank == 0)
            {
                return(MessageCode.Success);
            }
            var taskRecord = TaskRecordMgr.GetManagerTaskList(managerId);

            if (taskRecord == null || taskRecord.Count == 0)
            {
                return(MessageCode.Success);
            }
            foreach (var item in taskRecord)
            {
                var task = CacheFactory.TaskConfigCache.GetTask(item.TaskId);
                if (task == null)
                {
                    continue;
                }
                var require = CacheFactory.TaskConfigCache.GetTaskByRequire(item.TaskId);
                if (require == null)
                {
                    continue;
                }
                if (require.RequireType == (int)EnumTaskRequireFunc.DailyCupRank)
                {
                    if (rank <= require.RequireSub)
                    {
                        item.CurTimes   = rank;
                        item.UpdateTime = DateTime.Now;
                        item.Status     = 1;
                        TaskRecordMgr.Update(item);
                    }
                }
            }
            return(MessageCode.Success);
        }
예제 #3
0
        /// <summary>
        /// 更新成就背包
        /// </summary>
        /// <param name="managerId">经理ID</param>
        /// <param name="isOddDays">是否是单日</param>
        /// <param name="type">任务类型</param>
        /// <param name="isRank">是否是排名</param>
        /// <param name="isClear">是否清空数据</param>
        /// <param name="curTime">数量</param>
        /// <param name="isOverlay">是否叠加</param>
        /// <param name="reqsub">二级类型</param>
        /// <param name="reqthird">三级类型</param>
        /// <param name="overstate">四级类型</param>
        public void UpdateAchievementTaskPackage(Guid managerId, bool isOddDays, EnumTaskRequireFunc type, bool isRank, bool isClear, int curTime, bool isOverlay, int reqsub = 0,
                                                 int reqthird = 0, int overstate = 0, List <TaskRecordEntity> taskRecord = null, DbTransaction trans = null)
        {
            var taskList = CacheFactory.TaskConfigCache.GetAchievementTask(type, reqsub, reqthird, overstate);

            if (taskRecord == null)
            {
                taskRecord = TaskRecordMgr.GetManagerTaskList(managerId);
            }
            bool isUpdate = true;

            foreach (var item in taskRecord)
            {
                try
                {
                    if (item.Status != 0)
                    {
                        continue;
                    }
                    if (!taskList.Exists(r => r.TaskId == item.TaskId))
                    {
                        continue;
                    }
                    var taskConfig = CacheFactory.TaskConfigCache.GetTask(item.TaskId);
                    if (taskConfig == null)
                    {
                        continue;
                    }
                    if (isOddDays)
                    {
                        if (item.UpdateTime.Date != DateTime.Now.Date)
                        {
                            item.CurTimes = 0;
                        }
                    }
                    if (isOverlay)
                    {
                        item.CurTimes += curTime;
                    }
                    else
                    {
                        if (isRank)
                        {
                            if (item.CurTimes > curTime)
                            {
                                item.CurTimes = curTime;
                            }
                            else
                            {
                                isUpdate = false;
                            }
                        }
                        else
                        {
                            if (item.CurTimes < curTime)
                            {
                                item.CurTimes = curTime;
                            }
                            else
                            {
                                isUpdate = false;
                            }
                        }
                    }
                    if (isClear)
                    {
                        item.CurTimes = 0;
                    }

                    if (taskConfig.Times <= item.CurTimes)
                    {
                        item.Status = 1;
                        if (item.CurTimes > taskConfig.Times)
                        {
                            item.CurTimes = taskConfig.Times;
                        }
                    }
                    item.UpdateTime = DateTime.Now;
                    if (isUpdate)
                    {
                        TaskRecordMgr.Update(item, trans);
                    }
                }
                catch (Exception ex)
                {
                    SystemlogMgr.Error("增加成就任务记录", ex);
                }
            }
        }