예제 #1
0
        /// <summary>
        /// 至少两人到位了进行 开局 ,开局就会扣掉配置钱===============================================
        /// </summary>
        private void Start( )
        {
            lock (objLock)
            {
                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>();
                Dictionary <int, List <int> > _pokerList = new Dictionary <int, List <int> >();

                _pokerList[0] = BullFight.GetPokerbyBullFightType(PokerBullFightType.Bull_Bull);

                Dictionary <int, int> _pos2RobotAI = new Dictionary <int, int>();
                ForeashAllDo((i) =>
                {
                    _pos2RobotAI.Add(i, _DicPos2User[i]._tbUser.winpercent);
                });
                //  _judge.ChangePokerByRobotAI(_pos2RobotAI, _pokerList);

                List <int> _temppoker0 = new List <int>()
                {
                    0, 0, 0, 0, 0
                };
                List <UserIDMSG>      imList  = new List <UserIDMSG>();
                List <CommonPosValSD> _uplist = new List <CommonPosValSD>();
                ForeashAllDo((i) =>
                {
                    _uplist.Add(new CommonPosValSD()
                    {
                        pos = i, val = _DicPos2User[i]._userid
                    });
                });

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

                    tempUser._isPlaying  = true;
                    tempUser._shouPaiArr = _pokerList[i];
                    _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_bfc_n _start = new sc_tablestart_bfc_n()
                    {
                        result = 1, fn = "sc_tablestart_bfc_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        = false;//需要报价抢庄,不关闭自动显示功能
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_start), tempUser._isRobot, tempUser._isDisconnet));
                });

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

                _DicPos2User[_bankpos].SetTimeOutAction(1, "sc_gambleover_bfc_n", 4 * 60);//1分钟等待时间
                _strStatus = "Start...3  ";
            }
        }
예제 #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已释放
            }
            BullColorUser myu = BullColorLobby.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;
            }
            int _waittime3000 = 4000;

            switch (_csdata.fn)
            {
            case "sc_entertable_n":     //自动 准备
                //Thread.Sleep(900);
                sc_entertable_n _entertable = JsonUtils.Deserialize <sc_entertable_n>(strMSG);
                BullColorTable  myt001      = BullColorLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                if (myt001 != null && myu._Pos == _entertable.pos)
                {
                    //// myt001.GetReady(myu._userid); //  自己的进房间通知才准备
                }
                break;

            case "sc_ready_bf_n":     //
                break;

            case "sc_tablestart_bf_n":
                int _waittimeStart = ToolsEx.GetRandomSys(600, 3000);
                Thread.Sleep(_waittimeStart);
                sc_tablestart_bfc_n _tablestart = JsonUtils.Deserialize <sc_tablestart_bfc_n>(strMSG);
                BullColorTable      myt         = BullColorLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                //根据需求判断 是否抢庄
                if (myt != null && !_tablestart.closefun && _tablestart._canGetBanker)
                {
                }
                break;

            case "sc_gambleone_bfc_n":
                break;

            case "sc_setbulltype_bfc_n":         //无AI处理 直接等待摊牌

                break;

            case "sc_showone_bfc_n": break;

            case "sc_showdown_bfc_n":
                //Thread.Sleep(410);
                break;

            case "sc_end_bfc_n":
                break;

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

            case "sc_dealexittable_n": break;

            case "sc_one_exittable_n": break;

            case "sc_exittable_n":    //AI 在有人退出的情况下,全都退出
                ////sc_exittable  _exittable = JsonUtils.Deserialize<sc_exittable>(strMSG);
                ////Thread.Sleep(10);
                ////BullFightUser myu_exit;
                ////DicIDtoUser.TryGetValue(UserID, out myu_exit);
                ////if (_exittable.pos != myu_exit._Pos)
                ////{   //自己的退出消息不再处理  但是只能处理一次
                ////    ////BullColorTable mytexit = BullColorLobby.GetTableByRoomIDandTableID(myu_exit._roomid, _exittable.tableid);
                ////    ////if (mytexit != null) mytexit.ExitTable(myu_exit._userid); //
                ////}
                break;

            case "sc_chat_n": break;

            case "sc_disconnect_n": break;

            case "sc_warning_n": break;

            case "020":      //此桌结束了,正常结束
                break;

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