Ejemplo n.º 1
0
        MessageCode InitRobotManager()
        {
            List <CrossrobotManagerEntity> crossList = null;

            switch (_curMatchType)
            {
            case EnumMatchType.CrossCrowd:
                crossList = CrossrobotManagerMgr.GetCrossCrowd();
                break;

            default:
                return(MessageCode.Success);

                break;
            }
            if (_crossRobotManagerDic == null)
            {
                _crossRobotManagerDic = new ConcurrentDictionary <Guid, CrossrobotManagerEntity>();
            }
            if (crossList.Count > 0)
            {
                foreach (var entity in crossList)
                {
                    if (!_crossRobotManagerDic.ContainsKey(entity.Idx))
                    {
                        _crossRobotManagerDic.TryAdd(entity.Idx, entity);
                    }
                }
            }

            return(MessageCode.Success);
        }
Ejemplo n.º 2
0
 void RobotCrossCrowdHook(CrossrobotManagerEntity entity)
 {
     if (CrossCrowdFight(entity.SiteId, entity.Idx) == MessageCode.Success)
     {
         CrossrobotManagerMgr.UpdateStatus(entity.Idx, (int)EnumRobotMatchStatus.Run);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 启动机器人
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public RobotResponse StartRobot(string siteId, Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId, false, siteId);

            if (manager == null)
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.MissManager));
            }
            if (manager.Level < RobotLevel)
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.LackofManagerLevel));
            }
            if (!CheckManagerVip(manager))
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.LackofVipLevel));
            }

            var crossRobotManager = CrossrobotManagerMgr.GetById(managerId);

            if (crossRobotManager == null)
            {
                crossRobotManager = RobotCore.BuildCrossRobotManager(siteId, managerId);
                SetHookStatus(crossRobotManager, true);
                if (!CrossrobotManagerMgr.Insert(crossRobotManager))
                {
                    return(ResponseHelper.Create <RobotResponse>(MessageCode.FailUpdate));
                }
            }
            else
            {
                if (!GetHookStatus(crossRobotManager))
                {
                    SetHookStatus(crossRobotManager, true);
                    if (!CrossrobotManagerMgr.Update(crossRobotManager))
                    {
                        return(ResponseHelper.Create <RobotResponse>(MessageCode.FailUpdate));
                    }
                }
            }
            if (!_crossRobotManagerDic.ContainsKey(managerId))
            {
                _crossRobotManagerDic.TryAdd(managerId, crossRobotManager);
            }
            var response = ResponseHelper.CreateSuccess <RobotResponse>();

            return(RobotCore.BuildRobotResponse(response, crossRobotManager));
        }
Ejemplo n.º 4
0
        MessageCode StopCrossRobotManager(Guid managerId, out CrossrobotManagerEntity entity)
        {
            entity = CrossrobotManagerMgr.GetById(managerId);
            if (entity == null || !GetHookStatus(entity))
            {
                return(MessageCode.InvalidArgs);
            }
            SetHookStatus(entity, false);
            entity.Status = (int)EnumRobotMatchStatus.Stop;
            LogHelper.Insert("test", LogType.Info);
            if (!CrossrobotManagerMgr.Update(entity))
            {
                return(MessageCode.FailUpdate);
            }
            LogHelper.Insert("test2", LogType.Info);
            CrossrobotManagerEntity newEntity = null;

            _crossRobotManagerDic.TryRemove(managerId, out newEntity);
            return(MessageCode.Success);
        }
Ejemplo n.º 5
0
        public RobotResponse RobotInfo(string siteId, Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId, false, siteId);

            if (manager == null)
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.MissManager));
            }

            var crossRobotManager = CrossrobotManagerMgr.GetById(managerId);

            if (crossRobotManager == null)
            {
                crossRobotManager = BuildCrossRobotManager(siteId, managerId);
                if (!CrossrobotManagerMgr.Insert(crossRobotManager))
                {
                    return(ResponseHelper.Create <RobotResponse>(MessageCode.FailUpdate));
                }
            }

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

            return(BuildRobotResponse(response, crossRobotManager));
        }
Ejemplo n.º 6
0
 void doCrossCrowdFinish(CrossrobotManagerEntity entity)
 {
     CrossrobotManagerMgr.UpdateStatus(entity.Idx, (int)EnumRobotMatchStatus.Stop);
 }