def doQingYiSe(self, allTiles, leftTiles, seatId, abColors): ''' 是否做清一色 ''' isSanSha, bestColor = self.isSanShaQingYiSe(seatId, abColors) if isSanSha: ftlog.debug('SanSha, best situation!!! doSanShaQingYiSe') return True, bestColor length = 9 if len(leftTiles) >= 50: length = 8 elif len(leftTiles) >= 40: length = 9 elif len(leftTiles) >= 30: length = 10 elif len(leftTiles) >= 20: length = 11 allTilesArr = MHand.copyAllTilesToList(allTiles) cpgTiles = MHand.copyTiles( allTiles, [MHand.TYPE_CHI, MHand.TYPE_PENG, MHand.TYPE_GANG]) wans = MTile.filterTiles(allTilesArr, MTile.TILE_WAN) wanLength = len(wans) if wanLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_WAN: return False, MTile.TILE_FENG return True, MTile.TILE_WAN tongs = MTile.filterTiles(allTilesArr, MTile.TILE_TONG) tongLength = len(tongs) if tongLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_TONG: return False, MTile.TILE_FENG return True, MTile.TILE_TONG tiaos = MTile.filterTiles(allTilesArr, MTile.TILE_TIAO) tiaoLength = len(tiaos) if tiaoLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_TIAO: return False, MTile.TILE_FENG return True, MTile.TILE_TIAO if wanLength >= tongLength and wanLength >= tiaoLength: return False, MTile.TILE_WAN elif tongLength >= wanLength and tongLength >= tiaoLength: return False, MTile.TILE_TONG else: return False, MTile.TILE_TIAO
def doQingYiSe(self, allTiles, leftTiles): ''' 是否做清一色 ''' length = 9 if len(leftTiles) >= 50: length = 8 elif len(leftTiles) >= 40: length = 9 elif len(leftTiles) >= 30: length = 10 elif len(leftTiles) >= 20: length = 11 allTilesArr = MHand.copyAllTilesToList(allTiles) cpgTiles = MHand.copyTiles( allTiles, [MHand.TYPE_CHI, MHand.TYPE_PENG, MHand.TYPE_GANG]) wans = MTile.filterTiles(allTilesArr, MTile.TILE_WAN) wanLength = len(wans) if wanLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_WAN: return False, MTile.TILE_FENG return True, MTile.TILE_WAN tongs = MTile.filterTiles(allTilesArr, MTile.TILE_TONG) tongLength = len(tongs) if tongLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_TONG: return False, MTile.TILE_FENG return True, MTile.TILE_TONG tiaos = MTile.filterTiles(allTilesArr, MTile.TILE_TIAO) tiaoLength = len(tiaos) if tiaoLength >= length: for tile in cpgTiles: if MTile.getColor(tile) != MTile.TILE_TIAO: return False, MTile.TILE_FENG return True, MTile.TILE_TIAO if wanLength >= tongLength and wanLength >= tiaoLength: return False, MTile.TILE_WAN elif tongLength >= wanLength and tongLength >= tiaoLength: return False, MTile.TILE_TONG else: return False, MTile.TILE_TIAO