示例#1
0
    def handle_shot_poker(self, pokers):
        if pokers:
            if not rule.is_contains(self.hand_pokers, pokers):
                logger.warning('Player[%d] play non-exist poker', self.uid)
                return

            if self.table.last_shot_seat != self.seat and rule.compare_poker(
                    pokers, self.table.last_shot_poker) < 0:
                logger.warning('Player[%d] play small than last shot poker',
                               self.uid)
                return

        self.table.go_next_turn()
        if pokers:
            self.table.last_shot_seat = self.seat
            self.table.last_shot_poker = pokers
            for p in pokers:
                self.hand_pokers.remove(p)

        response = [Pt.RSP_SHOT_POKER, self.uid, pokers]
        for p in self.table.players:
            p.send(response)
        logger.info('Player[%d] shot[%s]', self.uid, str(pokers))

        if not self.hand_pokers:
            self.table.on_game_over(self)
示例#2
0
    def handle_shot_poker(self, pokers):
        if pokers:
            if not rule.is_contains(self.hand_pokers, pokers):
                logger.warning('Player[%d] play non-exist poker', self.uid)
                return

            if self.table.last_shot_seat != self.seat and rule.compare_poker(
                    pokers, self.table.last_shot_poker) < 0:
                logger.warning('Player[%d] play small than last shot poker',
                               self.uid)
                return

        self.table.go_next_turn()
        if pokers:
            self.table.last_shot_seat = self.seat
            self.table.last_shot_poker = pokers
            for p in pokers:
                self.hand_pokers.remove(p)

        response = [Pt.RSP_SHOT_POKER, self.uid, pokers]
        for p in self.table.players:
            p.send(response)

        if self.role == LANDLORD:
            f = open('../hand_cards.txt', 'w')
            for card in self.hand_pokers:
                f.write('%s,' % (str(card)))
            logger.info('hand left: ' + str(self.hand_pokers))
            f.close()
        logger.info('Player[%d] shot[%s]', self.uid, str(pokers))

        if not self.hand_pokers:
            self.table.on_game_over(self)
示例#3
0
    def handle_shot_poker(self, pokers):
        self.become_controller = False
        self.table.out_cards[self.table.whose_turn] = pokers
        self.table.log.append((self.uid, pokers))
        if pokers:
            if not rule.is_contains(self.hand_pokers, pokers):
                logger.warning('Player[%d] play non-exist poker', self.uid)
                return

            if self.table.last_shot_seat != self.seat and rule.compare_poker(
                    pokers, self.table.last_shot_poker) < 0:
                logger.warning('Player[%d] play small than last shot poker',
                               self.uid)
                return
        if pokers:
            self.become_controller = True
            self.table.history[self.seat] += pokers
            self.table.last_shot_seat = self.seat
            self.table.last_shot_poker = pokers
            for p in pokers:
                self.hand_pokers.remove(p)

        if self.hand_pokers:
            self.table.go_next_turn()

        import debug
        if self.uid == debug.over_in_advance:
            self.table.on_game_over(self)
            return

        if not self.hand_pokers:
            self.table.game_over = True
            self.table.on_game_over(self)

        response = [Pt.RSP_SHOT_POKER, self.uid, pokers]
        for p in self.table.players:
            p.send(response)
        logger.info('Player[%d] shot[%s]', self.uid, str(pokers))
示例#4
0
    def handle_shot_poker(self, pokers):
        if pokers:
            if not rule.is_contains(self.hand_pokers, pokers):
                logger.warning('Player[%d] play non-exist poker', self.uid)
                return

            if self.table.last_shot_seat != self.seat and rule.compare_poker(pokers, self.table.last_shot_poker) < 0:
                logger.warning('Player[%d] play small than last shot poker', self.uid)
                return

        self.table.go_next_turn()
        if pokers:
            self.table.last_shot_seat = self.seat
            self.table.last_shot_poker = pokers
            for p in pokers:
                self.hand_pokers.remove(p)

        response = [Pt.RSP_SHOT_POKER, self.uid, pokers]
        for p in self.table.players:
            p.send(response)
        logger.info('Player[%d] shot[%s]', self.uid, str(pokers))

        self.handle_game_over()