Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ cache
.env
*.sqlite3
art/dist/
__pycache__
133 changes: 129 additions & 4 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
from functools import wraps

from app.utils.species_lookup import load_species_data
from app.utils.calculate_heights import calculate_height_offset, convert_to_inches
from app.utils.calculate_heights import (
calculate_height_offset,
convert_to_inches,
inches_to_feet_inches,
)
from app.utils.parse_data import (
extract_characters,
filter_valid_characters,
Expand All @@ -34,6 +38,7 @@
from app.utils.stats import StatsManager
from app.utils.generate_image import render_image
from app.utils.character import Character
from app.utils.taur_calculator import calculate_taur

app = Flask(__name__)
app.secret_key = os.urandom(24)
Expand Down Expand Up @@ -300,13 +305,133 @@ def add_preset():
return redirect(f"/?characters={characters_query}{settings_query}")


@app.route("/taur")
@app.route("/taur", methods=["GET", "POST"])
def taur():
"""
Base route for volnar's sub-page!
Taur calculator!

Collaboration with Volnar <3
"""
# Filter out some ones we dont want to show/dont have data
filtered_species = [
s
for s in species_list
if s not in ["taur_(generic)", "preset_species", "rexouium"]
]

# Load species data for auto-population
species_data_map = {}
for species_name in filtered_species:
try:
data = load_species_data(species_name)
# Extract species_length, species_tail_length, species_weight from male section
# and get a default species_height from the first data point
if "male" in data:
male_data = data["male"]
species_data_map[species_name] = {
"species_length": male_data.get("species_length", 0),
"species_tail_length": male_data.get("species_tail_length", 0),
"species_weight": male_data.get("species_weight", 0),
"species_height": (
male_data.get("data", [{}])[0].get("height", 0)
if male_data.get("data")
else 0
),
}
except Exception as e:
logging.warning(f"Failed to load species data for {species_name}: {e}")
species_data_map[species_name] = {
"species_length": 0,
"species_tail_length": 0,
"species_weight": 0,
"species_height": 0,
}

if request.method == "POST":
# POST when handling a form submission - redirect with URL parameters
params = {}
for key in [
"name",
"measurement_type",
"anthro_height",
"species_height",
"species_length",
"species_tail_length",
"taur_full_height",
"species_weight",
"taur_length",
]:
value = request.form.get(key, "")
if value:
params[key] = value

query_string = "&".join([f"{k}={v}" for k, v in params.items()])
return redirect(f"/taur?{query_string}")

# Handle GET with calculation parameters
calculation_result = None
cleaned_calculation_result = {}
if request.args.get("anthro_height"):
try:
anthro_height = float(request.args.get("anthro_height", 0))
species_height = float(request.args.get("species_height", 0))
species_length = float(request.args.get("species_length", 0))
species_tail_length = float(request.args.get("species_tail_length", 0))
taur_full_height = float(request.args.get("taur_full_height", 0))
species_weight = float(request.args.get("species_weight", 0))
taur_length = request.args.get("taur_length")
measurement_type = request.args.get("measurement_type", "vitruvian")

taur_length_float = float(taur_length) if taur_length else None

calculation_result = calculate_taur(
anthro_height=anthro_height,
species_height=species_height,
species_length=species_length,
species_tail_length=species_tail_length,
taur_full_height=taur_full_height,
species_weight=species_weight,
taur_length=taur_length_float,
measurement_type=measurement_type,
)

return render_template("taur.html")
cleaned_calculation_result["AR"] = (
f"{inches_to_feet_inches(calculation_result['AR'])} (Anthropic Ratio)"
)
cleaned_calculation_result["TH"] = (
f"{inches_to_feet_inches(calculation_result['TH'])} (Taur Height)"
)
cleaned_calculation_result["TFH"] = (
f"{inches_to_feet_inches(calculation_result['TFH'])} (Taur Full Height)"
)
cleaned_calculation_result["TL"] = (
f"{inches_to_feet_inches(calculation_result['TL'])} (Taur Length)"
)
cleaned_calculation_result["TT"] = (
f"{inches_to_feet_inches(calculation_result['TT'])} (Taur Tail Length)"
)
cleaned_calculation_result["TTo"] = (
f"{inches_to_feet_inches(calculation_result['TTo'])} (Taur Torso Length)"
)
cleaned_calculation_result["THe"] = (
f"{inches_to_feet_inches(calculation_result['THe'])} (Taur Head Length)"
)
cleaned_calculation_result["TW"] = (
f"{calculation_result['TW']:.2f} lbs (Taur Weight)"
)

except (ValueError, TypeError) as e:
logging.warning(f"Taur calculation error: {e}")
calculation_result = None
cleaned_calculation_result = None

return render_template(
"taur.html",
species=filtered_species,
species_data=species_data_map,
calculation_result=cleaned_calculation_result,
form_data=dict(request.args) if request.args else None,
)


# For WSGI
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/african_buffalo.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Chrissy/missing.png"
ears_offset: 0
species_length: 96
species_tail_length: 30
species_weight: 1500 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 60
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Chrissy/missing.png"
ears_offset: 0
species_length: 96
species_tail_length: 30
species_weight: 1500 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 54
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/arctic_fox.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Chrissy/randal.png"
ears_offset: 4
species_length: 28
species_tail_length: 16
species_weight: 12 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 22 # 22"
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Chrissy/vixi.png"
ears_offset: 4
species_length: 28
species_tail_length: 16
species_weight: 12 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 20 # 22"
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/canine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ male:
image: "Hunner/Hieght_Ref_Maxene_for_Vixi.png"
ears_offset: 3
color: "870716"
species_length: 36
species_tail_length: 18
species_weight: 80 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 28
Expand All @@ -12,6 +15,9 @@ female:
image: "Hunner/Hieght_Ref_Ky-Li_for_Vixi.png"
ears_offset: 9
color: "add6ed"
species_length: 36
species_tail_length: 18
species_weight: 80 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 26
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/equine.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Placeholder/f_equine.png"
ears_offset: 0
species_length: 72
species_tail_length: 24
species_weight: 1000 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 72
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Placeholder/f_equine.png"
ears_offset: 0
species_length: 72
species_tail_length: 24
species_weight: 1000 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 70
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/feline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ male:
image: "Rhainbowmetall/Felid_Sketch_Male.png"
ears_offset: 9
color: "282b1d"
species_length: 30
species_tail_length: 12
species_weight: 15 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 14
Expand All @@ -12,6 +15,9 @@ female:
image: "Rhainbowmetall/Felid_Sketch_Female.png"
ears_offset: 9
color: "1d751d"
species_length: 30
species_tail_length: 12
species_weight: 15 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 11
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/fennec_fox.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Chrissy/m_fennec.png"
ears_offset: 10
species_length: 20
species_tail_length: 15
species_weight: 3 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 11
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Chrissy/missing.png"
ears_offset: 0
species_length: 20
species_tail_length: 14
species_weight: 3 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 10
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/giraffe.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Placeholder/m_giraffe.png"
ears_offset: 0
species_length: 120
species_tail_length: 36
species_weight: 3000 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 220
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Placeholder/m_giraffe.png"
ears_offset: 0
species_length: 120
species_tail_length: 36
species_weight: 2600 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 200
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/mouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ male:
image: "Hunner/Size_Refs_Mouse_for_Vixi (male).png"
ears_offset: 6
color: "007516"
species_length: 4
species_tail_length: 3
species_weight: 0.5 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 3
Expand All @@ -12,6 +15,9 @@ female:
image: "Hunner/Size_Refs_Mouse_for_Vixi (female).png"
ears_offset: 7
color: "7900ad"
species_length: 4
species_tail_length: 3
species_weight: 0.5 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 2.5
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/red_fox.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
male:
image: "Chrissy/randal.png"
ears_offset: 4
species_length: 28
species_tail_length: 16
species_weight: 12 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 17
Expand All @@ -10,6 +13,9 @@ male:
female:
image: "Chrissy/sinopa.png"
ears_offset: 1.5
species_length: 28
species_tail_length: 16
species_weight: 12 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 15
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/saber-toothed_tiger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ male:
image: "Hunner/Hieght_Ref_NO_BAK_Tirga_for_Tirga.png"
ears_offset: 3
color: "00730b"
species_length: 60
species_tail_length: 30
species_weight: 400 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 44
Expand All @@ -12,6 +15,9 @@ female:
image: "Hunner/Hieght_Ref_NO_BAK_Tirga_for_Tirga.png"
ears_offset: 3
color: "b216f0"
species_length: 60
species_tail_length: 30
species_weight: 400 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 46
Expand Down
6 changes: 6 additions & 0 deletions app/species_data/shark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ male:
image: "Mori/m_shark.png"
ears_offset: 3
# color: "311b9e"
species_length: 72
species_tail_length: 36
species_weight: 500 # Pounds
data:
- anthro_size: 76 # 6'4"
height: 90
Expand All @@ -13,6 +16,9 @@ female:
image: "Mori/f_shark.png"
ears_offset: 3
# color: "664ce6"
species_length: 72
species_tail_length: 36
species_weight: 500 # Pounds
data:
- anthro_size: 74 # 6'2"
height: 92
Expand Down
Loading
Loading