Code:
# This is a small text based adventure game
# Meant to test my python skills
# I will release this to the public if I decide it's good enough
# Starting date and time 2/5/2025 - 9:44 PM
class game():
def __init__(self):
self.player_info()
self.cuss_checker()
self.main()
def player_info(player_age=10, player_name="Chris Jones"):
player_name = input(cuss_checker(player_name))
player_age = int(input(f"What is your age {player_name}?"))
return {"age": player_age, "name": player_name}
def cuss_checker(word):
word = word.lower()
cuss_words = ["various cusswords"]
while word in cuss_words:
print("Sorry that is not allowed")
word = input("Please try again ")
continue
else:
print("That is allowed thank you!")
return word
def main(player_age, player_name):
game_running = True
print("Welcome to a small text based adventure")
while game_running:
start_game = input("Would you like to play this game? (yes/no): ").lower()
if start_game != "yes":
print("Thank you for considering this game, have a nice day")
game_running = False
continue
if player_age < 10:
print(f"I am sorry {player_name}, you are not old enough to play this game please try again after your tenth birthday ")
continue
else:
print(f"Welcome {player_name} to the game, let's get the story started!")
play_again = input("Would you like to play again? (yes/no): ").lower()
if play_again != "yes":
print("Thank you for playing this game, have a nice day")
game_running = False
continue
else:
print("Thanks for playing my game, have a nice day")
game_running = False
game()