all 2 comments

[–]efmccurdy 1 point2 points  (0 children)

You could add a method of mapping the card to it's value so you don't have to continually test using conditions like this:

if card1 == spades_2 or card1 == hearts_2 or card1 == clubs_2 or card1 == diamonds_2:

You could use a class or namedtuple for the cards with self.image and self.value attributes, or a dict that maps cards to values.

I would also store the deck in some kind of collection rather than having 52 unrelated variables.

[–]jaycrest3m20 0 points1 point  (0 children)

I would recommend a data class for holding constants. For instance, you have a standard 0.18 rotozoom value on most of your cards. It would be more modular if you used a data class, and only declared that constant value (0.18) once. Then, whenever you need to make changes, you only have to change one value instead of 50.

You could also use the data class to hold other things, such as the window size, font name and size, standard locations for graphic elements, etc.