示例#1
0
        /// <summary>
        /// 获取用户转盘信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public GetTurntableInfoResponse GetManagerInfo(Guid managerId)
        {
            GetTurntableInfoResponse response = new GetTurntableInfoResponse();

            response.Data = new TurntableInfo();
            try
            {
                var turntable = new TurntableFrame(managerId);
                if (turntable == null)
                {
                    return(ResponseHelper.Create <GetTurntableInfoResponse>((int)MessageCode.NbParameterError));
                }
                var data = GetTurntableInfo(turntable);
                if (data == null)
                {
                    return(ResponseHelper.Create <GetTurntableInfoResponse>((int)MessageCode.NbParameterError));
                }
                response.Data = data;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取经理转盘信息", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#2
0
        /// <summary>
        /// 购买通行证参数
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public ArenaBuyStaminaParaResponse BuyStaminaPara(Guid managerId)
        {
            ArenaBuyStaminaParaResponse response = new ArenaBuyStaminaParaResponse();

            response.Data = new ArenaBuyStaminaPara();
            try
            {
                //恢复体力
                var info = GetArenaInfo(managerId);
                if (info == null)
                {
                    return(ResponseHelper.Create <ArenaBuyStaminaParaResponse>(MessageCode.NbParameterError));
                }
                response.Data.StaminaEntity = RestoreStamina(info, true);
                if (info.Stamina >= CacheFactory.ArenaCache.ArenaMaxStamina)
                {
                    return(ResponseHelper.Create <ArenaBuyStaminaParaResponse>(MessageCode.StaminaHaveMax));
                }
                //获取消耗多少点卷
                var consumPoint = CacheFactory.ArenaCache.GetBuyStaminaPoint(info.BuyStaminaNumber + 1);
                if (consumPoint == -1)
                {
                    return(ResponseHelper.Create <ArenaBuyStaminaParaResponse>(MessageCode.NbParameterError));
                }
                response.Data.Point = consumPoint;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("购买通行证参数", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#3
0
        /// <summary>
        /// 获取拍卖物品详情
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <param name="transferId"></param>
        /// <returns></returns>
        public TransferMainResponse GetTransferInfo(Guid managerId, string zoneName, Guid transferId)
        {
            TransferMainResponse response = new TransferMainResponse();

            response.Data = new TransferMainEntity();
            try
            {
                if (!IsOpen(managerId, zoneName))
                {
                    return(ResponseHelper.Create <TransferMainResponse>(MessageCode.TransferNotOpen));
                }
                var entity = GetInfo(transferId);
                if (entity == null)
                {
                    return(ResponseHelper.Create <TransferMainResponse>(MessageCode.ItemSoldOut));
                }
                response.Data = entity;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取拍卖详情", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#4
0
        /// <summary>
        /// 获取排名信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="leagueId"></param>
        /// <returns></returns>
        public LeagueRankListResponse GetRank(Guid managerId, int leagueId)
        {
            try
            {
                var response     = ResponseHelper.CreateSuccess <LeagueRankListResponse>();
                var leagueRecord = LeagueManagerrecordMgr.GetManagerMarkInfo(managerId, leagueId);
                if (leagueRecord == null)
                {
                    SystemlogMgr.Error("获取联赛信息", "经理联赛记录未找到ManagerId:" + managerId);
                    return(ResponseHelper.InvalidParameter <LeagueRankListResponse>());
                }
                if (!leagueRecord.IsStart)
                {
                    return(ResponseHelper.Create <LeagueRankListResponse>(MessageCode.LeagueNotStart));
                }
                //获取排名
                var leagueFightMap = new LeagueFightMapFrame(managerId);
                int myRank         = 0;
                int myScore        = 0;
                var rankList       = leagueFightMap.GetRank(ref myRank, ref myScore);
                response.Data          = new LeagueRank();
                response.Data.RankList = rankList;
                response.Data.MyRank   = myRank;
                response.Data.MyScore  = myScore;

                return(response);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取排名信息", ex);
                return(ResponseHelper.Create <LeagueRankListResponse>(MessageCode.NbParameterError));
            }
        }
示例#5
0
        /// <summary>
        /// 获取联赛某一轮对阵记录
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="leagueId"></param>
        /// <param name="round"></param>
        /// <returns></returns>
        public LeagueGetFightMapRecordResponse GetLeagueFigMap(Guid managerId, int leagueId, int round)
        {
            LeagueGetFightMapRecordResponse response = new LeagueGetFightMapRecordResponse();

            response.Data = new LeagueGetFightMapRecord();
            try
            {
                var leagueRecord = LeagueManagerrecordMgr.GetManagerMarkInfo(managerId, leagueId);
                if (leagueRecord == null)
                {
                    SystemlogMgr.Error("获取联赛信息", "经理联赛记录未找到ManagerId:" + managerId);
                    return(ResponseHelper.InvalidParameter <LeagueGetFightMapRecordResponse>());
                }
                if (!leagueRecord.IsStart)
                {
                    return(ResponseHelper.Create <LeagueGetFightMapRecordResponse>(MessageCode.LeagueNotStart));
                }
                //获取对阵
                var leagueFightMap = new LeagueFightMapFrame(managerId);
                var fightMap       = leagueFightMap.GetFightMap(round);
                response.Data.FightRecord = fightMap;
                response.Data.Round       = round;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取联赛对阵记录", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#6
0
        //public Match_FightinfoResponse GetFightInfo(Guid managerId, Guid awayId, bool isHomeBot, bool isAwayBot, bool syncAwayFlag = false, string homeSiteId = "", string awaySiteId = "")
        //{
        //    DicNpcEntity homeNpc = null;
        //    DicNpcEntity awayNpc = null;
        //    if (string.IsNullOrEmpty(homeSiteId))
        //    {
        //        homeNpc = CacheFactory.NpcdicCache.GetNpc(managerId);
        //        awayNpc = CacheFactory.NpcdicCache.GetNpc(awayId);
        //    }
        //    bool isHomeNpc = null != homeNpc;
        //    bool isAwayNpc = null != awayNpc;
        //    DTOBuffMemberView homeView, awayView;
        //    BuffDataCore.Instance().GetMembers(out homeView, out awayView,
        //        homeSiteId, managerId, isHomeNpc, awaySiteId, awayId, isAwayNpc, true, syncAwayFlag);
        //    Match_FightManagerinfo home, away;
        //    if (isHomeNpc)
        //        home = MatchDataHelper.GetFightinfo(homeNpc, homeView);
        //    else
        //        home = MatchDataHelper.GetFightinfo(managerId, isHomeBot, homeView, homeSiteId);
        //    if (isAwayNpc)
        //        away = MatchDataHelper.GetFightinfo(awayNpc, awayView);
        //    else
        //        away = MatchDataHelper.GetFightinfo(awayId, isAwayBot, awayView, awaySiteId);
        //    if (home == null || away == null)
        //        return ResponseHelper.Create<Match_FightinfoResponse>(MessageCode.NbParameterError);

        //    var response = ResponseHelper.CreateSuccess<Match_FightinfoResponse>();
        //    response.Data = new Match_Fightinfo();
        //    response.Data.Home = home;
        //    response.Data.Away = away;
        //    return response;
        //}

        //public Match_FightManagerinfo GetFightManagerFightInfo(Guid managerId, bool isBot = false)
        //{
        //    if (CacheFactory.NpcdicCache.IsNpc(managerId))
        //    {
        //        return CacheFactory.NpcdicCache.GetFightManagerinfo(managerId);
        //    }
        //    else
        //    {
        //        return MatchDataHelper.GetFightinfo(managerId, isBot);
        //    }
        //}
        #endregion

        #region GetProcess
        public MatchProcessResponse GetCrossMatchProcess(Guid matchId, int matchType)
        {
            var baseData = MemcachedFactory.MatchClient.Get <BaseMatchData>(matchId);

            if (baseData != null)
            {
                if (baseData.ErrorCode != (int)MessageCode.Success)
                {
                    return(ResponseHelper.Create <MatchProcessResponse>(baseData.ErrorCode));
                }
            }
            var process = MemcachedFactory.MatchProcessClient.Get <byte[]>(matchId);

            if (null == process)
            {
                var dateChar = ShareUtil.GetDateFromComb(matchId);
                var match    = MatchprocessMgr.GetByMatchId(dateChar, matchType, matchId);
                if (null != match)
                {
                    process = match.Process;
                }
            }
            if (null == process)
            {
                return(ResponseHelper.Create <MatchProcessResponse>(MessageCode.MatchMiss));
            }
            var response = ResponseHelper.CreateSuccess <MatchProcessResponse>();

            response.Data = process;
            return(response);
        }
示例#7
0
        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="managerId">The manager id.</param>
        /// <returns></returns>
        public MessageCodeResponse Leave(Guid managerId)
        {
            var crowd = GetCurrent();

            if (crowd == null || crowd.Status != 1)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.CrowdNoData));
            }
            DateTime curTime = DateTime.Now;

            if (curTime < crowd.StartTime)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.CrowdNotStart));
            }
            if (!IsManagerBusy(managerId))
            {
                if (CompetitorDic.ContainsKey(managerId))
                {
                    lock (_competitorLock)
                    {
                        CrosscrowdManagerEntity entity = null;
                        CompetitorDic.TryRemove(managerId, out entity);
                    }
                    return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.Success));
                }
                else
                {
                    return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.Success));
                }
            }
            else
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.CrowdBusy));
            }
        }
