Exemple #1
0
        /// <summary>
        /// 正常轮换令牌。   通知所有人现在哪个说话
        /// </summary>
        private void NotifyNextUser(int userid)
        {
            lock (objLock)
            {
                TCUser myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (!myu.CheckFirstDeal())
                {
                    return;
                }
                if (HaveSomeBodyUnDeal())
                {
                    return;                       //其实只有一个等待操作
                }
                if (myu._Pos != _userTokenPos)
                {
                    ErrorRecord.Record("201611071850tc  不是你说话呀,,,,,,,bug....................");
                }


                _currentTurnCount++;
                if (_currentTurnCount >= _allTurnCount)
                {//所有人进行比牌,强制结束
                    CompareAll();
                    return;
                }
                if (GetGiveUp() >= _numpertable - 1)
                {
                    // End();   //==================================================================================
                    return;
                }

                //通知所有人
                List <UserIDMSG> imList = new List <UserIDMSG>();
                ForeashAllDo((i) =>
                {
                    TCUser tempUser = _DicPos2User[i];
                    if (i == _userTokenPos)
                    {
                        _DicPos2User[_userTokenPos].SetTimeOutAction(1, "sc_token_tc_n");//处理超时的动作
                    }

                    sc_token_tc_n _token = new sc_token_tc_n()
                    {
                        fn = "sc_token_tc_n", result = 1
                    };
                    _token.pos      = _userTokenPos;
                    _token.allmoney = _allMoney;
                    _token.alltoken = _allTurnCount;
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_token), tempUser._isRobot, tempUser._isDisconnet));
                });

                TCSendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);
            }
        }
        /// <summary>
        /// 摹仿客户端 消息处理  不加锁
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="strMSG"></param>
        private static void RobotDealMSG(int UserID, string strMSG)
        {
            if (!DicIDtoUser.ContainsKey(UserID))
            {   //同在BUG容易出现机器先清空了,没有收到结算的方法 需要延时处理      -------------==================================   什么器结算退出后需要休息一定的时间
                // ErrorRecord.Record(" 201206062215TC ");
                return;
            }
            sc_base _csdata = JsonUtils.Deserialize <sc_base>(strMSG);

            if (_csdata == null)
            {
                ErrorRecord.Record(" 201206062216TC ");
                return;
            }
            if (_csdata.fn == "")
            {
                ErrorRecord.Record(" 201206071117TC 没找到 _csdata.fn");
                return;
            }

            switch (_csdata.fn)
            {
            case "sc_entertable_n":     //自动 准备
                sc_entertable_n _entertable = JsonUtils.Deserialize <sc_entertable_n>(strMSG);
                Thread.Sleep(100);
                TCUser myuentertable;
                DicIDtoUser.TryGetValue(UserID, out myuentertable);

                TCTable myt001 = TCLobby.instance.GetTableByRoomIDandTableID(myuentertable._roomid, myuentertable._tableID);
                if (myt001 != null)
                {
                    myt001.GetReady(myuentertable._userid);                     //
                }
                break;

            case "sc_ready_tc_n":
                break;

            case "sc_entertable_tc_n":    //默认就是准备状态不处理的其他
                break;

            case "sc_tablestart_tc_n":
                break;

            case "sc_token_tc_n":     //判断是不是自己的token  AI只弃牌,如果有两个以前的机器人一直下注会卡,,,
                sc_token_tc_n _tabletoken = JsonUtils.Deserialize <sc_token_tc_n>(strMSG);
                Thread.Sleep(100);
                TCUser _myUserGiveUp;
                DicIDtoUser.TryGetValue(UserID, out _myUserGiveUp);
                if (_myUserGiveUp._Pos == _tabletoken.pos)
                {
                    TCTable _myt_token = TCLobby.instance.GetTableByRoomIDandTableID(_myUserGiveUp._roomid, _myUserGiveUp._tableID);
                    //if (_myt_token != null) _myt_token.GiveUp(_myUserGiveUp._userid); //弃牌
                    if (_myt_token != null)
                    {
                        _myt_token.Gamble(_myUserGiveUp._userid, 0);
                    }
                }
                break;

            case "sc_showcard_tc_n":
                break;

            case "sc_gamble_tc_n":
                break;

            case "sc_compare_tc_n":
                break;

            case "sc_giveup_tc_n":
                break;

            case "sc_end_tc_n":
                break;

            case "sc_exittable_n":
                ////sc_exittable_n _exittable = JsonUtils.Deserialize<sc_exittable_n>(strMSG);

                ////Thread.Sleep(10);
                ////TCUser myu_exit;
                ////DicIDtoUser.TryGetValue(UserID, out myu_exit);
                ////if (_exittable. != myu_exit._Pos)
                ////{   //自己的退出消息不再处理
                ////    TCTable mytexit = TCLobby.GetTableByRoomIDandTableID(myu_exit._roomid, _exittable.tableid);
                ////    if (mytexit != null) mytexit.ExitTable(myu_exit._userid); //
                ////}
                break;

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

            default:
                ErrorRecord.Record("201206190957 strSID:" + _csdata.fn);
                break;
            }
        }