breeding iframe functioning as intended
This commit is contained in:
parent
59fe208f5f
commit
954b2b0932
72
app.py
72
app.py
@ -132,54 +132,72 @@ def get_breeding_combinations():
|
|||||||
if not selected_monster:
|
if not selected_monster:
|
||||||
return jsonify({"error": "Invalid input"})
|
return jsonify({"error": "Invalid input"})
|
||||||
|
|
||||||
base_combinations = get_base_combinations(selected_monster)
|
# Fetch breed ID based on the selected monster as a target
|
||||||
mate_combinations = get_mate_combinations(selected_monster)
|
breed_id = get_breed_id(selected_monster)
|
||||||
|
|
||||||
return jsonify(
|
if breed_id is None:
|
||||||
{"base_combinations": base_combinations, "mate_combinations": mate_combinations}
|
return jsonify({"error": f"No breed information found for {selected_monster}"})
|
||||||
|
|
||||||
|
base_combinations, mate_combinations = get_breeding_info(breed_id)
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"breeding.html",
|
||||||
|
selected_monster={
|
||||||
|
"name": selected_monster,
|
||||||
|
"base_combinations": base_combinations,
|
||||||
|
"mate_combinations": mate_combinations,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Function to get base breeding combinations
|
def get_breed_id(target_monster):
|
||||||
def get_base_combinations(selected_monster):
|
|
||||||
cursor = g.db.cursor()
|
cursor = g.db.cursor()
|
||||||
|
|
||||||
# Fetch breed IDs based on the selected monster as a base
|
# Fetch breed ID based on the selected monster as a target
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
SELECT breeds.target
|
SELECT breeds.id
|
||||||
FROM breeds
|
FROM breeds
|
||||||
JOIN breed_requirements ON breeds.id = breed_requirements.breed_id
|
WHERE breeds.target = ?
|
||||||
WHERE breed_requirements.requirement_type = 'base'
|
""",
|
||||||
AND breed_requirements.requirement_value = ?
|
(target_monster,),
|
||||||
""",
|
|
||||||
(selected_monster,),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
base_combinations = cursor.fetchall()
|
breed_id = cursor.fetchone()
|
||||||
|
|
||||||
return [row[0] for row in base_combinations]
|
if breed_id:
|
||||||
|
return breed_id[0]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# Function to get mate breeding combinations
|
def get_breeding_info(breed_id):
|
||||||
def get_mate_combinations(selected_monster):
|
|
||||||
cursor = g.db.cursor()
|
cursor = g.db.cursor()
|
||||||
|
|
||||||
# Fetch breed IDs based on the selected monster as a mate
|
# Fetch base and mate breeding combinations based on the breed ID
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
SELECT breeds.target
|
SELECT requirement_type, requirement_value
|
||||||
FROM breeds
|
FROM breed_requirements
|
||||||
JOIN breed_requirements ON breeds.id = breed_requirements.breed_id
|
WHERE breed_id = ?
|
||||||
WHERE breed_requirements.requirement_type = 'mate'
|
""",
|
||||||
AND breed_requirements.requirement_value = ?
|
(breed_id,),
|
||||||
""",
|
|
||||||
(selected_monster,),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
mate_combinations = cursor.fetchall()
|
breeding_info = cursor.fetchall()
|
||||||
|
|
||||||
return [row[0] for row in mate_combinations]
|
base_combinations = [
|
||||||
|
value
|
||||||
|
for (requirement_type, value) in breeding_info
|
||||||
|
if requirement_type == "base"
|
||||||
|
]
|
||||||
|
mate_combinations = [
|
||||||
|
value
|
||||||
|
for (requirement_type, value) in breeding_info
|
||||||
|
if requirement_type == "mate"
|
||||||
|
]
|
||||||
|
|
||||||
|
return base_combinations, mate_combinations
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<h3 class="font-bold text-blue-500">Base Combinations</h3>
|
<h3 class="font-bold text-blue-500">Base Combinations</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for combination in selected_monster.base_combinations %}
|
{% for combination in selected_monster.base_combinations %}
|
||||||
<li>{{ combination.target }}</li>
|
<li>{{ combination }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<h3 class="font-bold text-blue-500">Mate Combinations</h3>
|
<h3 class="font-bold text-blue-500">Mate Combinations</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for combination in selected_monster.mate_combinations %}
|
{% for combination in selected_monster.mate_combinations %}
|
||||||
<li>{{ combination.target }}</li>
|
<li>{{ combination }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user