def can_win(self, handTiles, finalTile, win_op, idx): """ 能胡牌 """ quantity, result = 0, [] if len(handTiles) % 3 != 2: return False, quantity, result tiles = sorted(handTiles) chars, bambs, dots, dragon_red = self.classify_tiles(tiles) c_need1 = utility.meld_only_need_num(chars) c_need2 = utility.meld_with_pair_need_num(chars) if c_need1 > dragon_red and c_need2 > dragon_red: return False, quantity, result b_need1 = utility.meld_only_need_num(bambs) b_need2 = utility.meld_with_pair_need_num(bambs) if b_need1 > dragon_red and b_need2 > dragon_red: return False, quantity, result d_need1 = utility.meld_only_need_num(dots) d_need2 = utility.meld_with_pair_need_num(dots) if d_need1 > dragon_red and d_need2 > dragon_red: return False, quantity, result if c_need2 + b_need1 + d_need1 <= dragon_red or \ c_need1 + b_need2 + d_need1 <= dragon_red or \ c_need1 + b_need1 + d_need2 <= dragon_red: return True, quantity, result return False, quantity, result
def getNormalTipsWinList(self, handTiles, finalTile): copyHandTiles = handTiles[:] copyHandTiles = sorted(copyHandTiles) tipsList = [] copyHandTiles.remove(finalTile) # 万 条 筒 for tup in (const.CHARACTER, const.BAMBOO, const.DOT): for t in tup: tryTiles = copyHandTiles[:] tryTiles.append(t) tryTiles = sorted(tryTiles) if utility.meld_with_pair_need_num(tryTiles, {}) <= 0: tipsList.append(t) # 红中 tryTiles = copyHandTiles[:] tryTiles.append(const.DRAGON_RED) tryTiles = sorted(tryTiles) if utility.meld_with_pair_need_num(tryTiles, {}) <= 0: tipsList.append(const.DRAGON_RED) # 白板 tryTiles = copyHandTiles[:] tryTiles.append(const.DRAGON_WHITE) tryTiles = sorted(tryTiles) if utility.meld_with_pair_need_num(tryTiles, {}) <= 0: tipsList.append(const.DRAGON_WHITE) return tipsList
def can_win(self, handTiles): if len(handTiles) % 3 != 2: return False copyTiles = handTiles[:] copyTiles = sorted(copyTiles) if util.meld_with_pair_need_num(copyTiles, {}) <= 0: return True return False
def removeCheckPairWin(handTilesButKing, removeTuple, useKingNum, kingTilesNum): if useKingNum <= kingTilesNum: tryHandTilesButKing = handTilesButKing[:] tryHandTilesButKing = sorted(tryHandTilesButKing) for t in removeTuple: if t != -1: try: tryHandTilesButKing.remove(t) except: DEBUG_MSG("removeCheckPairWin remove fail.{0},{1}".format(removeTuple, tryHandTilesButKing)) if utility.meld_with_pair_need_num(tryHandTilesButKing, {}) <= kingTilesNum - useKingNum: return True return False
def checkIsOneDragon(handTilesButKing): """ 在已经是胡牌牌型的情况下,判断是否是一条龙 """ if len(handTilesButKing) < 9: return False handTilesButKing = sorted(handTilesButKing) dragonCharacter = False dragonNum = 0 for c in const.CHARACTER: if c in handTilesButKing: dragonNum += 1 if dragonNum >= len(const.CHARACTER): dragonCharacter = True # return True dragonBamboo = False dragonNum = 0 if dragonCharacter == False: for b in const.BAMBOO: if b in handTilesButKing: dragonNum += 1 if dragonNum >= len(const.BAMBOO): dragonBamboo = True dragonDot = False dragonNum = 0 if dragonCharacter == False and dragonBamboo == False: for d in const.DOT: if d in handTilesButKing: dragonNum += 1 if dragonNum >= len(const.DOT): dragonDot = True handTilesButKingTemp = list(handTilesButKing) if dragonCharacter: for t in const.CHARACTER: if t in handTilesButKing: handTilesButKingTemp.remove(t) if dragonBamboo: for t in const.BAMBOO: if t in handTilesButKing: handTilesButKingTemp.remove(t) if dragonDot: for t in const.DOT: if t in handTilesButKing: handTilesButKingTemp.remove(t) if dragonCharacter or dragonBamboo or dragonDot: if utility.meld_with_pair_need_num(handTilesButKingTemp) <= 0: return True return False
def can_win(self, handTiles, finalTile, win_op, idx): #"""平胡 爆头 七对子 清七对""" #"""杠 + 飘""" result_list = [0] * 4 multiply = 0 if len(handTiles) % 3 != 2: DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, self.base_score * (2**multiply), result_list if win_op == const.OP_WREATH_WIN: DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, 2 ** multiply, result_list if win_op == const.OP_GIVE_WIN and finalTile in self.kingTiles: DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, 2 ** multiply, result_list p = self.players_list[idx] handCopyTiles = list(handTiles) handCopyTiles = sorted(handCopyTiles) kings, handTilesButKing = utility.classifyKingTiles(handCopyTiles, self.kingTiles) kingTilesNum = len(kings) # 白板代替财神 if len(self.kingTiles) > 0: handTilesButKing = list(map(lambda x:self.kingTiles[0] if x == const.DRAGON_WHITE else x, handTilesButKing)) insteadFinalTile = self.kingTiles[0] if finalTile == const.DRAGON_WHITE else finalTile else: insteadFinalTile = finalTile handTilesButKing = sorted(handTilesButKing) #2N is7Pair, isBaoTou, kongNum = utility.checkIs7Pair(handCopyTiles, handTilesButKing, kingTilesNum, self.kingTiles, insteadFinalTile) if is7Pair: DEBUG_MSG("room:{},curround:{} is7Pair".format(self.roomID, self.current_round)) result_list[2] = 1 + kongNum multiply += result_list[2] if isBaoTou: result_list[1] = 1 kingKongList = [1 if op == const.OP_DISCARD else -1 for op in utility.serialKingKong(p.op_r, self.kingTiles)] multiply += len(kingKongList) + 1 result_list.extend(kingKongList) DEBUG_MSG("room:{},curround:{} is7Pair baotou".format(self.roomID, self.current_round)) return True , self.base_score * (2 ** multiply), result_list elif kingTilesNum <= 0: result_list[3] = 1 multiply += 1 DEBUG_MSG("room:{},curround:{} is7Pair not baotou kingNum:0".format(self.roomID, self.current_round)) return True, self.base_score * (2 ** multiply), result_list if self.bao_tou == 0: return True, self.base_score * (2**multiply), result_list #3N2 result_list = [0] * 4 multiply = 0 if kingTilesNum <= 0: #无财神(只要满足能胡就可以胡) DEBUG_MSG("room:{},curround:{} kingTilesNum <= 0".format(self.roomID, self.current_round)) if utility.meld_with_pair_need_num(handTilesButKing) <= kingTilesNum: result_list[0] = 1 for op in utility.serialKingKong(p.op_r, self.kingTiles): #只有连续杠开 if op != const.OP_DISCARD: result_list.append(-1) multiply += 1 else: break DEBUG_MSG("room:{},curround:{} 3N2 kingNum:0".format(self.roomID, self.current_round)) return True, self.base_score * (2**multiply), result_list DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, self.base_score * (2**multiply), result_list else: #有财神(只要暴头都可以胡, 如果有财必暴,非暴头不能胡) # 除去暴头一对组成3N baotou_n3_list = [] tryKingsNum = kingTilesNum if finalTile in self.kingTiles: # 最后一张 摸的是财神 if tryKingsNum >= 2: tryKingsNum -= 2 baotou_n3_list.append(list(handTilesButKing)) else: tryKingsNum -= 1 tryList = list(handTilesButKing) tryList.remove(insteadFinalTile) # 若最后一张不是财神 则用代替后的牌 baotou_n3_list.append(tryList) DEBUG_MSG("room:{},curround:{} baotou_n3_list:{}".format(self.roomID, self.current_round, baotou_n3_list)) #优先尝试暴头 for tryList in baotou_n3_list: if utility.getMeldNeed(tryList) <= tryKingsNum: result_list[1] = 1 # 连续飘杠胜利 kingKongList = [1 if op == const.OP_DISCARD else -1 for op in utility.serialKingKong(p.op_r, self.kingTiles)] multiply += len(kingKongList) + 1 result_list.extend(kingKongList) DEBUG_MSG("room:{},curround:{} 3N baotou".format(self.roomID, self.current_round)) return True, self.base_score * (2 ** multiply), result_list else: DEBUG_MSG("room:{},curround:{} try not baotou".format(self.roomID, self.current_round)) if self.bao_tou == 0 and utility.winWith3N2NeedKing(handTilesButKing) <= kingTilesNum: result_list[0] = 1 # 连续杠胜利 for op in utility.serialKingKong(p.op_r, self.kingTiles): # 只有连续杠开 if op != const.OP_DISCARD: result_list.append(-1) multiply += 1 else: break DEBUG_MSG("room:{},curround:{} 3N not baotou".format(self.roomID, self.current_round)) return True, self.base_score * (2 ** multiply), result_list DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, self.base_score * (2 ** multiply), result_list
def can_win(self, handTiles, finalTile, win_op, idx): DEBUG_MSG("check can win:{}".format(idx)) victory_value = 0 result = [0] * 12 if const.DRAGON_GREEN in handTiles: return False, victory_value, result if win_op == const.OP_GIVE_WIN and self.players_list[idx].pass_dealer[ 0]: # 没过庄不能胡 return False, victory_value, result p = self.players_list[idx] copyHandTiles = handTiles[:] copyHandTiles = sorted(copyHandTiles) tile2NumDict = utility.getTile2NumDict(handTiles) # 杠子 kongNum = sum([1 for meld in p.upTiles if len(meld) == 4]) # 门前清 pongExposedKongNum = sum([ 1 for player_op in p.op_r if player_op[0] == const.OP_EXPOSED_KONG ]) pongExposedKongNum += sum([1 for meld in p.upTiles if len(meld) <= 3]) # 发财数量 dragonGreenNum = len(p.dragon_greens) # 7对 if utility.checkIs7Pair(copyHandTiles): #**********1炮************* # 平胡 result[0] = 1 victory_value += 1 DEBUG_MSG("PingHu victory_value:{0}".format(victory_value)) DEBUG_MSG("平胡") # 自摸 if win_op == const.OP_DRAW_WIN: result[1] = 1 victory_value += 1 DEBUG_MSG("ZiMo victory_value:{0}".format(victory_value)) DEBUG_MSG("自摸") #**********2炮************* # 手抓 3 红中/白板 if const.DRAGON_RED in tile2NumDict and tile2NumDict[ const.DRAGON_RED] >= 3: victory_value += 2 DEBUG_MSG( "SanHongZhong victory_value:{0}".format(victory_value)) DEBUG_MSG("手抓 3 红中") if const.DRAGON_WHITE in tile2NumDict and tile2NumDict[ const.DRAGON_WHITE] >= 3: victory_value += 2 DEBUG_MSG("SanBaiBan victory_value:{0}".format(victory_value)) DEBUG_MSG("手抓 3 白板") #**********5炮************* # 抢杠 if win_op == const.OP_KONG_WIN: result[4] = 1 victory_value += 5 DEBUG_MSG("QiangGang victory_value:{0}".format(victory_value)) DEBUG_MSG("抢杠") # 流泪 if win_op == const.OP_GIVE_WIN and utility.checkIsKongDiscard( self.players_list[self.last_player_idx].op_r): result[5] = 1 victory_value += 5 DEBUG_MSG("LiuLei victory_value:{0}".format(victory_value)) DEBUG_MSG("流泪") #**********7炮************* # 7对 result[6] = 1 victory_value += 7 DEBUG_MSG("QiDui victory_value:{0}".format(victory_value)) DEBUG_MSG("7对") #**********8炮************* # 4发财 if dragonGreenNum == 4: result[7] = 1 victory_value += 8 DEBUG_MSG("SiFangCai victory_value:{0}".format(victory_value)) DEBUG_MSG("4发财") else: victory_value += dragonGreenNum DEBUG_MSG("FangCai victory_value:{0}".format(victory_value)) DEBUG_MSG("发财") #**********10炮************* # 清一色 if utility.checkIsSameSuit(handTiles, p.upTiles): result[8] = 1 victory_value += 10 DEBUG_MSG("QingYiSe victory_value:{0}".format(victory_value)) DEBUG_MSG("清一色") DEBUG_MSG("can win, True, 111, {0}:{1},{2}".format( idx, victory_value, result)) return True, victory_value, result # 3x+2 elif len(copyHandTiles) % 3 == 2 and utility.meld_with_pair_need_num( copyHandTiles, {}) <= 0: # 平胡 result[0] = 1 victory_value += 1 DEBUG_MSG("PingHu victory_value:{0}".format(victory_value)) DEBUG_MSG("平胡") # 全求人 if len(copyHandTiles) == 2 and win_op != const.OP_DRAW_WIN: result[11] = 1 victory_value += 10 DEBUG_MSG("QuanQiuRen victory_value:{0}".format(victory_value)) DEBUG_MSG("全求人") else: #**********1炮************* tipsList = self.getNormalTipsWinList(copyHandTiles, finalTile) if len(tipsList) == 1: victory_value += 1 DEBUG_MSG( "DiaoDanZhang victory_value:{0}".format(victory_value)) result[2] = 1 DEBUG_MSG("胡单张") #**********5炮************* # 碰碰胡 if utility.checkIsPongPongWin(handTiles, p.upTiles): result[9] = 1 victory_value += 5 DEBUG_MSG( "PengPengHu victory_value:{0}".format(victory_value)) DEBUG_MSG("碰碰胡") #**********1炮************* # 自摸 if win_op == const.OP_DRAW_WIN: result[1] = 1 victory_value += 1 DEBUG_MSG("ZiMo victory_value:{0}".format(victory_value)) DEBUG_MSG("自摸") # if len(copyHandTiles) > 2: # # 单张吊 # removePairTiles = utility.getRemoveFinalPairTiles(copyHandTiles, finalTile) # if len(removePairTiles) > 0 and utility.meld_only_need_num(removePairTiles, {}) <= 0: # victory_value += 1 # else: # # 卡张 # removeMidTiles = utility.getRemoveFinalMidTiles(copyHandTiles, finalTile) # if len(removeMidTiles) > 0 and and utility.meld_with_pair_need_num(removeMidTiles, {}) <= 0: # victory_value += 1 # 门前清 if pongExposedKongNum <= 0: result[3] = 1 victory_value += 1 DEBUG_MSG( "MenQianQing victory_value:{0}".format(victory_value)) DEBUG_MSG("门前清") # 碰红中/白板 victory_value += sum([i for i in p.pongList]) DEBUG_MSG( "PengBaiBan/HongZhong victory_value:{0}".format(victory_value)) DEBUG_MSG("碰红中/白板") # 明杠(不包括红中/白板) victory_value += p.exposedKongList[0] DEBUG_MSG("MingGang(WuBaiBan/HongZhong) victory_value:{0}".format( victory_value)) DEBUG_MSG("明杠") #**********2炮************* # 手抓 3 红中/白板 if const.DRAGON_RED in tile2NumDict and tile2NumDict[ const.DRAGON_RED] >= 3: victory_value += 2 DEBUG_MSG( "SanHongZhong victory_value:{0}".format(victory_value)) DEBUG_MSG("手抓 3 红中") if const.DRAGON_WHITE in tile2NumDict and tile2NumDict[ const.DRAGON_WHITE] >= 3: victory_value += 2 DEBUG_MSG("SanBaiBan victory_value:{0}".format(victory_value)) DEBUG_MSG("手抓 3 白板") # 暗杠 不包括 红中/白板 victory_value += 2 * p.concealedKongList[0] DEBUG_MSG("AnGang(WuBaiBan/HongZhong) victory_value:{0}".format( victory_value)) DEBUG_MSG("暗杠 不包括 红中/白板") #**********3炮************* # 明杠 红中/白板 victory_value += 3 * p.exposedKongList[1] victory_value += 3 * p.exposedKongList[2] DEBUG_MSG("MingGang victory_value:{0}".format(victory_value)) DEBUG_MSG("明杠 红中/白板") #**********4炮************* # 暗杠 红中/白板 victory_value += 4 * p.concealedKongList[1] victory_value += 4 * p.concealedKongList[2] DEBUG_MSG("AnGang victory_value:{0}".format(victory_value)) DEBUG_MSG("暗杠 红中/白板") #**********5炮************* # 抢杠 if win_op == const.OP_KONG_WIN: result[4] = 1 victory_value += 5 DEBUG_MSG( "QiangGangHu victory_value:{0}".format(victory_value)) DEBUG_MSG("抢杠") # 杠开 if win_op == const.OP_DRAW_WIN and utility.checkIsKongDrawWin( p.op_r): result[10] = 1 victory_value += 5 DEBUG_MSG("GangKai victory_value:{0}".format(victory_value)) DEBUG_MSG("杠开") # 流泪 if win_op == const.OP_GIVE_WIN and utility.checkIsKongDiscard( self.players_list[self.last_player_idx].op_r): result[5] = 1 victory_value += 5 DEBUG_MSG("LiuLei victory_value:{0}".format(victory_value)) DEBUG_MSG("流泪") #**********8炮************* # 4发财 if dragonGreenNum == 4: result[7] = 1 victory_value += 8 DEBUG_MSG("SiFaCai victory_value:{0}".format(victory_value)) DEBUG_MSG("4发财") else: victory_value += dragonGreenNum DEBUG_MSG("FaCai victory_value:{0}".format(victory_value)) DEBUG_MSG("发财") #**********10炮************* # 清一色 if utility.checkIsSameSuit(handTiles, p.upTiles): result[8] = 1 victory_value += 10 DEBUG_MSG("QingYiSe victory_value:{0}".format(victory_value)) DEBUG_MSG("清一色") DEBUG_MSG("can win:{0},{1}".format(victory_value, result)) # 一炮不能抓炮胡 if victory_value <= 1: DEBUG_MSG("can win,False 222,{0}:{1},{2}".format( idx, victory_value, result)) return False, victory_value, result DEBUG_MSG("can win,True 333,{0}:{1},{2}".format( idx, victory_value, result)) return True, victory_value, result DEBUG_MSG("can win,False 444,{0}:{1},{2}".format( idx, victory_value, result)) return False, victory_value, result
def can_win(self, handTiles, finalTile, win_op, idx): #"""0自摸 1点炮 2抢杠 3明杠 4暗杠 5庄家 6边张 7砍张 8吊将 9缺门 10清一色 11一条龙 12清龙""" result_list = [0] * 13 base_score = 1 p = self.players_list[idx] if p.state == const.DISCARD_FREE: DEBUG_MSG( "room:{},curround:{} 0 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list if len(handTiles) % 3 != 2: DEBUG_MSG( "room:{},curround:{} 1 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list if win_op == const.OP_WREATH_WIN: DEBUG_MSG( "room:{},curround:{} 2 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list # DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) handCopyTiles = list(handTiles) handCopyTiles = sorted(handCopyTiles) kings, handTilesButKing = utility.classifyKingTiles( handCopyTiles, self.kingTiles) kingTilesNum = len(kings) uptiles = p.upTiles #3N2 if kingTilesNum <= 0: #无财神(只要满足能胡就可以胡) if utility.meld_with_pair_need_num( handTilesButKing) <= kingTilesNum: result_list[0] = 1 if win_op == const.OP_DRAW_WIN else 0 # result_list[1] = 1 if win_op == const.OP_GIVE_WIN else 0 # result_list[2] = 1 if win_op == const.OP_KONG_WIN else 0 exposed_kong_num = sum( [1 for op in p.op_r if op[0] == const.OP_EXPOSED_KONG]) concealed_kong_num = sum( [1 for op in p.op_r if op[0] == const.OP_CONCEALED_KONG]) continue_kong_num = sum( [1 for op in p.op_r if op[0] == const.OP_CONTINUE_KONG]) if exposed_kong_num > 0 or continue_kong_num > 0: # 明杠 result_list[3] = 1 if concealed_kong_num > 0: # 暗杠 result_list[4] = 1 if p.idx == self.dealer_idx: # 庄家 result_list[5] = 1 base_score += 1 result_list[6], result_list[7], result_list[ 8] = utility.checkIsEdgeMidSingle(handTilesButKing, finalTile) if len(p.canWinTiles) != 1: result_list[6] = 0 result_list[7] = 0 result_list[8] = 0 if result_list[6] == 1 or result_list[7] == 1 or result_list[ 8] == 1: # 边张 砍张 吊将 base_score += 1 colorType = utility.getTileColorType(handTilesButKing, uptiles) if colorType == const.LACK_DOOR: # 缺门 result_list[9] = 1 base_score += 1 if self.same_suit_mode == 1 and colorType == const.SAME_SUIT: # 清一色 result_list[10] = 1 base_score += 10 if utility.checkIsOneDragon(handTilesButKing): # 一条龙 result_list[11] = 1 base_score += 10 if self.same_suit_loong == 1 and result_list[ 10] == 1 and result_list[11] == 1: # 清龙 result_list[12] = 1 DEBUG_MSG("room:{},curround:{} 3N2 result_list:{}".format( self.roomID, self.current_round, result_list)) return True, ( base_score * [2 if result_list[0] == 1 else 1][0]), result_list DEBUG_MSG( "room:{},curround:{} 3 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list
def can_win(self, handTiles, winType, idx): #winType 胡的类型 0-自摸 , 1-抢杠 , 2-放炮 """ 能胡牌 """ resultDesList = [ "自摸", "抢杠", "放炮", "天胡", "地胡", "7对", "清一色", "碰碰胡", "单吊", "杠开" ] resultList = [0] * len(resultDesList) if len(handTiles) % 3 != 2: return resultList handTiles = sorted(handTiles) finalDrawTile = self.players_list[idx].last_draw upTiles = self.players_list[idx].upTiles player_op_r = self.players_list[idx].op_r #chars, bambs, dots classifyList = util.classifyTiles3Type(handTiles) #七对 if util.checkIs7Pairs(handTiles, 0): resultList[5] = 1 resultList[5] += util.getKongNum(handTiles) #可以胡 if util.meld_with_pair_need_num(handTiles, {}) <= 0 or resultList[5] > 0: #天胡 地胡 discardNum = util.getDiscardNum(player_op_r) if discardNum <= 0 and len(handTiles) == 14: if self.dealer_idx == idx: resultList[3] = 1 else: resultList[4] = 1 #清一色 DEBUG_MSG("check is flush,handTiles:{0},upTiles:{1}".format( str(handTiles), str(upTiles))) if util.checkIsFlush(handTiles, upTiles, 0): resultList[6] = 1 #碰碰胡 if util.checkIsBigPair(handTiles, upTiles, 0, 0): resultList[7] = 1 # 天胡 地胡 七对 清一色 碰碰胡 允许放炮 #其他牌型只在放炮模式下才能放炮胡 isCanEatWin = False if resultList[3] | resultList[4] | resultList[5] | resultList[ 6] | resultList[7] > 0: isCanEatWin = True if winType == 2 and self.roomMode == 1: isCanEatWin = True if winType != 2 or isCanEatWin: #单吊 if len(handTiles) <= 2: resultList[8] = 1 #杠开 if winType <= 0: kongWinNum = util.getNearlyKongType(player_op_r) if kongWinNum > 0: resultList[9] = 1 resultList[winType] = 1 DEBUG_MSG("check nomal win, wintype is{0}".format(str(winType))) DEBUG_MSG("check can win, result is:{0}".format(str(resultList))) return resultList
def can_win(self, handTiles, finalTile, win_op, idx): #"""平胡 清一色 七小对 豪华七小对 一条龙 十三幺""" result_list = [0] * 6 base_score = 0 # return False, multiply, result_list p = self.players_list[idx] if p.state == const.DISCARD_FREE: # DEBUG_MSG("room:{},curround:{} 0 handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list DEBUG_MSG("room:{},curround:{} state:{} idx:{}".format( self.roomID, self.current_round, p.state, idx)) if self.pass_win_list[idx] == 1 and win_op != const.OP_DRAW_WIN: DEBUG_MSG( "room:{},curround:{} 00 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list if len(handTiles) % 3 != 2: DEBUG_MSG( "room:{},curround:{} 1 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list if win_op == const.OP_WREATH_WIN: DEBUG_MSG( "room:{},curround:{} 2 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list # if win_op == const.OP_GIVE_WIN and finalTile in self.kingTiles: # DEBUG_MSG("room:{},curround:{} handTiles:{} finalTile:{} win_op:{} idx:{}".format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) # return False, base_score, result_list if self.is_win_limit(finalTile, win_op) == False: return False, base_score, result_list handCopyTiles = list(handTiles) handCopyTiles = sorted(handCopyTiles) kings, handTilesButKing = utility.classifyKingTiles( handCopyTiles, self.kingTiles) kingTilesNum = len(kings) uptiles = p.upTiles if finalTile in self.kingTiles: for winTile in self.canWinTiles: if winTile in self.kingTiles: continue if winTile > const.BOUNDARY: base_score = 10 break elif base_score < winTile % 10: base_score = winTile % 10 elif finalTile > const.BOUNDARY: base_score = 10 else: base_score = finalTile % 10 #十三幺 if self.game_mode == const.SPECIAL_GAME_MODE: if utility.getThirteenOrphans(handTilesButKing, kingTilesNum): # if self.is_win_limit(finalTile, win_op) == False: # return False , base_score, result_list result_list[5] = 1 DEBUG_MSG("room:{},curround:{} isThirteenOrphans".format( self.roomID, self.current_round)) return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list #2N result_list = [0] * 6 is7Pair, isBaoTou, kongNum = utility.checkIs7Pair( handCopyTiles, handTilesButKing, kingTilesNum, self.kingTiles, finalTile) if is7Pair: DEBUG_MSG( "room:{},curround:{} is7Pair isBaoTou:{} kongNum:{}".format( self.roomID, self.current_round, isBaoTou, kongNum)) result_list[2] = 1 if kongNum > 0: result_list[3] = 1 if isBaoTou and self.king_num == 1: if win_op != const.OP_DRAW_WIN: return False, base_score, result_list # kingKongList = [1 if op == const.OP_DISCARD else -1 for op in utility.serialKingKong(p.op_r, self.kingTiles)] # result_list.extend(kingKongList) DEBUG_MSG("room:{},curround:{} is7Pair diaojiang".format( self.roomID, self.current_round)) if self.game_mode != const.SPECIAL_GAME_MODE: return True, 20, result_list return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list elif kingTilesNum <= 0: DEBUG_MSG( "room:{},curround:{} is7Pair not diaojiang kingNum:0". format(self.roomID, self.current_round)) return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list DEBUG_MSG( "room:{},curround:{} is7Pair not diaojiang kingNum>0".format( self.roomID, self.current_round)) return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list #3N2 result_list = [0] * 6 if kingTilesNum <= 0: #无财神(只要满足能胡就可以胡) DEBUG_MSG("room:{},curround:{} kingTilesNum <= 0".format( self.roomID, self.current_round)) if utility.meld_with_pair_need_num( handTilesButKing) <= kingTilesNum: # if self.is_win_limit(finalTile, win_op) == False: # return False , base_score, result_list if self.game_mode == const.SPECIAL_GAME_MODE: if utility.getTileColorType(handTilesButKing, uptiles) == const.SAME_SUIT: result_list[1] = 1 elif utility.checkIsOneDragon(handTilesButKing): result_list[4] = 1 else: result_list[0] = 1 DEBUG_MSG("room:{},curround:{} 3N2 kingNum:0".format( self.roomID, self.current_round)) return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list DEBUG_MSG( "room:{},curround:{} 3 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list else: #有财神 if utility.winWith3N2NeedKing(handTilesButKing) <= kingTilesNum: result_list[0] = 1 DEBUG_MSG( "room:{},curround:{} 3N win_op:{} finalTile:{}".format( self.roomID, self.current_round, win_op, finalTile)) # if self.is_win_limit(finalTile, win_op) == False: # return False , base_score, result_list isMouseGeneral = utility.isMouseGeneral( handTiles, handTilesButKing, kingTilesNum, self.kingTiles, finalTile) if isMouseGeneral and win_op != const.OP_DRAW_WIN: DEBUG_MSG( "room:{},curround:{} 3N win_op:{} isMouseGeneral:{}". format(self.roomID, self.current_round, win_op, isMouseGeneral)) return False, base_score, result_list elif isMouseGeneral and win_op == const.OP_DRAW_WIN: return True, 20, result_list return True, (base_score + utility.multiplyCalc( self.game_mode, win_op, result_list)) * [ 2 if win_op == const.OP_DRAW_WIN else 1 ][0], result_list DEBUG_MSG( "room:{},curround:{} 4 handTiles:{} finalTile:{} win_op:{} idx:{}" .format(self.roomID, self.current_round, handTiles, finalTile, win_op, idx)) return False, base_score, result_list
def getCanWinQuantity (self, handTiles, uptiles, wreaths, finalTile, p_op_r, p_wind, win_op, idx ,isDrawWin, isGunWin): #测试样例 # self.kingTiles = [1] # handTiles = [12,13,14,16,16,23,24] # uptiles = [[5,6,7],[7,8,9]] # wreaths = [41,44] # finalTile = 25 # p_op_r = [(1,[23],1),(3,[34],1),(4,[23,24,25],1)] # p_wind = 31 # win_op = 15 # idx = 1 # isDrawWin = True DEBUG_MSG("handTiles : {0}, uptiles: {1}, wreaths: {2} , finalTile: {3}".format(handTiles, uptiles, wreaths, finalTile)) DEBUG_MSG("p_op_r: {0}, p_wind: {1}, win_op: {2}, idx: {3}, isDrawWin: {4}".format(p_op_r, p_wind, win_op, idx ,isDrawWin)) result = [0] * 47 #胡牌类型 handTiles = sorted(handTiles) classifyList = utility.classifyTiles(handTiles, self.kingTiles) kingTilesNum = len(classifyList[0]) #百搭的数量 handTilesButKing = [] #除百搭外的手牌 kingDict = utility.getTile2NumDict(classifyList[0]) #百搭的dict isGiveWin = False #是否能放炮胡 isSelfWin = False #是否自摸 isHunadaWin = False # 是否是还搭 kongType = 0 #杠开的类型 0:不是杠开 1:直杠或暗杠杠开 2:风险杠杠开 for i in range(1, len(classifyList)): handTilesButKing.extend(classifyList[i]) def removeCheckPairWin(handTilesButKing, removeTuple, useKingNum, kingTilesNum): if useKingNum <= kingTilesNum: tryHandTilesButKing = handTilesButKing[:] tryHandTilesButKing = sorted(tryHandTilesButKing) for t in removeTuple: if t != -1: try: tryHandTilesButKing.remove(t) except: DEBUG_MSG("removeCheckPairWin remove fail.{0},{1}".format(removeTuple, tryHandTilesButKing)) if utility.meld_with_pair_need_num(tryHandTilesButKing, {}) <= kingTilesNum - useKingNum: return True return False def removeCheckOnlyWin(handTilesButKing, removeTuple, useKingNum, kingTilesNum): if useKingNum <= kingTilesNum: tryHandTilesButKing = handTilesButKing[:] tryHandTilesButKing = sorted(tryHandTilesButKing) for t in removeTuple: if t != -1: try: tryHandTilesButKing.remove(t) except: DEBUG_MSG("removeCheckOnlyWin remove fail.{0},{1}".format(removeTuple, tryHandTilesButKing)) if utility.meld_only_need_num(tryHandTilesButKing, {}) <= kingTilesNum - useKingNum: return True return False #显示杠的类型 for i in range(0, len(p_op_r))[::-1]: if p_op_r[i][0] == const.OP_CONCEALED_KONG: result[36] = 1 elif p_op_r[i][0] == const.OP_EXPOSED_KONG: result[34] = 1 elif p_op_r[i][0] == const.OP_RISK_KONG: result[38] = 1 quantity = 0 #分数 stand = 1 #台数 坐台为一台 result[16] = 1 DEBUG_MSG("zuotai: 1") if win_op == const.OP_WREATH_WIN:#8张花 if len(wreaths) == 8: # 8张花胡 = 8张花(14台) + 胡(8台) = 22台 quantities, stands= utility.getWreathQuantity(wreaths, p_wind) quantity += quantities stand += stands result[33] = 1 DEBUG_MSG("wreaths quantity:{0}, stand: {1}".format(quantities, stands)) elif len(handTiles) % 3 == 2: #其他 3x+2 胡 #抛百搭不能放炮胡 if isGunWin and kingTilesNum > 0 and len(self.tiles) > 0: if utility.getCheckWinThorw(handTiles, finalTile, self.kingTiles): DEBUG_MSG("pao baida buneng fangpao hu ") return False, 0, 0, 0, 0 #七对头 注:需要判断finalTile最后一张牌是别人的还是自己的 is7Double, isBrightTiles, isDarkTiles = utility.get7DoubleWin(handTiles, handTilesButKing, kingTilesNum, finalTile) starType = utility.getStarType(handTilesButKing, kingDict, finalTile, isDrawWin) if utility.getTileColorType(handTilesButKing, uptiles) == const.SAME_HONOR and (utility.meld_with_pair_need_num(handTilesButKing, {}) <= kingTilesNum or is7Double): quantity += 1000 result[0] = 1 # 清老头 DEBUG_MSG("qing laotou: 1000") if is7Double: if kingTilesNum > 0: quantity += 70 #七对头有搭 result[8] = 1 DEBUG_MSG("qiduitou youda: 70") else: quantity += 170 #七对头无搭 result[8] = 1 DEBUG_MSG("qiduitou wuda: 170") if isBrightTiles: quantity += 50 #明炸七对头 result[26] = 1 DEBUG_MSG("mingzha qiduitou: 50") if isDarkTiles: quantity += 100 #暗炸七对头 result[27] = 1 DEBUG_MSG("anzha qiduitou: 100") # 天胡 地胡 drawNum = utility.getDiscardNum(self.op_record) if drawNum == 1 and len(handTiles) == 14: if self.dealer_idx == idx: quantity += 150 result[6] = 1 #天胡 DEBUG_MSG("tian hu: 150") else: quantity += 150 result[7] = 1 #地胡 isSelfWin = True DEBUG_MSG("di hu: 150") isGiveWin = True isSelfWin = True elif is7Double: if kingTilesNum > 0: quantity += 70 #七对头有搭 result[8] = 1 DEBUG_MSG("qiduitou youda: 70") else: quantity += 170 #七对头无搭 result[8] = 1 DEBUG_MSG("qiduitou wuda: 170") if isBrightTiles: quantity += 50 #明炸七对头 result[26] = 1 DEBUG_MSG("mingzha qiduitou: 50") if isDarkTiles: quantity += 100 #暗炸七对头 result[27] = 1 DEBUG_MSG("anzha qiduitou: 100") #清一色 混一色 colorType = utility.getTileColorType(handTilesButKing, uptiles) if colorType == const.SAME_SUIT: quantity += 150 result[4] = 1 isGiveWin = True DEBUG_MSG("qing yi se 150") elif colorType == const.MIXED_ONE_SUIT: quantity += 70 result[5] = 1 isGiveWin = True DEBUG_MSG("hun yi se: 70") # 天胡 地胡 drawNum = utility.getDiscardNum(self.op_record) if drawNum == 1 and len(handTiles) == 14: if self.dealer_idx == idx: quantity += 150 result[6] = 1 #天胡 DEBUG_MSG("tian hu: 150") else: quantity += 150 result[7] = 1 #地胡 isSelfWin = True DEBUG_MSG("di hu: 150") isGiveWin = True isSelfWin = True elif len(starType) != 0: if starType[0] == 0: quantity += 50 #十三不搭 DEBUG_MSG("shisan buda: 50") elif starType[0] == 1: quantity += 200 result[30] = 1 # 十三不搭缺色 DEBUG_MSG("shisan buda quese: 200") elif starType[0] == 2: quantity += 150 result[28] = 1 # 十三不搭暗七星 DEBUG_MSG("shisan buda anqixing: 150") elif starType[0] == 3: quantity += 100 result[29] = 1 # 十三不搭明七星 DEBUG_MSG("shisan buda mingqixing: 100") elif starType[0] == 4: quantity += 300 result[28] = 1 result[30] = 1 # 十三不搭暗7星 缺色 DEBUG_MSG("shisan buda: 300") elif starType[0] == 5: quantity += 250 result[29] = 1 result[30] = 1 # 十三不搭明7星 缺色 DEBUG_MSG("shisan buda: 250") result[9] = 1 # 天胡 地胡 drawNum = utility.getDiscardNum(self.op_record) if drawNum == 1 and len(handTiles) == 14: if self.dealer_idx == idx: quantity += 150 result[6] = 1 #天胡 DEBUG_MSG("tian hu: 150") else: quantity += 150 result[7] = 1 #地胡 isSelfWin = True DEBUG_MSG("di hu: 150") isGiveWin = True isSelfWin = True elif utility.getAllColorType(uptiles, handTilesButKing): quantity += 500 result[1] = 1 # 乱老头 DEBUG_MSG("luan laotou: 500") # 天胡 地胡 drawNum = utility.getDiscardNum(self.op_record) if drawNum == 1 and len(handTiles) == 14: if self.dealer_idx == idx: quantity += 150 result[6] = 1 #天胡 DEBUG_MSG("tian hu: 150") else: quantity += 150 result[7] = 1 #地胡 isSelfWin = True DEBUG_MSG("di hu: 150") isGiveWin = True isSelfWin = True elif utility.meld_with_pair_need_num(handTilesButKing, {}) <= kingTilesNum: # 碰碰胡? isPongPongWin = utility.checkIsPongPongWin(handTilesButKing, uptiles, kingTilesNum) if isPongPongWin: if kingTilesNum > 0: quantity += 50 else: quantity += 100 result[2] = 1 isGiveWin = True DEBUG_MSG("peng peng hu: 50+") # 天胡 地胡 drawNum = utility.getDiscardNum(self.op_record) if drawNum == 1 and len(handTiles) == 14: if self.dealer_idx == idx: quantity += 150 result[6] = 1 #天胡 DEBUG_MSG("tian hu: 150") else: quantity += 150 result[7] = 1 #地胡 isSelfWin = True DEBUG_MSG("di hu: 150") # 自摸 if isDrawWin: stand += 1 result[15] = 1 isSelfWin = True DEBUG_MSG("zi mo: 1") # 抢杠胡 if win_op == const.OP_KONG_WIN: isSelfWin = True # 杠上开花 isKongWin, kongWinType = utility.checkIsKongDrawWin(p_op_r) # 连杠开花 isSeriesKongWin = utility.checkIsSeriesKongWin(p_op_r) if win_op == const.OP_DRAW_WIN and isSeriesKongWin > 0: if isSeriesKongWin == 1: quantity += 300 kongType = 3 DEBUG_MSG("liangge angang gangkai 300") elif isSeriesKongWin == 2: quantity += 350 kongType = 3 DEBUG_MSG("angang,fengxiangang gangkai 350") elif isSeriesKongWin == 3: quantity += 300 kongType = 4 DEBUG_MSG("zhigang,fengxiangang gangkai 300") elif isSeriesKongWin == 4: quantity += 400 kongType = 3 DEBUG_MSG("liangge fengxinagang gangkai 400") result[46] = 1 elif win_op == const.OP_DRAW_WIN and isKongWin: if kongWinType == 1: quantity += 150 result[37] = 1 kongType = 1 DEBUG_MSG("angang gang kai 50+") elif kongWinType == 2: quantity += 100 result[35] = 1 kongType = 1 DEBUG_MSG("zhigang gang kai 50+") elif kongWinType == 3: quantity += 50 result[41] = 1 DEBUG_MSG("huagang gang kai 50+") elif kongWinType == 4: quantity += 200 result[39] = 1 kongType = 2 DEBUG_MSG("fengxian gang kai 50+") # #海捞 if len(self.tiles) <= 0: quantity += 150 result[10] = 1 isGiveWin = True DEBUG_MSG("haidi lao yue 150") #大吊车 if len(handTiles) == 2: if kingTilesNum > 0: quantity += 50 else: quantity += 100 result[3] = 1 isGiveWin = True DEBUG_MSG("da diao che 50+") #清一色 混一色 colorType = utility.getTileColorType(handTilesButKing, uptiles) if colorType == const.SAME_SUIT: quantity += 150 result[4] = 1 isGiveWin = True DEBUG_MSG("qing yi se 150") elif colorType == const.MIXED_ONE_SUIT: quantity += 70 result[5] = 1 isGiveWin = True DEBUG_MSG("hun yi se: 70") # 座风三个为一台 sit_wind = const.WINDS[(idx - self.dealer_idx + 4) % 4]; isSitWind = utility.checkIsSitWind(sit_wind, uptiles, handTiles, handTilesButKing, kingTilesNum, self.kingTiles) if isSitWind > 0: if self.game_mode == 0: stand += 2 elif self.game_mode == 1: stand += 1 result[25] = 1 isGiveWin = True DEBUG_MSG("zuo feng: 1 or 2") # 判断是否有东风碰出暗刻 if self.game_mode == 0: isEastWind = utility.checkIsEastWind(const.WIND_EAST, uptiles, handTiles, handTilesButKing, kingTilesNum, self.kingTiles) if isEastWind > 0 and sit_wind != const.WIND_EAST: stand += 1 isGiveWin = True DEBUG_MSG("dongfeng pengchu: 1") # 中发白 isWordColor, dragon_type = utility.checkIsWordColor(uptiles, handTiles, handTilesButKing, kingTilesNum, self.kingTiles) if isWordColor > 0: stand += 1 isGiveWin = True if dragon_type[0] == 1: result[17] = 1 if dragon_type[1] == 1: result[18] = 1 if dragon_type[2] == 1: result[19] = 1 DEBUG_MSG("zhong fa bai: 1") #平打里面的圈风 if self.game_mode == 1: isCircleWind = utility.checkIsSitWind(self.prevailing_wind, uptiles, handTiles, handTilesButKing, kingTilesNum, self.kingTiles) if isCircleWind > 0 : stand += 1 DEBUG_MSG("quan feng: 1") # 还搭 抛百搭 朋胡 friend_win = False if kingTilesNum > 0 and kingTilesNum < 3: # 还搭 抛百搭 DEBUG_MSG("============ {0}, {1}".format(utility.meld_with_pair_need_num(handTilesButKing, {}), kingTilesNum)) if utility.meld_with_pair_need_num(handTilesButKing, {}) < kingTilesNum: stand += 1 result[24] = 1 isHunadaWin = True DEBUG_MSG("huan da: 1") series_win = True #判断对倒,只用过朋胡的条件 seriesDict = utility.getRemoveMatchOrderDict(handTilesButKing, finalTile, self.kingTiles) for key in seriesDict: seriesKingNum = seriesDict[key] if removeCheckPairWin(handTilesButKing, key, seriesKingNum, kingTilesNum): series_win = False DEBUG_MSG("dui dao") break # 朋胡 DEBUG_MSG("############# {0}".format(utility.meld_with_pair_need_num(handTiles, {}))) if series_win and (utility.getFriendWin(uptiles, handTiles, handTilesButKing, kingTilesNum, sit_wind, self.game_mode, self.prevailing_wind)): stand += 1 result[23] = 1 friend_win = True isGiveWin = True DEBUG_MSG("peng hu: 1") #胡两头 # if finalTile < 30: # isWinTwoSides = utility.getRemoveTwoSides(handTilesButKing, finalTile, kingTilesNum,self.kingTiles) # if isWinTwoSides: # if (isSitWind + isWordColor) >= 2 or (isSitWind > 0 and sit_wind == const.WIND_EAST) or friend_win: # isGiveWin = True # DEBUG_MSG("hu liangtou: 1") # else: # # isGiveWin = False # DEBUG_MSG("buneng hu liangtou") #对倒 边 嵌 单吊 #对倒 removeMatchOrderDict = utility.getRemoveMatchOrderDict(handTilesButKing, finalTile, self.kingTiles) for key in removeMatchOrderDict: useKingNum = removeMatchOrderDict[key] if removeCheckPairWin(handTilesButKing, key, useKingNum, kingTilesNum): stand += 1 result[22] = 1 DEBUG_MSG("dui dao: 1") break else: if not isPongPongWin: #边 removeEdgeDict = utility.getRemoveEdgeDict(handTilesButKing, finalTile, self.kingTiles) for key in removeEdgeDict: useKingNum = removeEdgeDict[key] if removeCheckPairWin(handTilesButKing, key, useKingNum, kingTilesNum): stand += 1 result[45] = 1 DEBUG_MSG("bian: 1") break else: #嵌 removeMidDict = utility.getRemoveMidDict(handTilesButKing, finalTile, self.kingTiles) for key in removeMidDict: useKingNum = removeMidDict[key] if removeCheckPairWin(handTilesButKing, key, useKingNum, kingTilesNum): stand += 1 result[20] = 1 DEBUG_MSG("jia: 1") break else: #单吊 removeSingleCraneDict = utility.getRemoveSingleCraneDict(handTilesButKing, finalTile, self.kingTiles) for key in removeSingleCraneDict: useKingNum = removeSingleCraneDict[key] if removeCheckOnlyWin(handTilesButKing, key, useKingNum, kingTilesNum): stand += 1 result[21] = 1 DEBUG_MSG("dandiao: 1") break else: # 胡两头 isGiveWin = False if (isSitWind + isWordColor) >= 2 or (isSitWind > 0 and sit_wind == const.WIND_EAST) or friend_win: isGiveWin = True DEBUG_MSG("hu liangtou: 1") else: DEBUG_MSG("buneng hu liangtou") #无搭, 一搭,二搭,三百搭, 三花三百搭 if kingTilesNum == 0: stand += 1 result[12] = 1 DEBUG_MSG("wuda: 1") elif kingTilesNum == 1: stand += 1 result[13] = 1 DEBUG_MSG("yida: 1") elif kingTilesNum == 2: stand += 2 result[14] = 1 DEBUG_MSG("erda: 1") elif kingTilesNum == 3: if self.kingTiles[0] in const.SEASON or self.kingTiles[0] in const.FLOWER: quantity += 300 result[43] = 1 DEBUG_MSG("san hua sanbaida: 300") else: quantity += 150 result[42] = 1 DEBUG_MSG("san baida: 150") # 花 手牌 桌牌 非胡台数 quantities, stands, four_flower= utility.getWreathQuantity(wreaths, p_wind) quantity += quantities stand += stands if four_flower: result[44] = 1 DEBUG_MSG("wreaths quantity:{0}, stand: {1}".format(quantities, stands)) # 抢杠胡 if win_op == const.OP_KONG_WIN: quantity += 100 result[32] = 1 DEBUG_MSG("qiangganghu: 100" ) #判断台数 DEBUG_MSG("quantity: {0}, stand: {1}, {2}".format(quantity, stand, isHunadaWin)) tatal_stands = quantity + stand if isGiveWin and isHunadaWin == False and tatal_stands >= self.win_quantity and (win_op == const.OP_GIVE_WIN or (win_op == const.OP_FINAL_WIN and idx != self.last_player_idx)): return True, quantity, stand, result, kongType elif isSelfWin: return True, quantity, stand, result, kongType else: return False, quantity, stand, result, kongType