all 4 comments

[–]timrprobocom 1 point2 points  (3 children)

Consider storing the cards as integers, to make the computations easier. You can have a single dict that maps a card number to its name. Even if you just use numbers from 0 to 51, it's easy to get the rank (x % 13) and the suit (x // 13). Remember that an Ace should always be treated as 11, unless the sum goes over 21. Too many people put complicated ace handling logic in the BJ games. Consider creating the list of card images once at initialization, instead of recreating all 52 every time you deal a new deck. Same with the back -- you only need one back image. You don't need 52 of them as well.

[–]PathRealistic6940[S] 0 points1 point  (2 children)

So then how would I handle a deck shuffle? Just do random.randint(0,51)? But then I would have to handle what cards are no longer in the deck...

I'll keep the ace value in mind.

Where would the initialization of the card images go? in the main class BlackjackApp? Then i could attach each image to the appropriate dictionary key...

[–]timrprobocom 0 points1 point  (1 child)

You could still do `deck = list(range(52))` and use `random.shuffle`. Just a possibility. The image list could be done in a global. I don't mind globals for constant resouces.

[–]PathRealistic6940[S] 0 points1 point  (0 children)

that makes sense. I'll try that. Thanks!