refactored monster information to stats
This commit is contained in:
parent
e34640cddc
commit
991f726fa1
38
app.py
38
app.py
@ -62,10 +62,10 @@ def get_monsters():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/monster/<monster_name>")
|
@app.route("/monster/<monster_name>")
|
||||||
def monster_info(monster_name):
|
def monster_stats(monster_name):
|
||||||
cursor = g.db.cursor()
|
cursor = g.db.cursor()
|
||||||
|
|
||||||
# Retrieve monster information from the database based on name
|
# Retrieve monster stats from the database based on name
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
@ -81,39 +81,39 @@ def monster_info(monster_name):
|
|||||||
(monster_name,),
|
(monster_name,),
|
||||||
)
|
)
|
||||||
|
|
||||||
monster_info = cursor.fetchone()
|
monster_stats = cursor.fetchone()
|
||||||
|
|
||||||
if monster_info is None:
|
if monster_stats is None:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
# Retrieve skills for the monster
|
# Retrieve skills for the monster
|
||||||
cursor.execute("SELECT skill FROM skills WHERE monster_id = ?", (monster_info[0],))
|
cursor.execute("SELECT skill FROM skills WHERE monster_id = ?", (monster_stats[0],))
|
||||||
skills = [row[0] for row in cursor.fetchall()]
|
skills = [row[0] for row in cursor.fetchall()]
|
||||||
|
|
||||||
# Retrieve spawn locations for the monster
|
# Retrieve spawn locations for the monster
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"SELECT map, description FROM spawn_locations WHERE monster_id = ?",
|
"SELECT map, description FROM spawn_locations WHERE monster_id = ?",
|
||||||
(monster_info[0],),
|
(monster_stats[0],),
|
||||||
)
|
)
|
||||||
spawn_locations = [
|
spawn_locations = [
|
||||||
{"map": row[0], "description": row[1]} for row in cursor.fetchall()
|
{"map": row[0], "description": row[1]} for row in cursor.fetchall()
|
||||||
]
|
]
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"monsters.html",
|
"stats.html",
|
||||||
monster={
|
monster={
|
||||||
"id": monster_info[0],
|
"id": monster_stats[0],
|
||||||
"name": monster_info[1],
|
"name": monster_stats[1],
|
||||||
"family": monster_info[2],
|
"family": monster_stats[2],
|
||||||
"in_story": "Yes" if monster_info[3] else "No",
|
"in_story": "Yes" if monster_stats[3] else "No",
|
||||||
"agl": monster_info[4],
|
"agl": monster_stats[4],
|
||||||
"int": monster_info[5],
|
"int": monster_stats[5],
|
||||||
"maxlvl": monster_info[6],
|
"maxlvl": monster_stats[6],
|
||||||
"atk": monster_info[7],
|
"atk": monster_stats[7],
|
||||||
"mp": monster_info[8],
|
"mp": monster_stats[8],
|
||||||
"exp": monster_info[9],
|
"exp": monster_stats[9],
|
||||||
"hp": monster_info[10],
|
"hp": monster_stats[10],
|
||||||
"def": monster_info[11],
|
"def": monster_stats[11],
|
||||||
"skills": skills,
|
"skills": skills,
|
||||||
"spawn_locations": spawn_locations,
|
"spawn_locations": spawn_locations,
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const familyDropdown = document.getElementById("familyDropdown");
|
const familyDropdown = document.getElementById("familyDropdown");
|
||||||
const monsterDropdown = document.getElementById("monsterDropdown");
|
const monsterDropdown = document.getElementById("monsterDropdown");
|
||||||
|
// Implementing Family Icon Grid in place of family dropdown
|
||||||
|
//const familyGrid = document.getElementById("familyGrid")
|
||||||
|
|
||||||
// Initialize dropdowns and iframes
|
// Initialize dropdowns
|
||||||
updateMonstersDropdown();
|
updateMonstersDropdown();
|
||||||
|
// Initialize Family Grid();
|
||||||
|
// populateFamilyGrid();
|
||||||
|
|
||||||
// Fetch families data from the server
|
// Fetch families data from the server and populate families dropdown
|
||||||
fetch("/get_families")
|
fetch("/get_families")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -13,6 +17,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
})
|
})
|
||||||
.catch(error => console.error("Error fetching families:", error));
|
.catch(error => console.error("Error fetching families:", error));
|
||||||
|
|
||||||
|
// Listeners for Dropdown Changes
|
||||||
familyDropdown.addEventListener("change", function () {
|
familyDropdown.addEventListener("change", function () {
|
||||||
updateMonstersDropdown();
|
updateMonstersDropdown();
|
||||||
});
|
});
|
||||||
@ -21,5 +26,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
updateIframes();
|
updateIframes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listener for a click on the one of the family icons
|
||||||
|
//familyGrid.addEventListener("on click", function() {
|
||||||
|
// updateMonsterGrid(); // Need a function for this too...
|
||||||
|
//});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
<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>Monster Information</title>
|
<title>Monster Stats</title>
|
||||||
<link rel="stylesheet" href="../static/style/output.css">
|
<link rel="stylesheet" href="../static/style/output.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="p-2 font-mono text-white bg-slate-700">
|
<body class="p-2 font-mono text-white bg-slate-700">
|
||||||
<h1>Monster Information</h1>
|
|
||||||
<div>
|
<div>
|
||||||
<h2>{{ monster.name }}</h2>
|
<h2>{{ monster.name }}</h2>
|
||||||
<p><strong>Family:</strong> {{ monster.family }}</p>
|
<p><strong>Family:</strong> {{ monster.family }}</p>
|
Loading…
Reference in New Issue
Block a user