Esempio n. 1
0
    def sendCards(self, table):
        seats = table.gameRound.seats
        assert (len(seats) == 3)
        goodCard = table.runConf.goodCard
        lucky = table.runConf.lucky
        sendCardConf = table.runConf.sendCardConf
        cards = None
        if gdata.enableTestHtml():
            userIds = [
                seat.userId for seat in table.gameRound.seats if seat.player
            ]
            cards = SendCardsPolicyUserSetting.sendCardsToUserIds(
                table.gameId, table.tableId, userIds)

        if ftlog.is_debug():
            ftlog.debug(
                'SendCardsPolicy3PlayerDefault.sendCards begin ......... tableId=',
                table.tableId, 'sendCardConf=', sendCardConf, 'goodCard=',
                goodCard, 'lucky=', lucky, 'enableTestHtml=',
                gdata.enableTestHtml(), 'cards=', cards)

        randFillAll = sendCardConf.get('RAND_FILL_ALL', 0)

        if not cards and random.randint(
                0, 100) < randFillAll and table.room.isMatch:
            SendCardsPolicyFillAll.sendCards(table)
        else:
            if not cards:
                if goodCard and not table.room.isMatch:
                    goodCardSeat, cards = self.sendCard2(table, sendCardConf)
                    if ftlog.is_debug():
                        ftlog.debug(
                            'SendCardsPolicy3PlayerDefault.sendCards',
                            'tableId=', table.tableId, 'sendCardConf=',
                            sendCardConf, 'cards=', cards, 'goodCardSeat=',
                            (goodCardSeat.userId,
                             goodCardSeat.seatId) if goodCardSeat else None)
                else:
                    cards = self.sendCard1(3, lucky)
                    if ftlog.is_debug():
                        ftlog.debug('SendCardsPolicy3PlayerDefault.sendCards',
                                    'tableId=', table.tableId, 'sendCardConf=',
                                    sendCardConf, 'lucky=', lucky, 'cards=',
                                    cards)
            for i, seat in enumerate(table.gameRound.seats):
                seat.status.cards = cards[i]
            # 设置底牌
            table.gameRound.baseCards = cards[-1]
Esempio n. 2
0
    def doRoomSigIn(self, roomId, userId, signinParams):
        msg = runcmd.getMsgPack()
        if ftlog.is_debug():
            ftlog.debug('msg=', msg, 'mode=', gdata.mode(), caller=self)
        if not signinParams and gdata.enableTestHtml():
            room = gdata.rooms()[roomId]
            signinParams = gamedata.getGameAttrJson(userId, room.gameId,
                                                    'test.signinParams')

        gdata.rooms()[roomId].doSignin(userId, signinParams)
Esempio n. 3
0
    def doRoomSigIn(self, roomId, userId, signinParams):
        msg = runcmd.getMsgPack()
        if ftlog.is_debug():
            ftlog.debug('msg=', msg, 'mode=', gdata.mode(),
                        caller=self)
        if not signinParams and gdata.enableTestHtml():
            room = gdata.rooms()[roomId]
            signinParams = gamedata.getGameAttrJson(userId, room.gameId, 'test.signinParams')

        gdata.rooms()[roomId].doSignin(userId, signinParams)
Esempio n. 4
0
 def doRoomQuickSigIn(self, roomId, userId, signinParams):
     msg = runcmd.getMsgPack()
     room = gdata.rooms()[roomId]
     if ftlog.is_debug():
         ftlog.debug('msg=', msg, 'mode=', gdata.mode(), caller=self)
     if isinstance(room, DizhuRoom):
         room.handleMsg(msg)
     else:
         if not signinParams and gdata.enableTestHtml():
             room = gdata.rooms()[roomId]
             signinParams = gamedata.getGameAttrJson(
                 userId, room.gameId, 'test.signinParams')
         feeIndex = msg.getParam('feeIndex', 0)
         room.doSignin(userId, signinParams, feeIndex)
    def _sendCard(self):
        '''
        发牌处理
        '''
        userCount, userids = self.table.getSeatUserIds()
        pcount = []
        for player in self.table.players:
            pcount.append(player.winratePlays)
        # 发牌处理
        goodSeatId = 0
        cards = None
        if gdata.enableTestHtml():
            cards = SendCardPolicyUserId.getInstance().sendCards(
                self.table.tableId, userids)

        if not cards:
            lucky = self.table.goodCardLucky()
            goodCard = self.table.runConfig.goodCard
            if ftlog.is_debug():
                ftlog.debug('DizhuMillionHeroMatchPlay._sendCard', 'tableId=',
                            self.table.tableId, 'lucky=', lucky, 'goodCard=',
                            goodCard)
            goodSeatId, cards = self.card.generateLuckCard(
                userids, pcount, goodCard, lucky,
                self.table.runConfig.sendCardConfig)
        # 设置取得的好牌座位号
        self.table.status.goodSeatId = goodSeatId if goodSeatId > 0 else 0
        # 设置每个玩家的手牌
        for x in xrange(len(self.table.seats)):
            self.table.seats[x].cards = cards[x]
        # 设置底牌
        self.table.status.baseCardList = cards[userCount]
        # 废弃牌
        if len(cards) == userCount + 2:
            self.table.status.kickOutCardList = cards[-1]

        bctype, bcmulti = self.card.getBaseCardInfo(
            self.table.status.baseCardList)
        self.table.status.baseCardType = bctype
        if self.table.isMatch or self.table.isFriendTable():
            self.table.status.baseCardMulti = 1
        else:
            self.table.status.baseCardMulti = bcmulti
    def sendCards(self, table):
        seats = table.gameRound.seats
        assert (len(seats) == 3)
        goodCard = table.runConf.goodCard
        lucky = table.runConf.lucky
        sendCardConf = table.runConf.sendCardConf
        cards = None

        if gdata.enableTestHtml():
            userIds = [
                seat.userId for seat in table.gameRound.seats if seat.player
            ]
            cards = self.sendCardsToAllUserIds(table.gameId, userIds)
            if ftlog.is_debug():
                ftlog.debug('QuickLaiZiSendCardsPolicy.enableTestHtml.cards=',
                            cards)

        if not cards:
            if goodCard and not table.room.isMatch:
                pcount = []
                for seatIndex in range(len(seats)):
                    seatPlayCount = seats[seatIndex].player.datas.get(
                        'plays', 0)
                    pcount.append(seatPlayCount)

                goodCardSeat, cards = self.sendCard2(pcount, sendCardConf)
            else:
                cards = self.sendCard1(3, lucky)

        if not cards:
            cards = self.sendCard(len(seats), lucky)

        for i, seat in enumerate(table.gameRound.seats):
            seat.status.cards = cards[i]

        # 设置底牌
        table.gameRound.baseCards = cards[-1]

        if ftlog.is_debug():
            ftlog.debug('QuickLaiZiSendCardsPolicy.over', 'tableId=',
                        table.tableId, 'sendCardConf=', sendCardConf, 'lucky=',
                        lucky, 'cards=', cards)
Esempio n. 7
0
 def isEnable(self):
     return gdata.enableTestHtml()