Removed unused code Text method and replaced with standard print commands

This commit is contained in:
kansaigaijin
2025-06-26 20:23:42 +12:00
parent 060e5bd0d6
commit b2f5e4eaf1

View File

@@ -1,49 +1,41 @@
import time import time
import player
from job_list import Barbarian, Cleric, Wizard
from player import * from player import *
from race_list import Elf, Dwarf, Human
def wait(): def wait():
input("Press enter to continue...") input("Press enter to continue...")
from pywebio.input import input, FLOAT, TEXT
from pywebio.output import put_text
from pywebio.session import run_js
def startGame(): def startGame():
put_text("Welcome, stranger.") print("Welcome, stranger.")
start = input("Would you like to create your own character or use pre-generated stats?" start = input("Would you like to create your own character or use pre-generated stats?"
"\n 1) Create a new character\n 2) Pre-generated\n >> ", type=TEXT).title() "\n 1) Create a new character\n 2) Pre-generated\n >> ")
while True: while True:
if start in ("2", "Pregen"): if start in ("2", "Pregen"):
put_text("Please be prepared to enter a name, gender, age, race, and class, from those available in the game." print("Please be prepared to enter a name, gender, age, race, and class, from those available in the game."
"\nIf you are unsure what the options are, please go back and create a new character.") "\nIf you are unsure what the options are, please go back and create a new character.")
create = input("Do you wish to continue? Y/N\n >> ", type=TEXT).lower() create = input("Do you wish to continue? Y/N\n >> ")
if create in ("y", "yes"): if create in ("y", "yes"):
name = input("Name: ", type=TEXT).title() name = input("Name: ")
gender = input("Gender: ", type=TEXT).title() gender = input("Gender: ")
age = int(input("Age: ", type=FLOAT)) age = int(input("Age: ")
race = input("Race: ", type=TEXT).title() race = input("Race: ")
job = input("Job: ", type=TEXT).title() job = input("Job: ")
return name, gender, age, race, job return name, gender, age, race, job
elif create in ("n", "no"): elif create in ("n", "no"):
start = "1" start = "1"
elif start in ("1", "Create"): elif start in ("1", "Create"):
while True: # Global check to see if Name, Age, and Gender are correct while True: # Global check to see if Name, Age, and Gender are correct
# Name # Name
name = input('What is your name?\n >> ', type=TEXT).title() name = input('What is your name?\n >> ')
while len(name) < 2: while len(name) < 2:
name = input('Input name was too short. Try again.\nWhat is your name?\n >> ', type=TEXT).title() name = input('Input name was too short. Try again.\nWhat is your name?\n >> ')
# Gender # Gender
while True: while True:
gender_select = input("What is your gender?\n" gender_select = input("What is your gender?\n"
"1) Male\n2) Female\n3) Other\n >> ", type=TEXT).lower() "1) Male\n2) Female\n3) Other\n >> ")
if gender_select not in ("male", "female", "other", "1", "2", "3"): if gender_select not in ("male", "female", "other", "1", "2", "3"):
put_text("Sorry I didn't recognise that gender. Please try again.") print("Sorry I didn't recognise that gender. Please try again.")
continue continue
else: else:
break break
@@ -56,20 +48,20 @@ def startGame():
while True: while True:
# Age # Age
try: try:
age = int(input('How old are you?\n >> ', type=FLOAT)) age = int(input('How old are you?\n >> ')
break break
except ValueError: except ValueError:
put_text("Sorry I didn't recognise that age. Please type in a whole number.") print("Sorry I didn't recognise that age. Please type in a whole number.")
continue continue
# Double check responses # Double check responses
correct = input(f"Hello, {name}. You are a {age} year old {gender}.\nIs this correct? Y/N\n >> ", type=TEXT).lower() correct = input(f"Hello, {name}. You are a {age} year old {gender}.\nIs this correct? Y/N\n >> ")
if correct in ['y', 'yes']: if correct in ['y', 'yes']:
break break
elif correct in ['n', 'no']: elif correct in ['n', 'no']:
continue continue
else: else:
put_text("Sorry, I didn't catch that.\n") print("Sorry, I didn't catch that.\n")
correct = input(f"You are a {age} year old {gender}. \nIs this correct? Y/N\n >> ", type=TEXT).lower() correct = input(f"You are a {age} year old {gender}. \nIs this correct? Y/N\n >> ")
if correct in ['y', 'yes']: if correct in ['y', 'yes']:
break break
elif correct in ['n', 'no']: elif correct in ['n', 'no']:
@@ -79,22 +71,22 @@ def startGame():
while True: # Global check to see if Race and Job are correct while True: # Global check to see if Race and Job are correct
# Race # Race
while True: while True:
race = input("Please select a race to learn more about it: Elf, Dwarf, or Human.\n >> ", type=TEXT).title() race = input("Please select a race to learn more about it: Elf, Dwarf, or Human.\n >> ")
if race not in ("Elf", "Dwarf", "Human", None): if race not in ("Elf", "Dwarf", "Human", None):
race = input("Sorry I didn't recognise that race. Please select 'Elf', 'Dwarf', or 'Human'.\n >> ", type=TEXT).title() race = input("Sorry I didn't recognise that race. Please select 'Elf', 'Dwarf', or 'Human'.\n >> ")
elif race is None: elif race is None:
race = input("Please select a race to learn more about it: Elf, Dwarf, or Human.\n >> ", type=TEXT).title() race = input("Please select a race to learn more about it: Elf, Dwarf, or Human.\n >> ")
continue continue
else: else:
# Replace these prints with appropriate explanations for the web interface # Replace these prints with appropriate explanations for the web interface
if race == "Elf": if race == "Elf":
put_text("Information about Elves...") print("Information about Elves...")
elif race == "Dwarf": elif race == "Dwarf":
put_text("Information about Dwarves...") print("Information about Dwarves...")
elif race == "Human": elif race == "Human":
put_text("Information about Humans...") print("Information about Humans...")
put_text('Would you like to proceed with this race or view another?') print('Would you like to proceed with this race or view another?')
proceed = input('1) Proceed\n2) View another race\n >> ', type=TEXT).lower() proceed = input('1) Proceed\n2) View another race\n >> ')
if proceed in ('1', 'proceed'): if proceed in ('1', 'proceed'):
break break
elif proceed in ('2', 'view', 'view another', 'view another race'): elif proceed in ('2', 'view', 'view another', 'view another race'):
@@ -102,22 +94,22 @@ def startGame():
continue continue
# Job # Job
while True: while True:
job = input("Please select a job to learn more about it: Barbarian, Cleric, or Wizard.\n >> ", type=TEXT).title() job = input("Please select a job to learn more about it: Barbarian, Cleric, or Wizard.\n >> ")
if job not in ("Barbarian", "Cleric", "Wizard", None): if job not in ("Barbarian", "Cleric", "Wizard", None):
job = input("Sorry I didn't recognise that job. Please select 'Barbarian', 'Cleric', or 'Wizard'.\n >> ", type=TEXT).title() job = input("Sorry I didn't recognise that job. Please select 'Barbarian', 'Cleric', or 'Wizard'.\n >> ")
elif job is None: elif job is None:
job = input("Please select a job to learn more about it: Barbarian, Cleric, or Wizard.\n >> ", type=TEXT).title() job = input("Please select a job to learn more about it: Barbarian, Cleric, or Wizard.\n >> ")
continue continue
else: else:
# Replace these prints with appropriate explanations for the web interface # Replace these prints with appropriate explanations for the web interface
if job == "Barbarian": if job == "Barbarian":
put_text("Information about Barbarians...") print("Information about Barbarians...")
elif job == "Cleric": elif job == "Cleric":
put_text("Information about Clerics...") print("Information about Clerics...")
elif job == "Wizard": elif job == "Wizard":
put_text("Information about Wizards...") print("Information about Wizards...")
put_text('Would you like to proceed with this job or view another?') print('Would you like to proceed with this job or view another?')
proceed = input('1) Proceed\n2) View another job\n >> ', type=TEXT).lower() proceed = input('1) Proceed\n2) View another job\n >> ')
if proceed in ('1', 'proceed'): if proceed in ('1', 'proceed'):
break break
elif proceed in ('2', 'view', 'view another', 'view another job'): elif proceed in ('2', 'view', 'view another', 'view another job'):
@@ -125,13 +117,13 @@ def startGame():
continue continue
while True: while True:
# Final check # Final check
correct = input(f"{name}, you are a {race} {job}.\nIs this correct? Y/N\n >> ", type=TEXT).lower() correct = input(f"{name}, you are a {race} {job}.\nIs this correct? Y/N\n >> ")
if correct in ['y', 'yes']: if correct in ['y', 'yes']:
break break
elif correct in ['n', 'no']: elif correct in ['n', 'no']:
continue continue
else: else:
put_text("Sorry, I didn't catch that. Please try again.\n") print("Sorry, I didn't catch that. Please try again.\n")
continue continue
return name, gender, age, race, job return name, gender, age, race, job