Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. # Used for random picking
  2. import random
  3. import sys
  4. import time
  5.  
  6. ## SUCCESSFULLY GENERATES A PACK OF CARDS ##
  7. 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
  8. suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] # Same here just with suits not numbers.
  9.  
  10. finalCardArray = [] # Declares the final array of cards, blank so it can be added to.
  11.  
  12. valueOfCard = 0 # Sets the default value of the card should not be set in for loop
  13. suitSelection = 0 # Sets the suit selection same as the value of the card just for suit.
  14.  
  15. for i in range(52):
  16.     addArray = []
  17.  
  18.     #POSITION IN PACK
  19.     addArray.append(i) # Declares First Value as Position In Deck Always Being i
  20.     # END POSITION IN PACK
  21.  
  22.     #VALUE
  23.     if valueOfCard > 12: # Capped at 1 - 13, same as 0 - 12 that's what this does.
  24.         valueOfCard = 1
  25.         suitSelection += 1 # Resets the value of card and pushes it up a suit.
  26.     else:
  27.         valueOfCard += 1 # If it doesn't reset it moves onto the next card e.g. Six -> Seven
  28.  
  29.     if valueOfCard > 10: # Capped at 10 just makes sure the value can never be more than 10
  30.         addArray.append(10) # Adds value of card in pack it's capped at 10
  31.     else:
  32.         addArray.append(valueOfCard)
  33.     #END VALUE
  34.  
  35.     #POSITION IN SUIT
  36.     addArray.append(valueOfCard)
  37.     #END_POSITION IN SUIT
  38.  
  39.     #NAME
  40.     addArray.append(names[valueOfCard - 1] + ' of ' + suits[suitSelection])
  41.     # 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.
  42.     #END_NAME
  43.  
  44.     finalCardArray.append(addArray) # Once it's all done it adds the array created on this itteration to the main array.
  45.  
  46. print(finalCardArray) ## opional test statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement