Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # Dictionary to get individual card values
  2.  
  3. AS = {'D': 0, 'C': 0.1, 'H': 0.2, 'S': 0.3}
  4.  
  5. AR = {'3': 1, '4': 2, '5': 3, '6': 4, '7': 5, '8': 6, '9': 7, '0': 8,
  6.       'J': 9, 'Q': 10, 'K': 11, 'A': 12, '2': 13}
  7.  
  8. # Main function
  9. def run(cards, play_to_beat):
  10.  
  11.     # Orders cards with enumeration
  12.  
  13.     def order(cards):
  14.  
  15.         t = cards
  16.  
  17.         order = []
  18.  
  19.         fin_hand = []
  20.  
  21.         for i in t:
  22.             x = i[1]
  23.             y = i[0]
  24.             add1 = AS.get(x)
  25.             add2 = AR.get(y)
  26.             sum = add1 + add2
  27.             order.append(sum)
  28.  
  29.         EnHand = list(zip(t, order))
  30.  
  31.         for i, (lowercase, uppercase) in enumerate(EnHand):
  32.  
  33.             fin_hand.append((i, lowercase, uppercase))
  34.  
  35.         return fin_hand
  36.  
  37.     old_hand  = (order(cards))
  38.  
  39.     # Checks for card values greater than the play_to_beat
  40.  
  41.     def higher_card(cards_to_chk):
  42.  
  43.         # New list to put card plays that can beat
  44.  
  45.         New_hand = []
  46.  
  47.         Value_PTB = AR.get(play_to_beat[0][0]) + AS.get(play_to_beat[0][1])
  48.  
  49.         for i in cards_to_chk:
  50.             if i[2] > Value_PTB:
  51.  
  52.                 New_hand.append(i)
  53.         return New_hand
  54.  
  55.     # Returns the New_Hand
  56.  
  57.     return higher_card(old_hand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement