# Check that users have entered a valid # option based on a list def string_checker(question, valid_ans=('yes', 'no')): error = f"please enter a valid option from the following list: {valid_ans}" while True: # get the user response and make sure its lowercase user_response = input(question).lower() for item in valid_ans: # check if a user response is a word in the list if item == user_response: return item # check if the user response is the same as # the first letter of an item in the list elif user_response == item[0]: return item # print error if user enters something invalid print(error) print() # displays instructions def instructions(): """prints instructions""" print(""" ⋆⁺。˚⋆˙‧₊☽ Instructions ☾₊‧˙⋆˚。⁺⋆ first select an ability to use: Rock, Paper, Or Scissors. the enemy will then also select an ability to use. Rock beats scissors, scissors beats paper, and paper beats rock. if the enemy beats you, you lose EXP. But if you win, you gain EXP. beat as many enemies as you can to gain points and climb up the leaderboard! good luck traveller, i have faith in you. hone your skills and im sure you will become a great fighter. """) # checks for an integer more than zero (allows ) def int_check(question): """Checks users enter an integer more than / equal to 1 and less than / equal to 150""" while True: error = "Result not rendered. Please enter an integer 1 or more (or type for infinite mode)." to_check = input(question) #Check if user wants infinite mode if to_check == "": return "infinite" try: response = int(to_check) if response < 1: print (error) elif response > 100: print(error) else: return response except ValueError: print(error) # Main Routine starts now # initialise game variables mode = "regular" rounds_played = 0 rps_list = ["rock", "paper", "scissors", "xxx"] print() print("🪨🧾✂️ ... Welcome to my Rock, Paper, Scissors Game!!! ...🪨🧾✂️") print() # Instructions: # ask the user if they want instructions (check if they say yes/no) want_instructions = string_checker("Would you like to read the rules? ") #display the instructions if the user wants to see them... if want_instructions == "yes": instructions() # Ask user for number of rounds / infinite mode num_rounds = int_check("How many rounds would you like? Push for infinite mode: ") if num_rounds == "infinite": mode = "infinite" num_rounds = 5 # game loop starts here while rounds_played < num_rounds: # Rounds heading if mode == "infinite": rounds_heading = f" --- Round {rounds_played + 1} (Infinite mode) --- " else: rounds_heading = f" --- Round {rounds_played + 1} of {num_rounds} --- " print(rounds_heading) print() # get user choice user_choice = string_checker("Choose: ", rps_list) print("you chose", user_choice) # if user choice it the exit code, break the loop if user_choice == "xxx": break rounds_played += 1 # If users ask for infinite mode increase number of rounds! if mode == "infinite": num_rounds += 1 # game loop ends here # Game history / statistics area