In this submission I fixed my text!!!

I learned about the os and the clear screen command.
It seems quite useful and it does exactly what I need it to do (clearing the text upon
receiving a confirmative input) and more (clearing the borders of the game for some
reason, lol!). I am still yet ti figure out the actualy consequences of the
life system and the endgame dialogue. That will be my last milestone submission hopefully!
This has been SUPER fun!
This commit is contained in:
caglazir
2025-12-13 22:17:47 -05:00
parent 3d6773be0a
commit 375480b4bc
2 changed files with 49 additions and 26 deletions

View File

@@ -1,6 +1,10 @@
import os
from time import sleep
class Questioner: class Questioner:
name = "Questioner" name = "Questioner"
character = '?' character = '?'
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def __init__(self, board_size): def __init__(self, board_size):
board_width, board_height = board_size board_width, board_height = board_size
@@ -9,6 +13,8 @@ class Questioner:
self.speak = True self.speak = True
def play_turn(self,game): def play_turn(self,game):
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
score=game.state.get("score", 0) score=game.state.get("score", 0)
person = game.get_agent_by_name('Person') person = game.get_agent_by_name('Person')
if not person: if not person:
@@ -23,8 +29,10 @@ class Questioner:
begin = input("Questioner: Shall we begin? [[Y/N]] \n" ) begin = input("Questioner: Shall we begin? [[Y/N]] \n" )
if begin.strip().upper() == "Y": if begin.strip().upper() == "Y":
print("Questioner: Well then, good luck player \n Come back to me once you accumulate 200 points! ") input("Questioner: Well then, good luck player \n Come back to me once you accumulate 200 points! \n (PRESS ENTER TO CONTINUE) ")
game.state["begin"] = True game.state["begin"] = True
clear_screen()
elif prompt.strip().upper() == "N": elif prompt.strip().upper() == "N":
print("Questioner: I'll be here when you're ready to restart. \n") print("Questioner: I'll be here when you're ready to restart. \n")
game.state["begin"] = False game.state["begin"] = False
@@ -34,28 +42,29 @@ class Questioner:
self.speak = False self.speak = False
if score >= self.score_prompt: if score == 200:
game.state["begin"] = False game.state["begin"] = False
self.ask_question_1(game) self.ask_question_1(game)
if score >= self.score_prompt: if score == 400:
game.state["begin"] = False game.state["begin"] = False
self.ask_question_2(game) self.ask_question_2(game)
if score >= self.score_prompt: if score == 600:
game.state["begin"] = False game.state["begin"] = False
self.ask_question_3(game) self.ask_question_3(game)
def ask_question_1(self,game): def ask_question_1(self,game):
score=game.state.get("score") score=game.state.get("score")
if score >= self.score_prompt: def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
if score == 200:
game.state["begin"] = False game.state["begin"] = False
self.score_prompt += 200 self.score_prompt += 200
self.speak = True self.speak = True
question_1 = input("Very well, here is the first question: \n What is the square root of 64? \n" ) question_1 = input("Very well, here is the first question: \n What is the square root of 64? \n" )
if question_1.strip().lower() == "8": if question_1.strip().lower() == "8":
print("You may proceed. See you again once you reach 400 points!") input("You may proceed. See you again once you reach 400 points! \n (PRESS ENTER TO CONTINUE)")
clear_screen()
else: else:
print("HMPH! WRONG!! YOU HAVE TWO LIVES REMAINIG.") print("HMPH! WRONG!! YOU HAVE TWO LIVES REMAINIG.")
game.state['lives'] = 2 game.state['lives'] = 2
@@ -63,51 +72,65 @@ class Questioner:
if proceed_1.strip().upper() == "Y": if proceed_1.strip().upper() == "Y":
game.state["begin"] = True game.state["begin"] = True
self.speak = False self.speak = False
clear_screen()
else: else:
print("I don't take this as an answer... CONTINUE!") print("I don't take this as an answer... CONTINUE!")
game.state["begin"] = True game.state["begin"] = True
self.speak = False self.speak = False
clear_screen()
def ask_question_2(self,game): def ask_question_2(self,game):
score=game.state.get("score") score=game.state.get("score")
if score >= self.score_prompt: life = game.state.get("lives")
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
if score == 400:
game.state["begin"] = False game.state["begin"] = False
self.score_prompt += 200 self.score_prompt += 200
self.speak = True self.speak = True
question_2 = input("Here is the second question: \n What is the 18th element of the periodic table? \n" ) question_2 = input("What number is the element 'Argon'? \n" )
if question_2.strip().lower() == "argon": if question_2.strip() == "18":
print("You may proceed. See you again once you reach 600 points!") input("You may proceed. See you again once you reach 600 points!")
clear_screen()
else: else:
print("HMPH! WRONG!! YOU HAVE ONE LIFE REMAINIG.") if life == 2:
print("HMPH! WRONG!! YOU HAVE ONE LIFE REMAINING.")
game.state['lives'] = 1 game.state['lives'] = 1
if life == 3:
print("HMPH! WRONG!! YOU HAVE TWO LIVES REMAINING.")
proceed_2 = input("Shall we continue? [[Y/N]]") proceed_2 = input("Shall we continue? [[Y/N]]")
if proceed_2.strip().upper() == "Y": if proceed_2.strip().upper() == "Y":
game.state["begin"] = True game.state["begin"] = True
self.speak = False self.speak = False
clear_screen()
else: else:
print("I don't take this as an answer... CONTINUE!") print("I don't take this as an answer... CONTINUE!")
game.state["begin"] = True game.state["begin"] = True
self.speak = False self.speak = False
clear_screen()
def ask_question_3(self,game): def ask_question_3(self,game):
score=game.state.get("score") score=game.state.get("score")
if score >= self.score_prompt: life = game.state.get("lives")
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
if score == 600:
game.state["begin"] = False game.state["begin"] = False
self.score_prompt += 200 self.score_prompt += 200
self.speak = True self.speak = True
question_3 = input("Last question: \n Which country is home to Bosphorus? \n" ) question_3 = input("How many states make up the USA? \n" )
if question_3.strip().lower() == "turkey": if question_3.strip() == "50":
print("Correct!") print("Correct!")
else: else:
print("HMPH! WRONG!! YOU HAVE ONE LIFE REMAINIG.") if life == 1:
game.state['lives'] = 1 print("HAHAHAHA WRONG ANSWER! YOU ARE OUT OF LIVES! \n")
proceed_3 = input("Shall we continue? [[Y/N]]") print("YOU LOST THE GAME!")
if proceed_3.strip().upper() == "Y": if life == 2:
game.state["begin"] = True print("HMPH! WRONG!! BUT YOU SURVIVE WITH ONE LIFE REMAINING.")
self.speak = False game.state["lives"] = 1
else: if life ==3:
print("I don't take this as an answer... CONTINUE!") print("HMPH! WRONG!! BUT YOU SURVIVE WITH TWO LIVES REMAINING.")
game.state["begin"] = True game.state['lives'] = 2
self.speak = False self.speak = False