/// <summary>
        /// 如果是强制结束此桌,此桌不会记录与结处
        /// </summary>
        /// <param name="_forceOver"></param>
        private void DoExecuteAllEnd(bool _forceOver)
        {
            lock (objLock)
            {
                ForeashAllDo((i) =>
                {   //更新数据
                    tb_UserEx.UpdateData(_DicPos2User[i]._tbUser);
                });

                List <CommonPosValSD> _watchlist = new List <CommonPosValSD>();
                //写入此桌的金钱交易记录
                if (!_forceOver)
                {
                    _pos2CardList = new Dictionary <int, List <int> >(_dicPokerList);//记录手牌
                    ForeashAllDo((i) =>
                    {
                        _pos2Money.Add(i, _DicPos2User[i]._CurrentGold);
                        _pos2Win.Add(i, _judge.CheckGameOverWin(_DicPos2User[i]._CurrentGold));
                        int _bfRate = BullFight._dicbullfightRate[_DicPos2User[i]._bulltype];
                        _pos2BullRate.Add(i, _bfRate);

                        //更新数据
                        tb_UserEx.UpdateData(_DicPos2User[i]._tbUser);
                    });
                    ForeashAllDo((i) =>
                    {
                        //低于一定分数就当观众了
                        if (_judge.MinLimitMoney((int)_DicPos2User[i]._tbUser.UserMoney))
                        {
                            _DicPos2User[i]._isWatch = true;
                        }
                        else
                        {
                            _DicPos2User[i]._isWatch = false; //金币模式中上局没开始成功的
                        }
                        _watchlist.Add(new CommonPosValSD()
                        {
                            pos = i, val = _DicPos2User[i]._isWatch ? 1 : 0
                        });
                        _pos2Watch.Add(i, _DicPos2User[i]._isWatch ? 1 : 0);
                    });
                }
                else
                {
                    _gameover = _forceOver;
                }

                _tablRecord.ActionList = "";     //写入此桌的录相 记录
                _tablRecord.EndTime    = DateTime.Now;
                _tablRecord.gameid     = _gameid;
                _tablRecord._isover    = (_judge._gameCoin2Room1 == 2 ? true : _gameover);
                LogWriteToDB(_tablRecord);

                bool _bankerCanGetBonusPot = _judge.CheckCanBankerGetBonusPot();   //必须在结算了后面


                tb_TableMoneyLogEx.SetRateDataByTableNum(_guid, _gameover, _numpertable);

                List <CommonPosValSD> _pos2Gold1 = _judge.GetCurrentPosGold();
                //向X家返回结果 通知 结束
                List <UserIDMSG> imList = new List <UserIDMSG>();
                ForeashAllDo((i) =>
                {
                    BullFight100User tempUser = _DicPos2User[i];

                    sc_end_bf100_n _end_n = new sc_end_bf100_n()
                    {
                        fn = "sc_end_bf100_n", result = 1, _msgid = _TurnWaitTime
                    };                                                                                                         // 显示结束面板就行

                    _end_n.gamemodel  = _judge._gameCoin2Room1;
                    _end_n._OverTable = _gameover ? 1 : 0;
                    _end_n.createpos  = _masterPos;
                    _end_n._pos2Watch = _watchlist;
                    _end_n._pos2Gold  = _pos2Gold1;

                    _end_n.closefun = _bankerCanGetBonusPot ? true : false;// 能收取奖池的时候   客户端不自动走准备方法,等下一个命令
                    if (_judge._gameCoin2Room1 == 2 && tempUser._isRobot)
                    {
                        return;                                                  //结束不发给机器人
                    }
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_end_n), tempUser._isRobot, tempUser._isDisconnet));
                });

                BF100SendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);
                ForeashAllDo((i) => { _DicPos2User[i].SetTimeOutAction(1, "sc_end_bf100_n", _bankerCanGetBonusPot  ? _TurnWaitTime : 6); }); //下把的自动开始功能        ReStart();

                Reset(_gameover);                                                                                                            //准备下局, 重置此桌信息
            }
        }
Пример #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;
            }
        }