示例#1
0
    def is13BuKao(self):
        """
        十三不靠:不同花色的 1、4、7 +  2、5、8 + 3、6、9 + 不相同的风牌4张
        #[[1, 4, 7, 12, 15, 18, 23, 26, 29, 31, 32, 33, 36], [], [], [], [], [35], [36], []]
        """

        handTile = copy.deepcopy(self.playerAllTiles[self.winSeatId][MHand.TYPE_HAND])
        handTile.extend(self.playerAllTiles[self.winSeatId][MHand.TYPE_HU])

        chiTile = copy.deepcopy(self.playerAllTiles[self.winSeatId][MHand.TYPE_CHI])
        pengTile = copy.deepcopy(self.playerAllTiles[self.winSeatId][MHand.TYPE_PENG])
        gangTile = copy.deepcopy(self.playerAllTiles[self.winSeatId][MHand.TYPE_GANG])

        if len(chiTile) > 0 or len(pengTile) > 0 or len(gangTile) > 0:
            return False

        result, _ = MWin.is13BuKao(handTile)

        ftlog.debug('jinan_one_result.is13BuKao result: ', result)
        return result
示例#2
0
    def isHu(self,
             tiles,
             tile,
             isTing,
             getTileType,
             magicTiles=[],
             tingNodes=[],
             winSeatId=0):
        ftlog.debug(self.TAG, '.isHu tiles:', tiles, ' tile:', tile,
                    ' isTing:', isTing, ' getTileType:', getTileType,
                    ' magicTiles:', magicTiles, ' tingNodes:', tingNodes,
                    ' winSeatId:', winSeatId)

        if self.tableTileMgr.isPassHuTileBySeatId(winSeatId, tile):
            return False, []

        # 济南麻将允许胡七对
        qiduiTiles = copy.deepcopy(tiles)
        resultQiDui, patternQiDui = MWin.isQiDui(qiduiTiles[MHand.TYPE_HAND])
        if resultQiDui:
            if self.tableConfig[MTDefine.ONLY_JIANG_258]:
                for pattern in patternQiDui:
                    tile = pattern[0]
                    if tile > MTile.TILE_NINE_TIAO:
                        continue

                    # 选了258将判断这里,而且不能是风牌
                    if (MTile.getValue(pattern[0]) % 3
                            == 2) and pattern[0] < MTile.TILE_DONG_FENG:
                        return True, patternQiDui
                return False, []
            else:
                return resultQiDui, patternQiDui

        # 花胡
        if getTileType == MWinRule.WIN_BY_MYSELF:
            flowerTiles = copy.deepcopy(tiles)
            resFlowerHu, patternFlowerHu = MWin.isFlowerHu(flowerTiles)
            if resFlowerHu:
                return resFlowerHu, patternFlowerHu

        # 全将
        jiangTiles = copy.deepcopy(tiles)
        resQuanj, patternQuanj = MWin.isQuanJiang(jiangTiles)
        if resQuanj:
            return resQuanj, patternQuanj

        # 十三不靠
        if not self.tableConfig[MTDefine.ONLY_JIANG_258]:
            bukaoTiles = copy.deepcopy(tiles)
            res13Bukao, pattern13Bukao = MWin.is13BuKao(
                bukaoTiles[MHand.TYPE_HAND])
            if res13Bukao:
                return res13Bukao, pattern13Bukao

        # 挑出2,5,8将,看剩下的牌是否能胡牌
        if self.tableConfig[MTDefine.ONLY_JIANG_258]:
            jiangPatterns = [[MTile.TILE_TWO_WAN, MTile.TILE_TWO_WAN],
                             [MTile.TILE_FIVE_WAN, MTile.TILE_FIVE_WAN],
                             [MTile.TILE_EIGHT_WAN, MTile.TILE_EIGHT_WAN],
                             [MTile.TILE_TWO_TONG, MTile.TILE_TWO_TONG],
                             [MTile.TILE_FIVE_TONG, MTile.TILE_FIVE_TONG],
                             [MTile.TILE_EIGHT_TONG, MTile.TILE_EIGHT_TONG],
                             [MTile.TILE_TWO_TIAO, MTile.TILE_TWO_TIAO],
                             [MTile.TILE_FIVE_TIAO, MTile.TILE_FIVE_TIAO],
                             [MTile.TILE_EIGHT_TIAO, MTile.TILE_EIGHT_TIAO]]

            jiangTiles = copy.deepcopy(tiles)
            for jiangPat in jiangPatterns:
                result, pattern = MWin.isHuWishSpecialJiang(
                    jiangTiles[MHand.TYPE_HAND], jiangPat)
                if result:
                    return result, pattern
        else:
            newTiles = copy.deepcopy(tiles)
            result, pattern = MWin.isHu(newTiles[MHand.TYPE_HAND])
            return result, pattern

        return False, []