From 47d2d7bc67bf9d550230d929a764b5234975778f Mon Sep 17 00:00:00 2001 From: Toasterkitten Date: Wed, 24 Jun 2026 12:57:21 -0400 Subject: [PATCH] lot --- .gitignore | 3 ++- tests/test_generation.py | 20 ++++++++++++++++++++ untitled/app.py | 10 ++++++---- untitled/generation.py | 11 ++++++++--- untitled/rules.py | 12 ++++++++++++ untitled/screens.py | 19 +++++++++++-------- untitled/ui.py | 4 ++++ 7 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 tests/test_generation.py create mode 100644 untitled/rules.py diff --git a/.gitignore b/.gitignore index cb8b165..6df5eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ wheels/ # CUSTOM STUFF untitled/saves .ruff_cache -.pytest_cache \ No newline at end of file +.pytest_cache +DEBUG_MODE \ No newline at end of file diff --git a/tests/test_generation.py b/tests/test_generation.py new file mode 100644 index 0000000..90772e6 --- /dev/null +++ b/tests/test_generation.py @@ -0,0 +1,20 @@ +from untitled import generation + + +def test_cat_description_gen(): + traits_a = { + "size": "tiny", + "color": "tuxedo", + "eyes": "blue", + "personality": "judges you silently", + } + traits_an = { + "size": "average sized", + "color": "tuxedo", + "eyes": "blue", + "personality": "judges you silently", + } + a = "A tiny tuxedo kitten with blue eyes who judges you silently" + an = "An average sized tuxedo kitten with blue eyes who judges you silently" + assert generation.generate_trait_sentence(traits_a) == a + assert generation.generate_trait_sentence(traits_an) == an diff --git a/untitled/app.py b/untitled/app.py index 71bcfdb..8ea46f9 100644 --- a/untitled/app.py +++ b/untitled/app.py @@ -1,3 +1,4 @@ +import os import time from untitled import content, screens, ui @@ -5,13 +6,14 @@ from untitled import content, screens, ui class App: def __init__(self): - pass + self.debug = os.path.exists("DEBUG_MODE") def run(self): # Intro - ui.clear() - time.sleep(1) - ui.splash() + if not self.debug: + ui.clear() + time.sleep(1) + ui.splash() # Main Menu while True: # forEVER!... forEVER!... forEVER!... forEVER!... diff --git a/untitled/generation.py b/untitled/generation.py index c2b94b1..fff7968 100644 --- a/untitled/generation.py +++ b/untitled/generation.py @@ -3,19 +3,24 @@ import random from untitled import content +def generate_trait_sentence(traits): + article = "An" if traits["size"][0] in "aeiou" else "A" + description = f"{article} {traits["size"]} {traits["color"]} kitten with {traits["eyes"]} eyes who {traits["personality"]}" + return description + + def generate_cat_choice(personality=None): size = random.choice(content.CAT_SIZES) color = random.choice(content.CAT_COLORS) eyes = random.choice(content.CAT_EYE_COLORS) personality = personality or random.choice(content.CAT_PERSONALITIES) - article = "An" if size[0] in "aeiou" else "A" - description = f"{article} {size} {color} kitten with {eyes} eyes who {personality}" - return description, { + traits = { "size": size, "color": color, "eyes": eyes, "personality": personality, } + return generate_trait_sentence(traits), traits def generate_cat_choices(n=5): diff --git a/untitled/rules.py b/untitled/rules.py new file mode 100644 index 0000000..2e9ce78 --- /dev/null +++ b/untitled/rules.py @@ -0,0 +1,12 @@ +import string + + +def validate_cat_name(name): + ALLOWED = set(string.ascii_letters + string.digits) + + if len(name) < 4 or len(name) > 24: + return "Your cat's name must be 4-24 characters long." + if not all(c in ALLOWED for c in name): + return "Letters and numbers only." + if not any(c in string.ascii_letters for c in name): + return "Your cat's name needs at least 1 letter." diff --git a/untitled/screens.py b/untitled/screens.py index ed29014..2eb3976 100644 --- a/untitled/screens.py +++ b/untitled/screens.py @@ -1,12 +1,15 @@ -from untitled import generation, ui +from untitled import generation, ui, rules def adoption(): print("Welcome to the shelter!") - choice = "Reroll" - while choice == "Reroll": - choices = generation.generate_cat_choices() - choice = ui.select( - "Please choose a cat to adopt!", - list(ui.Choice(cat[0], cat[1]) for cat in choices) + ["Reroll"], - ) + name = None + while not name: + choice = "Reroll" + while choice == "Reroll": + choices = generation.generate_cat_choices() + choice = ui.select( + "Please choose a cat to adopt:", + [ui.Choice(cat[0], cat[1]) for cat in choices] + ["Reroll"], + ) + name = ui.text("Please choose a name for your cat:") diff --git a/untitled/ui.py b/untitled/ui.py index f538ff3..ea88c47 100644 --- a/untitled/ui.py +++ b/untitled/ui.py @@ -38,3 +38,7 @@ def splash(): def select(title, options): return questionary.select(title, options).ask() + + +def text(title): + return questionary.text(title).ask()