Константин обнови решението на 26.03.2014 16:59 (преди над 10 години)
+
+#ranks = ['King', 'Six', 'Jack', 'Five', 'Queen', 'Ten', 'Ace', 'Three', 'Eight', 'Four', 'Two', 'Seven', 'Nine']
+ranks = ['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven', 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace']
+#symbols = ['K', '6', 'J', '5', 'Q', '10', 'A', '3', '8', '4', '2', '7', '9']
+ranks_symbols = [['King', 'K'], ['Six', '6'], ['Jack', 'J'], ['Five', '5'], ['Queen', 'Q'], ['Ten', '10'], ['Ace', 'A'], ['Three', '3'], ['Eight', '8'], ['Four', '4'], ['Two', '2'], ['Seven', '7']]
+suits = ['Diamonds', 'Clubs', 'Hearts', 'Spades']
+
+
+
+class Rank():
+ symbol = None
+
+class Suit():
+ color = None
+
+defalt_dict = {'__qualname__': 'Six', '__doc__': None, '__module__': '__main__'}
+
+RANKS = {}
+for r in ranks:
+ RANKS[r] = type(r,(Rank,),{'__qualname__': r, '__doc__': None, '__module__': '__main__'})
+
+for i in ranks_symbols:
+ RANKS[i[0]].symbol = i[1]
+
+SUITS = {}
+for s in suits:
+ SUITS[s] = type(s,(Suit,),{'__qualname__': s, '__doc__': None, '__module__': '__main__'})
+
+SUITS['Diamonds'].color = 'red'
+SUITS['Hearts'].color = 'red'
+SUITS['Spades'].color = 'black'
+SUITS['Clubs'].cplor = 'black'
+
+class Card:
+ def __init__(self,rank,suit):
+ self.rank = rank #RANKS[rank]
+ self.suit = suit #SUITS[suit]
+ def __eq__(self,other):
+ if self.rank == other.rank and self.suit == other.suit:
+ return True
+ else:
+ return False
+
+ def __str__(self):
+ return str(self.rank)+' of '+str(self.suit)
+
+ def __repr__(self):
+ return str(self.rank)+' of '+str(self.suit)
+
+class CardCollection(list):
+
+ def draw(self,index):
+ return self.pop(index)
+
+ def draw_from_top(self):
+ return self.pop(len(self)-1)
+
+ def draw_from_bottom(self):
+ return self.pop(0)
+
+ def top_card(self):
+ return self[len(self)-1]
+
+ def bottom_card(self):
+ return self[0]
+
+ def add(self, card):
+ self.append(card)
+
+ def index(self, card):
+ for i in range(len(self)):
+ if card == self[i]:
+ return i
+
+def BessDeck(ran):
+ allCards = []
+ for i in suits:
+ for j in ran:
+ allCards.append(Card(j,i))
+
+ #allCards = [Card(i,j) for i in suits for j in ranks]
+ return CardCollection(allCards)
+
+def StandartDeck():
+ return BessDeck(ranks)
+
+def BelotDeck():
+ return BessDeck(['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven' , 'Ace'])
+
+def SixtySixDeck():
+ return Bess(['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven' , 'Ace'])