def card_choice_human(suit, hand): choices = [x.number() for x in filter(lambda x: suit==x.type(), hand)] print("\nWhich card would you like to play? Please type the value of the card.") for value in choices: print('{}'.format(value)) ans = str(input("-> ")).lower().strip().capitalize() while True: if ans in choices: break elif str(NW.words_to_number(ans)) in choices: ans = str(NW.words_to_number(ans)) break elif ans in ['A','K','Q','J']: ans = c.Card.ALIASES[ans] else: print("That is invalid input. Please try again.") ans = input("-> ").lower().strip().capitalize() return(c.Card(suit, ans))
def bidding_human(player, bids): print("There are {} bags on the table".format(13 - sum(bids))) print("\nYour hand is:") print(", ".join(map(str, player.hand))) print("\n{}, what would you like to bid?".format(player.name)) while True: ans = input('-> ').strip() try: int(ans) if bid_check(int(ans)): bid = int(ans) break except ValueError: # Ensures that the input will not break if ans.lower() == 'nil' or ans == "#YOLO": bid = 0 break elif NW.words_to_number(ans) != None: bid = NW.words_to_number(ans) if bid_check(bid): break else: print("Sorry, I don't recognize that input. Type a number, or write 'nil'") return bid
def human_players(): while True: num = input("How many players are human? Note, the default is to be on different teams. ") try: num = int(num) if player_check(num): break else: pass except ValueError: num = NW.words_to_number(num) if (num is not None) and player_check(num): break else: pass return num