예제 #1
0
 def __init__(self, suit: Suit, *cards):
     if isinstance(suit, str):
         suit = Suit(suit)
     if not isinstance(suit, Suit):
         raise TypeError('\'suit\' must be a valid suit, not a '+str(type(suit)))
     self.suit = suit
     CardPile.__init__(self, *cards)
예제 #2
0
 def __init__(self, init_cards: tuple = None):
     cards = []
     if init_cards == None:
         for suit in Deck.suits:
             for rank in Deck.ranks:
                 cards.append(Card(suit, rank, True))
     else:
         if not isinstance(init_cards, (tuple, list)):
             raise TypeError(
                 'Deck() init_cards argument must be a tuple or a list, not a '
                 + str(type(init_cards)))
         for card in init_cards:
             if not isinstance(card, (Card, tuple)):
                 raise TypeError(
                     'Deck() init_cards argument must contain only Card or tuple types, not '
                     + str(type(card)))
             if isinstance(card, tuple):
                 cards.append(Card(card[0], card[1]))
             else:
                 cards.append(Card(card.suit, card.rank))
     CardPile.__init__(self, *cards)