示例#1
0
        /// <summary>
        /// 用户申请解散游戏
        /// </summary>
        /// <param name="userID"></param>
        public void ApplyExitTable(int userid)
        {
            lock (objLock)
            {
                TCUser myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (myu.CheckisWatch())
                {
                    return;                         //爆分的人不能申请
                }
                if (_applyExitTable)
                {
                    return;                 //如果 有人申请解散了 就不处理了,
                }
                _applyExitTable  = true;
                myu._isAgreeExit = 1;
                if (!_haveCheckRoomCard)
                {   //未开时扣房卡之前   1.如果是房主可以直接解散。2.非房主直接退出个人自己
                    if (_masterPos == myu._Pos)
                    {
                        DoExecuteExitTable(false);
                    }
                    else
                    {
                        base.ExitTableOne(myu._Pos, userid);//仅发送了消息,未处理逻辑,需要移出
                        base._pos2userbase.Remove(myu._Pos);
                        _DicPos2User.TryRemove(myu._Pos, out myu);
                    }
                    return;
                }

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

                    sc_applyexittable_n _gamble_n = new sc_applyexittable_n()
                    {
                        fn = "sc_applyexittable_n", result = 1, _msgid = _bsDataServer.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>
        /// <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状态自行处理
            }
        }
示例#3
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;
            }
        }
示例#4
0
        /// <summary>
        /// 摹仿客户端 消息处理  不加锁
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="strMSG"></param>
        private void RobotDealMSGEx(int UserID, string strMSG)
        {
            sc_base _csdata = JsonUtils.Deserialize <sc_base>(strMSG);

            if (_csdata == null)
            {
                TraceLogEx.Error(" 201206062216ll " + UserID);
                return;
            }

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

            case "sc_ready_ll_n":
                break;

            case "sc_tablestart_ll_n":

                break;

            case "sc_cangetbanker_ll":
                Thread.Sleep(1100);
                sc_cangetbanker_ll _cangetbanker    = JsonUtils.Deserialize <sc_cangetbanker_ll>(strMSG);
                LandLordTable      myt_cangetbanker = LandLordLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                //默认AI 直接抢庄
                if (myt_cangetbanker != null)
                {
                    if (_cangetbanker.pos == myu._Pos && !_cangetbanker.closefun)
                    {
                        myt_cangetbanker.GetBanker(myu._userid, true);                                                               //抢庄
                    }
                }
                break;

            case "sc_getbanker_ll_n":       //
                break;

            case "sc_canaddrate_ll_n":    //处理自己的加倍情况
                Thread.Sleep(1500);
                sc_canaddrate_ll_n _canaddrate    = JsonUtils.Deserialize <sc_canaddrate_ll_n>(strMSG);
                LandLordTable      myt_canaddrate = LandLordLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                //默认AI 直接加倍
                if (myt_canaddrate != null)
                {
                    myt_canaddrate.AddRate(myu._userid, true);     //加倍
                }
                break;

            case "sc_addrate_ll_n":
                break;

            case "sc_candiscard_ll_n":
                Thread.Sleep(700);
                sc_candiscard_ll_n _candiscard    = JsonUtils.Deserialize <sc_candiscard_ll_n>(strMSG);
                LandLordTable      myt_candiscard = LandLordLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                //默认AI 直接抢庄
                if (myt_candiscard != null)
                {
                    if (_candiscard.pos == myu._Pos && !_candiscard.closefun)
                    {
                        List <int> _DiscardMine = AIGetPai(myu, _candiscard._lastcard, myt_candiscard._judge._lastDiscardPos);
                        if (!myt_candiscard.DisCard(myu._userid, _DiscardMine))
                        {
                            TraceLogEx.Error("201702212024 fetal error  " + JsonUtils.Serialize(_DiscardMine));
                        }
                    }
                }
                break;

            case "sc_discard_ll_n":
                break;

            case "sc_end_ll_n":
                Thread.Sleep(1400);
                LandLordTable myt0014 = LandLordLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                if (myt0014 != null)
                {
                    myt0014.GetReady(myu._userid);                      //
                }
                break;

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

            case "sc_dealexittable_n": break;

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

                break;

            case "sc_one_exittable_n": break;

            case "sc_chat_n": break;

            case "sc_disconnect_n": break;

            case "sc_warning_n": break;

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

            default:
                TraceLogEx.Error("201206190957BF AI 未处理,strSID:" + _csdata.fn);
                break;
            }
        }
示例#5
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;
            }
        }