/// <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)); } }
CrosscrowdManagerEntity InnerGetManager(string siteId, Guid managerId, int crowdId, DateTime curTime) { var crowdManager = CrosscrowdManagerMgr.GetById(managerId); int domainId = 1; if (crowdManager == null) { var manager = NbManagerMgr.GetById(managerId, siteId); if (manager == null) { return(null); } //if (!ManagerUtil.CheckFunction(siteId, managerId, EnumOpenFunction.Crowd)) // return null; CrossSiteCache.Instance().TryGetDomainId(siteId, out domainId); crowdManager = new CrosscrowdManagerEntity(); crowdManager.DomainId = domainId; crowdManager.SiteId = siteId; crowdManager.SiteName = CacheFactory.FunctionAppCache.GetCrossZoneName(siteId); crowdManager.Name = manager.Name; crowdManager.Logo = manager.Logo; crowdManager.CrossCrowdId = crowdId; crowdManager.Morale = _initMorale; crowdManager.ManagerId = managerId; crowdManager.RowTime = curTime; crowdManager.UpdateTime = curTime; crowdManager.ScoreUpdateTime = curTime; crowdManager.ResurrectionTime = ShareUtil.BaseTime; crowdManager.NextMatchTime = ShareUtil.BaseTime; crowdManager.Kpi = ManagerUtil.GetKpi(managerId, siteId); CrosscrowdManagerMgr.Insert(crowdManager); } else if (crowdId > 0) { if (crowdManager.CrossCrowdId != crowdId) { CrossSiteCache.Instance().TryGetDomainId(siteId, out domainId); crowdManager.DomainId = domainId; crowdManager.CrossCrowdId = crowdId; crowdManager.KillNumber = 0; crowdManager.ByKillNumber = 0; crowdManager.Morale = _initMorale; crowdManager.Score = 0; crowdManager.ScoreUpdateTime = curTime; crowdManager.UpdateTime = curTime; crowdManager.WinningCount = 0; crowdManager.ResurrectionCount = 0; crowdManager.ResurrectionAuto = 0; crowdManager.ClearCdCount = 0; crowdManager.Kpi = ManagerUtil.GetKpi(managerId, siteId); CrosscrowdManagerMgr.Update(crowdManager); } else if (crowdManager.Morale <= 0) { if (curTime >= crowdManager.ResurrectionTime) { crowdManager.Morale = _initMorale; crowdManager.UpdateTime = curTime; crowdManager.ResurrectionAuto++; CrosscrowdManagerMgr.Update(crowdManager); } else { crowdManager.Morale = 0; } } } return(crowdManager); }