示例#8
0
        /// <summary>
        /// 获取签到信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public DailyAttendanceInfoResponse GetDailyAttendanceInfo(Guid managerId)
        {
            try
            {
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (manager == null)
                {
                    return(ResponseHelper.InvalidParameter <DailyAttendanceInfoResponse>());
                }

                int days;
                var dailyAttendManager = GetManager(managerId, manager.Name, out days);
                var response           = ResponseHelper.Create <DailyAttendanceInfoResponse>(MessageCode.Success);
                response.Data = new DailyAttendanceInfo
                {
                    AttendTimes    = dailyAttendManager.AttendTimes,
                    MaxAttendTimes = days,
                    IsAttend       = dailyAttendManager.IsAttend
                };
                //IsAttendance = dailyAttendManager.IsAttend;
                return(response);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("GetDailyAttendanceInfo", ex);
                return(ResponseHelper.Create <DailyAttendanceInfoResponse>(MessageCode.Exception));
            }
        }
示例#9
0
        public MatchCreateResponse Fight(Guid managerId, Guid awayId)
        {
            var lastTime = MemcachedFactory.FriendMutexClient.Get <DateTime>(managerId);

            if (lastTime > DateTime.Now)
            {
                return(ResponseHelper.Create <MatchCreateResponse>(MessageCode.FriendMatchWait));
            }

            //好友比赛每天每个好友只能挑战3次, 只有第一次有奖励
            var friend = FriendManagerMgr.GetOne(managerId, awayId);

            if (friend.DayMatchCount >= 3)//每日三次比赛
            {
                return(ResponseHelper.Create <MatchCreateResponse>(MessageCode.FriendMatchOver));
            }

            var matchId = ShareUtil.GenerateComb();
            var code    = MatchCore.CreateMatchFriendAsyn(matchId, managerId, awayId, friend, MatchCallback);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <MatchCreateResponse>(code));
            }
            MemcachedFactory.FriendMutexClient.Set(managerId, DateTime.Now.AddSeconds(_friendMatchWaitTime));

            return(ResponseHelper.MatchCreateResponse(matchId));
        }
