/// <summary> /// 报名天梯赛. /// </summary> /// <returns></returns> public MessageCodeResponse Attend(string siteId, Guid managerId) { if (!IsManagerBusy(managerId)) { if (!CompetitorDic.ContainsKey(managerId)) { var response = CrossLadderCore.Instance.GetManagerInfo(siteId, managerId); if (response.Code != ShareUtil.SuccessCode) { return(ResponseHelper.Create <MessageCodeResponse>(response.Code)); } if (response.Data == null) { return(ResponseHelper.InvalidParameter <MessageCodeResponse>()); } var ladderManager = response.Data; //if (ladderManager.Stamina <= 0) //{ // return ResponseHelper.Create<MessageCodeResponse>(MessageCode.LadderStaminaShortage); //} var kpi = ManagerUtil.GetKpi(managerId, siteId); bool needUpdate = false; if (kpi != ladderManager.Kpi) { ladderManager.Kpi = kpi; needUpdate = true; } if (ladderManager.DomainId != _domainId) { ladderManager.DomainId = _domainId; needUpdate = true; } if (needUpdate) { CrossladderManagerMgr.Update(ladderManager); } response.Data.ShowName = ShareUtil.GetCrossManagerNameByZoneId(siteId, response.Data.Name); //锁住 lock (_competitorLock) { if (_playerNum == 0) { _startTime = DateTime.Now; } CompetitorDic.Add(managerId, response.Data); _playerNum++; } } return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.Success)); } else { return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.LadderBusy)); } }
/// <summary> /// Builds the match info. /// </summary> /// <param name="ladderId">The ladder id.</param> /// <param name="group">The group.</param> /// <param name="home">The home.</param> /// <param name="away">The away.</param> /// <param name="fightDic">The fight dic.</param> private void BuildMatchInfo(Guid ladderId, int group, CrossladderManagerEntity home, CrossladderManagerEntity away, Dictionary <Guid, CrossladderMatchEntity> fightDic) { try { //筛选条件,当两个玩家分差超过阀值,将他们扔到排队池里继续等待 //int tmpScore = home.Score - away.Score; //if (tmpScore <= _arenaLowScore || tmpScore >= _arenaHighScore) //{ // if (!home.IsBot) // CrossLadderCore.Instance.PushFightToCompetitor(home.Clone()); // if (!away.IsBot) // CrossLadderCore.Instance.PushFightToCompetitor(away.Clone()); // return; //} var matchId = ShareUtil.GenerateComb(); var ladderMatch = new CrossladderMatchEntity(home, away, matchId, ladderId, group + 1); ladderMatch.HomeName = ShareUtil.GetCrossManagerNameByZoneId(home.SiteId, home.Name); ladderMatch.AwayName = ShareUtil.GetCrossManagerNameByZoneId(away.SiteId, away.Name); ladderMatch.DomainId = _domainId; fightDic.Add(ladderMatch.Idx, ladderMatch); MemcachedFactory.LadderMatchClient.Set(ladderMatch.Idx, ladderMatch); //更新经理-比赛关联字典 if (!home.IsBot) { var homeHeart = new CrossLadderHeartEntity(matchId, away.ManagerId, away.SiteId, away.IsBot, away.Kpi); ManagerFightDic[home.ManagerId] = homeHeart; MemcachedFactory.LadderHeartClient.Set(home.ManagerId, homeHeart); } if (!away.IsBot) { var awayHeart = new CrossLadderHeartEntity(matchId, home.ManagerId, home.SiteId, home.IsBot, away.Kpi); ManagerFightDic[away.ManagerId] = awayHeart; MemcachedFactory.LadderHeartClient.Set(away.ManagerId, awayHeart); } } catch (Exception ex) { SystemlogMgr.Error("CrossLadderThread-BuildMatchInfo", ex.Message, ex.StackTrace); } }
public CrosscrowdManagerResponse GetManagerInfo(string siteId, Guid managerId, int crowdId, DateTime curTime, int curPoint = -1, bool checkStatus = true) { var crowdManager = InnerGetManager(siteId, managerId, crowdId, curTime); if (crowdManager == null) { return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.NbFunctionNotOpen)); } if (checkStatus) { if (crowdManager.Morale <= 0) { return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.CrowdNoMorale)); } var code = MatchCdHandler.CheckCd(managerId, EnumMatchType.CrossCrowd); if (code != MessageCode.Success) { return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.NbMatchCd)); } crowdManager.ShowName = ShareUtil.GetCrossManagerNameByZoneId(siteId, crowdManager.Name); } else { crowdManager.CdSeconds = MatchCdHandler.GetCdMilSecondsInt(managerId, EnumMatchType.CrossCrowd); crowdManager.CurPoint = curPoint; crowdManager.ClearCdPoint = CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.CrowdClearCd, 0);//crowdManager.ClearCdCount+1); crowdManager.ResurrectionPoint = CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.CrowdResurrection); if (crowdManager.Morale < 1) { crowdManager.ResurrectionCdSeconds = ShareUtil.CalCountdown(crowdManager.ResurrectionTime, curTime); } else { crowdManager.ResurrectionCdSeconds = -1; } } var response = ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.Success); response.Data = crowdManager; return(response); }