Compare commits
2 Commits
cdfd01b053
...
13b8cd4b5e
| Author | SHA1 | Date | |
|---|---|---|---|
| 13b8cd4b5e | |||
| 47d2d7bc67 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ wheels/
|
|||||||
untitled/saves
|
untitled/saves
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
.pytest_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
|
import time
|
||||||
|
|
||||||
from untitled import content, screens, ui
|
from untitled import content, screens, ui
|
||||||
@@ -5,13 +6,14 @@ from untitled import content, screens, ui
|
|||||||
|
|
||||||
class App:
|
class App:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.debug = os.path.exists("DEBUG_MODE")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Intro
|
# Intro
|
||||||
ui.clear()
|
if not self.debug:
|
||||||
time.sleep(1)
|
ui.clear()
|
||||||
ui.splash()
|
time.sleep(1)
|
||||||
|
ui.splash()
|
||||||
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
while True: # forEVER!... forEVER!... forEVER!... forEVER!...
|
while True: # forEVER!... forEVER!... forEVER!... forEVER!...
|
||||||
|
|||||||
@@ -3,19 +3,24 @@ import random
|
|||||||
from untitled import content
|
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):
|
def generate_cat_choice(personality=None):
|
||||||
size = random.choice(content.CAT_SIZES)
|
size = random.choice(content.CAT_SIZES)
|
||||||
color = random.choice(content.CAT_COLORS)
|
color = random.choice(content.CAT_COLORS)
|
||||||
eyes = random.choice(content.CAT_EYE_COLORS)
|
eyes = random.choice(content.CAT_EYE_COLORS)
|
||||||
personality = personality or random.choice(content.CAT_PERSONALITIES)
|
personality = personality or random.choice(content.CAT_PERSONALITIES)
|
||||||
article = "An" if size[0] in "aeiou" else "A"
|
traits = {
|
||||||
description = f"{article} {size} {color} kitten with {eyes} eyes who {personality}"
|
|
||||||
return description, {
|
|
||||||
"size": size,
|
"size": size,
|
||||||
"color": color,
|
"color": color,
|
||||||
"eyes": eyes,
|
"eyes": eyes,
|
||||||
"personality": personality,
|
"personality": personality,
|
||||||
}
|
}
|
||||||
|
return generate_trait_sentence(traits), traits
|
||||||
|
|
||||||
|
|
||||||
def generate_cat_choices(n=5):
|
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."
|
||||||
@@ -3,10 +3,13 @@ from untitled import generation, ui
|
|||||||
|
|
||||||
def adoption():
|
def adoption():
|
||||||
print("Welcome to the shelter!")
|
print("Welcome to the shelter!")
|
||||||
choice = "Reroll"
|
name = None
|
||||||
while choice == "Reroll":
|
while not name:
|
||||||
choices = generation.generate_cat_choices()
|
choice = "Reroll"
|
||||||
choice = ui.select(
|
while choice == "Reroll":
|
||||||
"Please choose a cat to adopt!",
|
choices = generation.generate_cat_choices()
|
||||||
list(ui.Choice(cat[0], cat[1]) for cat in choices) + ["Reroll"],
|
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):
|
def select(title, options):
|
||||||
return questionary.select(title, options).ask()
|
return questionary.select(title, options).ask()
|
||||||
|
|
||||||
|
|
||||||
|
def text(title):
|
||||||
|
return questionary.text(title).ask()
|
||||||
|
|||||||
Reference in New Issue
Block a user