示例#10
0
 public MatchProcessResponse GetMatchProcess(Guid matchId, int matchType)
 {
     try
     {
         var baseData = MemcachedFactory.MatchClient.Get <BaseMatchData>(matchId);
         if (baseData != null)
         {
             if (baseData.ErrorCode != (int)MessageCode.Success)
             {
                 return(ResponseHelper.Create <MatchProcessResponse>(baseData.ErrorCode));
             }
         }
         var process = MemcachedFactory.MatchProcessClient.Get <byte[]>(matchId);
         if (process == null)
         {
             process = proxy.GetMatchProcess(matchId, matchType);
             if (process == null)
             {
                 return(ResponseHelper.Create <MatchProcessResponse>(MessageCode.MatchMiss));
             }
         }
         var response = ResponseHelper.CreateSuccess <MatchProcessResponse>();
         response.Data = process;
         return(response);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("GetMatchProcess", ex);
         return(ResponseHelper.Exception <MatchProcessResponse>());
     }
 }
示例#11
0
        /// <summary>
        /// 整理背包.
        /// </summary>
        /// <param name="managerId">The player id.</param>
        /// <returns></returns>
        public ItemPackageDataResponse Arrangepackage(Guid managerId)
        {
            var package = GetPackage(managerId, EnumTransactionType.Arrange);

            if (package == null)
            {
                return(ResponseHelper.Exception <ItemPackageDataResponse>());
            }

            var code = package.Arrange();

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <ItemPackageDataResponse>(code));
            }

            if (package.Save())
            {
                package.Shadow.Save();
                return(BuildPackageResponse(package));
            }
            else
            {
                return(ResponseHelper.Create <ItemPackageDataResponse>(MessageCode.NbUpdateFail));
            }
        }
