refactored breed combinations to pairs

This commit is contained in:
0ceanSlim 2024-02-02 12:00:10 -05:00
parent 0c73c2b88c
commit 4b3c76d1a7
2 changed files with 15 additions and 16 deletions

14
app.py
View File

@ -134,14 +134,14 @@ def get_breeding_combinations():
if breed_id is None: if breed_id is None:
return jsonify({"error": f"No breed information found for {selected_monster}"}) return jsonify({"error": f"No breed information found for {selected_monster}"})
base_combinations, mate_combinations = get_breeding_info(breed_id) base_pair, mate_pair = get_breeding_pairs(breed_id)
return render_template( return render_template(
"breeds.html", "breeds.html",
selected_monster={ selected_monster={
"name": selected_monster, "name": selected_monster,
"base_combinations": base_combinations, "base_pair": base_pair,
"mate_combinations": mate_combinations, "mate_pair": mate_pair,
}, },
) )
@ -167,7 +167,7 @@ def get_breed_id(target_monster):
return None return None
def get_breeding_info(breed_id): def get_breeding_pairs(breed_id):
cursor = g.db.cursor() cursor = g.db.cursor()
# Fetch base and mate breeding combinations based on the breed ID # Fetch base and mate breeding combinations based on the breed ID
@ -182,18 +182,18 @@ def get_breeding_info(breed_id):
breeding_info = cursor.fetchall() breeding_info = cursor.fetchall()
base_combinations = [ base_pair = [
value value
for (requirement_type, value) in breeding_info for (requirement_type, value) in breeding_info
if requirement_type == "base" if requirement_type == "base"
] ]
mate_combinations = [ mate_pair = [
value value
for (requirement_type, value) in breeding_info for (requirement_type, value) in breeding_info
if requirement_type == "mate" if requirement_type == "mate"
] ]
return base_combinations, mate_combinations return base_pair, mate_pair
@app.route("/footer") @app.route("/footer")

View File

@ -5,22 +5,22 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Breeding Combinations</title> <title>Breeding Pairs</title>
<link rel="stylesheet" href="../static/style/output.css" /> <link rel="stylesheet" href="../static/style/output.css" />
</head> </head>
<body class="font-mono text-white bg-slate-700"> <body class="font-mono text-white bg-slate-700">
<div id="breedingCombinations"> <div id="breedingPairs">
{% if selected_monster %} {% if selected_monster %}
<h2 class="text-xl font-bold text-center">Breeding Pairs</h2> <h2 class="text-xl font-bold text-center">Breeding Pairs</h2>
<div class="grid grid-cols-2 gap-1"> <div class="grid grid-cols-2 gap-1">
<div class="col-span-1"> <div class="col-span-1">
<h3 class="text-lg font-bold">Base</h3> <h3 class="text-lg font-bold">Base</h3>
<ul> <ul>
{% for combination in selected_monster.base_combinations %} {% for pair in selected_monster.base_pair %}
<li id="parent" class="text-center cursor-pointer hover:text-red-700 w-fit"> <li id="parent" class="text-center cursor-pointer hover:text-red-700 w-fit">
<!-- Add a class to make the monster name clickable --> <!-- Add a class to make the monster name clickable -->
<span class="monster-name" data-name="{{ combination }}" <span class="monster-name" data-name="{{ pair }}"
>{{ combination }}</span >{{ pair }}</span
> >
</li> </li>
{% endfor %} {% endfor %}
@ -29,11 +29,11 @@
<div class="col-span-1"> <div class="col-span-1">
<h3 class="text-lg font-bold">Mates</h3> <h3 class="text-lg font-bold">Mates</h3>
<ul> <ul>
{% for combination in selected_monster.mate_combinations %} {% for pair in selected_monster.mate_pair %}
<li id="parent" class="cursor-pointer hover:text-red-700 w-fit"> <li id="parent" class="cursor-pointer hover:text-red-700 w-fit">
<!-- Add a class to make the monster name clickable --> <!-- Add a class to make the monster name clickable -->
<span class="monster-name" data-name="{{ combination }}" <span class="monster-name" data-name="{{ pair }}"
>{{ combination }}</span >{{ pair }}</span
> >
</li> </li>
{% endfor %} {% endfor %}
@ -42,6 +42,5 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
</body> </body>
</html> </html>