/// <summary>
        /// 庄赢X局后奖池中还有钱,可以选择手动下庄,
        /// </summary>
        public bool BankerGetBonusPot(int userid)
        {
            BullFight100User myu = GetUserByID(userid);

            if (myu == null)
            {
                return(false);
            }
            if (myu.CheckisWatch())
            {
                return(false);
            }
            if (!_quePosGetBanker.Contains(myu._Pos))
            {
                return(false);
            }
            int _firstPos = 0;

            if (!_quePosGetBanker.TryPeek(out _firstPos))
            {
                return(false);
            }
            if (_firstPos != myu._Pos)
            {
                return(false);
            }
            _quePosGetBanker.TryDequeue(out _firstPos);

            return(true);
        }
        /// <summary>
        /// 下注   1次
        /// </summary>
        public bool GambleOne(int userid, int _targetpos, int _gamble)
        {
            BullFight100User myu = GetUserByID(userid);

            if (myu == null)
            {
                return(false);
            }
            if (_DicPos2User[myu._Pos]._isBanker)
            {
                return(false);                                      //庄不能下注
            }
            if (myu.CheckisWatch())
            {
                return(false);
            }
            if (!_judge.CheckGambleMaxLimit())
            {
                return(false);
            }
            //if (!myu.CheckFirstDeal()) return; //可以下多次
            if (_targetpos > 4 || _targetpos < 2)
            {
                return(false);
            }
            if (_gamble < 1)
            {
                return(false);
            }
            if (myu._CurrentGold < _gamble)
            {
                return(false);
            }
            myu._CurrentGold -= _gamble;

            _dicPokerGambleTotal[_targetpos] += _gamble;
            _allGambleTotal += _gamble;
            if (_pos2GambleTable.ContainsKey(_targetpos))
            {
                _pos2GambleTable[_targetpos] += _gamble;
            }
            else
            {
                _pos2GambleTable.Add(_targetpos, _gamble);
            }

            _DicPos2User[myu._Pos].AddorUpdateGamble(_targetpos, _gamble);
            _DicPos2User[myu._Pos]._gambletime = DateTime.Now;
            NotifyGambleOne(myu._Pos, myu._Pos, _gamble);
            _strStatus = "GambleOver...5    ";
            return(true);
        }
        /// <summary>
        ///  设置自己要抢庄,等judge处理
        /// </summary>
        /// <param name="userid"></param>
        public bool ApplyGetBanker(int userid, bool getbanker)
        {
            lock (objLock)
            {
                BullFight100User myu = GetUserByID(userid);
                if (myu == null)
                {
                    return(false);
                }
                if (myu.CheckisWatch())
                {
                    return(false);
                }
                //if (!myu.CheckFirstDeal()) return false;
                if (myu._CurrentGold < 1000)
                {
                    return(false);                         //1000才能申请上庄
                }
                if (_quePosGetBanker.Contains(myu._Pos))
                {
                    return(false);                  //已在申请列表中的人不能再申请了
                }
                _quePosGetBanker.Enqueue(myu._Pos); //放入抢庄列表设置抢庄标识

                List <UserIDMSG> imList = new List <UserIDMSG>();
                ForeashAllDo((i) =>
                {
                    BullFight100User tempUser = _DicPos2User[i];

                    sc_getbankerone_bf100_n _getbanker_n = new sc_getbankerone_bf100_n()
                    {
                        fn = "sc_getbankerone_bf100_n", result = 1, _msgid = _TurnWaitTime
                    };
                    _getbanker_n.pos = myu._Pos;
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_getbanker_n), tempUser._isRobot, tempUser._isDisconnet));
                });
                BF100SendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);

                // if (HaveSomeBodyUnDeal()) return false;
                _strStatus = "GetBanker...4 all getbanker  ";
                return(true);
            }
        }
        /// <summary>
        /// 用户申请解散游戏
        /// </summary>
        /// <param name="userID"></param>
        public void ApplyExitTable(int userid)
        {
            lock (objLock)
            {
                BullFight100User myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (myu.CheckisWatch())
                {
                    return;                         //爆分的人不能申请
                }
                ExcuteDelayedLogic();
                if (_applyExitTable && myu._isAgreeExit != 2)
                {           //有可能在有人申请解散后,其他人没有收到消息,然后就出现所有人卡死在房间的  myu._isAgreeExit != 2 补丁,允许自己申请当成同意解散。
                    return; //如果 有人申请解散了 就不处理了,
                }
                //申请游戏解散想其它用户发送消息过后执行定时任务超过指定时间没人反应则强制解散房间
                ExcuteDelayedLogic();
                _applyExitTable = true;

                myu._isAgreeExit = 1;
                if (!_haveCheckRoomCard)
                {   //未开时扣房卡之前   1.如果是房主可以直接解散。2.非房主直接退出个人自己
                    if (_masterPos == myu._Pos)
                    {
                        DoExecuteExitTable(false, true);
                    }
                    else
                    {
                        base.ExitTableOne(myu._Pos, userid);//仅发送了消息,未处理逻辑,需要移出
                        BaseUser mybu;
                        base._pos2userbase.TryRemove(myu._Pos, out mybu);
                        _DicPos2User.TryRemove(myu._Pos, out myu);
                        _applyExitTable = false;
                        StopTimer();
                    }
                    return;
                }

                List <UserIDMSG> imList = new List <UserIDMSG>();
                ForeashAllDo((i) =>
                {
                    BullFight100User tempUser = _DicPos2User[i];

                    sc_applyexittable_n _gamble_n = new sc_applyexittable_n()
                    {
                        fn = "sc_applyexittable_n", result = 1, _msgid = _TurnWaitTime
                    };
                    _gamble_n.gameid = _gameid;
                    _gamble_n.pos    = myu._Pos;
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_gamble_n), tempUser._isRobot, tempUser._isDisconnet));
                });

                BF100SendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);

                //处理超时的动作      由_isAgreeExit状态自行处理
            }
        }
        /// <summary>
        /// 至少两人到位了进行 开局 ,开局就会扣掉配置钱===============================================
        /// </summary>
        private void Start(int userid)
        {
            lock (objLock)
            {
                BullFight100User myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (myu.CheckisWatch())
                {
                    return;
                }
                if (!myu.CheckFirstDeal())
                {
                    return;
                }
                //if (HaveSomeBodyUnDeal()) return;
                if (_numpertable < _num_min)
                {
                    return;
                }

                base.StartBase(60 * 4);
                _pos2UserID   = new Dictionary <int, int>();
                _pos2IPPort   = new Dictionary <int, string>();
                _pos2Money    = new Dictionary <int, decimal>();
                _pos2Win      = new Dictionary <int, bool>();
                _pos2CardList = new Dictionary <int, List <int> >();
                _pos2BullRate = new Dictionary <int, int>();
                _pos2Watch    = new Dictionary <int, int>();

                Queue <int> _tcardLeft = new Queue <int>();
                var         type       = _judge._gametype;
                _dicPokerList        = new Dictionary <int, List <int> >();
                _dicPokerBFType      = new Dictionary <int, PokerBullFightType>();
                _dicPokerGambleTotal = new Dictionary <int, int>();
                _pos2GambleTable     = new Dictionary <int, int>();

                _allGambleTotal = 0;
                _dicPokerList   = BullFight.DistributePoker(out _tcardLeft, 4);
                foreach (int key in _dicPokerList.Keys)
                {
                    _dicPokerBFType.Add(key, BullFight.GetBullType(_dicPokerList[key]));
                    _dicPokerGambleTotal.Add(key, 0);
                }

                ////Dictionary<int, int> _pos2RobotAI = new Dictionary<int, int>();
                ////ForeashAllDo((i) =>
                ////{
                ////    _pos2RobotAI.Add(i, _DicPos2User[i]._tbUser.winpercent); //_pos2RobotAI.Add(i, i == 1 ? 101 : 0);
                ////});
                ////_judge.ChangePokerByRobotAI(_pos2RobotAI, _dicPokerList);

                List <int> _temppoker0 = new List <int>()
                {
                    0, 0, 0, 0, 0
                };
                List <UserIDMSG>      imList  = new List <UserIDMSG>();
                List <CommonPosValSD> _uplist = new List <CommonPosValSD>();

                _judge.DealReduceDiamond();//执行扣房卡 已处理只扣一次
                _judge.SetCurTableorBankerCount();

                //同时把每位玩家的数据确认修改了 //发送消息到所有玩家
                ForeashAllDo((i) =>
                {
                    BullFight100User tempUser = _DicPos2User[i];

                    tempUser._isPlaying = true;
                    //tempUser._shouPaiArr = _pokerList[i];
                    tempUser._pos2Gameble  = new Dictionary <int, int>();
                    tempUser._showCardList = new List <int>()
                    {
                        0, 0, 0, 0, 0
                    };
                    _DicPos2User[i] = tempUser;//必须要赋值回去 要求有3个返馈才处理

                    _tablRecord.MatchCode = _tableMathCode;
                    _tablRecord._guid     = _guid;
                    _tablRecord.StartTime = DateTime.Now;
                    _pos2UserID.Add(i, tempUser._userid);
                    _pos2IPPort.Add(i, tempUser._IPandPort);
                    //发送通知消息
                    sc_tablestart_bf100_n _start = new sc_tablestart_bf100_n()
                    {
                        result = 1, fn = "sc_tablestart_bf100_n", _msgid = _TurnWaitTime
                    };
                    _start.tableid = _tableid;
                    _start.pos     = i;

                    _start._canGetBanker   = false;
                    _start._pos2userid     = _uplist;//所有玩家及对应 的位置信息
                    _start._curTableCount  = _judge._curTableOverCount;
                    _start._curBankerCount = 1;
                    _start.ShowCardList    = _temppoker0;
                    _start.closefun        = true;//需要抢庄,不关闭自动显示功能
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_start), tempUser._isRobot, tempUser._isDisconnet));
                });

                BF100SendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);
                _strStatus = "Start...3  ";

                DoExecuteSetBanker();
            }
        }