/// <summary> /// 领取赛季奖励 /// </summary> /// <param name="managerId"></param> /// <param name="leagueRecordId"></param> /// <returns></returns> public LeaguePrizeResponse GetRankPrize(Guid managerId, Guid leagueRecordId) { var leagueRecordInfo = LeagueRecordMgr.GetById(leagueRecordId); if (leagueRecordInfo == null) { return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.NbParameterError)); } var npcCount = CacheFactory.LeagueCache.GetTeamCount(leagueRecordInfo.LaegueId); int maxWheel = npcCount * 2; //最后一轮 if (leagueRecordInfo.Schedule <= maxWheel) { return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeagueNoEnd)); } //玩家记录 var leagueManagerRecord = LeagueManagerrecordMgr.GetManagerMarkInfo(managerId, leagueRecordInfo.LaegueId); if (leagueRecordInfo.PrizeTime == DateTime.Today) { return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeaguePrizeReceivedToday)); } if (leagueRecordInfo.Rank == 1) //冠军奖励 { if (leagueManagerRecord.SendFirstPassPrize) //首次通关才有奖励 { return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeaguePrizeReceivedToday)); } leagueManagerRecord.SendFirstPassPrize = true; //排名奖励 var rankPrizes = LeagueCache.Instance.GetLeaguePrize(leagueRecordInfo.LaegueId, 5); int exp = 0; int coin = 0; int score = 0; int vipExp = 0; ItemPackageFrame package = null; int point = 0; var manager = ManagerCore.Instance.GetManager(managerId); SendPrize(rankPrizes, manager, leagueRecordInfo.LaegueId, ref exp, ref coin, ref score, ref package, ref point, ref vipExp); leagueRecordInfo.IsSend = true; leagueRecordInfo.Schedule = -1; leagueRecordInfo.PrizeTime = DateTime.Today; leagueRecordInfo.UpdateTime = DateTime.Now; leagueManagerRecord.Score += score; var leagueManager = LaegueManagerinfoMgr.GetById(managerId); leagueManager.SumScore += score; ManagerUtil.AddManagerData(manager, exp, coin, 0, EnumCoinChargeSourceType.LeaguePrize, ShareUtil.CreateSequential().ToString()); leagueManagerRecord.LastPrizeLeagueRecordId = new Guid(); using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main))) { transactionManager.BeginTransaction(); var messageCode = SaveRankPrize(manager, leagueRecordInfo, leagueManagerRecord, leagueManager, package, point, transactionManager.TransactionObject); if (messageCode == MessageCode.Success) { transactionManager.Commit(); } else { transactionManager.Rollback(); return(ResponseHelper.Create <LeaguePrizeResponse>(messageCode)); } } //leagueManagerRecord.LastPrizeLeagueRecordId = leagueManagerRecord.LeagueRecordId; //奖励结果 var response = ResponseHelper.CreateSuccess <LeaguePrizeResponse>(); response.Data = new LeaguePrizes { PrizeList = new List <LeaguePrizeEntity>() }; foreach (var prize in rankPrizes) { var entity = new LeaguePrizeEntity(); entity.PrizeType = prize.PrizeType; entity.ItemCode = prize.PrizeType; entity.Count = prize.Count; response.Data.PrizeList.Add(entity); } response.Data.VipExp = vipExp; return(response); } return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeagueNotChampion)); }
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); }
/// <summary> /// 确认比赛结果 /// </summary> /// <param name="manager"></param> /// <param name="leagueRecordInfo"></param> /// <returns></returns> public LeaguePrizeResponse MatchConfirm(NbManagerEntity manager, LeagueRecordEntity leagueRecordInfo, LeagueManagerrecordEntity leagueManagerRecord, LaegueManagerinfoEntity lagueManagerInfo, BaseMatchData matchData, LeagueFightMapFrame fightMap, NbManagerextraEntity managerExtra, LeagueWincountrecordEntity leagueWinCount) { //发放玩家单场比赛奖励--------------------------------------------------- int winType = 0; if (matchData.Home.ManagerId == manager.Idx) //玩家为主队 { if (matchData.Home.Score > matchData.Away.Score) //主队胜 { winType = 1; } else if (matchData.Home.Score == matchData.Away.Score) //平 { winType = 2; } else //负 { winType = 3; } } else //玩家为客队 { if (matchData.Home.Score < matchData.Away.Score)//客队胜 { winType = 1; } else if (matchData.Home.Score == matchData.Away.Score) //平 { winType = 2; } else//负 { winType = 3; } } var managerPrizes = LeagueCache.Instance.GetLeaguePrize(leagueRecordInfo.LaegueId, winType); int exp = 0; int coin = 0; int score = 0; ItemPackageFrame package = null; int point = 0; int vipExp = 0; SendPrize(managerPrizes, manager, leagueRecordInfo.LaegueId, ref exp, ref coin, ref score, ref package, ref point, ref vipExp); ManagerUtil.AddManagerData(manager, exp, coin, 0, EnumCoinChargeSourceType.LeaguePrize, ShareUtil.CreateSequential().ToString()); if (lagueManagerInfo == null) { lagueManagerInfo = LaegueManagerinfoMgr.GetById(manager.Idx); } lagueManagerInfo.SumScore += score; leagueManagerRecord.MatchId = new Guid(); leagueManagerRecord.UpdateTime = DateTime.Now; bool isLastWheel = false; leagueManagerRecord.Score += score; //本联赛最后一轮 if (leagueRecordInfo.Schedule >= leagueManagerRecord.MaxWheelNumber) { isLastWheel = true; leagueManagerRecord.IsPass = true; leagueManagerRecord.PassNumber += 1; } int myRank = 0; int myScore = 0; //更新排名 fightMap.UpdateRankList(); fightMap.GetRank(ref myRank, ref myScore); leagueRecordInfo.Score += score; leagueRecordInfo.Rank = myRank; //---------------------------- leagueRecordInfo.Schedule++; leagueRecordInfo.IsSend = true; leagueRecordInfo.UpdateTime = DateTime.Now; //本联赛最后一轮,如果是冠军解锁下一轮 bool isUpdatenextManagerRecord = false; LeagueManagerrecordEntity nextManagerRecord = null; if (isLastWheel) { if (leagueRecordInfo.Rank == 1) { leagueManagerRecord.LastPrizeLeagueRecordId = leagueManagerRecord.LeagueRecordId; if (leagueRecordInfo.LaegueId != 8) { nextManagerRecord = LeagueManagerrecordMgr.GetManagerMarkInfo(manager.Idx, leagueRecordInfo.LaegueId + 1); nextManagerRecord.IsLock = false; isUpdatenextManagerRecord = true; } //记录成就相关数据 AchievementTaskCore.Instance.UpdateLeagueScore(manager.Idx, leagueRecordInfo.LaegueId, myScore); TaskHandler.Instance.LeagueChampionScore(manager.Idx); } } using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main))) { transactionManager.BeginTransaction(); var messageCode = SaveMatchConfirm(manager, package, leagueRecordInfo, nextManagerRecord, leagueManagerRecord, point, isUpdatenextManagerRecord, lagueManagerInfo, fightMap, managerExtra, leagueWinCount, transactionManager.TransactionObject); if (messageCode == MessageCode.Success) { transactionManager.Commit(); } else { transactionManager.Rollback(); return(ResponseHelper.Create <LeaguePrizeResponse>(messageCode)); } } //奖励结果 var response = ResponseHelper.CreateSuccess <LeaguePrizeResponse>(); response.Data = new LeaguePrizes { PrizeList = new List <LeaguePrizeEntity>() }; foreach (var prize in managerPrizes) { var entity = new LeaguePrizeEntity(); entity.PrizeType = prize.PrizeType; entity.ItemCode = prize.ItemCode; entity.Count = prize.Count; response.Data.PrizeList.Add(entity); } response.Data.VipExp = vipExp; return(response); }