示例#12
0
 public MailAttachmentReceiveResponse AttachmentReceive(Guid managerId, int recordId)
 {
     if (recordId == -1)
     {
         var mailList = MailInfoMgr.GetForAttachmentBatch(managerId);
         return(AttachmentReceive(mailList));
     }
     else
     {
         var mail = MailInfoMgr.GetById(recordId);
         if (mail == null || mail.ManagerId != managerId)
         {
             return(ResponseHelper.InvalidParameter <MailAttachmentReceiveResponse>());
         }
         if (!ShareUtil.CheckBytes(mail.Attachment))
         {
             return(ResponseHelper.Create <MailAttachmentReceiveResponse>(MessageCode.MailNoAttachment));
         }
         if (mail.HasAttach == false)
         {
             return(ResponseHelper.Create <MailAttachmentReceiveResponse>(MessageCode.MailAttachmentReceiveRepeat));
         }
         var mailList = new List <MailInfoEntity>(1);
         mailList.Add(mail);
         return(AttachmentReceive(mailList));
     }
 }
示例#13
0
        public InvestInfoResponse InvestInfo(Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            var investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                investInfo = InnerBuildEntity(managerId);
            }
            if (investInfo.TheMonthly && DateTime.Today > investInfo.ExpirationTime)
            {
                investInfo.TheMonthly = false;
            }
            string stepStatus    = investInfo.StepStatus;
            string newStepStatus = Rebuild(stepStatus, manager.Level);

            investInfo.StepStatus = newStepStatus;
            if (!InvestManagerMgr.Update(investInfo))
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.NbUpdateFail));
            }
            List <int>    restitution = CacheFactory.ActivityCache.BuildRestitution(stepStatus);
            PayUserEntity payUser     = PayUserMgr.GetById(manager.Account);

            return(BuildInvestInfoResponse(investInfo, restitution, newStepStatus, payUser, 0));
        }
示例#14
0
        public LadderRefreshExchangeResponse RefreshExchange(Guid managerId)
        {
            var entity = GetLadderManager(managerId);

            entity.RefreshTimes++;
            var mallDirect = new MallDirectFrame(managerId, EnumConsumeSourceType.RefreshLadderExchange,
                                                 entity.RefreshTimes);
            var checkCode = mallDirect.Check();

            if (checkCode != MessageCode.Success)
            {
                return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
            }
            var equipmentProperties = "";
            var equipmentItemcode   = "";

            entity.ExchangeIds         = CacheFactory.LadderCache.GetExchanges(out equipmentItemcode, out equipmentProperties);
            entity.ExchangedIds        = "";
            entity.EquipmentProperties = equipmentProperties;
            entity.EquipmentItems      = equipmentItemcode;
            using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                transactionManager.BeginTransaction();
                checkCode = mallDirect.Save(Guid.NewGuid().ToString(), transactionManager.TransactionObject);
                if (checkCode != MessageCode.Success)
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
                }
                if (!LadderManagerMgr.Update(entity, transactionManager.TransactionObject))
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(MessageCode.NbUpdateFail));
                }
                transactionManager.Commit();
            }
            var response = ResponseHelper.CreateSuccess <LadderRefreshExchangeResponse>();

            response.Data              = new LadderRefreshExchangeEntity();
            response.Data.ExchangeIds  = entity.ExchangeIds;
            response.Data.ManagerPoint = mallDirect.RemainPoint;
            response.Data.RefreshPoint =
                CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.RefreshLadderExchange,
                                                      entity.RefreshTimes + 1);
            response.Data.Honor = entity.Honor;
            if (DateTime.Now.Hour >= 21)
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddDays(1).AddHours(21));
            }
            else
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddHours(21));
            }

            response.Data.AllEquipmentProperties =
                CacheFactory.LadderCache.AnalysisProperties(entity.EquipmentProperties);
            response.Data.LadderCoin = entity.LadderCoin;
            return(response);
        }
示例#15
0
        /// <summary>
        /// 天梯赛状态轮询.
        /// </summary>
        /// <param name="managerId">The manager id.</param>
        /// <returns></returns>
        public CrossLadderHeartResponse Heart(Guid managerId)
        {
            CrossLadderHeartResponse response;

            if (CompetitorDic.ContainsKey(managerId))
            {
                response = ResponseHelper.CreateSuccess <CrossLadderHeartResponse>();
            }
            else if (ManagerFightDic != null && ManagerFightDic.ContainsKey(managerId))
            {
                var heartEntity = ManagerFightDic[managerId];

                if (heartEntity == null)
                {
                    if (_status == EnumLadderStatus.Grouping)
                    {
                        response = ResponseHelper.Create <CrossLadderHeartResponse>(MessageCode.Success);
                    }
                    else
                    {
                        response = ResponseHelper.Create <CrossLadderHeartResponse>(MessageCode.Success);
                    }
                }
                else
                {
                    response      = ResponseHelper.Create <CrossLadderHeartResponse>(MessageCode.Success);
                    response.Data = heartEntity;
                }
            }
            else
            {
                var heartEntity = MemcachedFactory.LadderHeartClient.Get <CrossLadderHeartEntity>(managerId);
                if (heartEntity == null)
                {
                    return(ResponseHelper.Create <CrossLadderHeartResponse>(MessageCode.Success));
                }
                else
                {
                    response      = ResponseHelper.Create <CrossLadderHeartResponse>(MessageCode.Success);
                    response.Data = heartEntity;
                }
            }
            if (response.Data == null)
            {
                response.Data = new CrossLadderHeartEntity();
            }
            if (RecentlyAvgWaitSecond > 60)
            {
                response.Data.AvgWaitTime = 60;
            }
            else
            {
                response.Data.AvgWaitTime = RecentlyAvgWaitSecond;
            }

            return(response);
        }
