removed old code
This commit is contained in:
parent
04c1eecafa
commit
cd6fd8c6dd
3
app.py
3
app.py
@ -9,7 +9,7 @@ from src.api.get_breeding_pairs import *
|
||||
from src.api.get_breeding_usage import *
|
||||
|
||||
from src.views.serve_content import *
|
||||
from src.views.breed_info import *
|
||||
|
||||
from src.views.skills import *
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -29,7 +29,6 @@ app.register_blueprint(get_breeding_usage_bp)
|
||||
app.register_blueprint(serve_content)
|
||||
|
||||
# Register Other Views Blurprints (HTML Render Templates)
|
||||
app.register_blueprint(breed_info_bp)
|
||||
app.register_blueprint(skills_bp)
|
||||
|
||||
@app.route("/")
|
||||
|
@ -1,129 +0,0 @@
|
||||
from flask import Blueprint, render_template, g, request
|
||||
import jsonify
|
||||
|
||||
breed_info_bp = Blueprint('view_breed_info', __name__)
|
||||
|
||||
@breed_info_bp.route("/breed")
|
||||
def get_breeding_combinations():
|
||||
selected_monster = request.args.get("monster")
|
||||
if not selected_monster:
|
||||
return jsonify({"error": "Invalid input"})
|
||||
|
||||
# Fetch breed ID based on the selected monster as a target
|
||||
breed_id = get_breed_id(selected_monster)
|
||||
|
||||
if breed_id is None:
|
||||
return jsonify({"error": f"No breed information found for {selected_monster}"})
|
||||
|
||||
base_pair, mate_pair = get_breeding_pairs(breed_id)
|
||||
|
||||
# Fetch breeds in which the selected monster is used
|
||||
used_in_breeds = get_used_in_breeds(selected_monster)
|
||||
|
||||
return render_template(
|
||||
"breed.html",
|
||||
selected_monster={
|
||||
"name": selected_monster,
|
||||
"base_pair": base_pair,
|
||||
"mate_pair": mate_pair,
|
||||
},
|
||||
used_in_breeds=used_in_breeds,
|
||||
)
|
||||
|
||||
def get_used_in_breeds(target_monster):
|
||||
cursor = g.db.cursor()
|
||||
|
||||
# Fetch breed IDs where the selected monster is used as a base
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT breed_id
|
||||
FROM breed_requirements
|
||||
WHERE requirement_type = 'base'
|
||||
AND requirement_value = ?
|
||||
""",
|
||||
(target_monster,),
|
||||
)
|
||||
|
||||
base_breed_ids = [row[0] for row in cursor.fetchall()]
|
||||
|
||||
# Fetch breed IDs where the selected monster is used as a mate
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT breed_id
|
||||
FROM breed_requirements
|
||||
WHERE requirement_type = 'mate'
|
||||
AND requirement_value = ?
|
||||
""",
|
||||
(target_monster,),
|
||||
)
|
||||
|
||||
mate_breed_ids = [row[0] for row in cursor.fetchall()]
|
||||
|
||||
# Combine the results from both queries
|
||||
used_in_breed_ids = base_breed_ids + mate_breed_ids
|
||||
|
||||
# Fetch the target monsters for the obtained breed IDs
|
||||
used_in_breeds = []
|
||||
for breed_id in used_in_breed_ids:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT target
|
||||
FROM breeds
|
||||
WHERE id = ?
|
||||
""",
|
||||
(breed_id,),
|
||||
)
|
||||
target_monster = cursor.fetchone()
|
||||
if target_monster:
|
||||
used_in_breeds.append(target_monster[0])
|
||||
|
||||
return used_in_breeds
|
||||
|
||||
def get_breed_id(target_monster):
|
||||
cursor = g.db.cursor()
|
||||
|
||||
# Fetch breed ID based on the selected monster as a target
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT breeds.id
|
||||
FROM breeds
|
||||
WHERE breeds.target = ?
|
||||
""",
|
||||
(target_monster,),
|
||||
)
|
||||
|
||||
breed_id = cursor.fetchone()
|
||||
|
||||
if breed_id:
|
||||
return breed_id[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_breeding_pairs(breed_id):
|
||||
cursor = g.db.cursor()
|
||||
|
||||
# Fetch base and mate breeding combinations based on the breed ID
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT requirement_type, requirement_value
|
||||
FROM breed_requirements
|
||||
WHERE breed_id = ?
|
||||
""",
|
||||
(breed_id,),
|
||||
)
|
||||
|
||||
breeding_info = cursor.fetchall()
|
||||
|
||||
base_pair = [
|
||||
value
|
||||
for (requirement_type, value) in breeding_info
|
||||
if requirement_type == "base"
|
||||
]
|
||||
mate_pair = [
|
||||
value
|
||||
for (requirement_type, value) in breeding_info
|
||||
if requirement_type == "mate"
|
||||
]
|
||||
|
||||
return base_pair, mate_pair
|
@ -19,7 +19,6 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
|
||||
monsterDropdown.addEventListener("change", function () {
|
||||
updateIframes();
|
||||
updateMonsterStats();
|
||||
updateMonsterName();
|
||||
updateMonsterFamily();
|
||||
|
@ -1,10 +0,0 @@
|
||||
function updateIframes() {
|
||||
const selectedMonster = monsterDropdown.value;
|
||||
|
||||
// Update breedingIframe src based on the selected monster
|
||||
const breedingIframeSrc = selectedMonster
|
||||
? `/breed?monster=${selectedMonster}`
|
||||
: "about:blank";
|
||||
|
||||
breedingIframe.src = breedingIframeSrc;
|
||||
}
|
@ -57,14 +57,7 @@
|
||||
width="200"
|
||||
>
|
||||
</iframe>
|
||||
<iframe
|
||||
id="breedingIframe"
|
||||
src=""
|
||||
class="p-2 mt-4 border-2 rounded-md border-slate-400"
|
||||
height="200"
|
||||
width="272"
|
||||
>
|
||||
</iframe>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 text-center">
|
||||
|
@ -1,43 +0,0 @@
|
||||
{% extends '.layout.html' %} {% block head %}{% endblock %} {% block body %}
|
||||
<div id="breedingPairs">
|
||||
{% if selected_monster %}
|
||||
<h2 class="text-xl font-bold text-center">Breeding Pairs</h2>
|
||||
<div class="grid grid-cols-2 gap-1">
|
||||
<div class="col-span-1">
|
||||
<h3 class="text-lg font-bold">Base</h3>
|
||||
<ul>
|
||||
{% for pair in selected_monster.base_pair %}
|
||||
<li
|
||||
id="parent"
|
||||
class="text-center cursor-pointer hover:text-red-700 w-fit"
|
||||
>
|
||||
<span class="monster-name" data-name="{{ pair }}"> {{ pair }} </span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-span-1">
|
||||
<h3 class="text-lg font-bold">Mates</h3>
|
||||
<ul>
|
||||
{% for pair in selected_monster.mate_pair %}
|
||||
<li id="parent" class="cursor-pointer hover:text-red-700 w-fit">
|
||||
<span class="monster-name" data-name="{{ pair }}"> {{ pair }} </span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {% if used_in_breeds %}
|
||||
<h2 class="text-xl font-bold text-center">Used In</h2>
|
||||
<ul>
|
||||
{% for breed in used_in_breeds %}
|
||||
<li class="text-center cursor-pointer hover:text-green-700 w-fit">
|
||||
<span class="breed-name" data-name="{{ breed }}">{{ breed }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% for file in js_files %}
|
||||
<script src="{{ url_for('static', filename='js/' + file) }}"></script>
|
||||
{% endfor %} {% endblock %}
|
Loading…
Reference in New Issue
Block a user