Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Used for random picking
- import random
- import sys
- import time
- ## SUCCESSFULLY GENERATES A PACK OF CARDS ##
- names = ['Ace', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King'] # Stores all names needed so don't have to be typed individually
- suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] # Same here just with suits not numbers.
- finalCardArray = [] # Declares the final array of cards, blank so it can be added to.
- valueOfCard = 0 # Sets the default value of the card should not be set in for loop
- suitSelection = 0 # Sets the suit selection same as the value of the card just for suit.
- for i in range(52):
- addArray = []
- #POSITION IN PACK
- addArray.append(i) # Declares First Value as Position In Deck Always Being i
- # END POSITION IN PACK
- #VALUE
- if valueOfCard > 12: # Capped at 1 - 13, same as 0 - 12 that's what this does.
- valueOfCard = 1
- suitSelection += 1 # Resets the value of card and pushes it up a suit.
- else:
- valueOfCard += 1 # If it doesn't reset it moves onto the next card e.g. Six -> Seven
- if valueOfCard > 10: # Capped at 10 just makes sure the value can never be more than 10
- addArray.append(10) # Adds value of card in pack it's capped at 10
- else:
- addArray.append(valueOfCard)
- #END VALUE
- #POSITION IN SUIT
- addArray.append(valueOfCard)
- #END_POSITION IN SUIT
- #NAME
- addArray.append(names[valueOfCard - 1] + ' of ' + suits[suitSelection])
- # Just formats the name data in to a easy format, picks from the name array and converts say a 6 into Six, and the same with suits just convers position into the arrays.
- #END_NAME
- finalCardArray.append(addArray) # Once it's all done it adds the array created on this itteration to the main array.
- print(finalCardArray) ## opional test statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement