Hi all...
I need a working class for dealing with cards, decks, hands, or a brief explanation about its creation. Please, it's urgently!
I know Python and BGT...
Pages 1
You are not logged in. Please login or register.
AudioGames.net Forum → Developers room → Decks, hands, shuffling
Hi all...
I need a working class for dealing with cards, decks, hands, or a brief explanation about its creation. Please, it's urgently!
I know Python and BGT...
suits=['spades','clubs','diamonds','hearts']
values=['ace','2','3','4','5','6','7','8','9','10','jack','queen','king']
class card:
def __init__(self):
self.value=""
self.name=""
self.suit=""
deck=[]
def make_deck():
for a in range(len(suits)):
for b in range(len(values)):
c=card()
c.suit=a
c.value=b
c.name=b+" of "+a
#let me know if you need more help.
# Slightly fixed
# Haven't tested, though it should work
# Making a deck is left as an exercise for the reader (look up random.shuffle, l[index]...)
suits = ['spades','clubs','diamonds','hearts']
values = ['ace','2','3','4','5','6','7','8','9','10','jack','queen','king']
class card:
def __init__(self, deck, value):
self.deck = deck
self.value = value
self.name = "{} of {}".format(value, deck)
def __repr__(self):
# You don't need to understand this if you don't want to
# It lets you do print(card) and get pretty-printed names
return self.name
cards = []
if __name__ == "__main__": # On running the script
for i in suits:
for j in values:
cards.append(card(i, j))
print(cards)
AudioGames.net Forum → Developers room → Decks, hands, shuffling
Generated in 0.019 seconds (45% PHP - 55% DB) with 9 queries