2017-01-29 05:56:01 (edited by vlajna95 2017-01-29 05:57:24)

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...

Write me on FB, that's the best way to contact me right now. :)

2017-01-29 06:47:26

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.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support

2017-01-29 14:43:28 (edited by raven 2017-01-29 14:44:34)

# 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)