Esempio n. 1
0
    /// <summary>
    /// 第一家出的拖拉机,判断其他玩家出牌是否符合规则
    /// </summary>
    /// <param name="myOutPokerList">玩家打算出的牌</param>
    /// <param name="myPokerByType">玩家手牌中该类型的所有牌</param>
    /// <param name="OutPokerType">玩家打算出的牌中的该类型的所有牌</param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static bool IsSendByTuoLaJi(List <PokerInfo> myOutPokerList, List <PokerInfo> myPokerByType,
                                       List <PokerInfo> OutPokerType, int mLevelPokerNum, int masterPokerType)
    {
        int count = myOutPokerList.Count;

        if (myPokerByType.Count <= count)
        {
            return(OutPokerType.Count == myPokerByType.Count);
        }

        List <PokerInfo> myDoublePoker  = PlayRuleUtil.GetDoublePoker(myPokerByType);
        List <PokerInfo> outDoublePoker = PlayRuleUtil.GetDoublePoker(myOutPokerList);

        if (myDoublePoker.Count <= count)
        {
            return(outDoublePoker.Count == myDoublePoker.Count);
        }

        //很多对子+
        List <List <PokerInfo> > allTljFromDouble =
            PlayRuleUtil.GetAllTljFromDouble(myDoublePoker, mLevelPokerNum, masterPokerType);
        List <List <PokerInfo> > allTljFromoutDouble =
            PlayRuleUtil.GetAllTljFromDouble(outDoublePoker, mLevelPokerNum, masterPokerType);

        if (allTljFromDouble.Count > 0)
        {
            return(allTljFromoutDouble.Count > 0);
        }
        else
        {
            return(outDoublePoker.Count == count);
        }
    }
    public static OutPokerType checkOutPokerType(List <TLJCommon.PokerInfo> outPokerList, int mLevelPokerNum, int masterPokerType)
    {
        PlayRuleUtil.SetPokerWeight(outPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);

        int count = outPokerList.Count;

        if (count == 0)
        {
            return(OutPokerType.OutPokerType_Error);
        }
        // 单牌
        else if (count == 1)
        {
            return(OutPokerType.OutPokerType_Single);
        }
        // 检查是否是对子
        else if (count == 2)
        {
            if ((outPokerList[0].m_pokerType == outPokerList[1].m_pokerType) && (outPokerList[0].m_num == outPokerList[1].m_num))
            {
                return(OutPokerType.OutPokerType_Double);
            }
        }
        else if (count % 2 == 0 && count >= 4)
        {
            if (PlayRuleUtil.IsTuolaji(outPokerList, mLevelPokerNum, masterPokerType))
            {
                return(OutPokerType.OutPokerType_TuoLaJi);
            }
        }
        return(OutPokerType.OutPokerType_ShuaiPai);
    }
    // 比较这一轮出牌的大小
    public static PlayerData compareWhoMax(RoomData room)
    {
        /*
         * listPlayerData是按玩家进入房间顺序排的
         * 这里要改成按这一轮出牌顺序排
         */
        List <PlayerData> tempList = new List <PlayerData>();

        // 重新排序
        {
            int index = room.getPlayerDataList().IndexOf(room.m_curRoundFirstPlayer);

            for (int i = index; i < room.getPlayerDataList().Count; i++)
            {
                tempList.Add(room.getPlayerDataList()[i]);
            }

            for (int i = 0; i < index; i++)
            {
                tempList.Add(room.getPlayerDataList()[i]);
            }
        }
        //TLJ_PlayService.PlayService.log.Info("第一个人出牌数:"+ tempList[0].m_curOutPokerList.Count);

        //设权重
        for (int i = 0; i < tempList.Count; i++)
        {
            PlayerData       playerData   = tempList[i];
            List <PokerInfo> outPokerList = playerData.m_curOutPokerList;
            PlayRuleUtil.SetPokerWeight(outPokerList, room.m_levelPokerNum, (Consts.PokerType)room.m_masterPokerType);
        }

        //第一个人是甩牌主牌
        var checkOutPokerType = CheckOutPoker.checkOutPokerType(tempList[0].m_curOutPokerList, room.m_levelPokerNum,
                                                                room.m_masterPokerType);

        if (checkOutPokerType.Equals(CheckOutPoker.OutPokerType.OutPokerType_ShuaiPai))
        {
            if (PlayRuleUtil.IsAllMasterPoker(tempList[0].m_curOutPokerList, room.m_levelPokerNum,
                                              room.m_masterPokerType))
            {
                return(tempList[0]);
            }
        }

        List <PokerInfo> firstDoubleList = PlayRuleUtil.GetDoublePoker(tempList[0].m_curOutPokerList);
        List <PokerInfo> firstSingleList = PlayRuleUtil.GetSinglePoker(tempList[0].m_curOutPokerList, firstDoubleList);
        List <PokerInfo> firstTuoLaJi    =
            PlayRuleUtil.GetTuoLaJi(tempList[0].m_curOutPokerList, room.m_levelPokerNum, room.m_masterPokerType);

        PlayerData maxPlayer = CompareBoth(tempList[0], tempList[1], tempList[0], room.m_levelPokerNum,
                                           room.m_masterPokerType);

        maxPlayer = CompareBoth(maxPlayer, tempList[2], tempList[0], room.m_levelPokerNum, room.m_masterPokerType);
        maxPlayer = CompareBoth(maxPlayer, tempList[3], tempList[0], room.m_levelPokerNum, room.m_masterPokerType);
        //TLJ_PlayService.PlayService.log.Info("我是最大的:"+maxPlayer.m_curOutPokerList[0].m_pokerType+ maxPlayer.m_curOutPokerList[0].m_num+"\n------------");
        return(maxPlayer);
    }
