SHARE
TWEET

Untitled

a guest Jan 21st, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. class Card(object):
  5.     def __init__(self, suit, val):
  6.         self.suit = suit
  7.         self.value = val
  8.  
  9.  
  10.     def show(self):
  11.         if self.value == 1:
  12.             val = "Aso"
  13.         elif self.value == 11:
  14.             val = "Vale"
  15.         elif self.value == 12:
  16.             val = "Dama"
  17.         elif self.value == 13:
  18.             val = "Pop"
  19.         else:
  20.             val = self.value
  21.  
  22.         print("{} {}".format(val, self.suit))
  23.         pass
  24.  
  25. class Deck:
  26.     def __init__(self):
  27.         self.cards = []
  28.         self.build()
  29.  
  30.     def build(self):
  31.         for s in ["Pika","Spatia","Karo","Kupa"]:
  32.             for v in range(1, 14):
  33.                 self.cards.append(Card(s,v))
  34.  
  35.     def show(self):
  36.         for c in self.cards:
  37.             c.show()
  38.  
  39.     def shuffle(self):
  40.         for i in range(len(self.cards) - 1 , 0, -1):
  41.             r = random.randint(0,i)
  42.             self.cards[i], self.cards[r] = self.cards[r] , self.cards[i]
  43.  
  44.     def drawCard(self):
  45.         return self.cards.pop()
  46.         pass
  47.  
  48. class Player:
  49.     def __init__(self, name):
  50.         self.name = name
  51.         self.hand = []
  52.  
  53.     def draw(self, deck):
  54.         self.hand.append(deck.drawCard())
  55.         return self
  56.  
  57.     def showHand(self):
  58.         for card in self.hand:
  59.             card.show()
  60.         pass
  61.  
  62. deck = Deck()
  63. deck.shuffle()
  64. deck.show()
  65. deck.build()
  66. deck.show()
  67.  
  68.  
  69.  
  70. #bob = Player("Viktor")
  71. #bob.draw(Deck, 5)                                # ne iska da raboti
  72. #bob.showHand()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top