/// <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); }
void SavePackageTask(TaskRecordEntity taskRecord, int number, ConfigTaskEntity taskConfig, string zoneId = "", DbTransaction trans = null) { if (taskRecord == null || taskConfig == null) { return; } if (taskRecord.Status != 0) { return; } if (taskRecord.CurTimes < number) { taskRecord.CurTimes = number; if (taskRecord.CurTimes >= taskConfig.Times) { taskRecord.Status = 1; } taskRecord.UpdateTime = DateTime.Now; TaskRecordMgr.Update(taskRecord, trans, zoneId); } }
private PopMessageEntity Handler(TaskRecordEntity entity, EnumTaskRequireFunc requireType, int count, int subParam = 0, int thirdParam = 0, string doneKey = "", bool sendByChat = false) { try { if (entity.Status == (int)EnumTaskStatus.Done || entity.Status == (int)EnumTaskStatus.Pending) { return(null); } byte[] doneParam = entity.DoneParam; string stepRecord = entity.StepRecord; int oldTimes = entity.CurTimes; int curTimes = entity.CurTimes; int status = entity.Status; if (doTaskHandler(entity.ManagerId, entity.TaskId, count, ref doneParam, ref stepRecord, ref curTimes, ref status, requireType, subParam, thirdParam, doneKey)) { entity.DoneParam = doneParam; entity.StepRecord = stepRecord; entity.CurTimes = curTimes; entity.Status = status; if (TaskRecordMgr.Update(entity)) { //if (status == (int)EnumTaskStatus.Done) //{ // return ChatHelper.SendTaskFinishPop(entity.ManagerId, entity.TaskId, sendByChat); //} //else if (curTimes != oldTimes) //{ // return ChatHelper.SendTaskProgressPop(entity.ManagerId, entity.TaskId, curTimes, sendByChat); //} } } } catch (Exception ex) { SystemlogMgr.Error("Task Handler", ex); } return(null); }
/// <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); }
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); } }
/// <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); } } }
List <TaskRecordEntity> GetTaskList(Guid managerId) { return(TaskRecordMgr.GetByManager(managerId)); }