Пример #1
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            string userWinLose = string.Empty;//玩家输赢记录。房间信息表


            if (!Gongyong.userlist.Any(w => w.session.SessionID.Equals(session.SessionID)))
            {
                session.Logger.Debug("GetH : 非法连接");
                session.Close();
                return;
            }
            var getdata = SendHu.ParseFrom(requestInfo.Body);

            Room r = Gongyong.roomlist.Find(u => u.RoomID == getdata.Roomid);

            if (r == null)
            {
                return;
            }
            if (!r.Is_Hu)
            {
                session.Logger.Debug("房间并无胡牌");
                return;
            }
            ThreadUtility.RemoveManagedThreadByRoomID(r.RoomID);
            CardUser card = Gongyong.FKUser.Find(u => u.roomid == getdata.Roomid);

            model.ServerMaJiang mjfh = new model.ServerMaJiang();
            var jp     = ReturnFJ.CreateBuilder();
            var muuser = Gongyong.mulist.Find(u => u.Openid.Equals(getdata.Openid) && u.RoomID == getdata.Roomid);

            if (muuser == null)
            {
                return;
            }
            muuser.Is_jiao = true;
            if (muuser.ByteData == requestInfo.Key)
            {
                return;
            }
            else
            {
                muuser.ByteData = requestInfo.Key;
            }

            var huType = ReturnHType.CreateBuilder().SetFWZ(getdata.FWZ).SetFWB(getdata.FWB).SetMJ(getdata.MJ).SetType(getdata.Type);

            if (getdata.DXInfoCount > 1)
            {
                huType.AddRangeDXInfo(getdata.DXInfoList);
            }
            byte[] HType = huType.Build().ToByteArray();
            if (getdata.Type != 1 && getdata.Type != 5)
            {
                model.ServerMaJiang mjh = new model.ServerMaJiang()
                {
                    PaiHs = getdata.MJ.PaiHS,
                    PaiId = getdata.MJ.PaiID
                };

                var roomUsers = Gongyong.mulist.FindAll(u => u.RoomID == getdata.Roomid);
                if (getdata.DXInfoCount > 1)
                {
                    for (int i = 0; i < getdata.DXInfoList.Count; i++)
                    {
                        foreach (var item in roomUsers)
                        {
                            if (item.ZS_Fw == getdata.DXInfoList[i].DXFW)//如果当期玩家为一炮多响的玩家之一,则在手牌中加上 放炮的牌
                            {
                                item.majiangs.Add(mjh);
                            }
                        }
                    }
                }
                else
                {
                    roomUsers.Find(u => u.ZS_Fw == getdata.FWZ).majiangs.Add(mjh);
                }
            }

            if (getdata.Type == 1 || getdata.Type == 5)
            {
                Gongyong.mulist.Find(u => u.ZS_Fw == getdata.FWZ && u.RoomID == getdata.Roomid).zm_count += 1;
            }
            else
            {
                var mjInfo = Gongyong.mulist.Find(u => u.ZS_Fw == getdata.FWB && u.RoomID == getdata.Roomid);
                mjInfo.dp_count += 1;
                mjInfo.chuda.RemoveAll(w => w.PaiHs == getdata.MJ.PaiHS && w.PaiId == getdata.MJ.PaiID);
            }


            ///没有翻鸡牌
            if (r.RoomPai.Count == 0)
            {
                mjfh.PaiHs = -1;
                mjfh.PaiId = 0;
            }
            else
            {
                mjfh = r.RoomPai[0];
            }



            jp.SetHS(mjfh.PaiHs);
            ///清除牌
            r.RoomPai.Clear();

            List <mjuser>     mjlist      = Gongyong.mulist.FindAll(u => u.RoomID == getdata.Roomid);
            var               settle      = ReturnJS.CreateBuilder();
            var               returnallmj = ReturnUserSPai.CreateBuilder();
            List <UserSettle> listjs      = new List <UserSettle>();

            listjs = new Ting().Settle(r.RoomID, mjfh, getdata);
            var senddjs = ReturnDJS.CreateBuilder();

            if (getdata.DXInfoCount <= 1)
            {
                if (getdata.FWZ != card.win)
                {
                    card.win        = getdata.FWZ;
                    card.lianzCount = 1;
                }
                else// (getdata.FWZ == card.win)
                {
                    card.lianzCount += 1;
                }
            }
            else
            {//连庄情况 ,庄家放炮,胡牌的庄, 一炮多响情况 就是 胡牌的最近的人是庄
             //一炮多响非连庄,  谁放炮 谁是庄
                if (r.is_lianz)
                {
                    int zhuang = 0;
                    if (getdata.FWB == card.win)
                    {
                        if (getdata.FWB == 4)
                        {
                            zhuang = 1;
                        }
                        else
                        {
                            zhuang = getdata.FWB + 1;
                        }
                        for (int i = 1; i <= 4; i++)
                        {
                            if (getdata.FWB == 4)
                            {
                                zhuang = 1;
                            }
                            if (getdata.DXInfoList.Any(w => w.DXFW == zhuang))
                            {
                                card.win = zhuang;
                                break;
                            }
                            zhuang++;
                        }
                    }
                    else
                    {
                        card.lianzCount += 1;
                    }
                }
                else
                {
                    card.win = getdata.FWB;
                }                               //非连庄谁放炮谁 是庄
            }

            foreach (var item in mjlist)
            {
                var jsddr = UserAJS.CreateBuilder();
                #region 旧代码
                //if (item.ZS_Fw == getdata.FWZ)
                //{
                //    ///判断清一色
                //    //if (item.majiangs[item.majiangs.Count - 1].PaiHs - item.majiangs[0].PaiHs < 8)
                //    //{
                //    //    int paihs = item.majiangs[0].PaiHs;
                //    //    int qyshs = 0;
                //    //    int qy = 0;
                //    //    if (paihs < 10)
                //    //    {
                //    //        qyshs = 1;
                //    //    }
                //    //    else if (paihs > 10 && paihs < 20)
                //    //    {
                //    //        qyshs = 2;
                //    //    }
                //    //    else
                //    //    {
                //    //        qyshs = 3;
                //    //    }

                //    //    switch (qyshs)
                //    //    {

                //    //        case 1:
                //    //            int count = item.Peng.FindAll(u => u.PaiHs > 10).Count;
                //    //            if (count > 0)
                //    //            {
                //    //                qy++;
                //    //            }
                //    //            if (!string.IsNullOrEmpty(item.Gong))
                //    //            {
                //    //                string gong = string.Copy(item.Gong);
                //    //                string[] arr = gong.Remove(gong.Length - 1, 1).Split(',');
                //    //                foreach (var itemgong in arr)
                //    //                {
                //    //                    if (int.Parse(itemgong[0].ToString()) > 10)
                //    //                    {
                //    //                        qy++;
                //    //                    }
                //    //                }
                //    //            }

                //    //            break;
                //    //        case 2:

                //    //            int countt = item.Peng.FindAll(u => u.PaiHs < 10 || u.PaiHs > 20).Count;
                //    //            if (countt > 0)
                //    //            {
                //    //                qy++;
                //    //            }
                //    //            if (!string.IsNullOrEmpty(item.Gong))
                //    //            {
                //    //                string gong = string.Copy(item.Gong);
                //    //                string[] arr = gong.Remove(gong.Length - 1, 1).Split(',');
                //    //                foreach (var itemgong in arr)
                //    //                {
                //    //                    if (int.Parse(itemgong[0].ToString()) < 10 || int.Parse(itemgong[0].ToString()) > 20)
                //    //                    {
                //    //                        qy++;
                //    //                    }
                //    //                }
                //    //            }

                //    //            break;
                //    //        case 3:

                //    //            int countw = item.Peng.FindAll(u => u.PaiHs < 20).Count;
                //    //            if (countw > 0)
                //    //            {
                //    //                qy++;
                //    //            }
                //    //            if (!string.IsNullOrEmpty(item.Gong))
                //    //            {
                //    //                string gong = string.Copy(item.Gong);
                //    //                string[] arr = gong.Remove(gong.Length - 1, 1).Split(',');
                //    //                foreach (var itemgong in arr)
                //    //                {
                //    //                    if (int.Parse(itemgong[0].ToString()) < 20)
                //    //                    {
                //    //                        qy++;
                //    //                    }
                //    //                }
                //    //            }

                //    //            break;
                //    //        default:
                //    //            break;
                //    //    }
                //    //    if (qy == 0)
                //    //    {
                //    //        item.paixinfs = 10;
                //    //    }

                //    //}
                //}
                #endregion


                UserInfo user    = Gongyong.userlist.Find(u => u.openid == item.Openid);
                var      usermjs = UserSPai.CreateBuilder();
                usermjs.SetFw(item.ZS_Fw);
                var returnmj = MaJiang.CreateBuilder();
                foreach (var itemmj in item.majiangs)
                {
                    returnmj.SetPaiHS(itemmj.PaiHs);
                    returnmj.SetPaiID(itemmj.PaiId);
                    usermjs.AddMj(returnmj);
                }
                returnallmj.AddUsp(usermjs);
                UserInfo gamer = Gongyong.userlist.Find(u => u.openid == item.Openid);
                var      users = Userinfo.CreateBuilder().SetHeadimg(gamer.headimg).SetNickname(gamer.nickname).SetOpenid(gamer.openid).SetSex(int.Parse(gamer.sex)).SetUserFW(item.ZS_Fw).SetUserBean(0).SetUserGold(0).SetUserID(gamer.UserID).Build();
                ///分数加减
                foreach (var items in listjs)
                {
                    if (items.openid == item.Openid)
                    {
                        var usersone = UserJS.CreateBuilder();

                        foreach (var itrmj in items.jp)
                        {
                            var jpone = JiPaiF.CreateBuilder().SetPaiHS(itrmj.PaiHS).SetType(itrmj.type).SetCount(itrmj.PaiScare);
                            usersone.AddJp(jpone);
                        }
                        foreach (var itemD in items.gang)
                        {
                            var jpdou = Dou.CreateBuilder().SetCount(itemD.DScare).SetType(itemD.DType);
                            usersone.AddDc(jpdou);
                        }
                        if (getdata.HasFWB)
                        {
                            var info = mjlist.Find(w => w.ZS_Fw == getdata.FWB && w.Openid.Equals(items.openid));
                            if (info != null)
                            {
                                if (items.pai_type != 11)
                                {
                                    items.pai_type = 11;
                                }
                            }
                        }
                        usersone.SetIsPao(items.pai_type);
                        usersone.SetIsJiao(items.is_jiao);
                        usersone.SetFS(items.scare);
                        usersone.SetUserinfo(users);
                        usersone.SetDyFs(items.dy_fs);
                        var HuLeiXin = getdata.DXInfoList.FirstOrDefault(w => w.DXFW == item.ZS_Fw);
                        if (HuLeiXin != null)
                        {
                            usersone.SetHuType(HuLeiXin.DXType);
                        }

                        settle.AddJs(usersone);


                        switch (item.ZS_Fw)
                        {
                        case 1:
                            card.dong += items.scare;
                            break;

                        case 2:
                            card.nan += items.scare;
                            break;

                        case 3:
                            card.xi += items.scare;
                            break;

                        case 4:
                            card.bei += items.scare;
                            break;

                        default:
                            break;
                        }
                    }
                }



                ///牌局结束,返回大结算
                if (r.Dcount == r.count)
                {
                    new CardsLogic().Clear(item, r);
                    jsddr.SetUser(users);
                    jsddr.SetZdou(item.zwd_count);
                    jsddr.SetZimo(item.zm_count);
                    jsddr.SetAndou(item.ad_count);
                    jsddr.SetMdou(item.MD_count);
                    jsddr.SetDianpao(item.dp_count);

                    //switch (item.ZS_Fw)
                    //{
                    //    case 1:
                    //        jsddr.SetScare(card.dong);
                    //        break;
                    //    case 2:
                    //        jsddr.SetScare(card.nan);
                    //        break;
                    //    case 3:
                    //        jsddr.SetScare(card.xi);
                    //        break;
                    //    case 4:
                    //        jsddr.SetScare(card.bei);
                    //        break;
                    //    default:
                    //        break;
                    //}
                    jsddr.SetScare(card.GetScoreByPosition(item.ZS_Fw));
                    senddjs.AddUserjs(jsddr);
                    senddjs.SetState(1);

                    RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERGAME, gamer.openid, gamer.unionid));

                    if (!string.IsNullOrEmpty(userWinLose))
                    {
                        userWinLose += "|";
                    }
                    userWinLose += user.UserID + "," + jsddr.Scare;
                }
            }
            //牌局回放 翻鸡
            var gameOperationInfoFJ = GameOperationInfo.CreateBuilder().AddMJ(MaJiang.CreateBuilder().SetPaiHS(jp.HS).SetPaiID(0)).SetOperationType(9);

            StringBuilder logtxt = new StringBuilder();

            logtxt.Append("胡牌" + getdata.ToString());
            foreach (var item in mjlist)
            {
                item.SendData.Clear();
                logtxt.Append(string.Join(",", item.majiangs.Select(w => w.PaiHs)));
                UserInfo user         = Gongyong.userlist.Find(u => u.openid == item.Openid);
                var      sendData5021 = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5021, HType.Length, requestInfo.MessageNum, HType));
                item.SendData.Add(sendData5021);

                byte[] allsp = returnallmj.Build().ToByteArray();

                byte[] jpr = jp.Build().ToByteArray();
                //7005 返回翻鸡牌
                var sendData7005 = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7005, jpr.Length, requestInfo.MessageNum, jpr));
                item.SendData.Add(sendData7005);

                //7008 : 玩家手牌集合
                var sendData7008 = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7008, allsp.Length, requestInfo.MessageNum, allsp));
                item.SendData.Add(sendData7008);

                byte[] settlebyte = settle.Build().ToByteArray();
                r.gameOperationProcess.SetJieSuanInfo(ByteString.CopyFrom(settlebyte));
                //7009 : 返回结算信息(全体)
                var sendData = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7009, settlebyte.Length, requestInfo.MessageNum, settlebyte));
                item.SendData.Add(sendData);

                if (r.Dcount == r.count)
                {
                    byte[] senddjsbyte = senddjs.Build().ToByteArray();
                    //5014 : 大结算信息
                    var sendData5014 = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5014, senddjsbyte.Length, requestInfo.MessageNum, senddjsbyte));
                    item.SendData.Add(sendData5014);
                }
                foreach (var senddata in item.SendData)
                {
                    user.session.TrySend(senddata);
                }
            }
            session.Logger.Debug(logtxt);
            //牌局回放 胡牌
            var gameOperationInfo = GameOperationInfo.CreateBuilder()
                                    .SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount)
                                    .SetOperationFW(huType.FWZ)
                                    .SetOperationType(5)
                                    .SetTingHuType(muuser.Is_tianHu ? 1 : 0)
                                    .SetPaoFW(huType.FWB);

            if (getdata.DXInfoCount > 1)
            {
                gameOperationInfo.AddRangeDXInfo(getdata.DXInfoList);
            }
            r.gameOperationProcess.AddGameOperationInfo(gameOperationInfo);
            gameOperationInfoFJ.SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount).SetOperationFW(0);
            r.gameOperationProcess.AddGameOperationInfo(gameOperationInfoFJ);
            try
            {
                CardsLogic.AddboarddetailsTB(r);
            }
            catch (Exception ex)
            {
                session.Logger.Error(ex);
            }
            ///对局结束 清空所有信息
            if (r.Dcount == r.count)
            {
                Gongyong.mulist.RemoveAll(u => u.RoomID == r.RoomID);
                Gongyong.FKUser.RemoveAll(u => u.roomid == r.RoomID);
                Gongyong.roomlist.RemoveAll(u => u.RoomID == r.RoomID);
                RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYROOMINFO, r.RoomID.ToString(), ""));
                new RoomInfoDAL().UpdateEndRoomInfoByRoomInfoID(new RoomInfo {
                    RoomInfoID = r.RoomInfoID, EndTime = DateTime.Now, EndStatus = 0, UserWinLose = userWinLose
                });
                foreach (var item in mjlist)
                {
                    UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                    new userRecordLOGDAL().Add(new userRecordlogLOG {
                        UserID = user.UserID, RoomInfoID = r.RoomInfoID, UserWinLose = userWinLose, EndTime = DateTime.Now, CreateDate = r.CreateDate, RoomID = r.RoomID
                    });
                }
                r.startgame = 0;
            }
            else
            {
                if (r != null)
                {
                    r.RoomPai   = new CreateMj().CreateMJ(r.IsYuanQue);
                    r.Dcount   += 1;
                    r.startgame = 2;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 碰杠过消息
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            if (!Gongyong.userlist.Any(w => w.session.SessionID.Equals(session.SessionID)))
            {
                session.Logger.Debug(" Gang : 非法连接");
                session.Close();
                return;
            }

            var returnmsg = ReturnMsg.CreateBuilder();

            var retumsg  = ReturnPeng.CreateBuilder();
            var sendinfo = SendPeng.ParseFrom(requestInfo.Body);

            session.Logger.Debug(sendinfo);
            var           jp     = ReturnFJ.CreateBuilder();
            Room          r      = Gongyong.roomlist.Find(u => u.RoomID == sendinfo.Roomid);
            mjuser        mjuser = Gongyong.mulist.Find(u => u.RoomID == sendinfo.Roomid && u.Openid == sendinfo.Openid);
            List <mjuser> mjlist = Gongyong.mulist.FindAll(u => u.RoomID == sendinfo.Roomid);
            List <model.ServerMaJiang> listmj = new List <model.ServerMaJiang>();

            model.ServerMaJiang mjfh = new model.ServerMaJiang();

            if (!string.IsNullOrEmpty(mjuser.ByteData) && mjuser.ByteData.Equals(sendinfo.ToString()))
            {
                session.Logger.Debug("消息重复");
                return;
            }
            else
            {
                mjuser.ByteData = sendinfo.ToString();
            }

            if (mjuser == null)
            {
                session.Logger.Debug("用户不存在");
                return;
            }

            if (r.DQHY != 0 && r.DQHY != mjuser.ZS_Fw)
            {
                session.Logger.Debug("不是活跃用户");
                return;
            }
            mjuser.SendData.Clear();
            ThreadUtility.RemoveManagedThread(mjuser.Openid); //当用户已做操作 取消用户的倒计时
            var           zrjxx    = ReturnZR.CreateBuilder();
            List <HuInfo> huList   = new List <HuInfo>();     //处理一炮多响新增一个胡牌类型对象
            var           info     = mjlist.FirstOrDefault(w => w.ZS_Fw == sendinfo.FW);
            bool          isDelete = false;

            if (info != null)//先删除牌,否则过牌时判断冲锋鸡 会有问题
            {
                session.Logger.Debug("删除牌前手牌有 " + info.chuda.Count);
                isDelete = info.chuda.Remove(info.chuda.Find(w => w.PaiHs == sendinfo.Mj.PaiHS && w.PaiId == sendinfo.Mj.PaiID));
                session.Logger.Debug("删除牌前手牌后 " + info.chuda.Count);
            }
            ///不是过
            if (sendinfo.State == 1)
            {
                switch (sendinfo.Types)
                {
                ///碰
                case 1:
                    if (sendinfo.Mj.PaiHS != r.LastChuMJ.PaiHs || sendinfo.Mj.PaiID != r.LastChuMJ.PaiId)
                    {
                        session.Logger.Debug(r.LastChuMJ + "碰的牌不是最后一张打出的牌" + mjuser.Openid);
                        return;
                    }
                    listmj = mjuser.majiangs.FindAll(u => u.PaiHs == sendinfo.Mj.PaiHS);
                    List <model.ServerMaJiang> listP = mjuser.majiangs.FindAll(u => u.PaiHs == sendinfo.Mj.PaiHS);
                    if (listP.Count < 2)
                    {
                        session.Logger.Debug("碰的牌不够2张" + mjuser.Openid);
                        return;
                    }
                    mjuser.majiangs.Remove(listP[0]);
                    mjuser.majiangs.Remove(listP[1]);
                    mjuser.Peng.AddRange(listmj);
                    mjuser.Peng.Add(listmj[0]);
                    retumsg.SetState(1);
                    retumsg.SetMj(sendinfo.Mj);
                    retumsg.SetFw(mjuser.ZS_Fw);
                    retumsg.SetPfw(sendinfo.FW);

                    int    cfj        = 0;
                    int    wgj        = 0;
                    mjuser mjnewusers = Gongyong.mulist.Find(u => u.ZS_Fw == sendinfo.FW && u.RoomID == sendinfo.Roomid);
                    //判断责任鸡
                    if (sendinfo.Mj.PaiHS == 11)
                    {
                        foreach (var item in mjlist)
                        {
                            int count = item.chuda.FindAll(u => u.PaiHs == 11).Count;
                            if (count > 0)
                            {
                                cfj++;
                                break;
                            }
                        }
                        if (cfj == 0)
                        {
                            mjuser.Is_zrj     = 1;
                            mjnewusers.Is_cfj = false;
                            mjnewusers.Is_zrj = -1;
                            zrjxx.SetGtype(1);
                            zrjxx.SetZrfw(mjnewusers.ZS_Fw);
                            zrjxx.SetDzrfw(mjuser.ZS_Fw);
                        }
                    }
                    ///判断责任乌骨
                    if (r.is_wgj)
                    {
                        if (sendinfo.Mj.PaiHS == 8)
                        {
                            foreach (var item in mjlist)
                            {
                                int count = item.chuda.FindAll(u => u.PaiHs == 8).Count;
                                if (count > 0)
                                {
                                    wgj++;
                                    break;
                                }
                            }
                            if (wgj == 0)
                            {
                                mjuser.is_zrwg     = 1;
                                mjnewusers.is_cfwg = false;
                                mjnewusers.is_zrwg = -1;
                                zrjxx.SetGtype(2);
                                zrjxx.SetZrfw(mjnewusers.ZS_Fw);
                                zrjxx.SetDzrfw(mjuser.ZS_Fw);
                            }
                        }
                    }
                    r.DQHY = mjuser.ZS_Fw;
                    r.DQcz = "3001";    //出牌
                                        //牌局回放 碰牌
                    r.gameOperationProcess.AddGameOperationInfo(
                        GameOperationInfo.CreateBuilder()
                        .SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount)
                        .SetOperationFW(mjuser.ZS_Fw)
                        .SetOperationType(3)
                        .AddMJ(sendinfo.Mj)
                        .SetPengFW(mjnewusers.ZS_Fw)
                        .SetMJType(mjuser.Is_zrj == 1 ? "ZRJ" : (mjuser.is_zrwg == 1 ? "ZRWG" : ""))
                        );

                    break;

                //杠
                case 2:
                    int gangType = 0;
                    ///杠类型判断
                    switch (sendinfo.Gtype)
                    {
                    case "A":
                        //if (r.LastMoMJ != null && (sendinfo.Mj.PaiHS != r.LastMoMJ.PaiHs || sendinfo.Mj.PaiID != r.LastMoMJ.PaiId))
                        //{
                        //    session.Logger.Debug("M杠的牌不是最后一张摸到的牌" + mjuser.Openid);
                        //    return;
                        //}
                        if (mjuser.majiangs.Where(w => w.PaiHs == sendinfo.Mj.PaiHS).Count() < 3)
                        {
                            session.Logger.Debug("A杠的牌不是不够3张" + mjuser.Openid);
                            return;
                        }
                        mjuser.ad_count += 1;
                        gangType         = 5;
                        break;

                    case "Z":
                        if (sendinfo.Mj.PaiHS != r.LastMoMJ.PaiHs || sendinfo.Mj.PaiID != r.LastMoMJ.PaiId)
                        {
                            session.Logger.Debug("M杠的牌不是最后一张摸到的牌" + mjuser.Openid);
                            return;
                        }
                        if (!mjuser.Peng.Any(u => u.PaiHs == sendinfo.Mj.PaiHS))
                        {
                            session.Logger.Debug("Z杠的牌不是不够3张" + mjuser.Openid);
                            return;
                        }
                        mjuser.zwd_count += 1;
                        gangType          = 6;
                        break;

                    case "M":
                        if (sendinfo.Mj.PaiHS != r.LastChuMJ.PaiHs || sendinfo.Mj.PaiID != r.LastChuMJ.PaiId)
                        {
                            session.Logger.Debug("M杠的牌不是最后一张打出的牌" + mjuser.Openid);
                            return;
                        }
                        if (mjuser.majiangs.Where(w => w.PaiHs == sendinfo.Mj.PaiHS).Count() < 3)
                        {
                            session.Logger.Debug("M杠的牌不是不够3张" + mjuser.Openid);
                            return;
                        }
                        mjuser.MD_count += 1;
                        gangType         = 4;
                        break;

                    case "H":
                        if (mjuser.majiangs.Where(w => w.PaiHs == sendinfo.Mj.PaiHS).Count() < 3 && !mjuser.Peng.Any(u => u.PaiHs == sendinfo.Mj.PaiHS))
                        {
                            session.Logger.Debug("H杠的牌不是不够3张或者碰牌区没有" + mjuser.Openid);
                            return;
                        }
                        gangType = 7;
                        break;

                    default:
                        break;
                    }

                    mjuser.majiangs.RemoveAll(u => u.PaiHs == sendinfo.Mj.PaiHS);
                    mjuser.Gong += sendinfo.Mj.PaiHS + "|" + sendinfo.FW + "|" + sendinfo.Gtype + ",";
                    retumsg.SetState(2);
                    retumsg.SetMj(sendinfo.Mj);
                    retumsg.SetFw(mjuser.ZS_Fw);
                    retumsg.SetPfw(sendinfo.FW);
                    retumsg.SetGtype(sendinfo.Gtype);
                    //var gangInfo = mjlist.FirstOrDefault(w => w.ZS_Fw == sendinfo.FW);
                    //if (gangInfo != null)
                    //    gangInfo.chuda.Remove(gangInfo.chuda.Find(w => w.PaiHs == sendinfo.Mj.PaiHS && w.PaiId == sendinfo.Mj.PaiID));
                    ///明豆
                    if (sendinfo.Gtype == "M")
                    {
                        mjuser mjnewuser = Gongyong.mulist.Find(u => u.ZS_Fw == sendinfo.FW && u.RoomID == sendinfo.Roomid);

                        if (sendinfo.Mj.PaiHS == 11)
                        {
                            mjuser.Is_zrj    = 1;
                            mjnewuser.Is_cfj = false;
                            mjnewuser.Is_zrj = -1;
                            zrjxx.SetGtype(1);
                            zrjxx.SetZrfw(mjnewuser.ZS_Fw);
                            zrjxx.SetDzrfw(mjuser.ZS_Fw);
                        }

                        if (r.is_wgj)
                        {
                            if (sendinfo.Mj.PaiHS == 8)
                            {
                                mjuser.is_zrwg    = 1;
                                mjnewuser.is_cfwg = false;
                                mjnewuser.is_zrwg = -1;
                                zrjxx.SetGtype(2);
                                zrjxx.SetZrfw(mjnewuser.ZS_Fw);
                                zrjxx.SetDzrfw(mjuser.ZS_Fw);
                            }
                        }
                    }
                    ///转弯都抢杠
                    if (sendinfo.Gtype == "Z")
                    {
                        mjuser.Peng.RemoveAll(u => u.PaiHs == sendinfo.Mj.PaiHS);
                        foreach (var item in mjlist)
                        {
                            if (item.ZS_Fw != mjuser.ZS_Fw)
                            {
                                List <model.ServerMaJiang> mah = new List <model.ServerMaJiang>();
                                mah.AddRange(item.majiangs.ToArray());
                                model.ServerMaJiang mjone = new model.ServerMaJiang()
                                {
                                    PaiHs = sendinfo.Mj.PaiHS,
                                    PaiId = sendinfo.Mj.PaiID
                                };
                                mah.Add(mjone);

                                if (new Ting().GetTing(mah) == "H")
                                {
                                    //var sendh = ReturnHByType.CreateBuilder();
                                    //sendh.SetFWZ(item.ZS_Fw);
                                    //sendh.SetFWB(mjuser.ZS_Fw);
                                    //sendh.SetType(3);
                                    //sendh.SetMJ(sendinfo.Mj);
                                    //byte[] rbyte = sendh.Build().ToByteArray();
                                    //Gongyong.userlist.Find(u => u.openid == item.Openid).session.TrySend(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5015, rbyte.Length, requestInfo.MessageNum, rbyte)));
                                    HuInfo huInfo = new HuInfo();
                                    huInfo.HuIndex  = item.ZS_Fw;
                                    huInfo.HuType   = 3;
                                    huInfo.MJ       = mjone;
                                    huInfo.OpenID   = item.Openid;
                                    huInfo.PaoIndex = mjuser.ZS_Fw;
                                    huInfo.RoomID   = r.RoomID;
                                    huList.Add(huInfo);
                                    item.IsGrabBars           = true;
                                    item.WasGrabbedUserOpenID = mjuser.Openid;
                                    r.DQHY = item.ZS_Fw;
                                }
                            }
                        }
                        //if (mjlist.Any(w => w.IsGrabBars))
                        //    return;
                    }
                    //憨包豆
                    if (sendinfo.Gtype == "H")
                    {
                        if (mjuser.Peng.Any(u => u.PaiHs == sendinfo.Mj.PaiHS))
                        {
                            mjuser.Peng.RemoveAll(u => u.PaiHs == sendinfo.Mj.PaiHS);
                            foreach (var item in mjlist)
                            {
                                if (item.ZS_Fw != mjuser.ZS_Fw)
                                {
                                    List <model.ServerMaJiang> mah = new List <model.ServerMaJiang>();
                                    mah.AddRange(item.majiangs.ToArray());
                                    model.ServerMaJiang mjone = new model.ServerMaJiang()
                                    {
                                        PaiHs = sendinfo.Mj.PaiHS,
                                        PaiId = sendinfo.Mj.PaiID
                                    };
                                    mah.Add(mjone);

                                    if (new Ting().GetTing(mah) == "H")
                                    {
                                        //var sendh = ReturnHByType.CreateBuilder();
                                        //sendh.SetFWZ(item.ZS_Fw);
                                        //sendh.SetFWB(mjuser.ZS_Fw);
                                        //sendh.SetType(3);
                                        //sendh.SetMJ(sendinfo.Mj);
                                        //byte[] rbyte = sendh.Build().ToByteArray();
                                        //Gongyong.userlist.Find(u => u.openid == item.Openid).session.TrySend(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5015, rbyte.Length, requestInfo.MessageNum, rbyte)));

                                        HuInfo huInfo = new HuInfo();
                                        huInfo.HuIndex  = item.ZS_Fw;
                                        huInfo.HuType   = 3;
                                        huInfo.MJ       = mjone;
                                        huInfo.OpenID   = item.Openid;
                                        huInfo.PaoIndex = mjuser.ZS_Fw;
                                        huInfo.RoomID   = r.RoomID;
                                        huList.Add(huInfo);

                                        item.IsGrabBars           = true;
                                        item.WasGrabbedUserOpenID = mjuser.Openid;
                                        r.DQHY = item.ZS_Fw;
                                    }
                                }
                            }
                        }
                    }
                    r.DQHY = mjuser.ZS_Fw;
                    //牌局回放 杠牌
                    r.gameOperationProcess.AddGameOperationInfo(
                        GameOperationInfo.CreateBuilder()
                        .SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount)
                        .SetOperationFW(mjuser.ZS_Fw)
                        .SetOperationType(4)
                        .AddMJ(sendinfo.Mj)
                        .SetPengFW(sendinfo.FW)
                        .SetTingHuType(gangType)
                        .SetMJType(mjuser.Is_zrj == 1 ? "ZRJ" : (mjuser.is_zrwg == 1 ? "ZRWG" : ""))
                        );
                    break;

                case 3:
                    //if (r.count == r.Dcount)
                    //{
                    //    Gongyong.roomlist.Remove(r);
                    //    Gongyong.mulist.RemoveAll(u => u.RoomID == sendinfo.Roomid);
                    //}
                    //mjfh = r.RoomPai[0];
                    //jp.SetHS(mjfh.PaiHs);
                    break;

                default:
                    break;
                }
            }
            //过
            else
            {
                session.Logger.Debug("过牌");
                string mjType = string.Empty;

                //过类型
                if (sendinfo.Types == 1 || (sendinfo.Types == 2 && sendinfo.Gtype.Equals("M")) || (sendinfo.Types == 3 && sendinfo.FW != mjuser.ZS_Fw))
                {
                    //判断幺鸡过,是否下发冲锋鸡消息
                    if (sendinfo.Mj.PaiHS == 11)
                    {
                        bool cfj = true;
                        // List<mjuser> listnewJP = Gongyong.mulist.FindAll(U => U.RoomID == sendinfo.Roomid);
                        foreach (var item in mjlist)
                        {
                            int Ccount = item.chuda.FindAll(u => u.PaiHs == 11).Count;
                            if (Ccount > 0)
                            {
                                cfj = false;
                            }
                        }

                        if (cfj)
                        {
                            returnmsg.SetFW(sendinfo.FW);
                            returnmsg.SetMj(MaJiang.CreateBuilder().SetPaiHS(0).SetPaiID(0));
                            returnmsg.SetMsg("CFJ");
                            info.Is_cfj = true;
                            //  listnewJP.Find(w => w.ZS_Fw == sendinfo.FW).chuda.Add(new model.ServerMaJiang { PaiHs = 11, PaiId = sendinfo.HasMj ? sendinfo.Mj.PaiID : 211 });
                            mjType = returnmsg.Msg;
                            byte[] byteball = returnmsg.Build().ToByteArray();
                            foreach (var item in mjlist)
                            {
                                Gongyong.userlist.Find(u => u.openid == item.Openid).session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3009, byteball.Length, requestInfo.MessageNum, byteball)));
                            }
                        }
                    }

                    ///判断乌骨鸡过是否下发乌骨鸡消息
                    if (sendinfo.Mj.PaiHS == 8)
                    {
                        bool WGJ = true;
                        //  List<mjuser> listnewJPW = Gongyong.mulist.FindAll(U => U.RoomID == sendinfo.Roomid);
                        foreach (var item in mjlist)
                        {
                            int Ccount = item.chuda.FindAll(u => u.PaiHs == 8).Count;
                            if (Ccount > 0)
                            {
                                WGJ = false;
                            }
                        }

                        if (WGJ)
                        {
                            returnmsg.SetFW(sendinfo.FW);
                            returnmsg.SetMj(MaJiang.CreateBuilder().SetPaiHS(0).SetPaiID(0));
                            returnmsg.SetMsg("CFWG");
                            info.is_cfwg = true;
                            // listnewJPW.Find(w => w.ZS_Fw == sendinfo.FW).chuda.Add(new model.ServerMaJiang { PaiHs = 8, PaiId = sendinfo.HasMj ? sendinfo.Mj.PaiID : 208 });
                            mjType = returnmsg.Msg;
                            byte[] byteball = returnmsg.Build().ToByteArray();
                            foreach (var item in mjlist)
                            {
                                Gongyong.userlist.Find(u => u.openid == item.Openid).session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3009, byteball.Length, requestInfo.MessageNum, byteball)));
                            }
                        }
                    }
                }
                if (isDelete)
                {
                    info.chuda.Add(new model.ServerMaJiang {
                        PaiHs = sendinfo.Mj.PaiHS, PaiId = sendinfo.HasMj ? sendinfo.Mj.PaiID : 208
                    });
                }

                //牌局回放 过牌
                if (returnmsg.HasMsg)
                {
                    r.gameOperationProcess.AddGameOperationInfo(
                        GameOperationInfo.CreateBuilder()
                        .SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount)
                        .SetOperationFW(mjuser.ZS_Fw)
                        .SetOperationType(7)
                        .SetPengFW(returnmsg.FW)
                        .SetMJType(returnmsg.Msg)
                        );
                }
                else
                {
                    r.gameOperationProcess.AddGameOperationInfo(
                        GameOperationInfo.CreateBuilder()
                        .SetSerialNumber(r.gameOperationProcess.GameOperationInfoCount)
                        .SetOperationFW(mjuser.ZS_Fw)
                        .SetOperationType(7)
                        );
                }
                List <RoomMsgWirte> msglist = new List <RoomMsgWirte>();
                msglist = Gongyong.roommsg.FindAll(u => u.roomid == r.RoomID);
                session.Logger.Debug("过牌判断" + msglist.Count);
                if (msglist.Count > 0 && sendinfo.Types != 4 && sendinfo.Types != 5)
                {
                    foreach (var item in msglist)
                    {
                        var userInfo = Gongyong.userlist.Find(u => u.openid == item.openid);
                        if (userInfo != null)
                        {
                            userInfo.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + item.xiaoxihao, item.ArrList.Length, requestInfo.MessageNum, item.ArrList)));
                            r.DQHY = mjlist.Find(u => u.Openid.Equals(item.openid)).ZS_Fw;
                            r.DQcz = item.operating;
                            session.Logger.Debug("过牌后根据之前的消息分配活跃用户" + r.DQHY);
                        }
                    }

                    Gongyong.roommsg.RemoveAll(u => u.roomid == r.RoomID);
                    retumsg.SetState(4);
                    retumsg.SetMj(sendinfo.Mj);
                }
                else if (mjuser.IsGrabBars)
                {
                    session.Logger.Debug("过牌判断抢杠");
                    mjuser.IsGrabBars = false;
                    var PGH = ReturnAll.CreateBuilder();
                    PGH.SetMo(1);
                    PGH.SetFw(mjuser.ZS_Fw);
                    PGH.SetMType(1);
                    mjuser.Mtype = 1;
                    byte[] bytegou = PGH.Build().ToByteArray();
                    var    user    = Gongyong.userlist.Find(u => u.openid.Equals(mjuser.WasGrabbedUserOpenID));
                    var    mjaure  = mjlist.Find(w => w.Openid.Equals(mjuser.WasGrabbedUserOpenID));
                    r.DQHY = mjaure.ZS_Fw;
                    user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3008, bytegou.Length, requestInfo.MessageNum, bytegou)));
                }

                ///下发摸牌出牌消息
                else
                {
                    session.Logger.Debug("过牌摸牌");
                    var      shy  = ReturnHyUser.CreateBuilder();
                    CardUser card = Gongyong.FKUser.Find(u => u.roomid == mjuser.RoomID);
                    if (sendinfo.Types == 4 && mjuser.Is_tiant)//天听过牌
                    {
                        mjuser.Is_tiantX = 0;
                        mjuser.Is_tiant  = false;
                        if (!mjlist.Any(w => w.Is_tiantX == -1))
                        {
                            r.DQHY = card.win;
                            r.DQcz = "3001";
                            byte[] startHY = ReturnHyUser.CreateBuilder().SetCz("3001").SetFw(card.win).Build().ToByteArray();
                            foreach (var item in mjlist)
                            {
                                UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                                user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7004, startHY.Length, requestInfo.MessageNum, startHY)));
                            }
                            msglist = Gongyong.roommsg.FindAll(u => u.roomid == r.RoomID);
                            if (msglist.Count > 0)
                            {
                                // Room r = Gongyong.roomlist.Find(u => u.RoomID == r.RoomID);
                                foreach (var msgitem in msglist)
                                {
                                    var userInfo = Gongyong.userlist.Find(u => u.openid == msgitem.openid);
                                    if (userInfo != null)
                                    {
                                        var mjUser = mjlist.Find(u => u.Openid.Equals(msgitem.openid));
                                        r.DQHY = mjUser.ZS_Fw;
                                        mjUser.SendData.Clear();
                                        var data = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + msgitem.xiaoxihao, msgitem.ArrList.Length, requestInfo.MessageNum, msgitem.ArrList));
                                        userInfo.session.TrySend(data);
                                        //session.Logger.Debug("过牌后根据之前的消息分配活跃用户" + r.DQHY);
                                    }
                                }
                                Gongyong.roommsg.RemoveAll(u => u.roomid == r.RoomID);
                            }
                        }
                        return;
                    }
                    else if (sendinfo.Types == 5 && mjuser.Is_tianHu)
                    {
                        mjuser.Is_tianHu = false;
                        r.DQHY           = card.win;
                        r.DQcz           = "3001";
                        byte[] startHY = ReturnHyUser.CreateBuilder().SetCz("3001").SetFw(card.win).Build().ToByteArray();
                        foreach (var item in mjlist)
                        {
                            UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                            user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7004, startHY.Length, requestInfo.MessageNum, startHY)));
                        }
                        return;
                    }

                    else if ((sendinfo.Gtype.ToUpper() != "M" && sendinfo.Types == 2) || (sendinfo.Types == 3 && sendinfo.FW == mjuser.ZS_Fw))
                    {
                        if (mjuser.majiangs.Any(w => w.PaiId == sendinfo.Mj.PaiID) || sendinfo.Mj.PaiID == 0)// 有些情况在放炮过牌的时候会让过牌的用户出牌,然而应该摸牌
                        {
                            shy.SetCz("3001");
                            shy.SetFw(mjuser.ZS_Fw);
                            retumsg.SetState(4);
                            retumsg.SetMj(sendinfo.Mj);
                            retumsg.SetFw(mjuser.ZS_Fw);
                            retumsg.SetPfw(sendinfo.FW);
                            r.DQcz = "3001";
                        }
                        else
                        {
                            UserInfo user = Gongyong.userlist.Find(u => u.openid == mjuser.Openid);
                            r.DQcz = "30083";
                            var PGH = ReturnAll.CreateBuilder();
                            PGH.SetMo(1);
                            PGH.SetFw(mjuser.ZS_Fw);
                            mjuser.Mtype = 0;
                            byte[] bsss = PGH.Build().ToByteArray();
                            user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3008, bsss.Length, requestInfo.MessageNum, bsss)));
                        }
                    }
                    else //if( (sendinfo.Types == 3 && sendinfo.FW != mjuser.ZS_Fw))
                    {
                        if (sendinfo.Types == 3 && sendinfo.FW != mjuser.ZS_Fw)
                        {
                            mjuser.IsGuoHu = true;
                        }
                        shy.SetCz("30083");
                        // int peocount = Convert.ToInt32(r.room_peo.Remove(1, 1));
                        int peocount = r.room_peo;
                        if (sendinfo.FW == peocount)
                        {
                            r.DQHY = 1;
                            r.DQcz = "30083";
                            string   openid = mjlist.Find(u => u.ZS_Fw == 1).Openid;
                            UserInfo user   = Gongyong.userlist.Find(u => u.openid == openid);


                            shy.SetFw(1);

                            var PGH = ReturnAll.CreateBuilder();
                            PGH.SetMo(1);
                            PGH.SetFw(mjuser.ZS_Fw);
                            mjuser.Mtype = 0;
                            byte[] bsss = PGH.Build().ToByteArray();
                            user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3008, bsss.Length, requestInfo.MessageNum, bsss)));
                        }
                        else
                        {
                            r.DQHY = sendinfo.FW + 1;
                            r.DQcz = "30083";
                            string openid = mjlist.Find(u => u.ZS_Fw == sendinfo.FW + 1).Openid;

                            UserInfo user = Gongyong.userlist.Find(u => u.openid == openid);
                            var      PGH  = ReturnAll.CreateBuilder();
                            PGH.SetMo(1);
                            mjuser.Mtype = 0;
                            PGH.SetFw(Gongyong.mulist.Find(u => u.ZS_Fw == sendinfo.FW + 1).ZS_Fw);
                            shy.SetFw(Gongyong.mulist.Find(u => u.ZS_Fw == sendinfo.FW + 1).ZS_Fw);
                            byte[] bsss = PGH.Build().ToByteArray();
                            user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3008, bsss.Length, requestInfo.MessageNum, bsss)));
                        }
                        retumsg.SetState(4);
                        if (sendinfo.Mj.HasPaiHS)
                        {
                            retumsg.SetMj(sendinfo.Mj);
                        }
                        retumsg.SetFw(mjuser.ZS_Fw);
                        retumsg.SetPfw(sendinfo.FW);
                        r.DQcz = "30083";
                    }



                    byte[] senhy = shy.Build().ToByteArray();

                    session.Logger.Debug(shy.Build());
                    foreach (var item in mjlist)
                    {
                        UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                        user.IsActive = true;
                        user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7004, senhy.Length, requestInfo.MessageNum, senhy)));
                    }
                }
            }
            if (huList.Count > 0)
            {
                if (huList.Count > 1 || huList[0].HuType == 3)
                {
                    r.Is_Hu = true;
                    var sendh = SendHu.CreateBuilder();
                    foreach (var item in huList)
                    {
                        if (!sendh.HasFWZ)
                        {
                            sendh.SetFWZ(item.HuIndex);
                        }
                        if (!sendh.HasFWB)
                        {
                            sendh.SetFWB(item.PaoIndex);
                        }
                        sendh.SetType(item.HuType);
                        sendh.SetMJ(sendinfo.Mj);
                        if (!sendh.HasOpenid)
                        {
                            sendh.SetOpenid(item.OpenID);
                        }
                        if (!sendh.HasRoomid)
                        {
                            sendh.SetRoomid(r.RoomID);
                        }
                        sendh.AddDXInfo(DuoXiangHu.CreateBuilder().SetDXFW(item.HuIndex).SetDXType(item.HuType));
                    }
                    byte[] rbyte = sendh.Build().ToByteArray();
                    //Gongyong.userlist.Find(u => u.openid == item.Openid).session.TrySend(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5016, rbyte.Length, requestInfo.MessageNum, rbyte)));
                    int messageNum = (GameInformationBase.BASEAGREEMENTNUMBER + 5016);
                    //抢杠必胡,所以需要服务器自己返回胡牌的信息。
                    new GetH().ExecuteCommand(Gongyong.userlist.Find(u => u.openid == huList[0].OpenID).session,
                                              new ProtobufRequestInfo {
                        Body = rbyte, Key = messageNum.ToString(), Messagelength = rbyte.Length, MessageNum = messageNum, MessageResNum = 0
                    });
                }
                else
                {
                    var sendh = ReturnHByType.CreateBuilder();
                    sendh.SetFWZ(huList[0].HuIndex);
                    sendh.SetFWB(huList[0].PaoIndex);
                    sendh.SetType(huList[0].HuType);
                    sendh.SetMJ(sendinfo.Mj);
                    r.DQHY = huList[0].HuIndex;
                    byte[] rbyte    = sendh.Build().ToByteArray();
                    var    sendData = new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5015, rbyte.Length, requestInfo.MessageNum, rbyte));
                    mjlist.Find(w => w.Openid.Equals(huList[0].OpenID)).SendData.Add(sendData);
                    Gongyong.userlist.Find(u => u.openid == huList[0].OpenID).session.TrySend(sendData);
                }
            }
            else if (sendinfo.State == 1 && sendinfo.Types == 2)
            {
                r.Is_Hu = false;
                var PGH = ReturnAll.CreateBuilder();
                PGH.SetMo(1);
                PGH.SetFw(mjuser.ZS_Fw);
                PGH.SetMType(1);
                mjuser.Mtype = 1;
                byte[] bytegou = PGH.Build().ToByteArray();
                session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 3008, bytegou.Length, requestInfo.MessageNum, bytegou)));
            }
            else if (sendinfo.State == 2)//过牌后 会摸牌,不能强制修改为 出牌
            {
            }
            else
            {
                r.Is_Hu = false;
                r.DQcz  = "3001";
            }

            var settle = ReturnJS.CreateBuilder();

            session.Logger.Debug("处理完成下发消息");
            foreach (var item in mjlist)
            {
                UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);

                //if (sendinfo.Types == 3 && sendinfo.State == 1)
                //{
                //    byte[] jpr = jp.Build().ToByteArray();
                //    user.session.TrySend(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7005, jpr.Length, requestInfo.MessageNum, jpr)));
                //    byte[] settlebyte = settle.Build().ToByteArray();
                //    user.session.TrySend(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 7009, settlebyte.Length, requestInfo.MessageNum, settlebyte)));
                //}
                //else
                //{
                byte[] b = retumsg.Build().ToByteArray();
                user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 4002, b.Length, requestInfo.MessageNum, b)));
                //}


                if (zrjxx.Dzrfw != 0)
                {
                    byte[] zrj = zrjxx.Build().ToByteArray();

                    user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5018, zrj.Length, requestInfo.MessageNum, zrj)));
                }
            }
            ThreadUtility.StartManagedThread(Gongyong.mulist.Find(w => w.ZS_Fw == r.DQHY && w.RoomID == r.RoomID).Openid, r.RoomID, r.DQcz);
        }