import os from time import sleep class Questioner: name = "Questioner" character = '?' def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') def __init__(self, board_size): board_width, board_height = board_size self.position = (board_width // 2, board_height // 2) self.score_prompt = 200 self.speak = True def play_turn(self,game): def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') score=game.state.get("score", 0) person = game.get_agent_by_name('Person') if not person: return personx, persony = person.position questionerx, questionery = self.position if personx == questionerx and persony == questionery +1: if score == 0 and self.speak: prompt = input("Questioner: Are you ready to start the game? [[Y/N]] \n") if prompt.strip().upper() == "Y": print("Questioner: Well then, the rules are as follows... \n 1. You have 3 lives. \n 2. For every 200 points you accumulate during Starfall, you receive a question. \n 3. Each wrong answer costs you a life. You must answer 3 questions to escape this terminal. \n 4. You MUST enter NUMBERS ONLY.") begin = input("Questioner: Shall we begin? [[Y/N]] \n" ) if begin.strip().upper() == "Y": input("Questioner: Well then, good luck player \n Come back to me once you accumulate 200 points! \n (PRESS ANY KEY TO CONTINUE) ") game.state["begin"] = True clear_screen() elif prompt.strip().upper() == "N": print("Questioner: I'll be here when you're ready to restart. \n") game.state["begin"] = False else: print("Questioner: What now? (RESTART) \n") game.state["begin"] = False self.speak = False if score == 200: game.state["begin"] = False self.ask_question_1(game) if score == 400: game.state["begin"] = False self.ask_question_2(game) if score == 600: game.state["begin"] = False self.ask_question_3(game) def ask_question_1(self,game): score=game.state.get("score") def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') if score == 200: game.state["begin"] = False self.score_prompt += 200 self.speak = True qbuffer = input("QUESTION INCOMING (PRESS ANY KEY TO CONTINUE) \n ") question_1 = input("Very well, here is the first question: \n What is the square root of 64? \n" ) if int(question_1) == 8: print("You may proceed. See you again once you reach 400 points! \n ") else: print("HMPH! WRONG!! YOU HAVE TWO LIVES REMAINING. \n ") game.state['lives'] = 2 proceed_1 = input("Shall we continue? [[Y/N]]") if proceed_1.strip().upper() == "Y": game.state["begin"] = True self.speak = False clear_screen() else: print("I don't take this as an answer... CONTINUE!") game.state["begin"] = True self.speak = False clear_screen() def ask_question_2(self,game): score=game.state.get("score") life = game.state.get("lives") def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') if score == 400: game.state["begin"] = False self.score_prompt += 200 self.speak = True qbuffer = input("QUESTION INCOMING (PRESS ANY KEY TO CONTINUE) \n ") question_2 = input("What number is the element 'Argon'? \n") if int(question_2) == 18: print("You may proceed. See you again once you reach 600 points! \n") else: if life == 2: print("HMPH! WRONG!! YOU HAVE ONE LIFE REMAINING.") game.state['lives'] = 1 if life == 3: print("HMPH! WRONG!! YOU HAVE TWO LIVES REMAINING.") game.state['lives'] = 2 proceed_2 = input("Shall we continue? [[Y/N]]") if proceed_2.strip().upper() == "Y": game.state["begin"] = True self.speak = False clear_screen() else: print("I don't take this as an answer... CONTINUE!") game.state["begin"] = True self.speak = False clear_screen() def ask_question_3(self,game): score=game.state.get("score") life = game.state.get("lives") def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') if score == 600: game.state["begin"] = False self.score_prompt += 200 self.speak = True qbuffer = input("QUESTION INCOMING (PRESS ANY KEY TO CONTINUE) \n ") clear_screen() question_3 = input("How many states make up the USA? \n") if int(question_3) == 50: print("Correct!") if life >= 1: clear_screen() print("CONGRATULATIONS! YOU MAY ESCAPE THE TERMINAL. \n") else: if life == 1: clear_screen() print("HAHAHAHA WRONG ANSWER! YOU ARE OUT OF LIVES! \n") print("YOU LOST THE GAME!") if life == 2: clear_screen() print("HMPH! WRONG!! BUT YOU SURVIVE WITH ONE LIFE REMAINING.") game.state["lives"] = 1 if life ==3: clear_screen() print("HMPH! WRONG!! BUT YOU SURVIVE WITH TWO LIVES REMAINING.") game.state['lives'] = 2 self.speak = False