/// <summary> /// 好友赛最高连胜 /// </summary> /// <param name="managerId"></param> /// <param name="winType"></param> /// <returns></returns> public MessageCode UpdateFriendMatchComb(Guid managerId, EnumWinType winType, DbTransaction trans = null) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager == null) { return(MessageCode.NbParameterError); } bool isClear = false; if (winType == EnumWinType.Win) { achievementManager.FriendWinComb++; } else { achievementManager.FriendWinComb = 0; isClear = true; } UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.FriendMatchWin, false, isClear, 1, true); UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.FriendMatchCount, false, false, 1, true); UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.PkOrFriendMatchCount, false, false, 1, true); if (achievementManager.FriendWinComb > achievementManager.MaxFriendWinComb) { achievementManager.MaxFriendWinComb = achievementManager.FriendWinComb; } //if (AchievementManagerMgr.Update(achievementManager, trans)) // return MessageCode.Success; //else return(MessageCode.FailUpdate); }
/// <summary> /// 更新天梯赛单场进球及赛季最高胜场 /// </summary> /// <param name="managerId"></param> /// <param name="goals"></param> /// <returns></returns> public MessageCode UpdateLadderGoals(Guid managerId, int goals, EnumWinType winType, int score) { try { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager == null) { return(MessageCode.NbParameterError); } bool needUpdate = false; if (goals > achievementManager.MaxLadderGoals) { achievementManager.MaxLadderGoals = goals; needUpdate = true; } if (winType == EnumWinType.Win) { var ladderManager = LadderCore.Instance.GetLadderManager(managerId); if (ladderManager != null) { var season = ladderManager.Season; if (season == null) { SystemlogMgr.Error("赛季=null", "赛季=null"); } needUpdate = true; if (achievementManager.LadderSeason == season.Idx) { achievementManager.LadderWin++; } else { achievementManager.LadderSeason = season.Idx; achievementManager.LadderWin = 1; } if (achievementManager.LadderWin > achievementManager.MaxLadderWin) { achievementManager.MaxLadderWin = achievementManager.LadderWin; } } } UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.LadderMatchGoals, false, false, goals, false); UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.LadderMatchCount, false, false, 1, true); if (winType == EnumWinType.Win) { UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.LadderWinCountSeason, false, false, 1, true); } UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.LadderScore, false, false, score, false); } catch (Exception ex) { SystemlogMgr.Error("更新天梯赛单场进球及赛季最高胜场", ex); } return(MessageCode.Success); }
/// <summary> /// 更新PK赛单场进球及单日最多进球 /// </summary> /// <param name="managerId"></param> /// <param name="goals"></param> /// <returns></returns> public MessageCode UpdatePkMatchGoals(Guid managerId, int goals) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager == null) { return(MessageCode.NbParameterError); } if (goals > achievementManager.MaxPkMatchGoals) { achievementManager.MaxPkMatchGoals = goals; } var date = DateTime.Now.Date; if (achievementManager.DayPkMatchDate.Date == date) { achievementManager.DayPkMatchGoals += goals; } else { achievementManager.DayPkMatchDate = date; achievementManager.DayPkMatchGoals = goals; } if (achievementManager.DayPkMatchGoals > achievementManager.MaxDayPkMatchGoals) { achievementManager.MaxDayPkMatchGoals = achievementManager.DayPkMatchGoals; } UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.PkMatchGoals, false, false, goals, false); UpdateAchievementTask(managerId, true, EnumTaskRequireFunc.PkMatchDayGoals, false, false, goals, true); //if (AchievementManagerMgr.Update(achievementManager)) // return MessageCode.Success; //else return(MessageCode.FailUpdate); }
/// <summary> /// 更新联赛冠军积分 /// </summary> /// <param name="managerId"></param> /// <param name="leagueId"></param> /// <param name="score"></param> /// <returns></returns> public MessageCode UpdateLeagueScore(Guid managerId, int leagueId, int score) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager == null) { return(MessageCode.NbParameterError); } int reqthird = 0; bool needUpdate = false; switch (leagueId) { case 1: if (score > achievementManager.LeagueScore1) { achievementManager.LeagueScore1 = score; needUpdate = true; } reqthird = 80; break; case 2: if (score > achievementManager.LeagueScore2) { achievementManager.LeagueScore2 = score; needUpdate = true; } reqthird = 80; break; case 3: if (score > achievementManager.LeagueScore3) { achievementManager.LeagueScore3 = score; needUpdate = true; } reqthird = 90; break; case 4: if (score > achievementManager.LeagueScore4) { achievementManager.LeagueScore4 = score; needUpdate = true; } reqthird = 100; break; case 5: if (score > achievementManager.LeagueScore5) { achievementManager.LeagueScore5 = score; needUpdate = true; } reqthird = 100; break; case 6: if (score > achievementManager.LeagueScore6) { achievementManager.LeagueScore6 = score; needUpdate = true; } reqthird = 95; break; case 7: if (score > achievementManager.LeagueScore7) { achievementManager.LeagueScore7 = score; needUpdate = true; } reqthird = 106; break; case 8: if (score > achievementManager.LeagueScore8) { achievementManager.LeagueScore8 = score; needUpdate = true; } reqthird = 110; break; } UpdateAchievementTask(managerId, false, EnumTaskRequireFunc.LeagueChampionScore, false, false, score, false, leagueId, reqthird); //if (needUpdate) //{ // if (AchievementManagerMgr.Update(achievementManager)) // return MessageCode.Success; // else // return MessageCode.FailUpdate; //} return(MessageCode.Success); }
//成就任务 private bool doAchievementHandler(Guid managerId, int taskId, int count, ref byte[] doneParam, ref string stepRecord, ref int curTimes, ref int status, EnumTaskRequireFunc requireType, int subParam = 0, int thirdParam = 0, string doneKey = "") { try { var taskCache = CacheFactory.TaskConfigCache.GetTask(taskId); if (taskCache == null) { SystemlogMgr.Error("TaskHandler", "no task config taskid:" + taskId); return(false); } int tempRequireType = (int)requireType; if (!taskCache.RequireFuncDic.ContainsKey(tempRequireType)) { return(false); } TaskDoneRecordEntity doneRecordEntity = null; if (taskCache.UniqueConstraint) { if (doneParam == null || doneParam.Length <= 0) { doneRecordEntity = new TaskDoneRecordEntity(taskCache.RequireList.Count); } else { doneRecordEntity = SerializationHelper.FromByte <TaskDoneRecordEntity>(doneParam); } } var stepArray = BuildStepArray(stepRecord, taskCache.RequireList.Count); bool sync = false; for (int i = 0; i < taskCache.RequireList.Count; i++) { if (doneRecordEntity != null) { if (doneRecordEntity.Records[i].Params.Contains(doneKey)) { continue; } } var require = taskCache.RequireList[i]; if (require.RequireType == (int)EnumTaskRequireFunc.PlayCardCollection) { if (require.RequireSub != 0 && require.RequireSub <= 4) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { switch (require.RequireSub) { case 4: curTimes = achievementManager.PurpleCardCount; break; case 3: curTimes = achievementManager.OrangeCardCount; break; case 2: curTimes = achievementManager.SilverCardCount; break; case 1: curTimes = achievementManager.GoldCardCount; break; } stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.PlayerCardLevel) { if (require.RequireSub != 0 && require.RequireSub <= 30) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { switch (require.RequireSub) { case 5: curTimes = achievementManager.Level5CardCount; break; case 10: curTimes = achievementManager.Level10CardCount; break; case 20: curTimes = achievementManager.Level20CardCount; break; case 30: curTimes = achievementManager.Level30CardCount; break; } stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.LeagueChampionScore) { if (require.RequireSub != 0 && require.RequireSub <= 8) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { switch (require.RequireSub) { case 1: if (achievementManager.LeagueScore1 >= require.RequireThird) { curTimes = 1; } break; case 2: if (achievementManager.LeagueScore2 >= require.RequireThird) { curTimes = 1; } break; case 3: if (achievementManager.LeagueScore3 >= require.RequireThird) { curTimes = 1; } break; case 4: if (achievementManager.LeagueScore4 >= require.RequireThird) { curTimes = 1; } break; case 5: if (achievementManager.LeagueScore5 >= require.RequireThird) { curTimes = 1; } break; case 6: if (achievementManager.LeagueScore6 >= require.RequireThird) { curTimes = 1; } break; case 7: if (achievementManager.LeagueScore7 >= require.RequireThird) { curTimes = 1; } break; case 8: if (achievementManager.LeagueScore8 >= require.RequireThird) { curTimes = 1; } break; } } } } else if (require.RequireType == (int)EnumTaskRequireFunc.DailyCupRank) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.MaxDailyCupRank <= require.RequireSub) { curTimes = 1; stepArray[i] = "1"; } } } if (require.RequireType == (int)EnumTaskRequireFunc.PkMatchGoals) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.MaxPkMatchGoals >= curTimes) { curTimes = achievementManager.MaxPkMatchGoals; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.PkMatchDayGoals) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.DayPkMatchGoals >= curTimes) { curTimes = achievementManager.DayPkMatchGoals; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.LadderWinCountSeason) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.MaxLadderWin >= curTimes) { curTimes = achievementManager.MaxLadderWin; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.LadderMatchGoals) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.MaxLadderGoals >= curTimes) { curTimes = achievementManager.MaxLadderGoals; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.FriendMatchWin) { var achievementManager = AchievementManagerMgr.GetById(managerId); if (achievementManager != null) { if (achievementManager.MaxFriendWinComb >= curTimes) { curTimes = achievementManager.MaxFriendWinComb; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.PkOrFriendMatchCount) { var matchStat = NbMatchstatMgr.GetByManager(managerId); if (matchStat != null) { var matchCount = 0; foreach (var nbMatchstatEntity in matchStat) { if (nbMatchstatEntity.MatchType == (int)EnumMatchType.PlayerKill || nbMatchstatEntity.MatchType == (int)EnumMatchType.Friend) { matchCount += nbMatchstatEntity.TotalCount; } } if (matchCount >= curTimes) { curTimes = matchCount; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.LadderMatchCount) { var matchStat = NbMatchstatMgr.GetByManagerAndType(managerId, (int)EnumMatchType.Ladder); if (matchStat != null) { if (matchStat.TotalCount >= curTimes) { curTimes = matchStat.TotalCount; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.FriendMatchCount) { var matchStat = NbMatchstatMgr.GetByManagerAndType(managerId, (int)EnumMatchType.Friend); if (matchStat != null) { if (matchStat.TotalCount >= curTimes) { curTimes = matchStat.TotalCount; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.LadderScore) { var ladderInfo = LadderCore.Instance.GetLadderManager(managerId); if (ladderInfo != null) { if (ladderInfo.MaxScore >= require.RequireSub) { curTimes = ladderInfo.MaxScore; stepArray[i] = "1"; } } } else if (require.RequireType == (int)EnumTaskRequireFunc.PlayerCardStrengthCollection) { var package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.AchievementUpdate); if (package != null) { var cardCount = package.GetStrengthCardCount(require.RequireSub, require.RequireThird); if (cardCount >= curTimes) { curTimes = cardCount; stepArray[i] = "1"; } } } if (doneRecordEntity != null) { doneRecordEntity.Records[i].Add(doneKey); } } bool isDone = true; foreach (var s in stepArray) { if (s != "1") { isDone = false; break; } } if (isDone) { sync = true; if (curTimes >= taskCache.Times) { status = (int)EnumTaskStatus.Done; } stepRecord = ""; } else { stepRecord = string.Join(",", stepArray); } if (sync) { if (doneRecordEntity != null) { doneParam = SerializationHelper.ToByte(doneRecordEntity); } } return(sync); } catch (Exception ex) { SystemlogMgr.Error("Task Handler", ex); return(false); } }