示例#16
0
        /// <summary>
        /// 获取被邀请好友列表
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public FriendsAddInfoResponse GetFriendRequestList(Guid managerId)
        {
            var response = ResponseHelper.Create <FriendsAddInfoResponse>(MessageCode.Success);

            response.Data = new FriendsAddInfo {
                FriendAddList = FriendManagerMgr.GetFriendAddList(managerId)
            };
            return(response);
        }
示例#17
0
        /// <summary>
        /// 刷新点球兑换
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public PenaltyKickExChangeResponse RefreshExChange(Guid managerId)
        {
            PenaltyKickExChangeResponse response = new PenaltyKickExChangeResponse();

            response.Data = new PenaltyKickExChange();
            try
            {
                var info = GetManager(managerId);
                if (info == null)
                {
                    return(ResponseHelper.Create <PenaltyKickExChangeResponse>(MessageCode.MissManager));
                }
                var point = PayCore.Instance.GetPoint(managerId);
                if (point < _refreshExChangePoint)
                {
                    return(ResponseHelper.Create <PenaltyKickExChangeResponse>(MessageCode.NbPointShortage));
                }
                info.ExChangeString = RefreshExChange();
                var exList = GetExChangeEntity(info.ExChangeString);
                info.ExChangeString = SetExChangeString(exList);
                info.UpdateTime     = DateTime.Now;
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = MessageCode.NbUpdateFail;
                    do
                    {
                        messageCode = PayCore.Instance.GambleConsume(managerId, _refreshExChangePoint, ShareUtil.GenerateComb(),
                                                                     EnumConsumeSourceType.AdTopScoreResetExchange, transactionManager.TransactionObject);
                        if (messageCode != MessageCode.Success)
                        {
                            break;
                        }
                        messageCode = MessageCode.NbUpdateFail;
                        if (!PenaltykickManagerMgr.Update(info, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        messageCode = MessageCode.Success;
                    } while (false);
                    if (messageCode != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <PenaltyKickExChangeResponse>(messageCode));
                    }
                    transactionManager.Commit();
                }
                response.Data.AvailableScore = info.AvailableScore;
                response.Data.ExChangeList   = exList;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("刷新点球兑换", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#18
0
        public LadderExchangeResponse Exchange(string siteId, Guid managerId, int exchangeIdx)
        {
            var response1 = GetLadderManager(siteId, managerId);

            if (response1.Code != ShareUtil.SuccessCode)
            {
                return(ResponseHelper.Create <LadderExchangeResponse>(response1.Code));
            }
            if (response1.Data == null)
            {
                return(ResponseHelper.InvalidParameter <LadderExchangeResponse>());
            }
            var manager       = response1.Data;
            var exchangeCache = CacheFactory.CrossLadderCache.GetExchangeEntity(exchangeIdx);

            if (exchangeCache == null)
            {
                return(ResponseHelper.InvalidParameter <LadderExchangeResponse>());
            }
            if (manager.Honor < exchangeCache.CostHonor)
            {
                return(ResponseHelper.Create <LadderExchangeResponse>(MessageCode.LadderExchangeHonorShortage));
            }
            var package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.CrossLadderExchange, siteId);
            var code    = package.AddItem(exchangeCache.ItemCode, true, false);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <LadderExchangeResponse>(code));
            }
            manager.Honor      = manager.Honor - exchangeCache.CostHonor;
            manager.UpdateTime = DateTime.Now;
            var record = new CrossladderExchangerecordEntity()
            {
                SiteId    = siteId,
                CostHonor = exchangeCache.CostHonor,
                ItemCode  = exchangeCache.ItemCode,
                ManagerId = managerId,
                RowTime   = DateTime.Now
            };

            code = SaveExchange(manager, package, record);
            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <LadderExchangeResponse>(code));
            }
            else
            {
                package.Shadow.Save();
                var response = ResponseHelper.CreateSuccess <LadderExchangeResponse>();
                response.Data = new LadderExchangeEntity()
                {
                    CurHonor = manager.Honor, ItemCode = exchangeCache.ItemCode
                };
                return(response);
            }
        }
