lot
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ wheels/
|
||||
untitled/saves
|
||||
.ruff_cache
|
||||
.pytest_cache
|
||||
DEBUG_MODE
|
||||
20
tests/test_generation.py
Normal file
20
tests/test_generation.py
Normal file
@@ -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
|
||||
@@ -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!...
|
||||
|
||||
@@ -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):
|
||||
|
||||
12
untitled/rules.py
Normal file
12
untitled/rules.py
Normal file
@@ -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."
|
||||
@@ -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:")
|
||||
|
||||
@@ -38,3 +38,7 @@ def splash():
|
||||
|
||||
def select(title, options):
|
||||
return questionary.select(title, options).ask()
|
||||
|
||||
|
||||
def text(title):
|
||||
return questionary.text(title).ask()
|
||||
|
||||
Reference in New Issue
Block a user