Esempio n. 4
0
    public static OutPokerType checkOutPokerType(List <TLJCommon.PokerInfo> outPokerList, int mLevelPokerNum, int masterPokerType)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("CheckOutPoker_hotfix", "checkOutPokerType"))
        {
            OutPokerType outPokerType = (OutPokerType)ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.CheckOutPoker_hotfix", "checkOutPokerType", null, outPokerList, mLevelPokerNum, masterPokerType);
            return(outPokerType);
        }

        PlayRuleUtil.SetPokerWeight(outPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);

        int count = outPokerList.Count;

        if (count == 0)
        {
            return(OutPokerType.OutPokerType_Error);
        }
        // 单牌
        else if (count == 1)
        {
            return(OutPokerType.OutPokerType_Single);
        }
        // 检查是否是对子
        else if (count == 2)
        {
            if ((outPokerList[0].m_pokerType == outPokerList[1].m_pokerType) && (outPokerList[0].m_num == outPokerList[1].m_num))
            {
                return(OutPokerType.OutPokerType_Double);
            }
        }
        else if (count % 2 == 0 && count >= 4)
        {
            if (PlayRuleUtil.IsTuolaji(outPokerList, mLevelPokerNum, masterPokerType))
            {
//                TLJ_PlayService.PlayService.log.Info("出的是拖拉机");
                return(OutPokerType.OutPokerType_TuoLaJi);
            }
        }
