/// <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();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 摹仿客户端 消息处理  不加锁
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="strMSG"></param>
        private static void RobotDealMSG(int UserID, string strMSG)
        {
            UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(UserID);

            if (_us == null)
            {
                ErrorRecord.Record(" 201611301728BF " + UserID);
                return;
            }
            if (_us.Status == UserStatusEnum.InLobby)
            {
                return;                                      //一局结算了,收到的消息需要处理,也处理不了,Table已释放
            }
            BullFight100User myu = BullFight100Lobby.instance.GetUserByRoomIDandTableIDandUserID(_us.RoomID, _us.TableID, UserID);

            if (myu == null)
            {
                ErrorRecord.Record(" 201611301729BF " + UserID + ",_us.Status:" + _us.Status + " strMSG:" + strMSG);
                return;
            }
            sc_base _csdata = JsonUtils.Deserialize <sc_base>(strMSG);

            if (_csdata == null)
            {
                ErrorRecord.Record(" 201206062216BF " + UserID);
                return;
            }

            switch (_csdata.fn)
            {
            case "sc_entertable_n":     //自动 准备
                //Thread.Sleep(900);
                break;

            case "sc_tablestart_bf100_n":
                break;

            case "sc_applybanker_bf100_n":      //如果 自己是庄,需要执行庄下注
                int _waittimeStart = ToolsEx.GetRandomSys(600, 3000);
                Thread.Sleep(_waittimeStart);
                sc_tablestart_bf100_n _tablestart = JsonUtils.Deserialize <sc_tablestart_bf100_n>(strMSG);
                BullFight100Table     myt         = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                if (myt != null)
                {
                    lock (myt)
                    {
                        myt.GambleOne(myu._userid, 2, 10);     //下注
                    }
                }
                break;

            case "sc_getbankerone_bf_n":      //客户端显示 OK手势
                break;

            case "sc_gambleone_bf100_n":
                break;

            case "sc_end_bf100_n":
                sc_end_bf100_n _showdown = JsonUtils.Deserialize <sc_end_bf100_n>(strMSG);
                if (_showdown._OverTable == 1 || _showdown.gamemodel == 2)
                {
                    return;                                                           //OVer了
                }
                BullFight100Table _myt_showdown = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                BullFight100Table myt0014       = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                if (myt0014 != null && myt0014._judge._gameCoin2Room1 == 1)
                {
                }
                break;

            case "cs_bankergetbonuspot_bf100":     //有人下庄了

                break;

            case "sc_applyexittable_n":    //AI 都同意所有游戏解散
                Thread.Sleep(550);
                sc_applyexittable_n _applyExit      = JsonUtils.Deserialize <sc_applyexittable_n>(strMSG);
                BullFight100Table   _applyexitTable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                if (_applyexitTable != null)
                {
                    lock (_applyexitTable)
                    {
                        _applyexitTable.DealExitTable(myu._userid, true);
                    }
                }
                break;

            case "sc_showdown_bf100_n": break;

            case "sc_dealexittable_n": break;

            case "sc_one_exittable_n": break;

            case "sc_exittable_n":    //AI 在有人退出的情况下,全都退出

                break;

            case "sc_chat_n": break;

            case "sc_disconnect_n": break;

            case "sc_warning_n": break;

            default:
                ErrorRecord.Record("201206190957BF AI 未处理,strSID:" + _csdata.fn);
                break;
            }
        }