示例#19
0
 public CrossladderManagerResponse GetLadderManager(string siteId, Guid managerId)
 {
     try
     {
         var ladderManager = CrossladderManagerMgr.GetById(managerId);
         if (ladderManager == null)
         {
             if (!ManagerUtil.CheckFunction(siteId, managerId, EnumOpenFunction.CrossLadder))
             {
                 return(ResponseHelper.Create <CrossladderManagerResponse>(MessageCode.NbFunctionNotOpen));
             }
             var nbManager = NbManagerMgr.GetById(managerId, siteId);
             if (nbManager == null)
             {
                 return(ResponseHelper.Create <CrossladderManagerResponse>(MessageCode.MissManager));
             }
             int domainId = 0;
             int honor    = 0;
             CrossladderManagerMgr.GetOldHonor(managerId, ref honor);
             CrossSiteCache.Instance().TryGetDomainId(siteId, out domainId);
             ladderManager                 = new CrossladderManagerEntity();
             ladderManager.DomainId        = domainId;
             ladderManager.SiteId          = siteId;
             ladderManager.SiteName        = CacheFactory.FunctionAppCache.GetCrossZoneName(siteId);
             ladderManager.ManagerId       = managerId;
             ladderManager.Name            = nbManager.Name;
             ladderManager.SiteId          = siteId;
             ladderManager.Logo            = nbManager.Logo;
             ladderManager.Score           = _ladderRegisterScore;
             ladderManager.LastExchageTime = ShareUtil.BaseTime;
             ladderManager.RowTime         = DateTime.Now;
             ladderManager.UpdateTime      = DateTime.Now;
             ladderManager.Honor           = honor;
             ladderManager.MaxScore        = _ladderRegisterScore;
             ladderManager.DailyMaxScore   = _ladderRegisterScore;
             ladderManager.Stamina         = 50;
             CrossladderManagerMgr.Insert(ladderManager);
         }
         if (ladderManager.Stamina < 0)
         {
             ladderManager.Stamina = 0;
         }
         if (ladderManager.StaminaBuy < 0)
         {
             ladderManager.StaminaBuy = 0;
         }
         var response = ResponseHelper.CreateSuccess <CrossladderManagerResponse>();
         response.Data = ladderManager;
         return(response);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("GetCrossLadderManager", ex);
         return(ResponseHelper.Create <CrossladderManagerResponse>(MessageCode.Exception));
     }
 }
示例#20
0
        /// <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));
            }
        }
示例#21
0
        public LadderMatchMarqueeResponse GetMatchMarqueeResponse(string siteId)
        {
            var thread = GetThread(siteId);

            if (thread == null)
            {
                return(ResponseHelper.Create <LadderMatchMarqueeResponse>(MessageCode.NbDomainInvalid));
            }
            return(thread.GetMatchMarqueeResponse());
        }
示例#22
0
        public MessageCodeResponse Leave(string siteId, Guid managerId)
        {
            var thread = GetThread(siteId);

            if (thread == null)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbDomainInvalid));
            }
            return(thread.Leave(managerId));
        }
示例#23
0
        public CrowdHeartResponse Heart(string siteId, Guid managerId)
        {
            var thread = GetThread(siteId);

            if (thread == null)
            {
                return(ResponseHelper.Create <CrowdHeartResponse>(MessageCode.NbDomainInvalid));
            }
            return(thread.Heart(managerId));
        }
