Compare commits

..

No commits in common. "9f4d56b62777b11355df0e371bc5cb12caabb52c" and "e34640cddcb37cf34f22f123443ca7819b244b85" have entirely different histories.

7 changed files with 46 additions and 72 deletions

57
app.py
View File

@ -62,10 +62,10 @@ def get_monsters():
@app.route("/monster/<monster_name>")
def monster_stats(monster_name):
def monster_info(monster_name):
cursor = g.db.cursor()
# Retrieve monster stats from the database based on name
# Retrieve monster information from the database based on name
cursor.execute(
"""
SELECT
@ -81,39 +81,39 @@ def monster_stats(monster_name):
(monster_name,),
)
monster_stats = cursor.fetchone()
monster_info = cursor.fetchone()
if monster_stats is None:
if monster_info is None:
abort(404)
# Retrieve skills for the monster
cursor.execute("SELECT skill FROM skills WHERE monster_id = ?", (monster_stats[0],))
cursor.execute("SELECT skill FROM skills WHERE monster_id = ?", (monster_info[0],))
skills = [row[0] for row in cursor.fetchall()]
# Retrieve spawn locations for the monster
cursor.execute(
"SELECT map, description FROM spawn_locations WHERE monster_id = ?",
(monster_stats[0],),
(monster_info[0],),
)
spawn_locations = [
{"map": row[0], "description": row[1]} for row in cursor.fetchall()
]
return render_template(
"stats.html",
"monsters.html",
monster={
"id": monster_stats[0],
"name": monster_stats[1],
"family": monster_stats[2],
"in_story": "Yes" if monster_stats[3] else "No",
"agl": monster_stats[4],
"int": monster_stats[5],
"maxlvl": monster_stats[6],
"atk": monster_stats[7],
"mp": monster_stats[8],
"exp": monster_stats[9],
"hp": monster_stats[10],
"def": monster_stats[11],
"id": monster_info[0],
"name": monster_info[1],
"family": monster_info[2],
"in_story": "Yes" if monster_info[3] else "No",
"agl": monster_info[4],
"int": monster_info[5],
"maxlvl": monster_info[6],
"atk": monster_info[7],
"mp": monster_info[8],
"exp": monster_info[9],
"hp": monster_info[10],
"def": monster_info[11],
"skills": skills,
"spawn_locations": spawn_locations,
},
@ -121,9 +121,8 @@ def monster_stats(monster_name):
# Add this route for fetching breeding combinations
@app.route("/breeds")
@app.route("/get_breeding_combinations")
def get_breeding_combinations():
selected_monster = request.args.get("monster")
if not selected_monster:
return jsonify({"error": "Invalid input"})
@ -134,14 +133,14 @@ def get_breeding_combinations():
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)
base_combinations, mate_combinations = get_breeding_info(breed_id)
return render_template(
"breeds.html",
"breeding.html",
selected_monster={
"name": selected_monster,
"base_pair": base_pair,
"mate_pair": mate_pair,
"base_combinations": base_combinations,
"mate_combinations": mate_combinations,
},
)
@ -167,7 +166,7 @@ def get_breed_id(target_monster):
return None
def get_breeding_pairs(breed_id):
def get_breeding_info(breed_id):
cursor = g.db.cursor()
# Fetch base and mate breeding combinations based on the breed ID
@ -182,18 +181,18 @@ def get_breeding_pairs(breed_id):
breeding_info = cursor.fetchall()
base_pair = [
base_combinations = [
value
for (requirement_type, value) in breeding_info
if requirement_type == "base"
]
mate_pair = [
mate_combinations = [
value
for (requirement_type, value) in breeding_info
if requirement_type == "mate"
]
return base_pair, mate_pair
return base_combinations, mate_combinations
@app.route("/footer")

View File

@ -1,17 +1,11 @@
document.addEventListener("DOMContentLoaded", function () {
const familyDropdown = document.getElementById("familyDropdown");
const monsterDropdown = document.getElementById("monsterDropdown");
//const parent = document.getElementById("parent")
// Implementing Family Icon Grid in place of family dropdown
//const familyGrid = document.getElementById("familyGrid")
// Initialize dropdowns and iframes
updateMonstersDropdown();
// Initialize dropdowns
updateMonstersDropdownByFamily();
// Initialize Family Grid();
// populateFamilyGrid();
// Fetch families data from the server and populate families dropdown
// Fetch families data from the server
fetch("/get_families")
.then(response => response.json())
.then(data => {
@ -19,24 +13,13 @@ document.addEventListener("DOMContentLoaded", function () {
})
.catch(error => console.error("Error fetching families:", error));
// Listeners for Dropdown Changes
familyDropdown.addEventListener("change", function () {
updateMonstersDropdownByFamily();
updateMonstersDropdown();
});
monsterDropdown.addEventListener("change", function () {
updateIframes();
});
// Listener for a click on the one of the family icons
//familyGrid.addEventListener("click", function() {
// updateMonsterGrid(); // Need a function for this too...
//});
// Listener for a click on a breeding parent
//parent.addEventListener("click", function() {
// updateMonstersDropdownBySelected();
// updateIFrames();
//});
});

View File

@ -13,7 +13,7 @@ function updateIframes() {
// Update breedingIframe src based on the selected monster
const breedingIframeSrc = selectedMonster
? `/breeds?monster=${selectedMonster}`
? `/get_breeding_combinations?monster=${selectedMonster}`
: "about:blank";
breedingIframe.src = breedingIframeSrc;

View File

@ -1,4 +1,4 @@
function updateMonstersDropdownByFamily() {
function updateMonstersDropdown() {
const selectedFamily = familyDropdown.value;
// Fetch monsters data from the server based on the selected family

View File

@ -1,9 +0,0 @@
//function updateMonstersDropdownBySelected() {
// const selectedMonster = parent.value;
//
// // Fetch monsters data from the server based on the selected monster
// fetch(`/monster/${selectedMonster}`)
// .then(response => response.json())
// .then(data => populateDropdown(monsterDropdown, data))
// .catch(error => console.error("Error fetching monsters:", error));
//}

View File

@ -5,22 +5,22 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Breeding Pairs</title>
<title>Breeding Combinations</title>
<link rel="stylesheet" href="../static/style/output.css" />
</head>
<body class="font-mono text-white bg-slate-700">
<div id="breedingPairs">
<div id="breedingCombinations">
{% 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">
{% for combination in selected_monster.base_combinations %}
<li class="text-center cursor-pointer hover:text-red-700 w-fit">
<!-- Add a class to make the monster name clickable -->
<span class="monster-name" data-name="{{ pair }}"
>{{ pair }}</span
<span class="monster-name" data-name="{{ combination }}"
>{{ combination }}</span
>
</li>
{% endfor %}
@ -29,11 +29,11 @@
<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">
{% for combination in selected_monster.mate_combinations %}
<li class="cursor-pointer hover:text-red-700 w-fit">
<!-- Add a class to make the monster name clickable -->
<span class="monster-name" data-name="{{ pair }}"
>{{ pair }}</span
<span class="monster-name" data-name="{{ combination }}"
>{{ combination }}</span
>
</li>
{% endfor %}

View File

@ -3,10 +3,11 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Monster Stats</title>
<title>Monster Information</title>
<link rel="stylesheet" href="../static/style/output.css">
</head>
<body class="p-2 font-mono text-white bg-slate-700">
<h1>Monster Information</h1>
<div>
<h2>{{ monster.name }}</h2>
<p><strong>Family:</strong> {{ monster.family }}</p>