Пример #1
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public GetPenaltyKickInfoResponse GetInfo(Guid managerId)
        {
            var response = new GetPenaltyKickInfoResponse();

            response.Data = new GetPenaltyKickInfo();
            try
            {
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (null == manager)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.MissManager));
                }
                var info = GetManager(managerId);
                if (info == null)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.MissManager));
                }
                //活动结束了
                if (!IsActivity)
                {
                    info.FreeNumber       = 0;
                    info.GameCurrency     = 0;
                    info.ShooterAttribute = 0;
                    info.ShootLog         = "";
                    info.Status           = 0;
                    info.CombGoals        = 0;
                    info.MaxCombGoals     = 0;
                }
                response.Data = GetManagerInfoResponse(info);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取点球用户信息", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
Пример #2
0
        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public GetPenaltyKickInfoResponse Join(Guid managerId)
        {
            var response = new GetPenaltyKickInfoResponse();

            response.Data = new GetPenaltyKickInfo();
            try
            {
                //不在活动时间内
                if (!IsActivity)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.AdMissSeason));
                }
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (null == manager)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.MissManager));
                }
                var info = GetManager(managerId);
                if (info == null)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.MissManager));
                }
                //游戏还未结束
                if (info.Status == 1)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.GameNotEnd));
                }
                bool isfree = false;
                if (info.FreeNumber > 0)
                {
                    info.FreeNumber--;
                    isfree = true;
                }
                else
                {
                    if (info.GameCurrency <= 0)
                    {
                        return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.GameCurrencyNumberNot));
                    }
                    info.GameCurrency--;
                }
                info.Status = 1;
                //获取踢球球员属性
                var shooterAttribute = GetShooterId(managerId);
                if (shooterAttribute == 0)
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.NbParameterError));
                }
                info.ShooterAttribute = shooterAttribute;
                info.ShootNumber++;
                info.ShootLog     = "";
                info.CombGoals    = 0;
                info.MaxCombGoals = 0;
                info.UpdateTime   = DateTime.Now;
                if (!PenaltykickManagerMgr.Update(info))
                {
                    return(ResponseHelper.Create <GetPenaltyKickInfoResponse>(MessageCode.NbUpdateFail));
                }
                //插入消费记录
                PenaltykickManagerMgr.InsertRecord(managerId, 1, isfree);
                response.Data = GetManagerInfoResponse(info);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("点球开始游戏", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }