def isHunyise(self): """ 混一色:只有一色牌(如全是万),有金牌,但金牌不同色 """ ''' colorArr = [0, 0, 0, 0] handTile = MHand.copyAllTilesToList(self.playerAllTiles[self.winSeatId]) # 手牌区+吃+碰+杠+锚+胡区 for tile in handTile: color = MTile.getColor(tile) colorArr[color] = 1 magicTile = self.tableTileMgr.getMagicTile() magicTileColor = MTile.getColor(magicTile) handTile = MHand.copyAllTilesToList(self.playerAllTiles[self.winSeatId]) tilesArr = MTile.changeTilesToValueArr(handTile) count = MTile.getTileCountByColor(tilesArr, magicTileColor) magicCount = MTile.getTileCount(magicTile,handTile[MHand.TYPE_HAND]) if count!=magicCount: return False colorCount = 0 for eachColor in colorArr: if eachColor: colorCount += 1 if colorCount == 2 and colorArr[magicTileColor] == 1: return True return False ''' magicTile = self.tableTileMgr.getMagicTile() magicCount = 0 allTiles = MHand.copyAllTilesToList(self.playerAllTiles[self.winSeatId]) #allTiles = MHand.copyAllTilesToListButHu(handTile) allTileArr = MTile.changeTilesToValueArr(allTiles) allColors = MTile.getColorCount(allTileArr) for tile in allTiles: if magicTile and tile == magicTile: magicCount = magicCount + 1 for i in range(magicCount): allTiles.remove(magicTile) tileArr = MTile.changeTilesToValueArr(allTiles) colors = MTile.getColorCount(tileArr) if allColors == 2 and colors == 1: return True return False
def isJipinghu(self, pattern, tiles, tileArr, magicTiles): useforColor = tileArr if len(magicTiles) > 0: useforColor[magicTiles[0]] = 0 hasfeng = 0 for tile in MTile.traverseTile(MTile.TILE_FENG): if tileArr[tile]: hasfeng += 1 break if MTile.getColorCount(useforColor) - hasfeng <= 1: return False kecount = 0 shuncount = 0 bothok = 0 for p in pattern: if len(p) == 3: magiccount = 0 for x in p: if len(magicTiles) > 0 and x == magicTiles[0]: magiccount += 1 if magiccount >= 2: bothok += 1 else: if p[0] == p[1] or p[0] == p[2] or p[1] == p[2]: kecount += 1 else: shuncount += 1 kecount += len(tiles[MHand.TYPE_PENG]) kecount += len(tiles[MHand.TYPE_GANG]) ftlog.debug('MWinRuleJiPingHu.isJipinghu kecount:', kecount, 'shuncount:', shuncount, 'bothok:', bothok) # 排除掉碰碰胡 if shuncount == 0: return False # 排除掉三元 haszhong = 0 for tile in [35, 36, 37]: if tileArr[tile] > 0: haszhong += 1 if haszhong == 3: return False # 排除掉四喜 hasfeng = 0 for tile in [31, 32, 33, 34]: if tileArr[tile] > 0: hasfeng += 1 if hasfeng == 4: return False if shuncount > 0 and kecount > 0: ftlog.debug('MWinRuleJiPingHu.isJipinghu True') return True return False
def isQingyise(self, tiles): """ 清一色:由同一门花色(筒子或条子)组成的和牌牌型 """ tileArr = MTile.changeTilesToValueArr(MHand.copyAllTilesToListButHu(tiles)) colors = MTile.getColorCount(tileArr) #ftlog.debug('MWinRuleQueshou.isQingyise tileArr=',tileArr,colors) return colors == 1
def isQingyise(self, tiles): """ 清一色:由同一门花色(筒子或条子)组成的和牌牌型 """ tileArr = MTile.changeTilesToValueArr( MHand.copyAllTilesToListButHu(tiles)) colors = MTile.getColorCount(tileArr) #ftlog.debug('MWinRuleQueshou.isQingyise tileArr=',tileArr,colors) return colors == 1
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
def isHunyise(self, tiles, magicTiles): if not len(magicTiles): return False magicTile = magicTiles[0] magicCount = 0 allTiles = MHand.copyAllTilesToListButHu(tiles) allTileArr = MTile.changeTilesToValueArr(allTiles) allColors = MTile.getColorCount(allTileArr) for tile in allTiles: if tile == magicTile: magicCount = magicCount + 1 for i in range(magicCount): allTiles.remove(magicTile) tileArr = MTile.changeTilesToValueArr(allTiles) colors = MTile.getColorCount(tileArr) #ftlog.debug('MWinRuleQueshou.isHunyise allColors colors=',allColors,colors,magicCount,allTiles) if allColors == 2 and colors == 1: return True return False
def isHunyise(self, tiles, magicTiles): if not len(magicTiles): return False magicTile = magicTiles[0] magicCount = 0 allTiles = MHand.copyAllTilesToListButHu(tiles) allTileArr = MTile.changeTilesToValueArr(allTiles) allColors = MTile.getColorCount(allTileArr) for tile in allTiles: if tile == magicTile: magicCount = magicCount + 1 for i in range(magicCount): allTiles.remove(magicTile) tileArr = MTile.changeTilesToValueArr(allTiles) colors = MTile.getColorCount(tileArr) #ftlog.debug('MWinRuleQueshou.isHunyise allColors colors=',allColors,colors,magicCount,allTiles) if allColors == 2 and colors == 1: return True return False
def isQingYiSe(self): if self.colorState[self.winSeatId] == 1: return True if self.isMagicTile(): tileArr = MTile.changeTilesToValueArr( MHand.copyAllTilesToListButHu( self.playerAllTiles[self.winSeatId])) tempCountColor = MTile.getColorCount(tileArr) if tempCountColor == 1: return True return False
def canTing(self, tiles, leftTiles, tile, magicTiles=[], winSeatId=0): """子类必须实现 参数: 1)tiles 该玩家的手牌 2)leftTiles 剩余手牌 返回值: 是否可以听牌,听牌详情 """ handCount = len(tiles[MHand.TYPE_HAND]) if handCount < 5: return False, [] isTing, tingResults = MTing.canTing(self.tilePatternChecker, self.tableTileMgr, MTile.cloneTiles(tiles), leftTiles, self.winRuleMgr, tile, magicTiles, winSeatId) ftlog.debug('MTingHaerbinRule.MTing.canTing isTing:', isTing, ' tingResults:', tingResults) # [{'dropTile': 11, 'winNodes': [{'winTile': 1, 'winTileCount': 3, 'pattern': [[6, 6], [5, 6, 7], [4, 5, 6], [1, 2, 3]]}, {'winTile': 2, 'winTileCount': 2, 'pattern': [[6, 6, 6], [5, 6, 7], [3, 4, 5], [2, 2]]}, {'winTile': 4, 'winTileCount': 3, 'pattern': [[6, 6], [5, 6, 7], [4, 5, 6], [2, 3, 4]]}, {'winTile': 5, 'winTileCount': 2, 'pattern': [[6, 6, 6], [5, 6, 7], [5, 5], [2, 3, 4]]}, {'winTile': 7, 'winTileCount': 1, 'pattern': [[6, 6], [5, 6, 7], [5, 6, 7], [2, 3, 4]]}, {'winTile': 8, 'winTileCount': 1, 'pattern': [[6, 7, 8], [6, 6, 6], [5, 5], [2, 3, 4]]}]}] if not isTing: return False, [] chiCount = len(tiles[MHand.TYPE_CHI]) pengCount = len(tiles[MHand.TYPE_PENG]) gangCount = len(tiles[MHand.TYPE_GANG]) mingGangCount = 0 anGangCount = 0 #计算明杠个数,因为暗杠不算开门 if gangCount != 0: mingGangCount, anGangCount = MTile.calcGangCount( tiles[MHand.TYPE_GANG]) ftlog.debug('MTingHaerbinRule.gang tiles:', tiles[MHand.TYPE_GANG], ' mingGangCount=', mingGangCount, ' anGangCount=', anGangCount) if (chiCount + pengCount + mingGangCount) == 0: return False, [] # 检查刻,刻的来源,碰牌/明杠牌/手牌 keCount = pengCount + mingGangCount + anGangCount # 必须有顺牌 shunCount = chiCount newTingResults = [] for tingResult in tingResults: newWinNodes = [] winNodes = tingResult['winNodes'] for winNode in winNodes: newTiles = MTile.cloneTiles(tiles) newTiles[MHand.TYPE_HAND].remove(tingResult['dropTile']) newTiles[MHand.TYPE_HAND].append(winNode['winTile']) tileArr = MTile.changeTilesToValueArr( MHand.copyAllTilesToList(newTiles)) # ftlog.debug( 'MTingHaerbinRule.canTing tileArr:', tileArr ) # 清一色不可以听牌/和牌 if self.getTableConfig(MTDefine.YISE_CAN_TING, 0) != 1: newTileArr = copy.deepcopy(tileArr) newTileArr[MTile.TILE_HONG_ZHONG] = 0 colorCount = MTile.getColorCount(newTileArr) if colorCount == 1: # 清一色不能和牌 ftlog.debug('MTingHaerbinRule.canTing colorCount:', colorCount, ' can not win, continue....') continue # 检查牌中的幺/九 # 1软 听牌可以没有19,只要胡牌带19就可以 # 2硬 听牌时就要有19 RuanYaoJiuConfig = self.getTableConfig(MTDefine.RUAN_YAO_JIU, 1) if RuanYaoJiuConfig == 0: #硬幺九 :听牌必须有19 #tileArr 减去 winNode['winTile'] 后判断 tileArr[winNode['winTile']] -= 1 yaoCount = tileArr[MTile.TILE_ONE_WAN] + tileArr[ MTile.TILE_ONE_TONG] + tileArr[MTile.TILE_ONE_TIAO] jiuCount = tileArr[MTile.TILE_NINE_WAN] + tileArr[ MTile.TILE_NINE_TONG] + tileArr[MTile.TILE_NINE_TIAO] zhongCount = tileArr[MTile.TILE_HONG_ZHONG] ftlog.debug('MTingJixiRule.canTing : YING yaoCount:', yaoCount, 'jiuCount', jiuCount, 'zhongCount', zhongCount) if (yaoCount + jiuCount + zhongCount) <= 0: continue else: #软幺九 :只要胡牌有19就行 yaoCount = tileArr[MTile.TILE_ONE_WAN] + tileArr[ MTile.TILE_ONE_TONG] + tileArr[MTile.TILE_ONE_TIAO] jiuCount = tileArr[MTile.TILE_NINE_WAN] + tileArr[ MTile.TILE_NINE_TONG] + tileArr[MTile.TILE_NINE_TIAO] zhongCount = tileArr[MTile.TILE_HONG_ZHONG] ftlog.debug('MTingJixiRule.canTing : RUAN yaoCount:', yaoCount, 'jiuCount', jiuCount, 'zhongCount', zhongCount) if (yaoCount + jiuCount + zhongCount) == 0: continue patterns = winNode['pattern'] #夹起步(顺牌只能和夹和3,7) 除单吊 chunJiaConfig = self.getTableConfig(MTDefine.MIN_MULTI, 0) if chunJiaConfig: bianMulti = self.tableConfig.get(MTDefine.BIAN_MULTI, 0) danDiaoJia = self.tableConfig.get(MTDefine.DAN_DIAO_JIA, 1) hasJia = False for pattern in patterns: if winNode['winTile'] in pattern: if len(pattern) == 3 and pattern[0] != pattern[1]: if pattern.index(winNode['winTile']) == 2: if bianMulti: if MTile.getValue( winNode['winTile']) == 3: hasJia = True break if pattern.index(winNode['winTile']) == 0: if bianMulti: if MTile.getValue( winNode['winTile']) == 7: hasJia = True break if pattern.index(winNode['winTile']) == 1: hasJia = True break #单吊 if len(pattern) == 2 and pattern[0] == pattern[ 1] and danDiaoJia: hasJia = True break if not hasJia: ftlog.debug( 'MTingHaerbinRule.canTing :, can not win tile:', winNode['winTile'], ', not has jia continue....') continue patterns = winNode['pattern'] checkKeCount = keCount + self.getKeCount(patterns) checkShunCount = shunCount + self.getShunCount(patterns) ftlog.debug('MTingHaerbinRule.canTing keCount:', keCount, ' shunCount:', shunCount) if checkKeCount and checkShunCount: newWinNodes.append(winNode) if len(newWinNodes) > 0: newTingResult = {} newTingResult['dropTile'] = tingResult['dropTile'] newTingResult['winNodes'] = newWinNodes newTingResults.append(newTingResult) return len(newTingResults) > 0, newTingResults
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
def canTing(self, tiles, leftTiles, tile, magicTiles=[], winSeatId=0): """子类必须实现 参数: 1)tiles 该玩家的手牌 2)leftTiles 剩余手牌 返回值: 是否可以听牌,听牌详情 """ handCount = len(tiles[MHand.TYPE_HAND]) if handCount < 5: return False, [] isTing, tingResults = MTing.canTing(self.tilePatternChecker, self.tableTileMgr, MTile.cloneTiles(tiles), leftTiles, self.winRuleMgr, tile, magicTiles, winSeatId) ftlog.debug('MTingMudanjiangRule.MTing.canTing isTing:', isTing, ' tingResults:', tingResults) # [{'dropTile': 11, 'winNodes': [{'winTile': 1, 'winTileCount': 3, 'pattern': [[6, 6], [5, 6, 7], [4, 5, 6], [1, 2, 3]]}, {'winTile': 2, 'winTileCount': 2, 'pattern': [[6, 6, 6], [5, 6, 7], [3, 4, 5], [2, 2]]}, {'winTile': 4, 'winTileCount': 3, 'pattern': [[6, 6], [5, 6, 7], [4, 5, 6], [2, 3, 4]]}, {'winTile': 5, 'winTileCount': 2, 'pattern': [[6, 6, 6], [5, 6, 7], [5, 5], [2, 3, 4]]}, {'winTile': 7, 'winTileCount': 1, 'pattern': [[6, 6], [5, 6, 7], [5, 6, 7], [2, 3, 4]]}, {'winTile': 8, 'winTileCount': 1, 'pattern': [[6, 7, 8], [6, 6, 6], [5, 5], [2, 3, 4]]}]}] if not isTing: return False, [] chiCount = len(tiles[MHand.TYPE_CHI]) pengCount = len(tiles[MHand.TYPE_PENG]) gangCount = len(tiles[MHand.TYPE_GANG]) mingGangCount = 0 anGangCount = 0 #计算明杠个数,因为暗杠不算开门 if gangCount != 0: mingGangCount, anGangCount = MTile.calcGangCount( tiles[MHand.TYPE_GANG]) ftlog.debug('MTingMudanjiangRule.gang tiles:', tiles[MHand.TYPE_GANG], ' mingGangCount=', mingGangCount, ' anGangCount=', anGangCount) #daKouConfig = self.getTableConfig(MTDefine.DA_KOU, 0) daKouConfig = 1 ftlog.debug('.canTing daKouConfig:', daKouConfig) if daKouConfig != 1: if (chiCount + pengCount + mingGangCount) == 0: return False, [] # 检查刻,刻的来源,碰牌/明杠牌/手牌 keCount = pengCount + mingGangCount + anGangCount # 必须有顺牌 shunCount = chiCount newTingResults = [] for tingResult in tingResults: newWinNodes = [] winNodes = tingResult['winNodes'] for winNode in winNodes: newTiles = MTile.cloneTiles(tiles) newTiles[MHand.TYPE_HAND].remove(tingResult['dropTile']) newTiles[MHand.TYPE_HAND].append(winNode['winTile']) tileArr = MTile.changeTilesToValueArr( MHand.copyAllTilesToList(newTiles)) # ftlog.debug( 'MTingMudanjiangRule.canTing tileArr:', tileArr ) # 清一色不可以听牌/和牌 if self.getTableConfig(MTDefine.YISE_CAN_TING, 0) != 1: newTileArr = copy.deepcopy(tileArr) newTileArr[MTile.TILE_HONG_ZHONG] = 0 colorCount = MTile.getColorCount(newTileArr) if colorCount == 1: # 清一色不能和牌 ftlog.debug('MTingMudanjiangRule.canTing colorCount:', colorCount, ' can not win, continue....') continue # 检查牌中的幺/九 # 1软 听牌可以没有19,只要胡牌带19就可以 # 2硬 听牌时就要有19 RuanYaoJiuConfig = self.getTableConfig(MTDefine.RUAN_YAO_JIU, 1) if RuanYaoJiuConfig == 0: #硬幺九 :听牌必须有19 #tileArr 减去 winNode['winTile'] 后判断 tileArr[winNode['winTile']] -= 1 yaoCount = tileArr[MTile.TILE_ONE_WAN] + tileArr[ MTile.TILE_ONE_TONG] + tileArr[MTile.TILE_ONE_TIAO] jiuCount = tileArr[MTile.TILE_NINE_WAN] + tileArr[ MTile.TILE_NINE_TONG] + tileArr[MTile.TILE_NINE_TIAO] zhongCount = tileArr[MTile.TILE_HONG_ZHONG] ftlog.debug('MTingMudanjiangRule.canTing : YING yaoCount:', yaoCount, 'jiuCount', jiuCount, 'zhongCount', zhongCount) if (yaoCount + jiuCount + zhongCount) <= 0: continue else: #软幺九 :只要胡牌有19就行 yaoCount = tileArr[MTile.TILE_ONE_WAN] + tileArr[ MTile.TILE_ONE_TONG] + tileArr[MTile.TILE_ONE_TIAO] jiuCount = tileArr[MTile.TILE_NINE_WAN] + tileArr[ MTile.TILE_NINE_TONG] + tileArr[MTile.TILE_NINE_TIAO] zhongCount = tileArr[MTile.TILE_HONG_ZHONG] ftlog.debug('MTingMudanjiangRule.canTing : RUAN yaoCount:', yaoCount, 'jiuCount', jiuCount, 'zhongCount', zhongCount) if (yaoCount + jiuCount + zhongCount) == 0: continue patterns = winNode['pattern'] winTile = winNode['winTile'] #夹起步(顺牌只能和夹和3,7) 除单吊 chunJiaConfig = self.getTableConfig(MTDefine.MIN_MULTI, 0) if chunJiaConfig: hasJia = False bianMulti = self.tableConfig.get(MTDefine.BIAN_MULTI, 0) if bianMulti: if MTile.getValue( winTile ) == 3 and winTile < MTile.TILE_DONG_FENG: newTilesBian = copy.deepcopy(newTiles) # 1,2,3 if ((winTile - 2) in newTilesBian[MHand.TYPE_HAND]) and ( (winTile - 1) in newTilesBian[MHand.TYPE_HAND]): newTilesBian[MHand.TYPE_HAND].remove(winTile - 2) newTilesBian[MHand.TYPE_HAND].remove(winTile - 1) newTilesBian[MHand.TYPE_HAND].remove(winTile) newTilesBian[MHand.TYPE_CHI].append( [winTile - 2, winTile - 1, winTile]) rBian, rPattern = self.winRuleMgr.isHu( newTilesBian, winTile, True, MWinRule.WIN_BY_MYSELF, magicTiles) if rBian: ftlog.debug( 'MTingMudanjiangRule isJia 3 Bian : ', newTilesBian, ' patterns:', rPattern) hasJia = True if not hasJia and MTile.getValue( winTile ) == 7 and winTile < MTile.TILE_DONG_FENG: newTiles37 = copy.deepcopy(newTiles) # 7,8,9 if ((winTile + 1) in newTiles37[MHand.TYPE_HAND]) and ( (winTile + 2) in newTiles37[MHand.TYPE_HAND]): newTiles37[MHand.TYPE_HAND].remove(winTile + 1) newTiles37[MHand.TYPE_HAND].remove(winTile + 2) newTiles37[MHand.TYPE_HAND].remove(winTile) newTiles37[MHand.TYPE_CHI].append( [winTile, winTile + 1, winTile + 2]) rQi, qiPattern = self.winRuleMgr.isHu( newTiles37, winTile, True, MWinRule.WIN_BY_MYSELF, magicTiles) if rQi: ftlog.debug( 'MTingMudanjiangRule isJia 7 Bian : ', newTiles37, ' pattern:', qiPattern) hasJia = True danDiaoJia = self.tableConfig.get(MTDefine.DAN_DIAO_JIA, 1) if not hasJia and danDiaoJia: newTilesDan = copy.deepcopy(newTiles) ftlog.debug( 'MTingMudanjiangRule isJia in >> danDiao : ', newTilesDan) # 5,5 if winTile in newTilesDan[MHand.TYPE_HAND]: rDan, danPattern = MWin.isHuWishSpecialJiang( newTilesDan[MHand.TYPE_HAND], [winTile, winTile], magicTiles) if rDan: ftlog.debug( 'MTingMudanjiangRule isJia danDiao : ', newTilesDan, ' winTile:', winTile, ' pattern:', danPattern) hasJia = True if not hasJia: newTilesJia = copy.deepcopy(newTiles) # 2,3,4 if ((winTile - 1) in newTilesJia[MHand.TYPE_HAND]) and ( (winTile + 1) in newTilesJia[MHand.TYPE_HAND]): newTilesJia[MHand.TYPE_HAND].remove(winTile + 1) newTilesJia[MHand.TYPE_HAND].remove(winTile - 1) newTilesJia[MHand.TYPE_HAND].remove(winTile) newTilesJia[MHand.TYPE_CHI].append( [winTile - 1, winTile, winTile + 1]) rJia, jiaPattern = self.winRuleMgr.isHu( newTilesJia, winTile, True, MWinRule.WIN_BY_MYSELF, magicTiles) if rJia: ftlog.debug('MTingMudanjiangRule isJia : ', newTilesJia, ' pattern:', jiaPattern) hasJia = True # winNodes中的patterns只是胡牌的一种方式,不是全部的胡牌解,判断夹牌,只使用patterns的组合会有遗漏的情况 # 合理的做法是先把夹拿出来,在判断剩下的牌是否能胡。 if not hasJia: ftlog.debug( 'MTingMudanjiangRule.canTing :, can not win tile:', winNode['winTile'], ', not has jia continue....') continue patterns = winNode['pattern'] checkKeCount = keCount + self.getKeCount(patterns) checkShunCount = shunCount + self.getShunCount(patterns) ftlog.debug('MTingMudanjiangRule.canTing checkKeCount:', checkKeCount, ' checkShunCount:', checkShunCount) if checkKeCount and checkShunCount: newWinNodes.append(winNode) if len(newWinNodes) > 0: newTingResult = {} newTingResult['dropTile'] = tingResult['dropTile'] newTingResult['winNodes'] = newWinNodes newTingResults.append(newTingResult) return len(newTingResults) > 0, newTingResults