Exemple #1
0
def _restore_deck(str_exclude_cards):
    deck = Deck()
    exclude_ids = [Card.to_id(Card.from_str(s)) for s in str_exclude_cards]
    deck_cards = [
        Card.from_id(cid) for cid in Deck.GetFullDeck()
        if cid not in exclude_ids
    ]
    deck.cards = deck_cards
    return deck
Exemple #2
0
def gen_deck(exclude_cards=None):
    deck_ids = Deck.GetFullDeck()
    if exclude_cards:
        assert isinstance(exclude_cards, list)
        if isinstance(exclude_cards[0], str):
            exclude_cards = [Card.from_str(s) for s in exclude_cards]
        exclude_ids = [card for card in exclude_cards]
        deck_ids = [i for i in deck_ids if not i in exclude_ids]
    return Deck(deck_ids)
Exemple #3
0
def _pick_unused_card(card_num, used_card):
    used = [card for card in used_card]
    unused = [card_id for card_id in Deck.GetFullDeck() if card_id not in used]
    choiced = random.sample(unused, card_num)
    return [Card.from_id(card_id) for card_id in choiced]