示例#24
0
        /// <summary>
        /// 获取分享信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="shareType">分享类型   4=关注</param>
        /// <returns></returns>
        public ShareGetResponse GetShareInfo(Guid managerId, int shareType)
        {
            var response = new ShareGetResponse();

            response.Data = new ShareGet();
            try
            {
                var manager = NbManagerMgr.GetById(managerId);
                if (manager == null)
                {
                    return(ResponseHelper.Create <ShareGetResponse>(MessageCode.MissManager));
                }
                var config = CacheFactory.ManagerDataCache.GetShare(shareType);
                if (config == null || config.Count == 0)
                {
                    return(ResponseHelper.Create <ShareGetResponse>(MessageCode.ActivityNoConfigPrize));
                }
                var record = ShareManagerMgr.GetByManagerId(managerId, shareType);
                if (record != null)
                {
                    DateTime date = DateTime.Now;
                    if (record.UpdateTime.Date != date.Date)
                    {
                        var code = RefreshRecord(record, config[0]);
                        if (code != MessageCode.Success)
                        {
                            return(ResponseHelper.Create <ShareGetResponse>(code));
                        }
                    }
                    if (shareType == 1)//第一种特殊处理
                    {
                        if (record.ShareNumber > 0)
                        {
                            int seconds = 3600 - (date - record.UpdateTime).Seconds;
                            response.Data.NextShareEnd = seconds < 0 ? 0 : seconds;
                        }
                    }
                    response.Data.IsFirstShare = false;
                    response.Data.ShareNumber  = record.ShareNumber;
                    response.Data.IsHaveShare  = config[0].MaxShareNumber > record.ShareNumber;
                }
                else
                {
                    response.Data.IsHaveShare  = true;
                    response.Data.IsFirstShare = true;
                    response.Data.ShareNumber  = 0;
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取分享信息", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#25
0
        CrosscrowdManagerResponse doAction(string siteId, Guid managerId, EnumConsumeSourceType mallDirectType, bool isClearCd)
        {
            var crowd = CrossCrowdManager.Instance.GetCurrent(siteId);

            if (crowd == null || crowd.Status != 1)
            {
                return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.CrowdNoData));
            }
            DateTime curTime = DateTime.Now;
            CrosscrowdManagerEntity crowdManager = InnerGetManager(siteId, managerId, crowd.Idx, curTime);

            if (isClearCd)
            {
                var cd = MatchCdHandler.GetCdSecondsInt(managerId, EnumMatchType.CrossCrowd);
                if (cd <= 0)
                {
                    return(GetManagerInfo(siteId, managerId, crowd.Idx, DateTime.Now));
                }
                crowdManager.ClearCdCount++;
            }
            else
            {
                if (crowdManager.Morale <= 0)
                {
                    crowdManager.Morale = _initMorale;
                    crowdManager.ResurrectionCount++;
                    //crowdManager.NextMatchTime = ShareUtil.BaseTime;
                }
                else
                {
                    return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.CrowdHasMorale));
                }
            }
            var mallDirect = new CrossMallDirectFrame(siteId, managerId, mallDirectType, 0);// crowdManager.ClearCdCount);
            var checkCode  = mallDirect.Check();

            if (checkCode != MessageCode.Success)
            {
                return(ResponseHelper.Create <CrosscrowdManagerResponse>(checkCode));
            }
            crowdManager.UpdateTime = curTime;
            if (!CrosscrowdManagerMgr.Update(crowdManager))
            {
                return(ResponseHelper.Create <CrosscrowdManagerResponse>(MessageCode.NbUpdateFail));
            }

            MatchCdHandler.Delete(managerId, EnumMatchType.CrossCrowd);
            checkCode = mallDirect.Save(Guid.NewGuid().ToString());
            if (checkCode != MessageCode.Success)
            {
                SystemlogMgr.Error("CrossCrowd-doaction", string.Format("action:{0}", mallDirectType.ToString()));
            }
            return(GetManagerInfo(siteId, managerId, crowd.Idx, DateTime.Now, mallDirect.RemainPoint, false));
        }
示例#26
0
        public MessageCodeResponse AddFriend(Guid managerId, string name, bool hasTask)
        {
            var byManager = ManagerCore.Instance.GetManagerByName(name);

            if (byManager == null)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendNotExistsName));
            }
            if (managerId == byManager.Idx)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendNotSelf));
            }
            var manager = ManagerCore.Instance.GetManager(managerId);
            var friend  = FriendManagerMgr.GetOne(managerId, byManager.Idx);

            if (friend != null)
            {
                if (friend.Status == 0)
                {
                    return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendHasExists));
                }
                if (friend.Status == 2)
                {
                    return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendIsByBlack));
                }
            }
            int returnCode = 0;

            FriendManagerMgr.AddFriend(managerId, byManager.Idx, _friendMaxCount, (int)MessageCode.FriendCountOver,
                                       (int)MessageCode.FriendHasExists, ref returnCode);
            if (returnCode == 1) //自己已在对方好友列表
            {
                returnCode = 0;
            }
            else
            {
                InformationHelper.SendAddFriendPop(byManager.Idx, manager.Name);
            }

            if (returnCode == 0)
            {
                var response = ResponseHelper.CreateSuccess <MessageCodeResponse>();
                response.Data = new MessageDataEntity();
                if (hasTask)
                {
                    //response.Data.PopMsg = TaskHandler.Instance.FriendAdd(managerId);
                }
                return(response);
            }
            else
            {
                return(ResponseHelper.Create <MessageCodeResponse>(returnCode));
            }
        }
