Advertisement
Guest User

TCard

a guest
May 11th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. class TCard():
  2.     def __init__(self):
  3.       self.Suit = 0
  4.       aelf.Rank = 0
  5.  
  6.     Deck = [None]
  7.    
  8.     def LoadDeck(Deck):
  9.       CurrentFile = open('deck.txt', 'r')
  10.       Count = 1
  11.       while True:
  12.         LineFromFile = CurrentFile.readline()
  13.         if not LineFromFile:
  14.             CurrentFile.close()
  15.             break
  16.         Deck[Count].Suit = int(LineFromFile)
  17.         LineFromFile = CurrentFile.readline()
  18.         Deck[Count].Rank = int(LineFromFile)
  19.         Count = Count + 1
  20.  
  21.     def ShuffleDeck(Deck):
  22.         SwapSpace = TCard()
  23.         NoOfSwaps = 1000
  24.        
  25.         for NoOfSwapsMadeSoFar in range(1, NoOfSwaps + 1):
  26.             Position1 = random.randint(1, 52)
  27.             Position2 = random.randint(1, 52)
  28.             SwapSpace.Rank = Deck[Position1].Rank
  29.             SwapSpace.Suit = Deck[Position1].Suit
  30.             Deck[Position1].Rank = Deck[Position2].Rank
  31.             Deck[Position1].Suit = Deck[Position2].Suit
  32.             Deck[Position2].Rank = SwapSpace.Rank
  33.             Deck[Position2].Suit = SwapSpace.Suit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement