Add Loadout Planner and Quest Trees templates
- Created loadout.html for a comprehensive loadout planner, allowing users to filter and view gear options across various categories including guns, armor, helmets, headwear, backpacks, and rigs. - Implemented a build builder feature to calculate total loadout weight and save builds. - Added quests.html to display quest trees with trader dependencies, filtering options, and quest completion tracking.
This commit is contained in:
358
app.py
358
app.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template, request, redirect, url_for
|
from flask import Flask, render_template, request, redirect, url_for, jsonify
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -194,6 +194,85 @@ def rate_all():
|
|||||||
return redirect(base_url)
|
return redirect(base_url)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/quests")
|
||||||
|
def quests():
|
||||||
|
conn = get_db()
|
||||||
|
only_collector = request.args.get("collector") == "1"
|
||||||
|
|
||||||
|
# All quests + done state
|
||||||
|
all_quests = conn.execute("""
|
||||||
|
SELECT q.id, q.name, q.trader, q.wiki_link,
|
||||||
|
COALESCE(qp.done, 0) AS done
|
||||||
|
FROM quests q
|
||||||
|
LEFT JOIN quest_progress qp ON q.id = qp.quest_id
|
||||||
|
ORDER BY q.trader, q.name
|
||||||
|
""").fetchall()
|
||||||
|
|
||||||
|
# All dependency edges
|
||||||
|
all_deps = conn.execute("SELECT quest_id, depends_on FROM quest_deps").fetchall()
|
||||||
|
|
||||||
|
# Collector prereq set
|
||||||
|
collector_row = conn.execute("SELECT id FROM quests WHERE name = 'Collector'").fetchone()
|
||||||
|
collector_prereqs = set()
|
||||||
|
if collector_row:
|
||||||
|
rows = conn.execute("""
|
||||||
|
WITH RECURSIVE deps(quest_id) AS (
|
||||||
|
SELECT depends_on FROM quest_deps WHERE quest_id = ?
|
||||||
|
UNION
|
||||||
|
SELECT qd.depends_on FROM quest_deps qd
|
||||||
|
JOIN deps d ON qd.quest_id = d.quest_id
|
||||||
|
)
|
||||||
|
SELECT quest_id FROM deps
|
||||||
|
""", (collector_row["id"],)).fetchall()
|
||||||
|
collector_prereqs = {r[0] for r in rows}
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
# Build lookup structures
|
||||||
|
quest_by_id = {q["id"]: q for q in all_quests}
|
||||||
|
# children[parent_id] = [child_id, ...] (child depends_on parent)
|
||||||
|
children = {}
|
||||||
|
parents = {}
|
||||||
|
for dep in all_deps:
|
||||||
|
child, parent = dep["quest_id"], dep["depends_on"]
|
||||||
|
children.setdefault(parent, []).append(child)
|
||||||
|
parents.setdefault(child, []).append(parent)
|
||||||
|
# Sort each child list by quest name
|
||||||
|
for parent_id in children:
|
||||||
|
children[parent_id].sort(key=lambda i: quest_by_id[i]["name"] if i in quest_by_id else "")
|
||||||
|
|
||||||
|
# Filter to collector-only if requested
|
||||||
|
if only_collector:
|
||||||
|
visible = collector_prereqs | {collector_row["id"]}
|
||||||
|
else:
|
||||||
|
visible = set(quest_by_id.keys())
|
||||||
|
|
||||||
|
# Root quests: in visible set and have no parents also in visible set
|
||||||
|
roots = [
|
||||||
|
qid for qid in visible
|
||||||
|
if not any(p in visible for p in parents.get(qid, []))
|
||||||
|
]
|
||||||
|
|
||||||
|
# Group roots by trader, sorted
|
||||||
|
trader_roots = {}
|
||||||
|
for qid in sorted(roots, key=lambda i: (quest_by_id[i]["trader"], quest_by_id[i]["name"])):
|
||||||
|
t = quest_by_id[qid]["trader"]
|
||||||
|
trader_roots.setdefault(t, []).append(qid)
|
||||||
|
|
||||||
|
traders = sorted(trader_roots.keys())
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"quests.html",
|
||||||
|
quest_by_id=quest_by_id,
|
||||||
|
children=children,
|
||||||
|
trader_roots=trader_roots,
|
||||||
|
traders=traders,
|
||||||
|
visible=visible,
|
||||||
|
collector_prereqs=collector_prereqs,
|
||||||
|
only_collector=only_collector,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/collector")
|
@app.route("/collector")
|
||||||
def collector():
|
def collector():
|
||||||
conn = get_db()
|
conn = get_db()
|
||||||
@@ -205,7 +284,8 @@ def collector():
|
|||||||
conn.close()
|
conn.close()
|
||||||
return "Run import_quests.py first to populate quest data.", 503
|
return "Run import_quests.py first to populate quest data.", 503
|
||||||
|
|
||||||
# Recursive CTE to get all transitive prerequisites
|
# Recursive CTE: all transitive prerequisites, then keep only leaves
|
||||||
|
# (quests that are not themselves a dependency of another prereq)
|
||||||
prereqs = conn.execute("""
|
prereqs = conn.execute("""
|
||||||
WITH RECURSIVE deps(quest_id) AS (
|
WITH RECURSIVE deps(quest_id) AS (
|
||||||
SELECT depends_on FROM quest_deps WHERE quest_id = ?
|
SELECT depends_on FROM quest_deps WHERE quest_id = ?
|
||||||
@@ -218,6 +298,12 @@ def collector():
|
|||||||
FROM quests q
|
FROM quests q
|
||||||
JOIN deps d ON q.id = d.quest_id
|
JOIN deps d ON q.id = d.quest_id
|
||||||
LEFT JOIN quest_progress qp ON q.id = qp.quest_id
|
LEFT JOIN quest_progress qp ON q.id = qp.quest_id
|
||||||
|
WHERE q.id NOT IN (
|
||||||
|
SELECT qd2.depends_on
|
||||||
|
FROM quest_deps qd2
|
||||||
|
WHERE qd2.quest_id IN (SELECT quest_id FROM deps)
|
||||||
|
AND qd2.depends_on IN (SELECT quest_id FROM deps)
|
||||||
|
)
|
||||||
ORDER BY q.trader, q.name
|
ORDER BY q.trader, q.name
|
||||||
""", (collector["id"],)).fetchall()
|
""", (collector["id"],)).fetchall()
|
||||||
|
|
||||||
@@ -238,7 +324,273 @@ def collector_toggle():
|
|||||||
""", (quest_id, done))
|
""", (quest_id, done))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return redirect(url_for("collector"))
|
return jsonify({"quest_id": quest_id, "done": done})
|
||||||
|
|
||||||
|
|
||||||
|
# --- Loadout planner helpers ---
|
||||||
|
|
||||||
|
# Known user-facing slot filters: (label, slot_nameid)
|
||||||
|
LOADOUT_SLOT_FILTERS = [
|
||||||
|
("Suppressor", "mod_muzzle"),
|
||||||
|
("Scope", "mod_scope"),
|
||||||
|
("Flashlight", "mod_tactical"),
|
||||||
|
("Stock", "mod_stock"),
|
||||||
|
("Foregrip", "mod_foregrip"),
|
||||||
|
]
|
||||||
|
|
||||||
|
def _sort_col(sort):
|
||||||
|
return {
|
||||||
|
"weight_asc": "weight_kg ASC NULLS LAST",
|
||||||
|
"weight_desc": "weight_kg DESC NULLS LAST",
|
||||||
|
"name_asc": "name ASC",
|
||||||
|
"name_desc": "name DESC",
|
||||||
|
"class_desc": "armor_class DESC NULLS LAST, weight_kg ASC NULLS LAST",
|
||||||
|
"class_asc": "armor_class ASC NULLS LAST, weight_kg ASC NULLS LAST",
|
||||||
|
"capacity_desc": "capacity DESC NULLS LAST, weight_kg ASC NULLS LAST",
|
||||||
|
"capacity_asc": "capacity ASC NULLS LAST, weight_kg ASC NULLS LAST",
|
||||||
|
}.get(sort, "weight_kg ASC NULLS LAST")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/loadout")
|
||||||
|
def loadout():
|
||||||
|
conn = get_db()
|
||||||
|
tab = request.args.get("tab", "guns")
|
||||||
|
sort = request.args.get("sort", "weight_asc")
|
||||||
|
|
||||||
|
guns = armor = helmets = headwear = backpacks = rigs = []
|
||||||
|
builder_guns = builder_armor = builder_helmets = builder_rigs = builder_backpacks = []
|
||||||
|
requires = request.args.getlist("requires") # list of slot_nameids that must exist
|
||||||
|
min_class = request.args.get("min_class", 0, type=int)
|
||||||
|
min_capacity = request.args.get("min_capacity", 0, type=int)
|
||||||
|
|
||||||
|
sort_frag = _sort_col(sort)
|
||||||
|
|
||||||
|
if tab == "guns":
|
||||||
|
if requires:
|
||||||
|
placeholders = ",".join("?" * len(requires))
|
||||||
|
# Gun must have ALL required slots; compute lightest build weight
|
||||||
|
guns = conn.execute(f"""
|
||||||
|
SELECT g.*,
|
||||||
|
(g.weight_kg + COALESCE((
|
||||||
|
SELECT SUM(s.min_w) FROM (
|
||||||
|
SELECT gs.slot_id, MIN(m.weight_kg) AS min_w
|
||||||
|
FROM gun_slots gs
|
||||||
|
JOIN gun_slot_items gsi
|
||||||
|
ON gsi.gun_id = gs.gun_id AND gsi.slot_id = gs.slot_id
|
||||||
|
JOIN gear_items m ON m.id = gsi.item_id
|
||||||
|
WHERE gs.gun_id = g.id
|
||||||
|
AND gs.slot_nameid IN ({placeholders})
|
||||||
|
AND m.weight_kg IS NOT NULL
|
||||||
|
GROUP BY gs.slot_id
|
||||||
|
) s
|
||||||
|
), 0.0)) AS lightest_build_weight
|
||||||
|
FROM gear_items g
|
||||||
|
WHERE g.category = 'gun'
|
||||||
|
AND (
|
||||||
|
SELECT COUNT(DISTINCT gs2.slot_nameid)
|
||||||
|
FROM gun_slots gs2
|
||||||
|
WHERE gs2.gun_id = g.id
|
||||||
|
AND gs2.slot_nameid IN ({placeholders})
|
||||||
|
) = ?
|
||||||
|
ORDER BY lightest_build_weight ASC NULLS LAST
|
||||||
|
""", requires + requires + [len(requires)]).fetchall()
|
||||||
|
else:
|
||||||
|
guns = conn.execute(f"""
|
||||||
|
SELECT *, weight_kg AS lightest_build_weight
|
||||||
|
FROM gear_items
|
||||||
|
WHERE category = 'gun'
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""").fetchall()
|
||||||
|
|
||||||
|
elif tab == "armor":
|
||||||
|
armor = conn.execute(f"""
|
||||||
|
SELECT * FROM gear_items
|
||||||
|
WHERE category = 'armor'
|
||||||
|
AND (? = 0 OR armor_class >= ?)
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""", (min_class, min_class)).fetchall()
|
||||||
|
|
||||||
|
elif tab == "helmets":
|
||||||
|
helmets = conn.execute(f"""
|
||||||
|
SELECT * FROM gear_items
|
||||||
|
WHERE category = 'helmet'
|
||||||
|
AND (? = 0 OR armor_class >= ?)
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""", (min_class, min_class)).fetchall()
|
||||||
|
|
||||||
|
elif tab == "headwear":
|
||||||
|
headwear = conn.execute(f"""
|
||||||
|
SELECT * FROM gear_items
|
||||||
|
WHERE category = 'headwear'
|
||||||
|
AND (? = 0 OR armor_class >= ?)
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""", (min_class, min_class)).fetchall()
|
||||||
|
|
||||||
|
elif tab == "backpacks":
|
||||||
|
backpacks = conn.execute(f"""
|
||||||
|
SELECT * FROM gear_items
|
||||||
|
WHERE category = 'backpack'
|
||||||
|
AND (? = 0 OR capacity >= ?)
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""", (min_capacity, min_capacity)).fetchall()
|
||||||
|
|
||||||
|
elif tab == "rigs":
|
||||||
|
rigs = conn.execute(f"""
|
||||||
|
SELECT * FROM gear_items
|
||||||
|
WHERE category = 'rig'
|
||||||
|
AND (? = 0 OR capacity >= ?)
|
||||||
|
AND (? = 0 OR armor_class >= ?)
|
||||||
|
ORDER BY {sort_frag}
|
||||||
|
""", (min_capacity, min_capacity, min_class, min_class)).fetchall()
|
||||||
|
|
||||||
|
elif tab == "builder":
|
||||||
|
builder_guns = conn.execute("SELECT id, name, weight_kg FROM gear_items WHERE category='gun' ORDER BY name").fetchall()
|
||||||
|
builder_armor = conn.execute("SELECT id, name, weight_kg FROM gear_items WHERE category='armor' ORDER BY name").fetchall()
|
||||||
|
builder_helmets = conn.execute("SELECT id, name, weight_kg FROM gear_items WHERE category='helmet' ORDER BY name").fetchall()
|
||||||
|
builder_rigs = conn.execute("SELECT id, name, weight_kg FROM gear_items WHERE category='rig' ORDER BY name").fetchall()
|
||||||
|
builder_backpacks = conn.execute("SELECT id, name, weight_kg FROM gear_items WHERE category='backpack' ORDER BY name").fetchall()
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return render_template(
|
||||||
|
"loadout.html",
|
||||||
|
tab=tab, sort=sort,
|
||||||
|
guns=guns, armor=armor, helmets=helmets, headwear=headwear,
|
||||||
|
backpacks=backpacks, rigs=rigs,
|
||||||
|
slot_filters=LOADOUT_SLOT_FILTERS,
|
||||||
|
requires=requires,
|
||||||
|
min_class=min_class, min_capacity=min_capacity,
|
||||||
|
builder_guns=builder_guns,
|
||||||
|
builder_armor=builder_armor,
|
||||||
|
builder_helmets=builder_helmets,
|
||||||
|
builder_rigs=builder_rigs,
|
||||||
|
builder_backpacks=builder_backpacks,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/loadout/gun/<gun_id>")
|
||||||
|
def gun_detail(gun_id):
|
||||||
|
conn = get_db()
|
||||||
|
gun = conn.execute(
|
||||||
|
"SELECT * FROM gear_items WHERE id = ? AND category = 'gun'", (gun_id,)
|
||||||
|
).fetchone()
|
||||||
|
if not gun:
|
||||||
|
conn.close()
|
||||||
|
return "Gun not found.", 404
|
||||||
|
|
||||||
|
# All slots for this gun, with every compatible mod sorted by weight
|
||||||
|
slots_raw = conn.execute("""
|
||||||
|
SELECT gs.slot_id, gs.slot_name, gs.slot_nameid, gs.required,
|
||||||
|
m.id AS mod_id, m.name AS mod_name, m.short_name AS mod_short,
|
||||||
|
m.weight_kg, m.grid_image_url, m.wiki_url, m.mod_type
|
||||||
|
FROM gun_slots gs
|
||||||
|
LEFT JOIN gun_slot_items gsi ON gsi.gun_id = gs.gun_id AND gsi.slot_id = gs.slot_id
|
||||||
|
LEFT JOIN gear_items m ON m.id = gsi.item_id
|
||||||
|
WHERE gs.gun_id = ?
|
||||||
|
ORDER BY gs.slot_name, m.weight_kg ASC NULLS LAST
|
||||||
|
""", (gun_id,)).fetchall()
|
||||||
|
|
||||||
|
# Group by slot
|
||||||
|
slots = {}
|
||||||
|
slot_order = []
|
||||||
|
for row in slots_raw:
|
||||||
|
sid = row["slot_id"]
|
||||||
|
if sid not in slots:
|
||||||
|
slots[sid] = {
|
||||||
|
"slot_id": sid,
|
||||||
|
"slot_name": row["slot_name"],
|
||||||
|
"slot_nameid": row["slot_nameid"],
|
||||||
|
"required": row["required"],
|
||||||
|
"mods": [],
|
||||||
|
}
|
||||||
|
slot_order.append(sid)
|
||||||
|
if row["mod_id"]:
|
||||||
|
slots[sid]["mods"].append(dict(row))
|
||||||
|
|
||||||
|
# Key slots to show at top (highlighted)
|
||||||
|
KEY_SLOTS = {"mod_muzzle", "mod_magazine"}
|
||||||
|
ordered_slots = [slots[s] for s in slot_order]
|
||||||
|
key_slots = [s for s in ordered_slots if s["slot_nameid"] in KEY_SLOTS]
|
||||||
|
other_slots = [s for s in ordered_slots if s["slot_nameid"] not in KEY_SLOTS]
|
||||||
|
|
||||||
|
# Lightest total (base + lightest per slot)
|
||||||
|
lightest_total = (gun["weight_kg"] or 0) + sum(
|
||||||
|
s["mods"][0]["weight_kg"]
|
||||||
|
for s in ordered_slots
|
||||||
|
if s["mods"] and s["mods"][0]["weight_kg"] is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return render_template(
|
||||||
|
"gun_detail.html",
|
||||||
|
gun=gun,
|
||||||
|
key_slots=key_slots,
|
||||||
|
other_slots=other_slots,
|
||||||
|
lightest_total=lightest_total,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/loadout/gun/<gun_id>/slots.json")
|
||||||
|
def gun_slots_json(gun_id):
|
||||||
|
"""Returns slot summary for the expandable row (lightest mod per slot only)."""
|
||||||
|
conn = get_db()
|
||||||
|
rows = conn.execute("""
|
||||||
|
SELECT gs.slot_name, gs.slot_nameid, gs.required,
|
||||||
|
m.name AS mod_name, m.weight_kg
|
||||||
|
FROM gun_slots gs
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT gsi.gun_id, gsi.slot_id,
|
||||||
|
m2.name, m2.weight_kg
|
||||||
|
FROM gun_slot_items gsi
|
||||||
|
JOIN gear_items m2 ON m2.id = gsi.item_id
|
||||||
|
WHERE gsi.gun_id = ?
|
||||||
|
AND m2.weight_kg = (
|
||||||
|
SELECT MIN(m3.weight_kg) FROM gun_slot_items gsi3
|
||||||
|
JOIN gear_items m3 ON m3.id = gsi3.item_id
|
||||||
|
WHERE gsi3.gun_id = gsi.gun_id AND gsi3.slot_id = gsi.slot_id
|
||||||
|
AND m3.weight_kg IS NOT NULL
|
||||||
|
)
|
||||||
|
GROUP BY gsi.slot_id
|
||||||
|
) m ON m.gun_id = gs.gun_id AND m.slot_id = gs.slot_id
|
||||||
|
WHERE gs.gun_id = ?
|
||||||
|
ORDER BY gs.slot_name
|
||||||
|
""", (gun_id, gun_id)).fetchall()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
KEY_SLOTS = {"mod_muzzle", "mod_magazine"}
|
||||||
|
result = [
|
||||||
|
{
|
||||||
|
"slot_name": r["slot_name"],
|
||||||
|
"slot_nameid": r["slot_nameid"],
|
||||||
|
"required": r["required"],
|
||||||
|
"mod_name": r["mod_name"],
|
||||||
|
"weight_kg": r["weight_kg"],
|
||||||
|
"key": r["slot_nameid"] in KEY_SLOTS,
|
||||||
|
}
|
||||||
|
for r in rows
|
||||||
|
]
|
||||||
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/loadout/save-build", methods=["POST"])
|
||||||
|
def save_build():
|
||||||
|
data = request.get_json() or {}
|
||||||
|
name = (data.get("name") or "My Build").strip() or "My Build"
|
||||||
|
gun_id = data.get("gun_id") or None
|
||||||
|
armor_id = data.get("armor_id") or None
|
||||||
|
helmet_id = data.get("helmet_id") or None
|
||||||
|
rig_id = data.get("rig_id") or None
|
||||||
|
backpack_id = data.get("backpack_id") or None
|
||||||
|
notes = data.get("notes", "")
|
||||||
|
|
||||||
|
conn = get_db()
|
||||||
|
cur = conn.execute("""
|
||||||
|
INSERT INTO saved_builds (name, gun_id, armor_id, helmet_id, rig_id, backpack_id, notes)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
""", (name, gun_id, armor_id, helmet_id, rig_id, backpack_id, notes))
|
||||||
|
build_id = cur.lastrowid
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({"build_id": build_id, "name": name})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
535
import_gear.py
Normal file
535
import_gear.py
Normal file
@@ -0,0 +1,535 @@
|
|||||||
|
import requests
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DB_PATH = "tarkov.db"
|
||||||
|
API_URL = "https://api.tarkov.dev/graphql"
|
||||||
|
|
||||||
|
# Slot nameId patterns that identify what type of mod goes in a slot
|
||||||
|
SLOT_TYPE_MAP = {
|
||||||
|
"mod_muzzle": "suppressor",
|
||||||
|
"mod_scope": "scope",
|
||||||
|
"mod_tactical": "flashlight",
|
||||||
|
"mod_tactical_001": "flashlight",
|
||||||
|
"mod_tactical_002": "flashlight",
|
||||||
|
"mod_tactical_003": "flashlight",
|
||||||
|
"mod_stock": "stock",
|
||||||
|
"mod_stock_000": "stock",
|
||||||
|
"mod_stock_001": "stock",
|
||||||
|
"mod_pistol_grip": "grip",
|
||||||
|
"mod_grip": "foregrip",
|
||||||
|
"mod_foregrip": "foregrip",
|
||||||
|
"mod_magazine": "magazine",
|
||||||
|
"mod_barrel": "barrel",
|
||||||
|
"mod_gas_block": "gas_block",
|
||||||
|
"mod_handguard": "handguard",
|
||||||
|
"mod_launcher": "launcher",
|
||||||
|
"mod_bipod": "bipod",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fetch weapons separately due to large slots/allowedItems payload
|
||||||
|
GRAPHQL_QUERY_WEAPONS = """
|
||||||
|
{
|
||||||
|
weapons: items(types: [gun]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesWeapon {
|
||||||
|
caliber
|
||||||
|
fireRate
|
||||||
|
ergonomics
|
||||||
|
recoilVertical
|
||||||
|
defaultWeight
|
||||||
|
slots {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
nameId
|
||||||
|
required
|
||||||
|
filters {
|
||||||
|
allowedItems { id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
GRAPHQL_QUERY_GEAR = """
|
||||||
|
{
|
||||||
|
armor: items(types: [armor]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesArmor {
|
||||||
|
class
|
||||||
|
durability
|
||||||
|
material { name }
|
||||||
|
zones
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helmets: items(types: [helmet]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesHelmet {
|
||||||
|
class
|
||||||
|
durability
|
||||||
|
material { name }
|
||||||
|
headZones
|
||||||
|
deafening
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wearables: items(types: [wearable]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesHelmet {
|
||||||
|
class
|
||||||
|
durability
|
||||||
|
material { name }
|
||||||
|
headZones
|
||||||
|
deafening
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
backpacks: items(types: [backpack]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesBackpack {
|
||||||
|
capacity
|
||||||
|
grids { width height }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rigs: items(types: [rig]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
properties {
|
||||||
|
... on ItemPropertiesChestRig {
|
||||||
|
capacity
|
||||||
|
class
|
||||||
|
durability
|
||||||
|
zones
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suppressors: items(types: [suppressor]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
}
|
||||||
|
|
||||||
|
mods: items(types: [mods]) {
|
||||||
|
id name shortName weight gridImageLink wikiLink
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def gql(query, label="query"):
|
||||||
|
response = requests.post(
|
||||||
|
API_URL,
|
||||||
|
json={"query": query},
|
||||||
|
timeout=90
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
if "errors" in data:
|
||||||
|
raise RuntimeError(f"{label} errors: {data['errors']}")
|
||||||
|
return data["data"]
|
||||||
|
|
||||||
|
|
||||||
|
def upsert_item(cursor, item_id, name, short_name, category, weight,
|
||||||
|
grid_image_url, wiki_url,
|
||||||
|
caliber=None, fire_rate=None, ergonomics=None, recoil_vertical=None,
|
||||||
|
default_weight=None, armor_class=None, durability=None, material=None,
|
||||||
|
zones=None, head_zones=None, deafening=None, capacity=None, mod_type=None):
|
||||||
|
cursor.execute("SELECT id FROM gear_items WHERE api_id = ?", (item_id,))
|
||||||
|
existing = cursor.fetchone()
|
||||||
|
if existing:
|
||||||
|
cursor.execute("""
|
||||||
|
UPDATE gear_items
|
||||||
|
SET name=?, short_name=?, category=?, weight_kg=?, grid_image_url=?, wiki_url=?,
|
||||||
|
caliber=?, fire_rate=?, ergonomics=?, recoil_vertical=?, default_weight=?,
|
||||||
|
armor_class=?, durability=?, material=?, zones=?, head_zones=?, deafening=?,
|
||||||
|
capacity=?, mod_type=?, updated_at=CURRENT_TIMESTAMP
|
||||||
|
WHERE api_id=?
|
||||||
|
""", (name, short_name, category, weight, grid_image_url, wiki_url,
|
||||||
|
caliber, fire_rate, ergonomics, recoil_vertical, default_weight,
|
||||||
|
armor_class, durability, material, zones, head_zones, deafening,
|
||||||
|
capacity, mod_type, item_id))
|
||||||
|
return "updated"
|
||||||
|
else:
|
||||||
|
cursor.execute("""
|
||||||
|
INSERT INTO gear_items
|
||||||
|
(id, api_id, name, short_name, category, weight_kg, grid_image_url, wiki_url,
|
||||||
|
caliber, fire_rate, ergonomics, recoil_vertical, default_weight,
|
||||||
|
armor_class, durability, material, zones, head_zones, deafening,
|
||||||
|
capacity, mod_type)
|
||||||
|
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||||
|
""", (item_id, item_id, name, short_name, category, weight, grid_image_url, wiki_url,
|
||||||
|
caliber, fire_rate, ergonomics, recoil_vertical, default_weight,
|
||||||
|
armor_class, durability, material, zones, head_zones, deafening,
|
||||||
|
capacity, mod_type))
|
||||||
|
return "inserted"
|
||||||
|
|
||||||
|
|
||||||
|
def import_weapons(conn, weapons):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
# Collect slot data for phase 2
|
||||||
|
slot_data = {} # gun_id -> list of slot dicts
|
||||||
|
|
||||||
|
for w in weapons:
|
||||||
|
item_id = w.get("id")
|
||||||
|
name = w.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
props = w.get("properties") or {}
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, w.get("shortName"), "gun", w.get("weight"),
|
||||||
|
w.get("gridImageLink"), w.get("wikiLink"),
|
||||||
|
caliber=props.get("caliber"),
|
||||||
|
fire_rate=props.get("fireRate"),
|
||||||
|
ergonomics=props.get("ergonomics"),
|
||||||
|
recoil_vertical=props.get("recoilVertical"),
|
||||||
|
default_weight=props.get("defaultWeight"),
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
|
||||||
|
slots = props.get("slots") or []
|
||||||
|
if slots:
|
||||||
|
slot_data[item_id] = slots
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
return counts, slot_data
|
||||||
|
|
||||||
|
|
||||||
|
def import_armor(conn, items):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
props = item.get("properties") or {}
|
||||||
|
material = (props.get("material") or {}).get("name")
|
||||||
|
zones = ",".join(props.get("zones") or []) or None
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), "armor", item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
armor_class=props.get("class"),
|
||||||
|
durability=props.get("durability"),
|
||||||
|
material=material,
|
||||||
|
zones=zones,
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_helmets(conn, items):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
props = item.get("properties") or {}
|
||||||
|
material = (props.get("material") or {}).get("name")
|
||||||
|
head_zones_list = props.get("headZones") or []
|
||||||
|
head_zones = ",".join(head_zones_list) or None
|
||||||
|
# True helmets cover the top of the head; face masks etc. go to 'headwear'
|
||||||
|
category = "helmet" if any("Top of the head" in z for z in head_zones_list) else "headwear"
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), category, item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
armor_class=props.get("class"),
|
||||||
|
durability=props.get("durability"),
|
||||||
|
material=material,
|
||||||
|
head_zones=head_zones,
|
||||||
|
deafening=props.get("deafening"),
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_backpacks(conn, items):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
props = item.get("properties") or {}
|
||||||
|
capacity = props.get("capacity")
|
||||||
|
if capacity is None:
|
||||||
|
capacity = sum(
|
||||||
|
g.get("width", 0) * g.get("height", 0)
|
||||||
|
for g in (props.get("grids") or [])
|
||||||
|
) or None
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), "backpack", item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
capacity=capacity,
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_rigs(conn, items):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
props = item.get("properties") or {}
|
||||||
|
zones = ",".join(props.get("zones") or []) or None
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), "rig", item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
armor_class=props.get("class"),
|
||||||
|
durability=props.get("durability"),
|
||||||
|
capacity=props.get("capacity"),
|
||||||
|
zones=zones,
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_suppressors(conn, items):
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), "mod", item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
mod_type="suppressor",
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_mods(conn, items):
|
||||||
|
"""Import generic weapon mods (scopes, grips, stocks, barrels, etc.)"""
|
||||||
|
cursor = conn.cursor()
|
||||||
|
counts = {"inserted": 0, "updated": 0, "skipped": 0}
|
||||||
|
for item in items:
|
||||||
|
item_id = item.get("id")
|
||||||
|
name = item.get("name")
|
||||||
|
if not item_id or not name:
|
||||||
|
counts["skipped"] += 1
|
||||||
|
continue
|
||||||
|
# Don't overwrite suppressors already imported with their mod_type
|
||||||
|
cursor.execute("SELECT id FROM gear_items WHERE api_id = ?", (item_id,))
|
||||||
|
existing = cursor.fetchone()
|
||||||
|
if existing:
|
||||||
|
# Only update weight/image if item already exists — don't overwrite mod_type
|
||||||
|
cursor.execute("""
|
||||||
|
UPDATE gear_items
|
||||||
|
SET name=?, short_name=?, weight_kg=?, grid_image_url=?, wiki_url=?,
|
||||||
|
updated_at=CURRENT_TIMESTAMP
|
||||||
|
WHERE api_id=?
|
||||||
|
""", (name, item.get("shortName"), item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"), item_id))
|
||||||
|
counts["updated"] += 1
|
||||||
|
else:
|
||||||
|
result = upsert_item(
|
||||||
|
cursor, item_id, name, item.get("shortName"), "mod", item.get("weight"),
|
||||||
|
item.get("gridImageLink"), item.get("wikiLink"),
|
||||||
|
)
|
||||||
|
counts[result] += 1
|
||||||
|
conn.commit()
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
|
def import_slots(conn, slot_data):
|
||||||
|
"""
|
||||||
|
Phase 2: insert gun_slots and gun_slot_items rows.
|
||||||
|
slot_data: { gun_id: [slot_dict, ...] }
|
||||||
|
Only inserts gun_slot_items rows where item_id exists in gear_items.
|
||||||
|
"""
|
||||||
|
cursor = conn.cursor()
|
||||||
|
slots_inserted = 0
|
||||||
|
slot_items_inserted = 0
|
||||||
|
slot_items_skipped = 0
|
||||||
|
|
||||||
|
# Build set of known item IDs for fast lookup
|
||||||
|
known_ids = {row[0] for row in cursor.execute("SELECT id FROM gear_items").fetchall()}
|
||||||
|
|
||||||
|
for gun_id, slots in slot_data.items():
|
||||||
|
for slot in slots:
|
||||||
|
slot_id = slot.get("id")
|
||||||
|
slot_name = slot.get("name") or ""
|
||||||
|
slot_nameid = slot.get("nameId") or ""
|
||||||
|
required = 1 if slot.get("required") else 0
|
||||||
|
|
||||||
|
if not slot_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
cursor.execute("""
|
||||||
|
INSERT OR REPLACE INTO gun_slots (gun_id, slot_id, slot_name, slot_nameid, required)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
""", (gun_id, slot_id, slot_name, slot_nameid, required))
|
||||||
|
slots_inserted += 1
|
||||||
|
|
||||||
|
filters = slot.get("filters") or {}
|
||||||
|
allowed_items = filters.get("allowedItems") or []
|
||||||
|
for allowed in allowed_items:
|
||||||
|
item_id = allowed.get("id")
|
||||||
|
if not item_id or item_id not in known_ids:
|
||||||
|
slot_items_skipped += 1
|
||||||
|
continue
|
||||||
|
cursor.execute("""
|
||||||
|
INSERT OR IGNORE INTO gun_slot_items (gun_id, slot_id, item_id)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
""", (gun_id, slot_id, item_id))
|
||||||
|
slot_items_inserted += 1
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
return slots_inserted, slot_items_inserted, slot_items_skipped
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("=== OnlyScavs Gear Import ===")
|
||||||
|
|
||||||
|
# Phase 1a: fetch weapons (separate query — large payload)
|
||||||
|
print("\nFetching weapons from tarkov.dev...")
|
||||||
|
try:
|
||||||
|
weapon_data = gql(GRAPHQL_QUERY_WEAPONS, "weapons")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"ERROR fetching weapons: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
weapons = weapon_data.get("weapons", [])
|
||||||
|
print(f" Fetched {len(weapons)} weapons")
|
||||||
|
|
||||||
|
# Phase 1b: fetch other gear
|
||||||
|
print("Fetching armor, helmets, backpacks, rigs, suppressors...")
|
||||||
|
try:
|
||||||
|
gear_data = gql(GRAPHQL_QUERY_GEAR, "gear")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"ERROR fetching gear: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
armor = gear_data.get("armor", [])
|
||||||
|
helmets = gear_data.get("helmets", [])
|
||||||
|
backpacks = gear_data.get("backpacks", [])
|
||||||
|
rigs = gear_data.get("rigs", [])
|
||||||
|
suppressors = gear_data.get("suppressors", [])
|
||||||
|
mods = gear_data.get("mods", [])
|
||||||
|
|
||||||
|
# Wearables: only keep those whose properties resolved to ItemPropertiesHelmet
|
||||||
|
# (i.e. they have 'class' or 'headZones' set — not decorative items)
|
||||||
|
wearables_raw = gear_data.get("wearables", [])
|
||||||
|
# Known helmet IDs from the main helmet query — skip duplicates
|
||||||
|
helmet_ids = {h["id"] for h in helmets}
|
||||||
|
wearable_helmets = [
|
||||||
|
w for w in wearables_raw
|
||||||
|
if w["id"] not in helmet_ids
|
||||||
|
and isinstance(w.get("properties"), dict)
|
||||||
|
and (w["properties"].get("class") or w["properties"].get("headZones"))
|
||||||
|
]
|
||||||
|
print(f" armor={len(armor)}, helmets={len(helmets)}, wearable_helmets={len(wearable_helmets)}, "
|
||||||
|
f"backpacks={len(backpacks)}, rigs={len(rigs)}, suppressors={len(suppressors)}, mods={len(mods)}")
|
||||||
|
|
||||||
|
# Phase 2: insert into DB
|
||||||
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
conn.execute("PRAGMA foreign_keys = ON")
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("\nImporting weapons...")
|
||||||
|
wcounts, slot_data = import_weapons(conn, weapons)
|
||||||
|
print(f" guns: +{wcounts['inserted']} inserted, ~{wcounts['updated']} updated, -{wcounts['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing armor...")
|
||||||
|
c = import_armor(conn, armor)
|
||||||
|
print(f" armor: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing helmets...")
|
||||||
|
c = import_helmets(conn, helmets)
|
||||||
|
print(f" helmets: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing wearable helmets (missing from helmet type)...")
|
||||||
|
c = import_helmets(conn, wearable_helmets)
|
||||||
|
print(f" wearable helmets: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing backpacks...")
|
||||||
|
c = import_backpacks(conn, backpacks)
|
||||||
|
print(f" backpacks: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing rigs...")
|
||||||
|
c = import_rigs(conn, rigs)
|
||||||
|
print(f" rigs: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing suppressors...")
|
||||||
|
c = import_suppressors(conn, suppressors)
|
||||||
|
print(f" suppressors: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
print("Importing mods (scopes, grips, stocks, barrels, etc.)...")
|
||||||
|
c = import_mods(conn, mods)
|
||||||
|
print(f" mods: +{c['inserted']} inserted, ~{c['updated']} updated, -{c['skipped']} skipped")
|
||||||
|
|
||||||
|
# Phase 3: gun slots (needs all items in DB first)
|
||||||
|
print("Importing gun slots and compatibility data...")
|
||||||
|
slots_ins, slot_items_ins, slot_items_skip = import_slots(conn, slot_data)
|
||||||
|
print(f" gun_slots: {slots_ins} rows")
|
||||||
|
print(f" gun_slot_items: {slot_items_ins} rows inserted, {slot_items_skip} skipped (item not in DB)")
|
||||||
|
|
||||||
|
# Phase 4: classify mod_type for mods based on which slots they appear in
|
||||||
|
print("Classifying mod types from slot data...")
|
||||||
|
cursor = conn.cursor()
|
||||||
|
updated_mod_types = 0
|
||||||
|
for slot_nameid, mod_type in SLOT_TYPE_MAP.items():
|
||||||
|
result = cursor.execute("""
|
||||||
|
UPDATE gear_items
|
||||||
|
SET mod_type = ?
|
||||||
|
WHERE id IN (
|
||||||
|
SELECT gsi.item_id
|
||||||
|
FROM gun_slot_items gsi
|
||||||
|
JOIN gun_slots gs ON gs.gun_id = gsi.gun_id AND gs.slot_id = gsi.slot_id
|
||||||
|
WHERE gs.slot_nameid = ?
|
||||||
|
)
|
||||||
|
AND category = 'mod'
|
||||||
|
AND (mod_type IS NULL OR mod_type != 'suppressor')
|
||||||
|
""", (mod_type, slot_nameid))
|
||||||
|
updated_mod_types += result.rowcount
|
||||||
|
conn.commit()
|
||||||
|
print(f" mod_type set on {updated_mod_types} mod items")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
conn.rollback()
|
||||||
|
print(f"ERROR: Database operation failed — {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
sys.exit(1)
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
print("\n=== Import complete ===")
|
||||||
|
print("Run: SELECT category, COUNT(*) FROM gear_items GROUP BY category;")
|
||||||
|
print(" to verify row counts.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
74
migrations_v2.sql
Normal file
74
migrations_v2.sql
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
PRAGMA foreign_keys = ON;
|
||||||
|
|
||||||
|
-- Unified gear item table for weapons, armor, helmets, backpacks, rigs, and mods/attachments
|
||||||
|
CREATE TABLE IF NOT EXISTS gear_items (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
api_id TEXT UNIQUE NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
short_name TEXT,
|
||||||
|
category TEXT NOT NULL, -- 'gun' | 'armor' | 'helmet' | 'backpack' | 'rig' | 'mod'
|
||||||
|
weight_kg REAL,
|
||||||
|
grid_image_url TEXT,
|
||||||
|
wiki_url TEXT,
|
||||||
|
-- Weapon-specific fields
|
||||||
|
caliber TEXT,
|
||||||
|
fire_rate INTEGER,
|
||||||
|
ergonomics INTEGER,
|
||||||
|
recoil_vertical INTEGER,
|
||||||
|
default_weight REAL, -- weight of gun with default preset mods attached
|
||||||
|
-- Armor / Helmet / Rig shared fields
|
||||||
|
armor_class INTEGER, -- 1-6, NULL if not applicable
|
||||||
|
durability REAL,
|
||||||
|
material TEXT,
|
||||||
|
zones TEXT, -- comma-separated protection zone names
|
||||||
|
head_zones TEXT, -- comma-separated head zone names (helmets only)
|
||||||
|
deafening TEXT, -- None | Low | Medium | High | Complete (helmets)
|
||||||
|
-- Backpack / Rig capacity
|
||||||
|
capacity INTEGER, -- total grid cell count
|
||||||
|
-- Mod/attachment classification
|
||||||
|
mod_type TEXT, -- 'suppressor' | 'scope' | 'flashlight' | 'foregrip' | 'stock' | etc.
|
||||||
|
imported_at TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TEXT DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gear_category ON gear_items(category);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gear_armor_class ON gear_items(armor_class);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gear_capacity ON gear_items(capacity);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gear_weight ON gear_items(weight_kg);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gear_caliber ON gear_items(caliber);
|
||||||
|
|
||||||
|
-- Weapon mod slots: records which named slots exist on each gun
|
||||||
|
CREATE TABLE IF NOT EXISTS gun_slots (
|
||||||
|
gun_id TEXT NOT NULL REFERENCES gear_items(id) ON DELETE CASCADE,
|
||||||
|
slot_id TEXT NOT NULL, -- tarkov internal slot ID
|
||||||
|
slot_name TEXT NOT NULL, -- human-readable name (e.g. "Muzzle")
|
||||||
|
slot_nameid TEXT, -- normalized nameId (e.g. "mod_muzzle")
|
||||||
|
required INTEGER DEFAULT 0, -- 1 if the slot must be filled
|
||||||
|
PRIMARY KEY (gun_id, slot_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gun_slots_nameid ON gun_slots(slot_nameid);
|
||||||
|
|
||||||
|
-- Which items are compatible with each gun slot (from API filters.allowedItems)
|
||||||
|
CREATE TABLE IF NOT EXISTS gun_slot_items (
|
||||||
|
gun_id TEXT NOT NULL,
|
||||||
|
slot_id TEXT NOT NULL,
|
||||||
|
item_id TEXT NOT NULL REFERENCES gear_items(id) ON DELETE CASCADE,
|
||||||
|
PRIMARY KEY (gun_id, slot_id, item_id),
|
||||||
|
FOREIGN KEY (gun_id, slot_id) REFERENCES gun_slots(gun_id, slot_id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_gun_slot_items_item ON gun_slot_items(item_id);
|
||||||
|
|
||||||
|
-- Saved loadout builds
|
||||||
|
CREATE TABLE IF NOT EXISTS saved_builds (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL DEFAULT 'My Build',
|
||||||
|
gun_id TEXT REFERENCES gear_items(id),
|
||||||
|
armor_id TEXT REFERENCES gear_items(id),
|
||||||
|
helmet_id TEXT REFERENCES gear_items(id),
|
||||||
|
rig_id TEXT REFERENCES gear_items(id),
|
||||||
|
backpack_id TEXT REFERENCES gear_items(id),
|
||||||
|
notes TEXT,
|
||||||
|
created_at TEXT DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
@@ -101,7 +101,13 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<nav><a href="/">← Back to Keys</a></nav>
|
<nav>
|
||||||
|
<a href="/">← Keys</a>
|
||||||
|
|
|
||||||
|
<a href="/quests">Quest Trees</a>
|
||||||
|
|
|
||||||
|
<a href="/loadout">Loadout Planner</a>
|
||||||
|
</nav>
|
||||||
<h1>Collector Checklist</h1>
|
<h1>Collector Checklist</h1>
|
||||||
<p class="subtitle">
|
<p class="subtitle">
|
||||||
{{ done }} / {{ total }} quests completed
|
{{ done }} / {{ total }} quests completed
|
||||||
@@ -120,24 +126,53 @@
|
|||||||
{% set ns.current_trader = quest.trader %}
|
{% set ns.current_trader = quest.trader %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form method="post" action="/collector/toggle" style="margin:0">
|
<div class="quest-row {% if quest.done %}done{% endif %}" id="quest-{{ quest.id }}" data-id="{{ quest.id }}" data-done="{{ '1' if quest.done else '0' }}">
|
||||||
<input type="hidden" name="quest_id" value="{{ quest.id }}">
|
<span class="quest-name">
|
||||||
<input type="hidden" name="done" value="{{ '0' if quest.done else '1' }}">
|
{{ quest.name }}
|
||||||
<div class="quest-row {% if quest.done %}done{% endif %}">
|
{% if quest.wiki_link %}
|
||||||
<span class="quest-name">
|
<a href="{{ quest.wiki_link }}" target="_blank">wiki</a>
|
||||||
{{ quest.name }}
|
{% endif %}
|
||||||
{% if quest.wiki_link %}
|
</span>
|
||||||
<a href="{{ quest.wiki_link }}" target="_blank">wiki</a>
|
<button class="toggle-btn" onclick="toggle(this)">
|
||||||
{% endif %}
|
{{ '✓ Done' if quest.done else 'Mark done' }}
|
||||||
</span>
|
</button>
|
||||||
<button class="toggle-btn" type="submit">
|
</div>
|
||||||
{{ '✓ Done' if quest.done else 'Mark done' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if ns.current_trader is not none %}</div>{% endif %}
|
{% if ns.current_trader is not none %}</div>{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
let doneCount = {{ done }};
|
||||||
|
const total = {{ total }};
|
||||||
|
|
||||||
|
function updateProgress() {
|
||||||
|
document.querySelector('.subtitle').textContent = doneCount + ' / ' + total + ' quests completed';
|
||||||
|
const pct = total ? (doneCount / total * 100).toFixed(1) : 0;
|
||||||
|
document.querySelector('.progress-bar-fill').style.width = pct + '%';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle(btn) {
|
||||||
|
const row = btn.closest('.quest-row');
|
||||||
|
const id = row.dataset.id;
|
||||||
|
const nowDone = row.dataset.done === '1' ? 0 : 1;
|
||||||
|
|
||||||
|
const body = new URLSearchParams({ quest_id: id, done: nowDone });
|
||||||
|
fetch('/collector/toggle', { method: 'POST', body })
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(() => {
|
||||||
|
row.dataset.done = nowDone;
|
||||||
|
if (nowDone) {
|
||||||
|
row.classList.add('done');
|
||||||
|
btn.textContent = '✓ Done';
|
||||||
|
doneCount++;
|
||||||
|
} else {
|
||||||
|
row.classList.remove('done');
|
||||||
|
btn.textContent = 'Mark done';
|
||||||
|
doneCount--;
|
||||||
|
}
|
||||||
|
updateProgress();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
319
templates/gun_detail.html
Normal file
319
templates/gun_detail.html
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OnlyScavs – {{ gun.name }}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #121212;
|
||||||
|
--panel: #1a1a1a;
|
||||||
|
--text: #eee;
|
||||||
|
--muted: #bbb;
|
||||||
|
--border: #333;
|
||||||
|
--accent: #9ccfff;
|
||||||
|
--amber: #ffd580;
|
||||||
|
--key-border: #5a7a3a;
|
||||||
|
--key-bg: #141e10;
|
||||||
|
}
|
||||||
|
body { font-family: sans-serif; background: var(--bg); color: var(--text); margin: 0; padding: 16px; }
|
||||||
|
.page { max-width: 900px; margin: 0 auto; }
|
||||||
|
nav { margin-bottom: 20px; }
|
||||||
|
nav a { color: var(--accent); font-size: 0.9rem; }
|
||||||
|
a { color: var(--accent); }
|
||||||
|
h1 { margin: 0 0 2px; font-size: 1.4rem; }
|
||||||
|
.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 20px; }
|
||||||
|
|
||||||
|
/* Gun summary card */
|
||||||
|
.gun-card {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-start;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
.gun-card img { width: 96px; height: 96px; object-fit: contain; background: #222; border-radius: 6px; }
|
||||||
|
.gun-stats { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 8px; }
|
||||||
|
.stat { display: flex; flex-direction: column; }
|
||||||
|
.stat .val { font-size: 1.1rem; font-weight: bold; color: var(--amber); }
|
||||||
|
.stat .lbl { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
|
||||||
|
.gun-name { flex: 1; }
|
||||||
|
.gun-name h2 { margin: 0 0 4px; font-size: 1.2rem; }
|
||||||
|
.gun-name .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
|
||||||
|
|
||||||
|
/* Total bar */
|
||||||
|
.total-bar {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px 20px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.total-bar .big { font-size: 1.6rem; font-weight: bold; color: var(--amber); }
|
||||||
|
.total-bar .lbl { color: var(--muted); font-size: 0.9rem; }
|
||||||
|
.total-bar .breakdown { color: var(--muted); font-size: 0.82rem; margin-left: auto; }
|
||||||
|
|
||||||
|
/* Section headers */
|
||||||
|
.section-hdr {
|
||||||
|
font-size: 0.78rem;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--muted);
|
||||||
|
padding: 10px 0 6px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Slot cards */
|
||||||
|
.slot-section { margin-bottom: 24px; }
|
||||||
|
.slot-card {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.slot-card.key-slot {
|
||||||
|
border-color: var(--key-border);
|
||||||
|
background: var(--key-bg);
|
||||||
|
}
|
||||||
|
.slot-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
background: rgba(255,255,255,0.03);
|
||||||
|
}
|
||||||
|
.slot-header:hover { background: rgba(255,255,255,0.06); }
|
||||||
|
.slot-header .slot-name { font-weight: bold; font-size: 0.9rem; flex: 1; }
|
||||||
|
.slot-header .slot-count { color: var(--muted); font-size: 0.8rem; }
|
||||||
|
.slot-header .slot-lightest { color: var(--amber); font-size: 0.85rem; white-space: nowrap; }
|
||||||
|
.slot-header .chevron { color: var(--muted); font-size: 0.8rem; transition: transform 0.15s; }
|
||||||
|
.slot-card.open .chevron { transform: rotate(90deg); }
|
||||||
|
.required-badge {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
background: #2a2a2a;
|
||||||
|
border: 1px solid #555;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1px 5px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.key-badge {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
background: #1a3010;
|
||||||
|
border: 1px solid var(--key-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1px 5px;
|
||||||
|
color: #8fc87f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mod list inside slot */
|
||||||
|
.mod-list { display: none; border-top: 1px solid var(--border); }
|
||||||
|
.slot-card.open .mod-list { display: block; }
|
||||||
|
.mod-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-bottom: 1px solid #1a1a1a;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
.mod-row:last-child { border-bottom: none; }
|
||||||
|
.mod-row:hover { background: rgba(255,255,255,0.03); }
|
||||||
|
.mod-row img { width: 36px; height: 36px; object-fit: contain; background: #222; border-radius: 4px; flex-shrink: 0; }
|
||||||
|
.mod-name { flex: 1; }
|
||||||
|
.mod-name small { display: block; color: var(--muted); font-size: 0.78rem; }
|
||||||
|
.mod-weight { font-weight: bold; color: var(--amber); white-space: nowrap; min-width: 60px; text-align: right; }
|
||||||
|
.mod-weight.lightest { color: #8fc87f; }
|
||||||
|
.mod-wiki { font-size: 0.78rem; color: var(--muted); }
|
||||||
|
.no-mods { padding: 10px 12px; color: var(--muted); font-size: 0.85rem; font-style: italic; }
|
||||||
|
|
||||||
|
/* Toggle other slots */
|
||||||
|
.toggle-other {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--muted);
|
||||||
|
padding: 5px 14px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.toggle-other:hover { border-color: var(--accent); color: var(--accent); }
|
||||||
|
#other-slots { display: none; }
|
||||||
|
#other-slots.visible { display: block; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
<nav>
|
||||||
|
<a href="/loadout?tab=guns">← Back to Guns</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="gun-card">
|
||||||
|
{% if gun.grid_image_url %}
|
||||||
|
<img src="{{ gun.grid_image_url }}" alt="{{ gun.name }}">
|
||||||
|
{% endif %}
|
||||||
|
<div class="gun-name">
|
||||||
|
<h2>{{ gun.name }}</h2>
|
||||||
|
<div class="sub">
|
||||||
|
{{ gun.caliber or '?' }}
|
||||||
|
{% if gun.wiki_url %} <a href="{{ gun.wiki_url }}" target="_blank">wiki ↗</a>{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="gun-stats">
|
||||||
|
<div class="stat">
|
||||||
|
<span class="val">{{ "%.3f"|format(gun.weight_kg) if gun.weight_kg is not none else '?' }}</span>
|
||||||
|
<span class="lbl">Base weight (kg)</span>
|
||||||
|
</div>
|
||||||
|
{% if gun.ergonomics %}
|
||||||
|
<div class="stat">
|
||||||
|
<span class="val">{{ gun.ergonomics }}</span>
|
||||||
|
<span class="lbl">Ergonomics</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if gun.recoil_vertical %}
|
||||||
|
<div class="stat">
|
||||||
|
<span class="val">{{ gun.recoil_vertical }}</span>
|
||||||
|
<span class="lbl">Recoil (V)</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if gun.fire_rate %}
|
||||||
|
<div class="stat">
|
||||||
|
<span class="val">{{ gun.fire_rate }}</span>
|
||||||
|
<span class="lbl">Fire rate</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="total-bar">
|
||||||
|
<span class="lbl">Lightest possible build:</span>
|
||||||
|
<span class="big">{{ "%.3f"|format(lightest_total) }} kg</span>
|
||||||
|
<span class="breakdown">base {{ "%.3f"|format(gun.weight_kg or 0) }} kg + lightest mod per slot</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if key_slots %}
|
||||||
|
<div class="slot-section">
|
||||||
|
<div class="section-hdr">Key slots</div>
|
||||||
|
{% for slot in key_slots %}
|
||||||
|
{% set lightest = slot.mods[0] if slot.mods else none %}
|
||||||
|
<div class="slot-card key-slot {% if loop.first %}open{% endif %}" id="slot-{{ slot.slot_id }}">
|
||||||
|
<div class="slot-header" onclick="toggleSlot('slot-{{ slot.slot_id }}')">
|
||||||
|
<span class="slot-name">{{ slot.slot_name }}</span>
|
||||||
|
<span class="key-badge">key slot</span>
|
||||||
|
{% if slot.required %}<span class="required-badge">required</span>{% endif %}
|
||||||
|
<span class="slot-count">{{ slot.mods | length }} mods</span>
|
||||||
|
<span class="slot-lightest">
|
||||||
|
{% if lightest and lightest.weight_kg is not none %}
|
||||||
|
lightest {{ "%.3f"|format(lightest.weight_kg) }} kg
|
||||||
|
{% else %}—{% endif %}
|
||||||
|
</span>
|
||||||
|
<span class="chevron">▶</span>
|
||||||
|
</div>
|
||||||
|
<div class="mod-list">
|
||||||
|
{% if slot.mods %}
|
||||||
|
{% for mod in slot.mods %}
|
||||||
|
<div class="mod-row">
|
||||||
|
{% if mod.grid_image_url %}
|
||||||
|
<img src="{{ mod.grid_image_url }}" loading="lazy" alt="">
|
||||||
|
{% else %}
|
||||||
|
<div style="width:36px;height:36px;background:#222;border-radius:4px;flex-shrink:0"></div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="mod-name">
|
||||||
|
{{ mod.mod_name }}
|
||||||
|
{% if mod.mod_short and mod.mod_short != mod.mod_name %}
|
||||||
|
<small>{{ mod.mod_short }}</small>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if mod.wiki_url %}
|
||||||
|
<a class="mod-wiki" href="{{ mod.wiki_url }}" target="_blank">wiki</a>
|
||||||
|
{% endif %}
|
||||||
|
<span class="mod-weight {% if loop.first %}lightest{% endif %}">
|
||||||
|
{% if mod.weight_kg is not none %}{{ "%.3f"|format(mod.weight_kg) }} kg{% else %}—{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="no-mods">No compatible mods found in database.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if other_slots %}
|
||||||
|
<button class="toggle-other" onclick="toggleOther(this)">Show {{ other_slots | length }} other slots ▼</button>
|
||||||
|
<div id="other-slots">
|
||||||
|
<div class="slot-section">
|
||||||
|
<div class="section-hdr">All other slots</div>
|
||||||
|
{% for slot in other_slots %}
|
||||||
|
{% set lightest = slot.mods[0] if slot.mods else none %}
|
||||||
|
<div class="slot-card" id="slot-{{ slot.slot_id }}">
|
||||||
|
<div class="slot-header" onclick="toggleSlot('slot-{{ slot.slot_id }}')">
|
||||||
|
<span class="slot-name">{{ slot.slot_name }}</span>
|
||||||
|
{% if slot.required %}<span class="required-badge">required</span>{% endif %}
|
||||||
|
<span class="slot-count">{{ slot.mods | length }} mods</span>
|
||||||
|
<span class="slot-lightest">
|
||||||
|
{% if lightest and lightest.weight_kg is not none %}
|
||||||
|
lightest {{ "%.3f"|format(lightest.weight_kg) }} kg
|
||||||
|
{% else %}—{% endif %}
|
||||||
|
</span>
|
||||||
|
<span class="chevron">▶</span>
|
||||||
|
</div>
|
||||||
|
<div class="mod-list">
|
||||||
|
{% if slot.mods %}
|
||||||
|
{% for mod in slot.mods %}
|
||||||
|
<div class="mod-row">
|
||||||
|
{% if mod.grid_image_url %}
|
||||||
|
<img src="{{ mod.grid_image_url }}" loading="lazy" alt="">
|
||||||
|
{% else %}
|
||||||
|
<div style="width:36px;height:36px;background:#222;border-radius:4px;flex-shrink:0"></div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="mod-name">
|
||||||
|
{{ mod.mod_name }}
|
||||||
|
{% if mod.mod_short and mod.mod_short != mod.mod_name %}
|
||||||
|
<small>{{ mod.mod_short }}</small>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if mod.wiki_url %}
|
||||||
|
<a class="mod-wiki" href="{{ mod.wiki_url }}" target="_blank">wiki</a>
|
||||||
|
{% endif %}
|
||||||
|
<span class="mod-weight {% if loop.first %}lightest{% endif %}">
|
||||||
|
{% if mod.weight_kg is not none %}{{ "%.3f"|format(mod.weight_kg) }} kg{% else %}—{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="no-mods">No compatible mods found in database.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function toggleSlot(id) {
|
||||||
|
document.getElementById(id).classList.toggle('open');
|
||||||
|
}
|
||||||
|
function toggleOther(btn) {
|
||||||
|
const div = document.getElementById('other-slots');
|
||||||
|
div.classList.toggle('visible');
|
||||||
|
btn.textContent = div.classList.contains('visible')
|
||||||
|
? 'Hide other slots ▲'
|
||||||
|
: 'Show {{ other_slots | length }} other slots ▼';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -168,7 +168,13 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<nav style="margin-bottom:12px"><a href="/collector">Collector Checklist →</a></nav>
|
<nav style="margin-bottom:12px">
|
||||||
|
<a href="/collector">Collector Checklist</a>
|
||||||
|
|
|
||||||
|
<a href="/quests">Quest Trees</a>
|
||||||
|
|
|
||||||
|
<a href="/loadout">Loadout Planner</a>
|
||||||
|
</nav>
|
||||||
<h1>OnlyScavs – Keys</h1>
|
<h1>OnlyScavs – Keys</h1>
|
||||||
|
|
||||||
<form method="get" class="filters">
|
<form method="get" class="filters">
|
||||||
|
|||||||
748
templates/loadout.html
Normal file
748
templates/loadout.html
Normal file
@@ -0,0 +1,748 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OnlyScavs – Loadout Planner</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #121212;
|
||||||
|
--panel: #1a1a1a;
|
||||||
|
--text: #eee;
|
||||||
|
--muted: #bbb;
|
||||||
|
--border: #333;
|
||||||
|
--accent: #9ccfff;
|
||||||
|
--amber: #ffd580;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
margin: 0;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.page { max-width: 1100px; margin: 0 auto; }
|
||||||
|
h1 { margin-bottom: 4px; }
|
||||||
|
nav { margin-bottom: 20px; }
|
||||||
|
nav a { color: var(--accent); font-size: 0.9rem; }
|
||||||
|
a { color: var(--accent); }
|
||||||
|
|
||||||
|
/* Tab bar */
|
||||||
|
.tab-bar {
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-bottom: 2px solid var(--border);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.tab-bar a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--muted);
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
margin-bottom: -2px;
|
||||||
|
}
|
||||||
|
.tab-bar a.active {
|
||||||
|
color: var(--accent);
|
||||||
|
border-bottom-color: var(--accent);
|
||||||
|
}
|
||||||
|
.tab-bar a:hover { color: var(--text); }
|
||||||
|
|
||||||
|
/* Filter bar */
|
||||||
|
.filter-bar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.filter-bar label { color: var(--muted); font-size: 0.9rem; }
|
||||||
|
.filter-bar select, .filter-bar input[type=number] {
|
||||||
|
background: #222;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
.filter-bar button {
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
.filter-bar button:hover { border-color: var(--accent); }
|
||||||
|
|
||||||
|
/* Slot filter checkboxes */
|
||||||
|
.slot-check {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
background: #222;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 3px 9px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.slot-check.active {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
.slot-check input { cursor: pointer; }
|
||||||
|
|
||||||
|
/* Gear table */
|
||||||
|
.gear-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
}
|
||||||
|
.gear-table th {
|
||||||
|
text-align: left;
|
||||||
|
padding: 6px 10px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.gear-table td {
|
||||||
|
padding: 7px 10px;
|
||||||
|
border-bottom: 1px solid #1e1e1e;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.gear-table tr:hover td { background: #1c1c1c; }
|
||||||
|
.gear-table img {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #222;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
.w { font-weight: bold; color: var(--amber); white-space: nowrap; }
|
||||||
|
.muted { color: var(--muted); }
|
||||||
|
.name-cell strong { display: block; }
|
||||||
|
.name-cell small { color: var(--muted); font-size: 0.8rem; }
|
||||||
|
|
||||||
|
/* Armor class badges */
|
||||||
|
.cls {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 2px 7px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: bold;
|
||||||
|
background: #2a2a2a;
|
||||||
|
border: 1px solid #444;
|
||||||
|
}
|
||||||
|
.cls-1, .cls-2 { border-color: #444; color: #aaa; }
|
||||||
|
.cls-3 { border-color: #5a7a3a; color: #8fc87f; }
|
||||||
|
.cls-4 { border-color: #3a6a8a; color: #7fc4e8; }
|
||||||
|
.cls-5 { border-color: #7a4a8a; color: #c090e0; }
|
||||||
|
.cls-6 { border-color: #8a4a3a; color: #e09070; }
|
||||||
|
|
||||||
|
/* Empty state */
|
||||||
|
.empty {
|
||||||
|
color: var(--muted);
|
||||||
|
padding: 28px 14px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build builder */
|
||||||
|
.builder-total {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px 24px;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.builder-total .big { font-size: 2rem; font-weight: bold; color: var(--amber); }
|
||||||
|
.builder-total .label { color: var(--muted); font-size: 0.9rem; }
|
||||||
|
.builder-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.slot-card {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
.slot-card h3 {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.07em;
|
||||||
|
}
|
||||||
|
.slot-card select {
|
||||||
|
width: 100%;
|
||||||
|
background: #222;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 5px 8px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
.slot-weight { margin-top: 6px; font-size: 0.85rem; color: var(--amber); min-height: 1.2em; }
|
||||||
|
.save-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||||
|
.save-row input[type=text] {
|
||||||
|
background: #222;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
.save-row button {
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 5px 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
.save-row button:hover { border-color: var(--accent); }
|
||||||
|
.save-status { color: var(--muted); font-size: 0.85rem; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
<nav>
|
||||||
|
<a href="/">← Keys</a> |
|
||||||
|
<a href="/collector">Collector</a>
|
||||||
|
</nav>
|
||||||
|
<h1>Loadout Planner</h1>
|
||||||
|
<p style="color:var(--muted);margin:0 0 16px;font-size:0.9rem;">
|
||||||
|
Find the lightest gear for each slot. Filter by requirements.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="tab-bar">
|
||||||
|
{% for t_id, t_label in [('guns','Guns'),('armor','Armor'),('helmets','Helmets'),('headwear','Headwear'),('backpacks','Backpacks'),('rigs','Rigs'),('builder','Build Builder')] %}
|
||||||
|
<a href="/loadout?tab={{ t_id }}" class="{% if tab == t_id %}active{% endif %}">{{ t_label }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# =============================== GUNS TAB =============================== #}
|
||||||
|
{% if tab == "guns" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="guns">
|
||||||
|
<span style="color:var(--muted);font-size:0.85rem;">Must have slot:</span>
|
||||||
|
{% for label, nameid in slot_filters %}
|
||||||
|
<label class="slot-check {% if nameid in requires %}active{% endif %}">
|
||||||
|
<input type="checkbox" name="requires" value="{{ nameid }}"
|
||||||
|
{% if nameid in requires %}checked{% endif %}>
|
||||||
|
{{ label }}
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
{% if requires %}<a href="/loadout?tab=guns" style="font-size:0.85rem;color:var(--muted)">clear</a>{% endif %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if requires %}
|
||||||
|
<p style="color:var(--muted);font-size:0.85rem;margin-bottom:12px;">
|
||||||
|
"Lightest build" = gun base weight + lightest compatible mod per required slot.
|
||||||
|
Guns without all required slots are hidden.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Caliber</th>
|
||||||
|
<th>Ergo</th>
|
||||||
|
<th title="Vertical recoil">Recoil</th>
|
||||||
|
<th>Base weight</th>
|
||||||
|
<th>{% if requires %}Lightest build{% else %}Slots{% endif %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for gun in guns %}
|
||||||
|
<tr class="gun-row" data-gun-id="{{ gun.id }}" onclick="toggleGunRow(this)" style="cursor:pointer">
|
||||||
|
<td>
|
||||||
|
{% if gun.grid_image_url %}
|
||||||
|
<img src="{{ gun.grid_image_url }}" loading="lazy" alt="">
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ gun.short_name or gun.name }}</strong>
|
||||||
|
{% if gun.short_name and gun.short_name != gun.name %}
|
||||||
|
<small>{{ gun.name }}</small>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ gun.caliber or '—' }}</td>
|
||||||
|
<td class="muted">{{ gun.ergonomics or '—' }}</td>
|
||||||
|
<td class="muted">{{ gun.recoil_vertical or '—' }}</td>
|
||||||
|
<td class="w">
|
||||||
|
{% if gun.weight_kg is not none %}{{ "%.3f"|format(gun.weight_kg) }} kg{% else %}—{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if requires %}
|
||||||
|
<span class="w">{% if gun.lightest_build_weight is not none %}{{ "%.3f"|format(gun.lightest_build_weight) }} kg{% else %}—{% endif %}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="muted" style="font-size:0.8rem">▶ expand</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="gun-expand-row" id="expand-{{ gun.id }}" style="display:none">
|
||||||
|
<td colspan="7" style="padding:0">
|
||||||
|
<div class="gun-expand-inner" style="padding:10px 14px;background:#151515;border-bottom:1px solid var(--border)">
|
||||||
|
<div class="expand-loading" style="color:var(--muted);font-size:0.85rem">Loading slots…</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="7" class="empty">No guns found matching those requirements.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.gun-row:hover td { background: #1c1c1c; }
|
||||||
|
.gun-row.expanded td { background: #181818; }
|
||||||
|
.slot-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
|
||||||
|
.slot-pill {
|
||||||
|
display: flex; flex-direction: column;
|
||||||
|
background: #1e1e1e; border: 1px solid var(--border);
|
||||||
|
border-radius: 6px; padding: 5px 10px; font-size: 0.8rem; min-width: 110px;
|
||||||
|
}
|
||||||
|
.slot-pill.key { border-color: #5a7a3a; background: #141e10; }
|
||||||
|
.slot-pill .sp-name { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
|
||||||
|
.slot-pill .sp-mod { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
|
||||||
|
.slot-pill .sp-w { color: var(--amber); font-size: 0.82rem; font-weight: bold; margin-top: 2px; }
|
||||||
|
.expand-footer { display: flex; align-items: center; gap: 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #222; }
|
||||||
|
.expand-total { color: var(--amber); font-weight: bold; font-size: 0.9rem; }
|
||||||
|
.expand-link { font-size: 0.82rem; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const _gunSlotCache = {};
|
||||||
|
|
||||||
|
function toggleGunRow(tr) {
|
||||||
|
const gunId = tr.dataset.gunId;
|
||||||
|
const expandRow = document.getElementById('expand-' + gunId);
|
||||||
|
const isOpen = expandRow.style.display !== 'none';
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
expandRow.style.display = 'none';
|
||||||
|
tr.classList.remove('expanded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.classList.add('expanded');
|
||||||
|
expandRow.style.display = '';
|
||||||
|
|
||||||
|
if (_gunSlotCache[gunId]) {
|
||||||
|
renderGunExpand(gunId, _gunSlotCache[gunId]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch('/loadout/gun/' + gunId + '/slots.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
_gunSlotCache[gunId] = data;
|
||||||
|
renderGunExpand(gunId, data);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
const inner = expandRow.querySelector('.gun-expand-inner');
|
||||||
|
inner.innerHTML = '<span style="color:var(--muted)">Failed to load slots.</span>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderGunExpand(gunId, slots) {
|
||||||
|
const inner = document.getElementById('expand-' + gunId).querySelector('.gun-expand-inner');
|
||||||
|
if (!slots.length) {
|
||||||
|
inner.innerHTML = '<span style="color:var(--muted);font-size:0.85rem">No slot data available for this gun.</span>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const KEY = new Set(['mod_muzzle', 'mod_magazine']);
|
||||||
|
let baseWeight = 0;
|
||||||
|
const baseCell = document.querySelector('[data-gun-id="' + gunId + '"] td:nth-child(6)');
|
||||||
|
if (baseCell) baseWeight = parseFloat(baseCell.textContent) || 0;
|
||||||
|
|
||||||
|
let total = baseWeight;
|
||||||
|
let pills = '';
|
||||||
|
for (const s of slots) {
|
||||||
|
const isKey = KEY.has(s.slot_nameid);
|
||||||
|
const w = s.weight_kg != null ? s.weight_kg.toFixed(3) + ' kg' : '—';
|
||||||
|
if (s.weight_kg != null) total += s.weight_kg;
|
||||||
|
pills += `<div class="slot-pill${isKey ? ' key' : ''}">
|
||||||
|
<span class="sp-name">${s.slot_name}</span>
|
||||||
|
<span class="sp-mod">${s.mod_name || '—'}</span>
|
||||||
|
<span class="sp-w">${w}</span>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
inner.innerHTML = `
|
||||||
|
<div class="slot-summary">${pills}</div>
|
||||||
|
<div class="expand-footer">
|
||||||
|
<span class="expand-total">Lightest build: ${total.toFixed(3)} kg</span>
|
||||||
|
<a class="expand-link" href="/loadout/gun/${gunId}">Full breakdown →</a>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== ARMOR TAB =============================== #}
|
||||||
|
{% if tab == "armor" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="armor">
|
||||||
|
<label>Min class</label>
|
||||||
|
<select name="min_class">
|
||||||
|
<option value="0" {% if min_class==0 %}selected{% endif %}>Any</option>
|
||||||
|
{% for c in range(1,7) %}
|
||||||
|
<option value="{{ c }}" {% if min_class==c %}selected{% endif %}>Class {{ c }}+</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="class_desc" {% if sort=='class_desc' %}selected{% endif %}>Class ↓</option>
|
||||||
|
<option value="class_asc" {% if sort=='class_asc' %}selected{% endif %}>Class ↑</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
</form>
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th><th>Name</th><th>Class</th>
|
||||||
|
<th>Durability</th><th>Material</th><th>Zones</th><th>Weight</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in armor %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if item.grid_image_url %}<img src="{{ item.grid_image_url }}" loading="lazy" alt="">{% endif %}</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ item.short_name or item.name }}</strong>
|
||||||
|
{% if item.short_name and item.short_name != item.name %}<small>{{ item.name }}</small>{% endif %}
|
||||||
|
{% if item.wiki_url %}<a href="{{ item.wiki_url }}" target="_blank" style="font-size:0.78rem;margin-left:4px">wiki</a>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if item.armor_class %}
|
||||||
|
<span class="cls cls-{{ item.armor_class }}">{{ item.armor_class }}</span>
|
||||||
|
{% else %}—{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ item.durability | int if item.durability else '—' }}</td>
|
||||||
|
<td class="muted">{{ item.material or '—' }}</td>
|
||||||
|
<td class="muted" style="font-size:0.8rem">{{ item.zones or '—' }}</td>
|
||||||
|
<td class="w">{% if item.weight_kg is not none %}{{ "%.3f"|format(item.weight_kg) }} kg{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="7" class="empty">No armor found.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== HELMETS TAB =============================== #}
|
||||||
|
{% if tab == "helmets" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="helmets">
|
||||||
|
<label>Min class</label>
|
||||||
|
<select name="min_class">
|
||||||
|
<option value="0" {% if min_class==0 %}selected{% endif %}>Any</option>
|
||||||
|
{% for c in range(1,7) %}
|
||||||
|
<option value="{{ c }}" {% if min_class==c %}selected{% endif %}>Class {{ c }}+</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="class_desc" {% if sort=='class_desc' %}selected{% endif %}>Class ↓</option>
|
||||||
|
<option value="class_asc" {% if sort=='class_asc' %}selected{% endif %}>Class ↑</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
</form>
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th><th>Name</th><th>Class</th>
|
||||||
|
<th>Durability</th><th>Head zones</th><th>Deafening</th><th>Weight</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in helmets %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if item.grid_image_url %}<img src="{{ item.grid_image_url }}" loading="lazy" alt="">{% endif %}</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ item.short_name or item.name }}</strong>
|
||||||
|
{% if item.short_name and item.short_name != item.name %}<small>{{ item.name }}</small>{% endif %}
|
||||||
|
{% if item.wiki_url %}<a href="{{ item.wiki_url }}" target="_blank" style="font-size:0.78rem;margin-left:4px">wiki</a>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if item.armor_class %}
|
||||||
|
<span class="cls cls-{{ item.armor_class }}">{{ item.armor_class }}</span>
|
||||||
|
{% else %}<span class="muted">—</span>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ item.durability | int if item.durability else '—' }}</td>
|
||||||
|
<td class="muted" style="font-size:0.8rem">{{ item.head_zones or '—' }}</td>
|
||||||
|
<td class="muted">{{ item.deafening or '—' }}</td>
|
||||||
|
<td class="w">{% if item.weight_kg is not none %}{{ "%.3f"|format(item.weight_kg) }} kg{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="7" class="empty">No helmets found.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== HEADWEAR TAB =============================== #}
|
||||||
|
{% if tab == "headwear" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="headwear">
|
||||||
|
<label>Min class</label>
|
||||||
|
<select name="min_class">
|
||||||
|
<option value="0" {% if min_class==0 %}selected{% endif %}>Any</option>
|
||||||
|
{% for c in range(1,7) %}
|
||||||
|
<option value="{{ c }}" {% if min_class==c %}selected{% endif %}>Class {{ c }}+</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="class_desc" {% if sort=='class_desc' %}selected{% endif %}>Class ↓</option>
|
||||||
|
<option value="class_asc" {% if sort=='class_asc' %}selected{% endif %}>Class ↑</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
</form>
|
||||||
|
<p style="color:var(--muted);font-size:0.85rem;margin-bottom:12px;">Face masks, armored masks, and non-helmet head protection. Does not cover the top of the head.</p>
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th><th>Name</th><th>Class</th>
|
||||||
|
<th>Durability</th><th>Head zones</th><th>Weight</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in headwear %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if item.grid_image_url %}<img src="{{ item.grid_image_url }}" loading="lazy" alt="">{% endif %}</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ item.short_name or item.name }}</strong>
|
||||||
|
{% if item.short_name and item.short_name != item.name %}<small>{{ item.name }}</small>{% endif %}
|
||||||
|
{% if item.wiki_url %}<a href="{{ item.wiki_url }}" target="_blank" style="font-size:0.78rem;margin-left:4px">wiki</a>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if item.armor_class %}
|
||||||
|
<span class="cls cls-{{ item.armor_class }}">{{ item.armor_class }}</span>
|
||||||
|
{% else %}<span class="muted">—</span>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ item.durability | int if item.durability else '—' }}</td>
|
||||||
|
<td class="muted" style="font-size:0.8rem">{{ item.head_zones or '—' }}</td>
|
||||||
|
<td class="w">{% if item.weight_kg is not none %}{{ "%.3f"|format(item.weight_kg) }} kg{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="6" class="empty">No headwear found.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== BACKPACKS TAB =============================== #}
|
||||||
|
{% if tab == "backpacks" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="backpacks">
|
||||||
|
<label>Min slots</label>
|
||||||
|
<input type="number" name="min_capacity" value="{{ min_capacity or '' }}" min="0" placeholder="0" style="width:60px">
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="capacity_desc" {% if sort=='capacity_desc' %}selected{% endif %}>Capacity ↓</option>
|
||||||
|
<option value="capacity_asc" {% if sort=='capacity_asc' %}selected{% endif %}>Capacity ↑</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
</form>
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th><th>Name</th><th>Capacity (slots)</th><th>Weight</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in backpacks %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if item.grid_image_url %}<img src="{{ item.grid_image_url }}" loading="lazy" alt="">{% endif %}</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ item.short_name or item.name }}</strong>
|
||||||
|
{% if item.short_name and item.short_name != item.name %}<small>{{ item.name }}</small>{% endif %}
|
||||||
|
{% if item.wiki_url %}<a href="{{ item.wiki_url }}" target="_blank" style="font-size:0.78rem;margin-left:4px">wiki</a>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ item.capacity or '—' }}</td>
|
||||||
|
<td class="w">{% if item.weight_kg is not none %}{{ "%.3f"|format(item.weight_kg) }} kg{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="4" class="empty">No backpacks found.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== RIGS TAB =============================== #}
|
||||||
|
{% if tab == "rigs" %}
|
||||||
|
<form method="get" class="filter-bar">
|
||||||
|
<input type="hidden" name="tab" value="rigs">
|
||||||
|
<label>Min slots</label>
|
||||||
|
<input type="number" name="min_capacity" value="{{ min_capacity or '' }}" min="0" placeholder="0" style="width:60px">
|
||||||
|
<label>Min class</label>
|
||||||
|
<select name="min_class">
|
||||||
|
<option value="0" {% if min_class==0 %}selected{% endif %}>Any</option>
|
||||||
|
{% for c in range(1,7) %}
|
||||||
|
<option value="{{ c }}" {% if min_class==c %}selected{% endif %}>Class {{ c }}+</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<label>Sort</label>
|
||||||
|
<select name="sort">
|
||||||
|
<option value="weight_asc" {% if sort=='weight_asc' %}selected{% endif %}>Weight ↑</option>
|
||||||
|
<option value="weight_desc" {% if sort=='weight_desc' %}selected{% endif %}>Weight ↓</option>
|
||||||
|
<option value="capacity_desc" {% if sort=='capacity_desc' %}selected{% endif %}>Capacity ↓</option>
|
||||||
|
<option value="class_desc" {% if sort=='class_desc' %}selected{% endif %}>Class ↓</option>
|
||||||
|
<option value="name_asc" {% if sort=='name_asc' %}selected{% endif %}>Name A→Z</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Filter</button>
|
||||||
|
</form>
|
||||||
|
<table class="gear-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th><th>Name</th><th>Class</th><th>Capacity (slots)</th><th>Zones</th><th>Weight</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in rigs %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if item.grid_image_url %}<img src="{{ item.grid_image_url }}" loading="lazy" alt="">{% endif %}</td>
|
||||||
|
<td class="name-cell">
|
||||||
|
<strong>{{ item.short_name or item.name }}</strong>
|
||||||
|
{% if item.short_name and item.short_name != item.name %}<small>{{ item.name }}</small>{% endif %}
|
||||||
|
{% if item.wiki_url %}<a href="{{ item.wiki_url }}" target="_blank" style="font-size:0.78rem;margin-left:4px">wiki</a>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if item.armor_class %}
|
||||||
|
<span class="cls cls-{{ item.armor_class }}">{{ item.armor_class }}</span>
|
||||||
|
{% else %}<span class="muted">—</span>{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="muted">{{ item.capacity or '—' }}</td>
|
||||||
|
<td class="muted" style="font-size:0.8rem">{{ item.zones or '—' }}</td>
|
||||||
|
<td class="w">{% if item.weight_kg is not none %}{{ "%.3f"|format(item.weight_kg) }} kg{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr><td colspan="6" class="empty">No rigs found.</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# =============================== BUILD BUILDER TAB =============================== #}
|
||||||
|
{% if tab == "builder" %}
|
||||||
|
<script>
|
||||||
|
const WEIGHTS = {
|
||||||
|
{% for item in builder_guns + builder_armor + builder_helmets + builder_rigs + builder_backpacks %}
|
||||||
|
"{{ item.id }}": {{ item.weight_kg if item.weight_kg is not none else 0 }},
|
||||||
|
{% endfor %}
|
||||||
|
};
|
||||||
|
|
||||||
|
function recalcWeight() {
|
||||||
|
const slots = ['gun', 'armor', 'helmet', 'rig', 'backpack'];
|
||||||
|
let total = 0;
|
||||||
|
for (const slot of slots) {
|
||||||
|
const sel = document.getElementById('slot_' + slot);
|
||||||
|
const id = sel ? sel.value : '';
|
||||||
|
const w = id ? (WEIGHTS[id] || 0) : 0;
|
||||||
|
const disp = document.getElementById('sw_' + slot);
|
||||||
|
if (disp) disp.textContent = id ? w.toFixed(3) + ' kg' : '';
|
||||||
|
total += w;
|
||||||
|
}
|
||||||
|
document.getElementById('total-weight').textContent = total.toFixed(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveBuild() {
|
||||||
|
const slots = ['gun', 'armor', 'helmet', 'rig', 'backpack'];
|
||||||
|
const payload = { name: document.getElementById('build-name').value.trim() || 'My Build' };
|
||||||
|
for (const s of slots) {
|
||||||
|
const sel = document.getElementById('slot_' + s);
|
||||||
|
payload[s + '_id'] = (sel && sel.value) ? sel.value : null;
|
||||||
|
}
|
||||||
|
fetch('/loadout/save-build', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(d => {
|
||||||
|
document.getElementById('save-status').textContent = 'Saved as "' + d.name + '" (build #' + d.build_id + ')';
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
document.getElementById('save-status').textContent = 'Error saving build.';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="builder-total">
|
||||||
|
<div class="label">Total loadout weight</div>
|
||||||
|
<div class="big"><span id="total-weight">0.000</span> kg</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="builder-grid">
|
||||||
|
{% set slot_defs = [
|
||||||
|
('gun', 'Primary Weapon', builder_guns),
|
||||||
|
('armor', 'Body Armor', builder_armor),
|
||||||
|
('helmet', 'Helmet', builder_helmets),
|
||||||
|
('rig', 'Chest Rig', builder_rigs),
|
||||||
|
('backpack', 'Backpack', builder_backpacks),
|
||||||
|
] %}
|
||||||
|
{% for slot_id, slot_label, items in slot_defs %}
|
||||||
|
<div class="slot-card">
|
||||||
|
<h3>{{ slot_label }}</h3>
|
||||||
|
<select id="slot_{{ slot_id }}" onchange="recalcWeight()">
|
||||||
|
<option value="">— None —</option>
|
||||||
|
{% for item in items %}
|
||||||
|
<option value="{{ item.id }}">
|
||||||
|
{{ item.name }}{% if item.weight_kg is not none %} ({{ "%.3f"|format(item.weight_kg) }} kg){% endif %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="slot-weight" id="sw_{{ slot_id }}"></div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="save-row">
|
||||||
|
<input type="text" id="build-name" placeholder="Build name…">
|
||||||
|
<button onclick="saveBuild()">Save Build</button>
|
||||||
|
<span class="save-status" id="save-status"></span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
244
templates/quests.html
Normal file
244
templates/quests.html
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OnlyScavs – Quest Trees</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #121212;
|
||||||
|
--panel: #1a1a1a;
|
||||||
|
--text: #eee;
|
||||||
|
--muted: #888;
|
||||||
|
--border: #2a2a2a;
|
||||||
|
--accent: #9ccfff;
|
||||||
|
--done-text: #6ec96e;
|
||||||
|
--done-bg: #1a2a1a;
|
||||||
|
--kappa: #f0c040;
|
||||||
|
}
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
margin: 0;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.page { max-width: 960px; margin: 0 auto; }
|
||||||
|
nav { margin-bottom: 16px; font-size: 0.9rem; }
|
||||||
|
nav a { color: var(--accent); }
|
||||||
|
h1 { margin: 0 0 4px; }
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.filter-btn {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid #444;
|
||||||
|
color: var(--text);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.filter-btn.active {
|
||||||
|
border-color: var(--kappa);
|
||||||
|
color: var(--kappa);
|
||||||
|
}
|
||||||
|
.legend {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--muted);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.legend span { display: flex; align-items: center; gap: 5px; }
|
||||||
|
|
||||||
|
/* Trader section */
|
||||||
|
.trader-section { margin-bottom: 8px; }
|
||||||
|
.trader-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 8px;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.trader-header:hover { border-color: #444; }
|
||||||
|
.trader-name {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.trader-counts { font-size: 0.8rem; color: var(--muted); }
|
||||||
|
.chevron { color: var(--muted); font-size: 0.8rem; transition: transform 0.15s; }
|
||||||
|
.trader-section.collapsed .chevron { transform: rotate(-90deg); }
|
||||||
|
.trader-body { padding: 6px 0 6px 8px; }
|
||||||
|
.trader-section.collapsed .trader-body { display: none; }
|
||||||
|
|
||||||
|
/* Tree nodes */
|
||||||
|
.tree-root { margin: 4px 0; }
|
||||||
|
.tree-children {
|
||||||
|
margin-left: 20px;
|
||||||
|
border-left: 1px solid var(--border);
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
.quest-node {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 5px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
|
.quest-node:hover { background: #1e1e1e; }
|
||||||
|
.quest-node.done .quest-label { text-decoration: line-through; color: var(--done-text); }
|
||||||
|
.quest-node.done { background: var(--done-bg); }
|
||||||
|
.quest-label { flex: 1; font-size: 0.9rem; }
|
||||||
|
.quest-label a { color: var(--accent); font-size: 0.75rem; margin-left: 6px; }
|
||||||
|
.kappa-star { color: var(--kappa); font-size: 0.75rem; flex-shrink: 0; }
|
||||||
|
.cross-trader {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--muted);
|
||||||
|
font-style: italic;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.toggle-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid #444;
|
||||||
|
color: var(--muted);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 2px 7px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.quest-node.done .toggle-btn {
|
||||||
|
border-color: #3a6a3a;
|
||||||
|
color: var(--done-text);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
<nav>
|
||||||
|
<a href="/">← Keys</a>
|
||||||
|
|
|
||||||
|
<a href="/collector">Collector Checklist</a>
|
||||||
|
</nav>
|
||||||
|
<h1>Quest Trees</h1>
|
||||||
|
|
||||||
|
<div class="toolbar">
|
||||||
|
<a class="filter-btn {% if not only_collector %}active{% endif %}" href="/quests">All quests</a>
|
||||||
|
<a class="filter-btn {% if only_collector %}active{% endif %}" href="/quests?collector=1">★ Collector only</a>
|
||||||
|
<div class="legend">
|
||||||
|
<span><span style="color:var(--kappa)">★</span> Required for Collector</span>
|
||||||
|
<span><span style="color:var(--done-text)">✓</span> Marked done</span>
|
||||||
|
<span><span style="color:var(--muted);font-style:italic">← Trader</span> Cross-trader dependency</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% macro render_node(qid, quest_by_id, children, visible, collector_prereqs) %}
|
||||||
|
{% set q = quest_by_id[qid] %}
|
||||||
|
{% set visible_kids = [] %}
|
||||||
|
{% for cid in children.get(qid, []) %}
|
||||||
|
{% if cid in visible %}{% set _ = visible_kids.append(cid) %}{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<div class="tree-root">
|
||||||
|
<div class="quest-node {% if q.done %}done{% endif %}"
|
||||||
|
id="qnode-{{ qid }}" data-id="{{ qid }}" data-done="{{ '1' if q.done else '0' }}">
|
||||||
|
{% if qid in collector_prereqs %}<span class="kappa-star" title="Required for Collector">★</span>{% endif %}
|
||||||
|
<span class="quest-label">
|
||||||
|
{{ q.name }}
|
||||||
|
{% if q.wiki_link %}<a href="{{ q.wiki_link }}" target="_blank">wiki</a>{% endif %}
|
||||||
|
</span>
|
||||||
|
<button class="toggle-btn" onclick="toggle(this)">
|
||||||
|
{{ '✓' if q.done else '○' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% if visible_kids %}
|
||||||
|
<div class="tree-children">
|
||||||
|
{% for cid in visible_kids %}
|
||||||
|
{% set child = quest_by_id[cid] %}
|
||||||
|
{% if child.trader != q.trader %}
|
||||||
|
<div class="quest-node {% if child.done %}done{% endif %}"
|
||||||
|
data-id="{{ cid }}" data-done="{{ '1' if child.done else '0' }}">
|
||||||
|
{% if cid in collector_prereqs %}<span class="kappa-star">★</span>{% endif %}
|
||||||
|
<span class="quest-label">
|
||||||
|
{{ child.name }}
|
||||||
|
{% if child.wiki_link %}<a href="{{ child.wiki_link }}" target="_blank">wiki</a>{% endif %}
|
||||||
|
</span>
|
||||||
|
<span class="cross-trader">← {{ child.trader }}</span>
|
||||||
|
<button class="toggle-btn" onclick="toggle(this)">{{ '✓' if child.done else '○' }}</button>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ render_node(cid, quest_by_id, children, visible, collector_prereqs) }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% for trader in traders %}
|
||||||
|
{% set roots = trader_roots[trader] %}
|
||||||
|
{% set total_trader = namespace(n=0) %}
|
||||||
|
{% set done_trader = namespace(n=0) %}
|
||||||
|
{# count visible quests for this trader #}
|
||||||
|
{% for qid in visible %}
|
||||||
|
{% if quest_by_id[qid].trader == trader %}
|
||||||
|
{% set total_trader.n = total_trader.n + 1 %}
|
||||||
|
{% if quest_by_id[qid].done %}{% set done_trader.n = done_trader.n + 1 %}{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<div class="trader-section" id="trader-{{ trader | replace(' ', '-') }}">
|
||||||
|
<div class="trader-header" onclick="toggleTrader(this)">
|
||||||
|
<span class="trader-name">{{ trader }}</span>
|
||||||
|
<span class="trader-counts">{{ done_trader.n }} / {{ total_trader.n }}</span>
|
||||||
|
<span class="chevron">▾</span>
|
||||||
|
</div>
|
||||||
|
<div class="trader-body">
|
||||||
|
{% for root_id in roots %}
|
||||||
|
{{ render_node(root_id, quest_by_id, children, visible, collector_prereqs) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleTrader(header) {
|
||||||
|
header.closest('.trader-section').classList.toggle('collapsed');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle(btn) {
|
||||||
|
const node = btn.closest('.quest-node');
|
||||||
|
const id = node.dataset.id;
|
||||||
|
const nowDone = node.dataset.done === '1' ? 0 : 1;
|
||||||
|
|
||||||
|
fetch('/collector/toggle', {
|
||||||
|
method: 'POST',
|
||||||
|
body: new URLSearchParams({ quest_id: id, done: nowDone })
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(() => {
|
||||||
|
// Update all nodes with this quest id (may appear as cross-trader duplicate)
|
||||||
|
document.querySelectorAll(`.quest-node[data-id="${id}"]`).forEach(n => {
|
||||||
|
n.dataset.done = nowDone;
|
||||||
|
const b = n.querySelector('.toggle-btn');
|
||||||
|
if (nowDone) { n.classList.add('done'); b.textContent = '✓'; }
|
||||||
|
else { n.classList.remove('done'); b.textContent = '○'; }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user