Beispiel #1
0
 def isFengyise(self):
     """
     风一色:由东南西北中发白组成的胡牌
     """
     handTile = MHand.copyAllTilesToList(
         self.playerAllTiles[self.winSeatId])  # 手牌区+吃+碰+杠+锚+胡区
     handArr = MTile.changeTilesToValueArr(handTile)
     colorCount = MTile.getColorCount(handArr)
     result, _ = MWin.isLuanFengyise(handTile, colorCount)
     return result
Beispiel #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)
        # 平度麻将即可以听也可以不听,听牌后,校验tingNodes即可,无其他限制条件
        if isTing:
            #[{'winTile': 16, 'winTileCount': 0, 'pattern': [[16, 17, 18], [12, 12]]}, {'winTile': 19, 'winTileCount': 0, 'pattern': [[17, 18, 19], [12, 12]]}]
            for tingNode in tingNodes:
                if tingNode['winTile'] == tile:
                    pattern = tingNode['pattern']
                    return True, pattern

        # 烟台麻将允许胡七对
        resultQiDui, patternQiDui = MWin.isQiDui(tiles[MHand.TYPE_HAND])
        if resultQiDui:
            if self.tableConfig[MTDefine.ONLY_JIANG_258]:
                ftlog.debug('MWinRuleYantai.isHu checkQiDui with 258')
                for pattern in patternQiDui:
                    tile = pattern[0]
                    if tile > MTile.TILE_NINE_TIAO:
                        continue

                    if MTile.getValue(pattern[0]) % 3 == 2:
                        return True, patternQiDui

                return False, []
            return True, patternQiDui

        # 烟台麻将允许胡十三幺
        self.tilePatternChecker.setPlayerAllTiles(tiles)
        if self.tilePatternChecker.isShisanyao():
            if self.tableConfig[MTDefine.ONLY_JIANG_258]:
                ftlog.debug(
                    'MWinRuleYantai.isHu isShisanyao with 258, return False')
                return False, []
            return True, tiles[MHand.TYPE_HAND]

        # 烟台麻将允许胡风一色
        allTiles = MHand.copyAllTilesToList(tiles)
        allArr = MTile.changeTilesToValueArr(allTiles)
        colorCount = MTile.getColorCount(allArr)
        resultFeng, patternFeng = MWin.isLuanFengyise(tiles[MHand.TYPE_HAND],
                                                      colorCount)
        if resultFeng:
            if self.tableConfig[MTDefine.ONLY_JIANG_258]:
                ftlog.debug(
                    'MWinRuleYantai.isHu isLuanFengyise with 258, return False'
                )
                return False, []
            return True, patternFeng

        # 挑出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]]
            ftlog.debug('MWinRuleYantai.isHu with 258')
            for jiangPat in jiangPatterns:
                result, pattern = MWin.isHuWishSpecialJiang(
                    tiles[MHand.TYPE_HAND], jiangPat)
                if result:
                    return result, pattern

            return False, []
        else:
            result, pattern = MWin.isHu(tiles[MHand.TYPE_HAND])
            return result, pattern