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 player
from job_list import Barbarian, Cleric, Wizard
from player import *
from race_list import Elf, Dwarf, Human
def wait():
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():
put_text("Welcome, stranger.")
print("Welcome, stranger.")
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:
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.")
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"):
name = input("Name: ", type=TEXT).title()
gender = input("Gender: ", type=TEXT).title()
age = int(input("Age: ", type=FLOAT))
race = input("Race: ", type=TEXT).title()
job = input("Job: ", type=TEXT).title()
name = input("Name: ")
gender = input("Gender: ")
age = int(input("Age: ")
race = input("Race: ")
job = input("Job: ")
return name, gender, age, race, job
elif create in ("n", "no"):
start = "1"
elif start in ("1", "Create"):
while True: # Global check to see if Name, Age, and Gender are correct
# Name
name = input('What is your name?\n >> ', type=TEXT).title()
name = input('What is your name?\n >> ')
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
while True:
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"):
put_text("Sorry I didn't recognise that gender. Please try again.")
print("Sorry I didn't recognise that gender. Please try again.")
continue
else:
break
@@ -56,20 +48,20 @@ def startGame():
while True:
# Age
try:
age = int(input('How old are you?\n >> ', type=FLOAT))
age = int(input('How old are you?\n >> ')
break
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
# 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']:
break
elif correct in ['n', 'no']:
continue
else:
put_text("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()
print("Sorry, I didn't catch that.\n")
correct = input(f"You are a {age} year old {gender}. \nIs this correct? Y/N\n >> ")
if correct in ['y', 'yes']:
break
elif correct in ['n', 'no']:
@@ -79,22 +71,22 @@ def startGame():
while True: # Global check to see if Race and Job are correct
# Race
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):
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:
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
else:
# Replace these prints with appropriate explanations for the web interface
if race == "Elf":
put_text("Information about Elves...")
print("Information about Elves...")
elif race == "Dwarf":
put_text("Information about Dwarves...")
print("Information about Dwarves...")
elif race == "Human":
put_text("Information about Humans...")
put_text('Would you like to proceed with this race or view another?')
proceed = input('1) Proceed\n2) View another race\n >> ', type=TEXT).lower()
print("Information about Humans...")
print('Would you like to proceed with this race or view another?')
proceed = input('1) Proceed\n2) View another race\n >> ')
if proceed in ('1', 'proceed'):
break
elif proceed in ('2', 'view', 'view another', 'view another race'):
@@ -102,22 +94,22 @@ def startGame():
continue
# Job
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):
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:
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
else:
# Replace these prints with appropriate explanations for the web interface
if job == "Barbarian":
put_text("Information about Barbarians...")
print("Information about Barbarians...")
elif job == "Cleric":
put_text("Information about Clerics...")
print("Information about Clerics...")
elif job == "Wizard":
put_text("Information about Wizards...")
put_text('Would you like to proceed with this job or view another?')
proceed = input('1) Proceed\n2) View another job\n >> ', type=TEXT).lower()
print("Information about Wizards...")
print('Would you like to proceed with this job or view another?')
proceed = input('1) Proceed\n2) View another job\n >> ')
if proceed in ('1', 'proceed'):
break
elif proceed in ('2', 'view', 'view another', 'view another job'):
@@ -125,13 +117,13 @@ def startGame():
continue
while True:
# 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']:
break
elif correct in ['n', 'no']:
continue
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
return name, gender, age, race, job