//        TLJ_PlayService.PlayService.log.Info("有人尝试甩牌");
        return(OutPokerType.OutPokerType_ShuaiPai);
    }
    /// <summary>
    /// 第一家出的拖拉机,判断其他玩家出牌是否符合规则
    /// </summary>
    /// <param name="myOutPokerList">玩家打算出的牌</param>
    /// <param name="myPokerByType">玩家手牌中该类型的所有牌</param>
    /// <param name="OutPokerType">玩家打算出的牌中的该类型的所有牌</param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static bool IsSendByTuoLaJi(List <PokerInfo> myOutPokerList, List <PokerInfo> myPokerByType,
                                       List <PokerInfo> OutPokerType, int mLevelPokerNum, int masterPokerType)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PlayRuleUtil_hotfix", "IsSendByTuoLaJi"))
        {
            bool b = (bool)ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PlayRuleUtil_hotfix", "IsSendByTuoLaJi", null, myOutPokerList, myPokerByType, OutPokerType, mLevelPokerNum, masterPokerType);
            return(b);
        }

        int count = myOutPokerList.Count;

        if (myPokerByType.Count <= count)
        {
            return(OutPokerType.Count == myPokerByType.Count);
        }

        List <PokerInfo> myDoublePoker  = PlayRuleUtil.GetDoublePoker(myPokerByType);
        List <PokerInfo> outDoublePoker = PlayRuleUtil.GetDoublePoker(myOutPokerList);

        if (myDoublePoker.Count <= count)
        {
            return(outDoublePoker.Count == myDoublePoker.Count);
        }

        //很多对子+
        List <List <PokerInfo> > allTljFromDouble =
            PlayRuleUtil.GetAllTljFromDouble(myDoublePoker, mLevelPokerNum, masterPokerType);
        List <List <PokerInfo> > allTljFromoutDouble =
            PlayRuleUtil.GetAllTljFromDouble(outDoublePoker, mLevelPokerNum, masterPokerType);

        if (allTljFromDouble.Count > 0)
        {
            return(allTljFromoutDouble.Count > 0);
        }
        else
        {
            return(outDoublePoker.Count == count);
        }
    }
    // 托管:出牌
    public static void trusteeshipLogic_OutPoker(GameBase gameBase, RoomData room, PlayerData playerData)
    {
        try
        {
            // 轮到自己出牌
            {
                if (playerData.getPokerList().Count > 0)
                {
                    JObject backData = new JObject();

                    backData.Add("tag", room.m_tag);
                    backData.Add("uid", playerData.m_uid);
                    backData.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_PlayerOutPoker);

                    // 自己出的牌
                    {
                        // 任意出
                        if (playerData.m_uid.CompareTo(room.m_curRoundFirstPlayer.m_uid) == 0)
                        {
                            List <TLJCommon.PokerInfo> listPoker = PlayRuleUtil.GetPokerWhenFirst(playerData.getPokerList(), room.m_levelPokerNum, room.m_masterPokerType);

                            {
                                string str = "托管出牌--任意出:roomID = " + room.getRoomId() + "  uid = " + playerData.m_uid + "    ";
                                for (int i = 0; i < listPoker.Count; i++)
                                {
                                    int num       = listPoker[i].m_num;
                                    int pokerType = (int)listPoker[i].m_pokerType;

                                    str += ("num=" + num + "  type = " + pokerType + ",");
                                }

                                str += "。";

                                LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + str);
                            }

                            JArray jarray = new JArray();
                            for (int i = 0; i < listPoker.Count; i++)
                            {
                                int num       = listPoker[i].m_num;
                                int pokerType = (int)listPoker[i].m_pokerType;

                                {
                                    JObject temp = new JObject();
                                    temp.Add("num", num);
                                    temp.Add("pokerType", pokerType);
                                    jarray.Add(temp);
                                }
                            }
                            backData.Add("pokerList", jarray);
                        }
                        // 跟牌
                        else
                        {
                            List <TLJCommon.PokerInfo> listPoker = PlayRuleUtil.GetPokerWhenTuoGuan(room.m_curRoundFirstPlayer.m_curOutPokerList, playerData.getPokerList(), room.m_levelPokerNum, room.m_masterPokerType);

                            {
                                string str = "托管出牌--跟牌:roomID = " + room.getRoomId() + "  uid = " + playerData.m_uid + "    ";
                                for (int i = 0; i < listPoker.Count; i++)
                                {
                                    int num       = listPoker[i].m_num;
                                    int pokerType = (int)listPoker[i].m_pokerType;

                                    str += ("num=" + num + "  type = " + pokerType + ",");
                                }

                                str += "。";

                                LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + str);
                            }

                            JArray jarray = new JArray();
                            for (int i = 0; i < listPoker.Count; i++)
                            {
                                int num       = listPoker[i].m_num;
                                int pokerType = (int)listPoker[i].m_pokerType;

                                {
                                    JObject temp = new JObject();
                                    temp.Add("num", num);
                                    temp.Add("pokerType", pokerType);
                                    jarray.Add(temp);
                                }
                            }
                            backData.Add("pokerList", jarray);
                        }
                    }

                    //LogUtil.getInstance().addDebugLog(m_logFlag + "----" + "托管出牌:" + playerData.m_uid + "  " + backData.ToString());
                    GameLogic.doTask_ReceivePlayerOutPoker(gameBase, playerData.m_connId, backData.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":trusteeshipLogic异常1:" + ex);
        }
    }
    /// <summary>
    /// 托管的时候自动获取跟牌时要出的牌
    /// </summary>
    /// <param name="firstPokerList"></param>
    /// <param name="myPokerList"></param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static List <PokerInfo> GetPokerWhenTuoGuan(List <PokerInfo> firstPokerList, List <PokerInfo> myPokerList,
                                                       int mLevelPokerNum, int masterPokerType)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PlayRuleUtil_hotfix", "GetPokerWhenTuoGuan"))
        {
            List <PokerInfo> list_temp = (List <PokerInfo>)ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PlayRuleUtil_hotfix", "GetPokerWhenTuoGuan", null, firstPokerList, myPokerList, mLevelPokerNum, masterPokerType);
            return(list_temp);
        }

        List <PokerInfo> tempAll = new List <PokerInfo>();

        foreach (var poker in myPokerList)
        {
            tempAll.Add(poker);
        }
        //设置权重
        SetPokerWeight(firstPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);
        SetPokerWeight(myPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);

        List <PokerInfo> resultList = new List <PokerInfo>();
        //第一个人出牌的牌数
        int count = firstPokerList.Count;

        switch (CheckOutPoker.checkOutPokerType(firstPokerList, mLevelPokerNum,
                                                masterPokerType))
        {
        //第一个人是单牌
        case CheckOutPoker.OutPokerType.OutPokerType_Single:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenSingle(tempAll, masterPoker, resultList);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenSingle(tempAll, typeInfo, resultList);
            }
            break;

        //第一个人是对子
        case CheckOutPoker.OutPokerType.OutPokerType_Double:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenDouble(tempAll, masterPoker, resultList);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenDouble(tempAll, typeInfo, resultList);
            }
            break;

        //第一个人是拖拉机
        case CheckOutPoker.OutPokerType.OutPokerType_TuoLaJi:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenTlj(tempAll, masterPoker, resultList, count, mLevelPokerNum, masterPokerType);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenTlj(tempAll, typeInfo, resultList, count, mLevelPokerNum, masterPokerType);
            }
            break;

        case CheckOutPoker.OutPokerType.OutPokerType_ShuaiPai:
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                //第一个人出的是主牌
                List <PokerInfo> masterPoker = GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenShuaiP(firstPokerList, masterPoker, tempAll, count, resultList);
            }
            //甩的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenShuaiP(firstPokerList, typeInfo, tempAll, count, resultList);
            }
            break;
        }

        if (firstPokerList.Count != resultList.Count)
        {
//            TLJ_PlayService.PlayService.log.Warn($"托管的出的牌的牌数不一致,托管出了{resultList.Count}张,第一个人出了{firstPokerList.Count}张");
        }
        return(resultList);
    }
    /// <summary>
    /// 只在客户端调用,得到能够亮主的牌
    /// </summary>
    /// <param name="handerPoker"></param>
    /// <param name="liangZhuPoker"></param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static List <PokerInfo> GetLiangzhuPoker(List <PokerInfo> handerPoker, List <PokerInfo> liangZhuPoker,
                                                    int mLevelPokerNum,
                                                    int masterPokerType)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PlayRuleUtil_hotfix", "GetLiangzhuPoker"))
        {
            List <PokerInfo> list_temp = (List <PokerInfo>)ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PlayRuleUtil_hotfix", "GetLiangzhuPoker", null, handerPoker, liangZhuPoker, mLevelPokerNum, masterPokerType);
            return(list_temp);
        }

        List <PokerInfo> pokerInfos   = new List <PokerInfo>();
        List <PokerInfo> jiPaiAndWang = PlayRuleUtil.GetJiPaiAndWang(handerPoker, mLevelPokerNum);

        if (jiPaiAndWang.Count == 0)
        {
            return(pokerInfos);
        }

        //第一次亮主
        if (liangZhuPoker == null || liangZhuPoker.Count == 0)
        {
            for (int i = 0; i < handerPoker.Count; i++)
            {
                if (handerPoker[i].m_num == mLevelPokerNum)
                {
                    pokerInfos.Add(handerPoker[i]);
                }
            }
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            //大小王
            foreach (var poker in doublePoker)
            {
                if (poker.m_pokerType == Consts.PokerType.PokerType_Wang)
                {
                    pokerInfos.Add(poker);
                }
            }
            return(pokerInfos);
        }
        else if (liangZhuPoker.Count == 1)
        {
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            return(doublePoker);
        }
        else if (liangZhuPoker.Count == 2)
        {
            Consts.PokerType mPokerType  = liangZhuPoker[0].m_pokerType;
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            for (int i = 0; i < doublePoker.Count - 1; i += 2)
            {
                if (doublePoker[i].m_pokerType > mPokerType)
                {
                    pokerInfos.Add(doublePoker[i]);
                    pokerInfos.Add(doublePoker[i + 1]);
                }

                if (liangZhuPoker[0].m_num == 15 && doublePoker[i].m_num == 16)
                {
                    pokerInfos.Add(doublePoker[i]);
                    pokerInfos.Add(doublePoker[i + 1]);
//                    ToastScript.createToast("dawang");
                }
            }
            return(pokerInfos);
        }
        else
        {
            return(pokerInfos);
        }
    }
