Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dictionary to get individual card values
- AS = {'D': 0, 'C': 0.1, 'H': 0.2, 'S': 0.3}
- AR = {'3': 1, '4': 2, '5': 3, '6': 4, '7': 5, '8': 6, '9': 7, '0': 8,
- 'J': 9, 'Q': 10, 'K': 11, 'A': 12, '2': 13}
- # Main function
- def run(cards, play_to_beat):
- # Orders cards with enumeration
- def order(cards):
- t = cards
- order = []
- fin_hand = []
- for i in t:
- x = i[1]
- y = i[0]
- add1 = AS.get(x)
- add2 = AR.get(y)
- sum = add1 + add2
- order.append(sum)
- EnHand = list(zip(t, order))
- for i, (lowercase, uppercase) in enumerate(EnHand):
- fin_hand.append((i, lowercase, uppercase))
- return fin_hand
- old_hand = (order(cards))
- # Checks for card values greater than the play_to_beat
- def higher_card(cards_to_chk):
- # New list to put card plays that can beat
- New_hand = []
- Value_PTB = AR.get(play_to_beat[0][0]) + AS.get(play_to_beat[0][1])
- for i in cards_to_chk:
- if i[2] > Value_PTB:
- New_hand.append(i)
- return New_hand
- # Returns the New_Hand
- return higher_card(old_hand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement