mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-29 21:28:07 +00:00
22 lines
659 B
Python
22 lines
659 B
Python
'''
|
|
Deck module that defines the Deck class.
|
|
'''
|
|
import random
|
|
class Deck:
|
|
def __init__(self):
|
|
self.cards = self.create_deck()
|
|
def create_deck(self):
|
|
suits = ["Spades", "Hearts", "Diamonds", "Clubs"]
|
|
ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
|
|
deck = []
|
|
for suit in suits:
|
|
for rank in ranks:
|
|
deck.append(rank + " of " + suit)
|
|
return deck
|
|
def shuffle(self):
|
|
random.shuffle(self.cards)
|
|
def draw(self, num_cards):
|
|
cards = []
|
|
for _ in range(num_cards):
|
|
cards.append(self.cards.pop())
|
|
return cards |