示例#27
0
        public PlayerKillOpponentResponse GetOpponents(Guid managerId, string opponentName)
        {
            var info = InnerGetInfo(managerId);

            if (info == null)
            {
                return(ResponseHelper.InvalidParameter <PlayerKillOpponentResponse>("managerId"));
            }
            var manager = ManagerCore.Instance.GetManager(managerId, true);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <PlayerKillOpponentResponse>("managerId"));
            }

            if (manager.Coin < 200)
            {
                return(ResponseHelper.Create <PlayerKillOpponentResponse>(MessageCode.LackofCoin));
            }

            var response = ResponseHelper.CreateSuccess <PlayerKillOpponentResponse>();

            if (!string.IsNullOrEmpty(opponentName))
            {
                var opponent = PlayerkillInfoMgr.GetOpponentByName(opponentName, 1);
                if (opponent == null)
                {
                    return(ResponseHelper.Create <PlayerKillOpponentResponse>(MessageCode.MissManager));
                }
                else if (opponent.Level < _pkMinLevel)
                {
                    return(ResponseHelper.Create <PlayerKillOpponentResponse>(MessageCode.PlayerKillMinLevel));
                }
                PlayerKillOpponentListEntity opponentList = new PlayerKillOpponentListEntity();
                opponentList.Opponents = new List <PlayerKillOpponentEntity>(1);

                opponent.FormationId = TeammemberCore.Instance.GetSolution(opponent.ManagerId).FormationId;
                opponentList.Opponents.Add(opponent);
                response.Data = opponentList;
            }
            else
            {
                RefreshOpponent(info, manager.Kpi);
                response.Data           = new PlayerKillOpponentListEntity();
                response.Data.Opponents = info.Opponents;
            }
            if (response.Data != null && response.Data.Opponents.Count > 0)
            {
                //扣除金币
                ManagerCore.Instance.CostCoin(manager, 200, EnumCoinConsumeSourceType.PkMatchRefresh, ShareUtil.GenerateComb().ToString());
            }
            response.Data.OpponentRefreshTimeTick = ShareUtil.GetTimeTick(info.OpponentRefreshTime);
            return(response);
        }
示例#28
0
        /// <summary>
        /// 忽略添加好友
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="friendId"></param>
        /// <returns></returns>
        public MessageCodeResponse IgnoreAddFriend(Guid managerId, Guid friendId)
        {
            int returnCode = 0;

            FriendManagerMgr.IgnoreAddFriend(managerId, friendId, ref returnCode);
            if (returnCode == -1)//已经是好友了
            {
                returnCode = 0;
            }
            return(ResponseHelper.Create <MessageCodeResponse>(returnCode));
        }
示例#29
0
        /// <summary>
        /// 教练升级
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="coachId"></param>
        /// <returns></returns>
        public CoachGetInfoResponse CoachUpgrade(Guid managerId, int coachId)
        {
            var response = new CoachGetInfoResponse();

            response.Data = new CoachGetInfoEntity();
            try
            {
                var frame = GetFrame(managerId);
                var info  = frame.GetCoachInfo(coachId);
                if (info == null)
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.CoachNotAlready));
                }
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (manager == null)
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.NbParameterError));
                }
                if (info.CoachLevel >= manager.Level)
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.LackofManagerLevel));
                }
                if (frame.Entity == null)
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.NbParameterError));
                }
                if (frame.Entity.HaveExp <= 0)
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.CoachExpNot));
                }
                var costExp = frame.CoachUpgarde(coachId);
                if (!frame.Save())
                {
                    return(ResponseHelper.Create <CoachGetInfoResponse>(MessageCode.NbUpdateFail));
                }
                //插入扣除记录
                if (costExp > 0)
                {
                    CoachManagerMgr.CostExpRecord(managerId, costExp);
                }
                response.Data.CoachInfo     = frame.GetCoachInfo(coachId);
                response.Data.EnableCoachId = frame.Entity.EnableCoachId;
                response.Data.SumExp        = frame.Entity.HaveExp;

                MatchDataCacheHelper.DeleteTeammemberAndSolutionCache(managerId, true);
                response.Data.Kpi = ManagerCore.Instance.GetKpi(managerId);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("教练升级", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
示例#30
0
        /// <summary>
        /// 开启一个联赛
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="leagueId"></param>
        /// <returns></returns>
        public GetLeagueInfoResponse StarLeague(Guid managerId, int leagueId)
        {
            LeagueManagerrecordEntity leagueManagerRecord = null;
            var code = LeagueProcess.Instance.StartLeague(managerId, leagueId, ref leagueManagerRecord);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <GetLeagueInfoResponse>(code));
            }
            return(GetLeagueInfo(managerId, leagueId, leagueManagerRecord));
        }