Example #1
0
    def hasPeng(self, tiles, tile, extendInfo = {}):
        """是否有碰牌解

        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        pengSolutions = []
        seatId = extendInfo.get('seatId', [])
        if seatId == -1:
            return pengSolutions
        
        # 花牌不能碰
        if tile in tile_const.FLOWERS:
            return pengSolutions

        # 过碰状态,还碰这张牌不让碰
        p = self.tableTileMgr.players[seatId]
        if tile in p.guoPengTiles:
            return pengSolutions

        # 手牌里加上这张牌>=3张,可以碰
        normalPeng = MPeng.hasPeng(tiles[MHand.TYPE_HAND], tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])
        return pengSolutions
Example #2
0
 def hasPeng(self, tiles, tile, seatId=-1):
     """是否有碰牌解
     
     参数说明;
     tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
     tile - 待碰的牌
     """
     
     #是否允许会牌参与,如果不允许,删除会牌
     tilesForPeng = copy.deepcopy(tiles[MHand.TYPE_HAND])
     if not self.tableTileMgr.allowMagicChiPengGang():
         magicTile = self.tableTileMgr.getMagicTile()
         while magicTile in tilesForPeng:
             tilesForPeng.remove(magicTile)
             
             
     pengSolutions = []
     normalPeng = MPeng.hasPeng(tilesForPeng, tile)
     if normalPeng:
         pengSolutions.append([tile, tile, tile])
         
     magics = self.tableTileMgr.getMagicTiles(False)
     tileArr = MTile.changeTilesToValueArr(tiles[MHand.TYPE_HAND])
     tileArr, magicTiles = self.tableTileMgr.exculeMagicTiles(tileArr, magics)
     magicCount = len(magicTiles)
     if magicCount == 0:
         return pengSolutions
     
     if not self.tableTileMgr.canUseMagicTile(MTableState.TABLE_STATE_PENG):
         return pengSolutions
     
     ftlog.debug('MPengRule.hasPeng tile:', tile
                 , ' tileCount:', tileArr[tile]
                 , ' magicCount:', magicCount)
     
     if (magicCount == 0) or (tileArr[tile] == 0):
         return pengSolutions
     
     if magicCount >= 1 and tileArr[tile] >= 2:
         # 使用一个癞子
         pengSolutions.append([tile, tile, magicTiles[0]])
         
     if magicCount >= 2 and tileArr[tile] >= 1:
         # 使用两个癞子
         pengSolutions.append([tile, magicTiles[0], magicTiles[1]])
         
     return pengSolutions
Example #3
0
    def hasPeng(self, tiles, tile, seatId=-1):
        """是否有碰牌解
        
        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """

        #是否允许会牌参与,如果不允许,删除会牌
        tilesForPeng = copy.deepcopy(tiles[MHand.TYPE_HAND])
        if not self.tableTileMgr.allowMagicChiPengGang():
            magicTile = self.tableTileMgr.getMagicTile()
            while magicTile in tilesForPeng:
                tilesForPeng.remove(magicTile)

        pengSolutions = []
        normalPeng = MPeng.hasPeng(tilesForPeng, tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])

        magics = self.tableTileMgr.getMagicTiles(False)
        tileArr = MTile.changeTilesToValueArr(tiles[MHand.TYPE_HAND])
        tileArr, magicTiles = self.tableTileMgr.exculeMagicTiles(
            tileArr, magics)
        magicCount = len(magicTiles)
        if magicCount == 0:
            return pengSolutions

        if not self.tableTileMgr.canUseMagicTile(MTableState.TABLE_STATE_PENG):
            return pengSolutions

        ftlog.debug('MPengRule.hasPeng tile:', tile, ' tileCount:',
                    tileArr[tile], ' magicCount:', magicCount)

        if (magicCount == 0) or (tileArr[tile] == 0):
            return pengSolutions

        if magicCount >= 1 and tileArr[tile] >= 2:
            # 使用一个癞子
            pengSolutions.append([tile, tile, magicTiles[0]])

        if magicCount >= 2 and tileArr[tile] >= 1:
            # 使用两个癞子
            pengSolutions.append([tile, magicTiles[0], magicTiles[1]])

        return pengSolutions
Example #4
0
    def hasPeng(self, tiles, tile, extendInfo = {}):
        """是否有碰牌解

        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        pengSolutions = []
        magics = self.tableTileMgr.getMagicTiles()
        if tile in magics:
            return pengSolutions

        # 手牌里加上这张牌>=3张,可以碰
        normalPeng = MPeng.hasPeng(tiles[MHand.TYPE_HAND], tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])
        return pengSolutions
Example #5
0
    def hasPeng(self, tiles, tile, seatId=-1):
        """是否有碰牌解

        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        pengSolutions = []

        # 过碰状态,还碰这张牌不让碰
        p = self.tableTileMgr.players[seatId]
        if tile in p.guoPengTiles:
            return pengSolutions

        # 手牌里加上这张牌>=3张,可以碰
        normalPeng = MPeng.hasPeng(tiles[MHand.TYPE_HAND], tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])
        return pengSolutions
Example #6
0
    def hasPeng(self, tiles, tile, seatId=-1):
        """是否有碰牌解

        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        pengSolutions = []

        # 过碰状态,还碰这张牌不让碰
        p = self.tableTileMgr.players[seatId]
        if tile in p.guoPengTiles:
            return pengSolutions

        # 手牌里加上这张牌>=3张,可以碰
        normalPeng = MPeng.hasPeng(tiles[MHand.TYPE_HAND], tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])
        return pengSolutions
Example #7
0
 def hasPeng(self, tiles, tile, extendInfo = {}):
     """是否有碰牌解
     
     参数说明;
     tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
     tile - 待碰的牌
     """
     
     tilesForPeng = copy.deepcopy(tiles[MHand.TYPE_HAND])
     magicTiles = self.tableTileMgr.getMagicTiles()
     for magicTile in magicTiles:
         while magicTile in tilesForPeng:
             tilesForPeng.remove(magicTile)
             
     pengSolutions = []
     normalPeng = MPeng.hasPeng(tilesForPeng, tile)
     if normalPeng:
         pengSolutions.append([tile, tile, tile])
     
     return pengSolutions    
Example #8
0
    def hasPeng(self, tiles, tile, extendInfo={}):
        """是否有碰牌解
        
        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        absenceColor = extendInfo.get('absenceColor', -1)
        if MTile.getColor(tile) == absenceColor:
            return []

        tilesForPeng = copy.deepcopy(tiles[MHand.TYPE_HAND])
        tilesForPeng = MTile.filterTilesWithOutColor(tilesForPeng,
                                                     absenceColor)

        pengSolutions = []
        if MPeng.hasPeng(tilesForPeng, tile):
            pengSolutions.append([tile, tile, tile])

        return pengSolutions
Example #9
0
    def hasPeng(self, tiles, tile, extendInfo={}):
        """是否有碰牌解

        参数说明;
        tiles - 玩家的所有牌,包括手牌,吃牌,碰牌,杠牌,胡牌
        tile - 待碰的牌
        """
        pengSolutions = []
        seatId = extendInfo.get('seatId', -1)
        if seatId == -1:
            return pengSolutions

        # 缺门不能碰
        absenceColor = self.tableTileMgr.absenceColors[seatId]
        if MTile.getColor(tile) == absenceColor:
            return pengSolutions

        # 手牌里加上这张牌>=3张,可以碰
        normalPeng = MPeng.hasPeng(tiles[MHand.TYPE_HAND], tile)
        if normalPeng:
            pengSolutions.append([tile, tile, tile])
        return pengSolutions