Esempio n. 9
0
    /// <summary>
    /// 托管的时候自动获取跟牌时要出的牌
    /// </summary>
    /// <param name="firstPokerList"></param>
    /// <param name="myPokerList"></param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static List <PokerInfo> GetPokerWhenTuoGuan(List <PokerInfo> firstPokerList, List <PokerInfo> myPokerList,
                                                       int mLevelPokerNum, int masterPokerType)
    {
        List <PokerInfo> tempAll = new List <PokerInfo>();

        foreach (var poker in myPokerList)
        {
            tempAll.Add(poker);
        }
        //设置权重
        SetPokerWeight(firstPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);
        SetPokerWeight(myPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);

        List <PokerInfo> resultList = new List <PokerInfo>();
        //第一个人出牌的牌数
        int count = firstPokerList.Count;

        switch (CheckOutPoker.checkOutPokerType(firstPokerList, mLevelPokerNum,
                                                masterPokerType))
        {
        //第一个人是单牌
        case CheckOutPoker.OutPokerType.OutPokerType_Single:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenSingle(tempAll, masterPoker, resultList);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenSingle(tempAll, typeInfo, resultList);
            }
            break;

        //第一个人是对子
        case CheckOutPoker.OutPokerType.OutPokerType_Double:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenDouble(tempAll, masterPoker, resultList);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenDouble(tempAll, typeInfo, resultList);
            }
            break;

        //第一个人是拖拉机
        case CheckOutPoker.OutPokerType.OutPokerType_TuoLaJi:
            //第一个人出的是主牌
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                List <PokerInfo> masterPoker =
                    PlayRuleUtil.GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenTlj(tempAll, masterPoker, resultList, count, mLevelPokerNum, masterPokerType);
            }
            //出的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenTlj(tempAll, typeInfo, resultList, count, mLevelPokerNum, masterPokerType);
            }
            break;

        case CheckOutPoker.OutPokerType.OutPokerType_ShuaiPai:
            if (PlayRuleUtil.IsMasterPoker(firstPokerList[0], mLevelPokerNum, masterPokerType))
            {
                //第一个人出的是主牌
                List <PokerInfo> masterPoker = GetMasterPoker(tempAll, mLevelPokerNum, masterPokerType);
                GetPokerWhenShuaiP(firstPokerList, masterPoker, tempAll, count, resultList);
            }
            //甩的是副牌
            else
            {
                //如果有该副牌花色必须出该花色
                List <PokerInfo> typeInfo;
                PlayRuleUtil.IsContainTypePoke(tempAll, mLevelPokerNum, firstPokerList[0].m_pokerType,
                                               out typeInfo);
                GetPokerWhenShuaiP(firstPokerList, typeInfo, tempAll, count, resultList);
            }
            break;
        }

        if (firstPokerList.Count != resultList.Count)
        {
            TLJ_PlayService.PlayService.log.Warn($"托管的出的牌的牌数不一致,托管出了{resultList.Count}张,第一个人出了{firstPokerList.Count}张");
        }

        TLJ_PlayService.PlayService.log.Warn($"托管跟牌数:{resultList.Count},{Newtonsoft.Json.JsonConvert.SerializeObject(resultList)}");
        return(resultList);
    }
