def discard_card(self, player, card):
        """Discard card and apply its game effects.

        Parameters:
        player -- Player who discards card
        card -- Card to be discarded
        """
        # remove card from player hand
        player.hand.remove(card)
        # and add to discard pile
        self.discards.append(card)
        UI.print_discard_result(True, card)
        # we are done if the player has no more cards in his hand
        if not player.hand:
            return
        # if card is an eight, skip next player
        elif card.value == '8':
            self.skip = True
        # if card is a two, next player needs to draw two
        elif card.value == '2':
            self.draw2 = True
        # if card is a queen, next player needs to draw four
        elif card.value == 'Q':
            self.draw4 = True
        # if card is a king, game direction reverses
        elif card.value == 'K':
            self.direction *= -1
            UI.print_message("Game direction reversed.")
        # if card is a jack, ask player with whom to swap hands
        elif card.value == 'J':
            others = [p for p in self.players if p is not player]
            choice = player.ask_for_swap(others)
            self.swap_hands(player, choice)
    def draw_and_discard(self, player, top_card):
        """Draw a card from stock and discard it if possible.

        Parameters:
        player -- the Player that draws the card

        calls pick_up_card to obtain a stock card and adds it to the
        player's hand. If the card can be discarded, discard_card is
        called with the newly picked card.
        """
        UI.print_message("No matching card. Drawing ...")
        # return if no card could be picked
        if not self.pick_up_card(player):
            return
        # discard picked card if possible
        card = player.hand[-1]
        if self.can_discard(card, top_card) is True:
            self.discard_card(player, card)
        # otherwise inform the player
        elif not player.is_ai:
            UI.print_discard_result(False, card)