Esempio n. 10
0
    /// <summary>
    /// 只在客户端调用,得到能够亮主的牌
    /// </summary>
    /// <param name="handerPoker"></param>
    /// <param name="liangZhuPoker"></param>
    /// <param name="mLevelPokerNum"></param>
    /// <param name="masterPokerType"></param>
    /// <returns></returns>
    public static List <PokerInfo> GetLiangzhuPoker(List <PokerInfo> handerPoker, List <PokerInfo> liangZhuPoker,
                                                    int mLevelPokerNum,
                                                    int masterPokerType)
    {
        List <PokerInfo> pokerInfos   = new List <PokerInfo>();
        List <PokerInfo> jiPaiAndWang = PlayRuleUtil.GetJiPaiAndWang(handerPoker, mLevelPokerNum);

        if (jiPaiAndWang.Count == 0)
        {
            return(pokerInfos);
        }

        //第一次亮主
        if (liangZhuPoker == null || liangZhuPoker.Count == 0)
        {
            for (int i = 0; i < handerPoker.Count; i++)
            {
                if (handerPoker[i].m_num == mLevelPokerNum)
                {
                    pokerInfos.Add(handerPoker[i]);
                }
            }
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            //大小王
            foreach (var poker in doublePoker)
            {
                if (poker.m_pokerType == Consts.PokerType.PokerType_Wang)
                {
                    pokerInfos.Add(poker);
                }
            }
            return(pokerInfos);
        }
        else if (liangZhuPoker.Count == 1)
        {
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            return(doublePoker);
        }
        else if (liangZhuPoker.Count == 2)
        {
            Consts.PokerType mPokerType  = liangZhuPoker[0].m_pokerType;
            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(jiPaiAndWang);
            for (int i = 0; i < doublePoker.Count - 1; i += 2)
            {
                if (doublePoker[i].m_pokerType > mPokerType)
                {
                    pokerInfos.Add(doublePoker[i]);
                    pokerInfos.Add(doublePoker[i + 1]);
                }

                if (liangZhuPoker[0].m_num == 15 && doublePoker[i].m_num == 16)
                {
                    pokerInfos.Add(doublePoker[i]);
                    pokerInfos.Add(doublePoker[i + 1]);
                    //                    ToastScript.createToast("dawang");
                }
            }
            return(pokerInfos);
        }
        else
        {
            return(pokerInfos);
        }
    }
    /// <summary>
    /// 两两比较
    /// </summary>
    /// <param name="player1"></param>
    /// <param name="player2"></param>
    /// <param name="firstPlay">第一个人出的牌</param>
    /// <param name="roomMLevelPokerNum"></param>
    /// <param name="roomMMasterPokerType"></param>
    /// <returns>牌最大的玩家数据</returns>
    public static PlayerData CompareBoth(PlayerData player1, PlayerData player2, PlayerData firstPlay,
                                         int roomMLevelPokerNum,
                                         int roomMMasterPokerType)
    {
        List <PokerInfo> firstPlayOutPokerList = firstPlay.m_curOutPokerList;
        List <PokerInfo> playerOutPokerList1   = player1.m_curOutPokerList;
        List <PokerInfo> playerOutPokerList2   = player2.m_curOutPokerList;

        if (playerOutPokerList1 == null || playerOutPokerList2 == null)
        {
            TLJ_PlayService.PlayService.log.Warn("有玩家出牌的数据为空");
            LogAllPoker(player1);
            LogAllPoker(player2);
            return(player1);
        }

        if (playerOutPokerList2.Count == 0 || playerOutPokerList1.Count == 0)
        {
            TLJ_PlayService.PlayService.log.Warn("有玩家出牌的数据为0");
            LogAllPoker(player1);
            LogAllPoker(player2);
            return(player1);
        }

        if (playerOutPokerList1.Count != playerOutPokerList2.Count)
        {
            TLJ_PlayService.PlayService.log.Warn("出牌的牌数不一样");
            LogAllPoker(player1);
            LogAllPoker(player2);
            return(player1);
        }

        CheckOutPoker.OutPokerType outPokerType =
            CheckOutPoker.checkOutPokerType(playerOutPokerList1, roomMLevelPokerNum, roomMMasterPokerType);
        CheckOutPoker.OutPokerType outPokerType2 =
            CheckOutPoker.checkOutPokerType(playerOutPokerList2, roomMLevelPokerNum, roomMMasterPokerType);

        //单牌
        if (outPokerType.Equals(CheckOutPoker.OutPokerType.OutPokerType_Single))
        {
            if (PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
            {
                if (PlayRuleUtil.IsMasterPoker(playerOutPokerList2[0], roomMLevelPokerNum, roomMMasterPokerType))
                {
                    return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight ? player1 : player2);
                }
                else
                {
                    return(player1);
                }
            }
            else
            {
                //毙了
                if (PlayRuleUtil.IsMasterPoker(playerOutPokerList2[0], roomMLevelPokerNum, roomMMasterPokerType))
                {
                    return(player2);
                }
                //双方都是副牌
                else
                {
                    if (playerOutPokerList1[0].m_pokerType != playerOutPokerList2[0].m_pokerType)
                    {
                        return(player1);
                    }
                    else
                    {
                        return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight ? player1 : player2);
                    }
                }
            }
        }
        //对子比较
        else if (outPokerType.Equals(CheckOutPoker.OutPokerType.OutPokerType_Double))
        {
            if (outPokerType2.Equals(CheckOutPoker.OutPokerType.OutPokerType_Double))
            {
                if (PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
                {
                    if (PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
                    {
                        return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight ? player1 : player2);
                    }
                    else
                    {
                        return(player1);
                    }
                }
                else
                {
                    //毙了
                    if (PlayRuleUtil.IsMasterPoker(playerOutPokerList2[0], roomMLevelPokerNum, roomMMasterPokerType))
                    {
                        return(player2);
                    }
                    else
                    {
                        if (playerOutPokerList1[0].m_pokerType != playerOutPokerList2[0].m_pokerType)
                        {
                            return(player1);
                        }
                        else
                        {
                            return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight
                                ? player1
                                : player2);
                        }
                    }
                }
            }
            else
            {
                return(player1);
            }
        }
        //拖拉机
        else if (outPokerType.Equals(CheckOutPoker.OutPokerType.OutPokerType_TuoLaJi))
        {
            if (outPokerType2.Equals(CheckOutPoker.OutPokerType.OutPokerType_TuoLaJi))
            {
                if (PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
                {
                    if (PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
                    {
                        return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight ? player1 : player2);
                    }
                    else
                    {
                        return(player1);
                    }
                }
                //玩家1不是主牌
                else
                {
                    //毙了
                    if (PlayRuleUtil.IsMasterPoker(playerOutPokerList2[0], roomMLevelPokerNum, roomMMasterPokerType))
                    {
                        return(player2);
                    }
                    else
                    {
                        if (playerOutPokerList1[0].m_pokerType != playerOutPokerList2[0].m_pokerType)
                        {
                            return(player1);
                        }
                        else
                        {
                            return(playerOutPokerList1[0].m_weight >= playerOutPokerList2[0].m_weight
                                ? player1
                                : player2);
                        }
                    }
                }
            }
        }
        else if (outPokerType.Equals(CheckOutPoker.OutPokerType.OutPokerType_ShuaiPai))
        {
            //得到牌中的对子和单牌
            List <PokerInfo> firstDoubleList = PlayRuleUtil.GetDoublePoker(firstPlayOutPokerList);
            List <PokerInfo> firstSingleList = PlayRuleUtil.GetSinglePoker(firstPlayOutPokerList, firstDoubleList);
            List <PokerInfo> firstTuoLaJi    =
                PlayRuleUtil.GetTuoLaJi(firstPlayOutPokerList, roomMLevelPokerNum, roomMMasterPokerType);

            List <PokerInfo> play1DoubleList = PlayRuleUtil.GetDoublePoker(playerOutPokerList1);
            List <PokerInfo> play1SingleList = PlayRuleUtil.GetSinglePoker(playerOutPokerList1, firstDoubleList);
            List <PokerInfo> play1TuoLaJi    =
                PlayRuleUtil.GetTuoLaJi(playerOutPokerList1, roomMLevelPokerNum, roomMMasterPokerType);

            List <PokerInfo> play2DoubleList = PlayRuleUtil.GetDoublePoker(playerOutPokerList2);
            List <PokerInfo> play2SingleList = PlayRuleUtil.GetSinglePoker(playerOutPokerList2, play2DoubleList);
            List <PokerInfo> play2TuoLaJi    =
                PlayRuleUtil.GetTuoLaJi(playerOutPokerList2, roomMLevelPokerNum, roomMMasterPokerType);

            if (!PlayRuleUtil.IsMasterPoker(playerOutPokerList1[0], roomMLevelPokerNum, roomMMasterPokerType))
            {
                if (PlayRuleUtil.IsAllMasterPoker(playerOutPokerList2, roomMLevelPokerNum, roomMMasterPokerType))
                {
                    //第一个人全是单牌
                    if (firstDoubleList.Count == 0)
                    {
                        return(player2);
                    }

                    //第一个人有对子
                    if (play2DoubleList.Count >= firstDoubleList.Count)
                    {
                        if (play2TuoLaJi.Count >= firstTuoLaJi.Count)
                        {
                            return(player2);
                        }
                    }
                    return(player1);
                }
            }
            else
            {
                if (PlayRuleUtil.IsAllMasterPoker(playerOutPokerList2, roomMLevelPokerNum, roomMMasterPokerType))
                {
                    //第一个人全是单牌
                    if (firstDoubleList.Count == 0)
                    {
                        return(play1SingleList[play1SingleList.Count - 1].m_weight >=
                               play2SingleList[play2SingleList.Count - 1].m_weight
                            ? player1
                            : player2);
                    }
                    //第一个人没有拖拉机
                    if (firstTuoLaJi.Count == 0)
                    {
                        if (play2DoubleList.Count >= firstDoubleList.Count)
                        {
                            return(play1DoubleList[play1DoubleList.Count - 1].m_weight >=
                                   play2DoubleList[play2DoubleList.Count - 1].m_weight
                                ? player1
                                : player2);
                        }
                    }
                    //第一个人有拖拉机
                    if (play2TuoLaJi.Count >= firstTuoLaJi.Count)
                    {
                        return(play1TuoLaJi[play1TuoLaJi.Count - 1].m_weight >=
                               play2TuoLaJi[play2TuoLaJi.Count - 1].m_weight
                            ? player1
                            : player2);
                    }
                }
            }
        }
        return(player1);
    }
    // 检测出牌合理性
    public static bool checkOutPoker(bool isFreeOutPoker, List <TLJCommon.PokerInfo> myOutPokerList,
                                     List <TLJCommon.PokerInfo> beforeOutPokerList, List <TLJCommon.PokerInfo> myRestPokerList,
                                     int mLevelPokerNum, int masterPokerType)
    {
        PlayRuleUtil.SetPokerWeight(beforeOutPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);
        PlayRuleUtil.SetPokerWeight(myOutPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);
        PlayRuleUtil.SetPokerWeight(myRestPokerList, mLevelPokerNum, (Consts.PokerType)masterPokerType);
        // 自由出牌
        if (isFreeOutPoker)
        {
            //判断是否是主牌
            if (PlayRuleUtil.IsAllMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType))
            {
                return(true);
            }
            //判断是否为同花色副牌
            else if (PlayRuleUtil.IsAllFuPoker(myOutPokerList, mLevelPokerNum, masterPokerType))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // 跟牌
        else
        {
            // 检查张数是否一致
            {
                if (myOutPokerList.Count != beforeOutPokerList.Count)
                {
                    return(false);
                }
            }
            switch (CheckOutPoker.checkOutPokerType(beforeOutPokerList, mLevelPokerNum, masterPokerType))
            {
            //第一个人是单牌
            case CheckOutPoker.OutPokerType.OutPokerType_Single:
            {
                //第一个人出的是主牌
                if (PlayRuleUtil.IsMasterPoker(beforeOutPokerList[0], mLevelPokerNum, masterPokerType))
                {
                    if (PlayRuleUtil.IsContainMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType))
                    {
                        if (PlayRuleUtil.IsMasterPoker(myOutPokerList[0], mLevelPokerNum, masterPokerType))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                //出的是副牌
                else
                {
                    if (PlayRuleUtil.IsAllMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType))
                    {
                        return(true);
                    }

                    //如果有该副牌花色必须出该花色
                    List <PokerInfo> typeInfo;
                    if (PlayRuleUtil.IsContainTypePoke(myRestPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType, out typeInfo))
                    {
                        if (myOutPokerList[0].m_pokerType == beforeOutPokerList[0].m_pokerType)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            break;

            //第一个人是对子
            case CheckOutPoker.OutPokerType.OutPokerType_Double:
            {
                //第一个人出的是主牌对子
                if (PlayRuleUtil.IsMasterPoker(beforeOutPokerList[0], mLevelPokerNum, masterPokerType))
                {
                    List <PokerInfo> masterPoker =
                        PlayRuleUtil.GetMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType);
                    //手中有主牌
                    if (masterPoker.Count > 0)
                    {
                        if (masterPoker.Count == 1)
                        {
                            if (PlayRuleUtil.IsContainMasterPoker(myOutPokerList, mLevelPokerNum,
                                                                  masterPokerType))
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        //出的主牌中包含对子
                        List <PokerInfo> masterDoublePoker;
                        if (PlayRuleUtil.IsContainDoublePoker(masterPoker, out masterDoublePoker))
                        {
                            //出的牌都要是主牌
                            if (PlayRuleUtil.IsAllMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType))
                            {
                                if (myOutPokerList[0].m_num == myOutPokerList[1].m_num &&
                                    myOutPokerList[0].m_pokerType == myOutPokerList[1].m_pokerType)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        //主牌中没有对子,且大于两张
                        else
                        {
                            if (PlayRuleUtil.IsAllMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType))
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    //手中没有主牌
                    else
                    {
                        return(true);
                    }
                }
                //出的是副牌
                else
                {
                    if (PlayRuleUtil.IsAllMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType))
                    {
                        return(true);
                    }

                    List <PokerInfo> typeInfo;
                    if (PlayRuleUtil.IsContainTypePoke(myRestPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType, out typeInfo))
                    {
                        if (typeInfo.Count == 1)
                        {
                            if (myOutPokerList[0].m_pokerType == beforeOutPokerList[0].m_pokerType ||
                                myOutPokerList[1].m_pokerType == beforeOutPokerList[0].m_pokerType)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        //手中有该花色副牌,且有两张以上
                        else
                        {
                            if (!PlayRuleUtil.IsAllFuPoker(myOutPokerList, mLevelPokerNum, masterPokerType))
                            {
                                return(false);
                            }

                            List <PokerInfo> doublePoker = PlayRuleUtil.GetDoublePoker(typeInfo);

                            List <PokerInfo> outdoublePoker = PlayRuleUtil.GetDoublePoker(myOutPokerList);
                            //有对子走对子
                            if (doublePoker.Count > 0)
                            {
                                return(outdoublePoker.Count > 0);
                            }
                            else
                            {
                                if (myOutPokerList[0].m_pokerType == beforeOutPokerList[0].m_pokerType &&
                                    myOutPokerList[1].m_pokerType == beforeOutPokerList[0].m_pokerType)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            break;

            //第一个人是拖拉机
            case CheckOutPoker.OutPokerType.OutPokerType_TuoLaJi:
            {
                int count = beforeOutPokerList.Count;
                //出的是主牌拖拉机
                if (PlayRuleUtil.IsAllMasterPoker(beforeOutPokerList, mLevelPokerNum, masterPokerType))
                {
                    List <PokerInfo> MyMasterPoker  = PlayRuleUtil.GetMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType);
                    List <PokerInfo> outMasterPoker = PlayRuleUtil.GetMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType);
                    return(PlayRuleUtil.IsSendByTuoLaJi(myOutPokerList, MyMasterPoker, outMasterPoker, mLevelPokerNum, masterPokerType));
                }
                //出的是副牌的拖拉机
                else if (PlayRuleUtil.IsAllFuPoker(beforeOutPokerList, mLevelPokerNum, masterPokerType))
                {
                    //得到手牌中该副牌
                    List <PokerInfo> myPokerByType = PlayRuleUtil.GetPokerByType(myRestPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType);
                    //得到出牌中该副牌
                    List <PokerInfo> outPokerByType = PlayRuleUtil.GetPokerByType(myOutPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType);
                    return(PlayRuleUtil.IsSendByTuoLaJi(myOutPokerList, myPokerByType, outPokerByType, mLevelPokerNum, masterPokerType));
                }
            }
            break;

            //第一个人是甩牌
            case CheckOutPoker.OutPokerType.OutPokerType_ShuaiPai:
            {
                List <PokerInfo> firstDoublePoker = PlayRuleUtil.GetDoublePoker(beforeOutPokerList);
                List <PokerInfo> firstSinglePoker = PlayRuleUtil.GetSinglePoker(beforeOutPokerList, firstDoublePoker);
                if (PlayRuleUtil.IsAllMasterPoker(beforeOutPokerList, mLevelPokerNum, masterPokerType))
                {
                    List <PokerInfo> myMasterPoker       = PlayRuleUtil.GetMasterPoker(myRestPokerList, mLevelPokerNum, masterPokerType);
                    List <PokerInfo> myMasterDoublePoker = PlayRuleUtil.GetDoublePoker(myMasterPoker);

                    List <PokerInfo> myOutMasterPoker       = PlayRuleUtil.GetMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType);
                    List <PokerInfo> myOutMasterDoublePoker = PlayRuleUtil.GetDoublePoker(myOutMasterPoker);

                    //甩的牌全是单牌
                    if (firstDoublePoker.Count == 0)
                    {
                        if (myMasterPoker.Count <= beforeOutPokerList.Count)
                        {
                            return(myOutMasterPoker.Count == myMasterPoker.Count);
                        }
                        return(PlayRuleUtil.IsAllMasterPoker(myOutPokerList, mLevelPokerNum, masterPokerType));
                    }
                    //甩的牌中有对子
                    else
                    {
                        //自己手中的对子不够
                        if (myMasterDoublePoker.Count <= firstDoublePoker.Count)
                        {
                            return(myOutMasterDoublePoker.Count == myMasterDoublePoker.Count);
                        }
                        //对子够
                        List <List <PokerInfo> > allTljFromFirst = PlayRuleUtil.GetAllTljFromDouble(firstDoublePoker, mLevelPokerNum, masterPokerType);
                        List <List <PokerInfo> > allTljFromMy    = PlayRuleUtil.GetAllTljFromDouble(myMasterDoublePoker, mLevelPokerNum, masterPokerType);
                        List <List <PokerInfo> > allTljFromMyOut = PlayRuleUtil.GetAllTljFromDouble(myOutMasterDoublePoker, mLevelPokerNum, masterPokerType);
                        if (allTljFromFirst.Count == 0 || allTljFromMy.Count == 0)
                        {
                            return(firstDoublePoker.Count == myOutMasterDoublePoker.Count);
                        }
                        if (allTljFromFirst.Count <= allTljFromMy.Count)
                        {
                            return(allTljFromMyOut.Count == allTljFromFirst.Count);
                        }
                        else
                        {
                            return(allTljFromMyOut.Count == allTljFromMy.Count);
                        }
                    }
                }
                //甩的牌是同花色的副牌
                else
                {
                    List <PokerInfo> myFuPoker       = PlayRuleUtil.GetPokerByType(myRestPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType);
                    List <PokerInfo> myFuDoublePoker = PlayRuleUtil.GetDoublePoker(myFuPoker);

                    List <PokerInfo> myOutFuPoker       = PlayRuleUtil.GetPokerByType(myOutPokerList, mLevelPokerNum, beforeOutPokerList[0].m_pokerType);
                    List <PokerInfo> myOutFuDoublePoker = PlayRuleUtil.GetDoublePoker(myOutFuPoker);

                    //甩的牌全是单牌
                    if (firstDoublePoker.Count == 0)
                    {
                        if (myFuPoker.Count <= beforeOutPokerList.Count)
                        {
                            return(myOutFuPoker.Count == myFuPoker.Count);
                        }
                        return(PlayRuleUtil.IsAllFuPoker(myOutPokerList, mLevelPokerNum, mLevelPokerNum));
                    }
                    //甩的牌中有对子
                    else
                    {
                        //自己手中的对子不够
                        if (myFuDoublePoker.Count <= firstDoublePoker.Count)
                        {
                            return(myOutFuDoublePoker.Count == myFuDoublePoker.Count);
                        }

                        //对子够
                        List <List <PokerInfo> > allTljFromFirst = PlayRuleUtil.GetAllTljFromDouble(firstDoublePoker, mLevelPokerNum, masterPokerType);
                        List <List <PokerInfo> > allTljFromMy    = PlayRuleUtil.GetAllTljFromDouble(myFuDoublePoker, mLevelPokerNum, masterPokerType);
                        List <List <PokerInfo> > allTljFromMyOut = PlayRuleUtil.GetAllTljFromDouble(myOutFuDoublePoker, mLevelPokerNum, masterPokerType);
                        if (allTljFromFirst.Count == 0 || allTljFromMy.Count == 0)
                        {
                            return(myOutFuDoublePoker.Count == firstDoublePoker.Count);
                        }
                        if (allTljFromFirst.Count <= allTljFromMy.Count)
                        {
                            return(allTljFromMyOut.Count == allTljFromFirst.Count);
                        }
                        else
                        {
                            return(allTljFromMyOut.Count == allTljFromMy.Count);
                        }
                    }
                }
            }
            break;
            }
        }

        return(true);
    }
Esempio n. 13
0
    public void UpdateUi(List <PokerInfo> handerPoker, List <PokerInfo> lastLiangZhuPoker)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LiangZhu_hotfix", "UpdateUi"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LiangZhu_hotfix", "UpdateUi", null, handerPoker, lastLiangZhuPoker);
            return;
        }

        this.handerPoker = handerPoker;

        ButtonFang.interactable = false;
        ButtonMei.interactable  = false;
        ButtonHong.interactable = false;
        ButtonHei.interactable  = false;
        ButtonWang.interactable = false;

        switch (m_useType)
        {
        case UseType.UseType_chaodi:
            GiveUp.transform.localScale = new Vector3(1, 1, 1);
            textLiangzhu.text           = "抄底";
            break;

        case UseType.UseType_liangzhu:
            GiveUp.transform.localScale = new Vector3(0, 0, 0);
            textLiangzhu.text           = "亮主";
            break;
        }


        liangzhuPoker = PlayRuleUtil.GetLiangzhuPoker(handerPoker, lastLiangZhuPoker, GameData.getInstance().m_levelPokerNum, GameData.getInstance().m_masterPokerType);

        foreach (PokerInfo pokerInfo in liangzhuPoker)
        {
            switch (pokerInfo.m_pokerType)
            {
            case Consts.PokerType.PokerType_FangKuai:
                if (!ButtonFang.interactable)
                {
                    ButtonFang.interactable = true;
                }
                break;

            case Consts.PokerType.PokerType_MeiHua:
                if (!ButtonMei.interactable)
                {
                    ButtonMei.interactable = true;
                }
                break;

            case Consts.PokerType.PokerType_HongTao:
                if (!ButtonHong.interactable)
                {
                    ButtonHong.interactable = true;
                }
                break;

            case Consts.PokerType.PokerType_HeiTao:
                if (!ButtonHei.interactable)
                {
                    ButtonHei.interactable = true;
                }
                break;

            case Consts.PokerType.PokerType_Wang:
                if (!ButtonWang.interactable)
                {
                    ButtonWang.interactable = true;
                }
                break;
            }
        }
    }