diff --git a/app.py b/app.py index 3f103ce..f519e2c 100644 --- a/app.py +++ b/app.py @@ -277,6 +277,29 @@ def quanah_clear_items(): return jsonify(store.payload()) +# Dimensional missions: checkmarks whose completion cascades along each chain. +@app.get("/api/quanah/missions") +def quanah_missions(): + from quanah import missions + + return jsonify(missions.payload()) + + +@app.put("/api/quanah/missions/") +def quanah_set_mission(identifier): + from quanah import missions + + body = request.get_json(silent=True) or {} + return jsonify(missions.set_done(identifier, body.get("done"))) + + +@app.delete("/api/quanah/missions/round") +def quanah_reset_round_missions(): + from quanah import missions + + return jsonify(missions.reset_round()) + + @app.post("/api/quanah/scan") def quanah_scan(): """Watch the game and capture every event item hovered, until /api/scan/cancel.""" diff --git a/src/quanah/data/missions.json b/src/quanah/data/missions.json new file mode 100644 index 0000000..3a56174 --- /dev/null +++ b/src/quanah/data/missions.json @@ -0,0 +1,719 @@ +{ + "_note": "Dimensional missions. Each chain is ordered: reaching a mission completes every one before it.", + "grades": [ + { + "grade": 1, + "points": 0 + }, + { + "grade": 2, + "points": 5000 + }, + { + "grade": 3, + "points": 10000 + }, + { + "grade": 4, + "points": 17500 + }, + { + "grade": 5, + "points": 25000 + } + ], + "groups": [ + { + "key": "inspector", + "name": "Inspector Level", + "type": "round", + "chains": [ + { + "key": "level", + "name": "Inspector level", + "missions": [ + { + "id": "level-5", + "label": "Lv. 5", + "points": 50 + }, + { + "id": "level-10", + "label": "Lv. 10", + "points": 50 + }, + { + "id": "level-15", + "label": "Lv. 15", + "points": 100 + }, + { + "id": "level-20", + "label": "Lv. 20", + "points": 200 + }, + { + "id": "level-25", + "label": "Lv. 25", + "points": 300 + }, + { + "id": "level-30", + "label": "Lv. 30", + "points": 400 + }, + { + "id": "level-35", + "label": "Lv. 35", + "points": 500 + }, + { + "id": "level-40", + "label": "Lv. 40", + "points": 600 + }, + { + "id": "level-45", + "label": "Lv. 45", + "points": 700 + }, + { + "id": "level-50", + "label": "Lv. 50", + "points": 800 + }, + { + "id": "level-55", + "label": "Lv. 55", + "points": 1000 + }, + { + "id": "level-60", + "label": "Lv. 60", + "points": 1200 + }, + { + "id": "level-65", + "label": "Lv. 65", + "points": 1400 + }, + { + "id": "level-70", + "label": "Lv. 70", + "points": 1600 + }, + { + "id": "level-75", + "label": "Lv. 75", + "points": 1800 + }, + { + "id": "level-80", + "label": "Lv. 80", + "points": 2000 + }, + { + "id": "level-85", + "label": "Lv. 85", + "points": 2000 + }, + { + "id": "level-90", + "label": "Lv. 90", + "points": 2000 + }, + { + "id": "level-95", + "label": "Lv. 95", + "points": 2000 + }, + { + "id": "level-100", + "label": "Lv. 100", + "points": 2000 + } + ] + } + ] + }, + { + "key": "battlesim", + "name": "Infinite Dungeon: Battlesim", + "type": "round", + "chains": [ + { + "key": "floor", + "name": "Battlesim floor", + "missions": [ + { + "id": "floor-5", + "label": "Floor 5", + "points": 100 + }, + { + "id": "floor-10", + "label": "Floor 10", + "points": 200 + }, + { + "id": "floor-15", + "label": "Floor 15", + "points": 300 + }, + { + "id": "floor-20", + "label": "Floor 20", + "points": 400 + }, + { + "id": "floor-25", + "label": "Floor 25", + "points": 500 + }, + { + "id": "floor-30", + "label": "Floor 30", + "points": 600 + }, + { + "id": "floor-35", + "label": "Floor 35", + "points": 700 + }, + { + "id": "floor-40", + "label": "Floor 40", + "points": 800 + }, + { + "id": "floor-45", + "label": "Floor 45", + "points": 900 + }, + { + "id": "floor-50", + "label": "Floor 50", + "points": 1000 + }, + { + "id": "floor-55", + "label": "Floor 55", + "points": 1100 + }, + { + "id": "floor-60", + "label": "Floor 60", + "points": 1200 + }, + { + "id": "floor-65", + "label": "Floor 65", + "points": 1300 + }, + { + "id": "floor-70", + "label": "Floor 70", + "points": 1400 + }, + { + "id": "floor-75", + "label": "Floor 75", + "points": 1500 + }, + { + "id": "floor-80", + "label": "Floor 80", + "points": 1600 + }, + { + "id": "floor-85", + "label": "Floor 85", + "points": 1700 + }, + { + "id": "floor-90", + "label": "Floor 90", + "points": 1800 + }, + { + "id": "floor-95", + "label": "Floor 95", + "points": 1900 + }, + { + "id": "floor-100", + "label": "Floor 100", + "points": 2000 + }, + { + "id": "floor-105", + "label": "Floor 105", + "points": 2000 + }, + { + "id": "floor-110", + "label": "Floor 110", + "points": 2000 + }, + { + "id": "floor-115", + "label": "Floor 115", + "points": 2000 + }, + { + "id": "floor-120", + "label": "Floor 120", + "points": 2000 + }, + { + "id": "floor-125", + "label": "Floor 125", + "points": 2000 + }, + { + "id": "floor-130", + "label": "Floor 130", + "points": 2000 + }, + { + "id": "floor-135", + "label": "Floor 135", + "points": 2000 + }, + { + "id": "floor-140", + "label": "Floor 140", + "points": 2000 + }, + { + "id": "floor-145", + "label": "Floor 145", + "points": 2000 + }, + { + "id": "floor-150", + "label": "Floor 150", + "points": 2000 + } + ] + } + ] + }, + { + "key": "bosses", + "name": "Bosses", + "type": "permanent", + "chains": [ + { + "key": "lotus", + "name": "Lotus", + "missions": [ + { + "id": "boss-lotus-normal", + "label": "Normal", + "points": 50 + }, + { + "id": "boss-lotus-hard", + "label": "Hard", + "points": 250 + }, + { + "id": "boss-lotus-extreme", + "label": "Extreme", + "points": 1300 + } + ] + }, + { + "key": "damien", + "name": "Damien", + "missions": [ + { + "id": "boss-damien-normal", + "label": "Normal", + "points": 50 + }, + { + "id": "boss-damien-hard", + "label": "Hard", + "points": 250 + } + ] + }, + { + "key": "guardian-angel-slime", + "name": "Guardian Angel Slime", + "missions": [ + { + "id": "boss-guardian-angel-slime-normal", + "label": "Normal", + "points": 100 + }, + { + "id": "boss-guardian-angel-slime-chaos", + "label": "Chaos", + "points": 400 + } + ] + }, + { + "key": "lucid", + "name": "Lucid", + "missions": [ + { + "id": "boss-lucid-easy", + "label": "Easy", + "points": 100 + }, + { + "id": "boss-lucid-normal", + "label": "Normal", + "points": 150 + }, + { + "id": "boss-lucid-hard", + "label": "Hard", + "points": 300 + } + ] + }, + { + "key": "will", + "name": "Will", + "missions": [ + { + "id": "boss-will-easy", + "label": "Easy", + "points": 150 + }, + { + "id": "boss-will-normal", + "label": "Normal", + "points": 200 + }, + { + "id": "boss-will-hard", + "label": "Hard", + "points": 400 + } + ] + }, + { + "key": "gloom", + "name": "Gloom", + "missions": [ + { + "id": "boss-gloom-normal", + "label": "Normal", + "points": 200 + }, + { + "id": "boss-gloom-chaos", + "label": "Chaos", + "points": 400 + } + ] + }, + { + "key": "darknell", + "name": "Darknell", + "missions": [ + { + "id": "boss-darknell-normal", + "label": "Normal", + "points": 200 + }, + { + "id": "boss-darknell-hard", + "label": "Hard", + "points": 500 + } + ] + }, + { + "key": "verus-hilla", + "name": "Verus Hilla", + "missions": [ + { + "id": "boss-verus-hilla-normal", + "label": "Normal", + "points": 300 + }, + { + "id": "boss-verus-hilla-hard", + "label": "Hard", + "points": 500 + } + ] + }, + { + "key": "chosen-seren", + "name": "Chosen Seren", + "missions": [ + { + "id": "boss-chosen-seren-normal", + "label": "Normal", + "points": 600 + }, + { + "id": "boss-chosen-seren-hard", + "label": "Hard", + "points": 800 + }, + { + "id": "boss-chosen-seren-extreme", + "label": "Extreme", + "points": 2000 + } + ] + }, + { + "key": "kalos-the-guardian", + "name": "Kalos the Guardian", + "missions": [ + { + "id": "boss-kalos-the-guardian-easy", + "label": "Easy", + "points": 800 + }, + { + "id": "boss-kalos-the-guardian-normal", + "label": "Normal", + "points": 1000 + }, + { + "id": "boss-kalos-the-guardian-chaos", + "label": "Chaos", + "points": 2000 + }, + { + "id": "boss-kalos-the-guardian-extreme", + "label": "Extreme", + "points": 2000 + } + ] + }, + { + "key": "first-adversary", + "name": "First Adversary", + "missions": [ + { + "id": "boss-first-adversary-easy", + "label": "Easy", + "points": 800 + }, + { + "id": "boss-first-adversary-normal", + "label": "Normal", + "points": 1000 + }, + { + "id": "boss-first-adversary-hard", + "label": "Hard", + "points": 2000 + }, + { + "id": "boss-first-adversary-extreme", + "label": "Extreme", + "points": 2000 + } + ] + }, + { + "key": "kaling", + "name": "Kaling", + "missions": [ + { + "id": "boss-kaling-easy", + "label": "Easy", + "points": 1000 + }, + { + "id": "boss-kaling-normal", + "label": "Normal", + "points": 1600 + }, + { + "id": "boss-kaling-hard", + "label": "Hard", + "points": 2000 + } + ] + }, + { + "key": "malefic-star", + "name": "Malefic Star", + "missions": [ + { + "id": "boss-malefic-star-normal", + "label": "Normal", + "points": 1300 + }, + { + "id": "boss-malefic-star-hard", + "label": "Hard", + "points": 2000 + } + ] + }, + { + "key": "limbo", + "name": "Limbo", + "missions": [ + { + "id": "boss-limbo-normal", + "label": "Normal", + "points": 2000 + }, + { + "id": "boss-limbo-hard", + "label": "Hard", + "points": 2000 + } + ] + }, + { + "key": "baldrix", + "name": "Baldrix", + "missions": [ + { + "id": "boss-baldrix-normal", + "label": "Normal", + "points": 2000 + }, + { + "id": "boss-baldrix-hard", + "label": "Hard", + "points": 2000 + } + ] + }, + { + "key": "jupiter", + "name": "Jupiter", + "missions": [ + { + "id": "boss-jupiter-normal", + "label": "Normal", + "points": 2000 + } + ] + } + ] + }, + { + "key": "starforce", + "name": "Star Force", + "type": "permanent", + "chains": [ + { + "key": "starforce", + "name": "Star Force", + "missions": [ + { + "id": "sf-5", + "label": "5★", + "points": 50 + }, + { + "id": "sf-8", + "label": "8★", + "points": 50 + }, + { + "id": "sf-10", + "label": "10★", + "points": 100 + }, + { + "id": "sf-12", + "label": "12★", + "points": 100 + }, + { + "id": "sf-15", + "label": "15★", + "points": 150 + }, + { + "id": "sf-16", + "label": "16★", + "points": 150 + }, + { + "id": "sf-17", + "label": "17★", + "points": 150 + }, + { + "id": "sf-18", + "label": "18★", + "points": 200 + }, + { + "id": "sf-19", + "label": "19★", + "points": 200 + }, + { + "id": "sf-20", + "label": "20★", + "points": 300 + }, + { + "id": "sf-21", + "label": "21★", + "points": 400 + }, + { + "id": "sf-22", + "label": "22★", + "points": 600 + }, + { + "id": "sf-23", + "label": "23★", + "points": 900 + }, + { + "id": "sf-24", + "label": "24★", + "points": 1200 + }, + { + "id": "sf-25", + "label": "25★", + "points": 1200 + }, + { + "id": "sf-26", + "label": "26★", + "points": 1200 + }, + { + "id": "sf-27", + "label": "27★", + "points": 1500 + }, + { + "id": "sf-28", + "label": "28★", + "points": 1800 + }, + { + "id": "sf-29", + "label": "29★", + "points": 2000 + }, + { + "id": "sf-30", + "label": "30★", + "points": 2000 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/quanah/missions.py b/src/quanah/missions.py new file mode 100644 index 0000000..741ef9a --- /dev/null +++ b/src/quanah/missions.py @@ -0,0 +1,128 @@ +"""Dimensional mission progress: which missions are complete, their points and the grade. + +One global list, like the Quanah pieces. Missions sit in ordered chains (inspector +levels, Battlesim floors, each boss's difficulties, star force levels): completing a +mission completes every one before it in its chain, and undoing one undoes every +one after it, so a chain never has gaps. Round missions reset when the character +dies; permanent missions are kept. +""" + +import json +import os +import tempfile +import threading +from functools import lru_cache +from pathlib import Path + +from utils.payload_data import read_payload_json + +PATH = Path("configs/quanah_missions.json") + + +def _backup_path(): + """Where a damaged save is kept; follows PATH, which tests move.""" + return PATH.with_suffix(".damaged.json") + +lock = threading.RLock() + + +@lru_cache(maxsize=1) +def catalog(): + return read_payload_json("src/quanah/data/missions.json") + + +@lru_cache(maxsize=1) +def _index(): + """Each mission id -> (group type, its chain's ids in order, its place in the chain).""" + index = {} + for group in catalog()["groups"]: + for chain in group["chains"]: + ids = [m["id"] for m in chain["missions"]] + for place, identifier in enumerate(ids): + index[identifier] = (group["type"], ids, place) + return index + + +def _points(): + return {m["id"]: m["points"] for g in catalog()["groups"] for c in g["chains"] for m in c["missions"]} + + +def read(): + """The ids of completed missions, in catalog order; unknown ids are dropped.""" + with lock: + if not PATH.exists(): + return [] + # A file that can't be opened right now (e.g. held by antivirus) raises, so the request + # fails rather than saving over real progress. + text = PATH.read_text(encoding="utf-8") + try: + data = json.loads(text) + except ValueError: + data = None + if not (isinstance(data, dict) and isinstance(data.get("done"), list)): + # Damaged: keep a copy to recover from, then start over instead of failing every request. + _backup_path().write_text(text, encoding="utf-8") + PATH.unlink() + return [] + done = {i for i in data["done"] if isinstance(i, str)} + return [i for i in _index() if i in done] + + +def _write(done): + PATH.parent.mkdir(parents=True, exist_ok=True) + fd, name = tempfile.mkstemp(dir=PATH.parent, suffix=".tmp") + try: + with os.fdopen(fd, "w", encoding="utf-8") as stream: + json.dump({"done": done}, stream) + os.replace(name, PATH) + finally: + if os.path.exists(name): + os.unlink(name) + + +def cascade(done, identifier, complete): + """DONE (a set of ids) after marking IDENTIFIER complete or not, cascading along its chain.""" + if identifier not in _index(): + raise ValueError("Unknown mission") + _, ids, place = _index()[identifier] + return set(done) | set(ids[: place + 1]) if complete else set(done) - set(ids[place:]) + + +def set_done(identifier, complete): + if not isinstance(complete, bool): + raise ValueError("done must be true or false") + with lock: + done = cascade(read(), identifier, complete) + _write([i for i in _index() if i in done]) + return payload() + + +def reset_round(): + """Clear every round mission, as when the character dies; permanent missions stay.""" + with lock: + _write([i for i in read() if _index()[i][0] != "round"]) + return payload() + + +def summary(done): + points, index = _points(), _index() + total = sum(points[i] for i in done) + permanent = sum(points[i] for i in done if index[i][0] == "permanent") + grades = catalog()["grades"] + grade = max((g for g in grades if total >= g["points"]), key=lambda g: g["points"]) + upcoming = [g for g in grades if g["points"] > total] + return { + "points": total, + "permanent": permanent, + "round": total - permanent, + "grade": grade["grade"], + "next": upcoming[0] if upcoming else None, + "completed": len(done), + "total": len(index), + "max_points": sum(points.values()), + } + + +def payload(): + done = read() + return {"catalog": catalog(), "done": done, "summary": summary(done)} diff --git a/tests/js/quanah-missions.test.cjs b/tests/js/quanah-missions.test.cjs new file mode 100644 index 0000000..16b9312 --- /dev/null +++ b/tests/js/quanah-missions.test.cjs @@ -0,0 +1,40 @@ +const {test}=require('node:test'); +const assert=require('node:assert/strict'); +const fs=require('node:fs'); +const path=require('node:path'); + +const catalog=JSON.parse(fs.readFileSync(path.join(__dirname,'../../src/quanah/data/missions.json'),'utf8')); +const model=(done=[],summary={})=>({catalog,done,summary:{points:0,permanent:0,round:0,grade:1,next:{grade:2,points:5000},completed:done.length,total:110,max_points:114650,...summary}}); + +test('summary shows grade, progress to the next, completed count and permanent points',async()=>{ + const {renderSummary}=await import('../../web/pages/quanah-missions.js'); + const html=renderSummary(model(['sf-5','sf-8'],{points:7500,permanent:2500,round:5000,grade:2,next:{grade:3,points:10000},completed:2})); + assert.match(html,/2<\/strong>/); + assert.match(html,/2,500 pts to Grade 3/); + assert.match(html,/aria-valuenow="50"/); + assert.match(html,/Missions completed<\/dt>
2 \/ 110/); + assert.match(html,/Permanent points<\/dt>
2,500/); + assert.doesNotMatch(html,/data-act="reset-round" disabled/); +}); + +test('top grade says so, and reset is off with no round points',async()=>{ + const {renderSummary}=await import('../../web/pages/quanah-missions.js'); + const html=renderSummary(model([],{points:30000,grade:5,next:null})); + assert.match(html,/Highest grade reached/); + assert.match(html,/aria-valuenow="100"/); + assert.match(html,/data-act="reset-round" disabled/); +}); + +test('groups render a checkmark per mission; bosses get a row each',async()=>{ + const {renderGroup}=await import('../../web/pages/quanah-missions.js'); + const [inspector,,bosses]=catalog.groups; + const html=renderGroup(inspector,['level-5','level-10']); + assert.equal((html.match(/type="checkbox"/g)||[]).length,20); + assert.equal((html.match(/ checked/g)||[]).length,2); + assert.match(html,/2\/20 · 100 \/ 20,700 pts/); + assert.match(html,/>Round/g)||[]).length,16); + assert.match(boss,/Kalos the Guardian<\/span>(.*?Easy.*?Normal.*?Chaos.*?Extreme)/); + assert.match(boss,/>PermanentNumber(n).toLocaleString('en-US'); +const TYPE={round:'Round',permanent:'Permanent'}; + +export function renderSummary(model){ + const s=model.summary,next=s.next; + const floor=model.catalog.grades.find(g=>g.grade===s.grade).points; + const pct=next?Math.round((s.points-floor)/(next.points-floor)*100):100; + return `
+
Dimensional grade${s.grade} +
+ ${next?`${fmt(next.points-s.points)} pts to Grade ${next.grade}`:'Highest grade reached'}
+
+
Total points
${fmt(s.points)}
+
Missions completed
${s.completed} / ${s.total}
+
Permanent points
${fmt(s.permanent)}
+
Round points
${fmt(s.round)}
+
+ +
`; +} + +const box=(m,on)=>``; + +export function renderGroup(group,done){ + const set=new Set(done),missions=group.chains.flatMap(c=>c.missions); + const finished=missions.filter(m=>set.has(m.id)); + const points=finished.reduce((a,m)=>a+m.points,0),max=missions.reduce((a,m)=>a+m.points,0); + // A single chain is a grid of checkmarks; bosses get a row each. + const body=group.chains.length===1 + ?`
${missions.map(m=>box(m,set.has(m.id))).join('')}
` + :`
    ${group.chains.map(c=>`
  • ${esc(c.name)}${c.missions.map(m=>box(m,set.has(m.id))).join('')}
  • `).join('')}
`; + return `
+

${esc(group.name)} ${TYPE[group.type]}

${finished.length}/${missions.length} · ${fmt(points)} / ${fmt(max)} pts
+ ${body}
`; +} + +export function renderMissions(model){ + // Round missions in one column, permanent in the other. + const column=type=>`
${model.catalog.groups.filter(g=>g.type===type).map(g=>renderGroup(g,model.done)).join('')}
`; + return renderSummary(model)+`
${column('round')}${column('permanent')}
`; +} + +function confirmReset(onConfirm){ + const dialog=document.createElement('dialog');dialog.className='qm-reset-dialog'; + dialog.setAttribute('aria-label','Reset round missions'); + dialog.innerHTML=`

Reset round missions?

This clears every Inspector Level and Battlesim mission, as when your character dies. Boss and Star Force missions are permanent and stay complete.

`; + document.body.append(dialog);dialog.showModal(); + dialog.addEventListener('close',()=>dialog.remove(),{once:true}); + dialog.querySelector('[data-cancel]').onclick=()=>dialog.close(); + dialog.querySelector('.qm-reset-confirm').onclick=async e=>{ + const button=e.currentTarget;button.disabled=true; + try{await onConfirm();dialog.close();} + catch(error){dialog.querySelector('[role="alert"]').textContent=error.message;button.disabled=false;} + }; +} + +export async function mountMissions(root){ + // Saves go out one at a time, in click order, so the server applies them in that order and a + // slow reply can't overwrite a newer one. Redraws wait for the last queued save, so boxes ticked meanwhile don't flicker back. + let model,disposed=false,queue=Promise.resolve(),pending=0; + function send(request){ + pending++; + const run=queue.then(request).then(next=>{model=next;}).finally(()=>{if(!--pending)draw();}); + queue=run.catch(()=>{}); // One failed save mustn't stop the ones queued after it. + return run; + } + const alive=()=>!disposed&&root.isConnected; + root.innerHTML='

Loading missions...

'; + function draw(){ + if(!alive())return; + const focused=document.activeElement?.dataset?.mission; + root.innerHTML=renderMissions(model); + if(focused)root.querySelector(`[data-mission="${CSS.escape(focused)}"]`)?.focus({preventScroll:true}); + } + root.addEventListener('change',e=>{ + const id=e.target.dataset.mission;if(!id)return; + const done=e.target.checked; + // A failed save redraws from the last saved state, unticking the box again. + send(()=>api.put('/api/quanah/missions/'+encodeURIComponent(id),{done})).catch(error=>{if(alive())toast(error.message);}); + }); + root.addEventListener('click',e=>{ + if(!e.target.closest('[data-act="reset-round"]'))return; + confirmReset(async()=>{await send(()=>api.delete('/api/quanah/missions/round'));toast('Round missions reset.');}); + }); + try{model=await api.get('/api/quanah/missions');draw();} + catch(error){if(alive())root.innerHTML=`

${esc(error.message)}

`;} + return ()=>{disposed=true;}; +} diff --git a/web/pages/quanah.js b/web/pages/quanah.js index 7c5f4ac..8a802f3 100644 --- a/web/pages/quanah.js +++ b/web/pages/quanah.js @@ -1,5 +1,6 @@ import {api} from '../api.js'; import {escapeHtml as esc,toast} from '../ui.js'; +import {mountMissions} from './quanah-missions.js'; // Quanah: farm event pieces, scan or add them, and see the best 18-line set for a build. const QUEUE='quanah'; @@ -104,12 +105,11 @@ export function renderGear(model,editing=null,combo=0,menu=null){ }).join(''); } -export async function mountQuanah(root){ +async function mountSolver(root){ // EDITING is the id of a saved piece loaded into the hand-entry panel, or null when adding. // COMBO is the winning combo on show; any change to the pieces or build starts again at the first. let model,disposed=false,slot='hat',pending=[],confirmClear=false,editing=null,combo=0,menu=null; let scanning=false,windows=[],selectedWindow=null,timer=0,known=new Set(),scanState=null,queue=null; - root.className='quanah-page'; root.innerHTML='

Loading Quanah...

'; const alive=()=>!disposed&&root.isConnected; async function save(request){ @@ -194,11 +194,10 @@ export async function mountQuanah(root){ // Keep keyboard focus on the same control across redraws. const sig=el=>JSON.stringify(el.dataset),active=document.activeElement; const focus=active&&root.contains(active)&&active.dataset.act?sig(active):null; - const head=`

Quanah

Seasonal event equipment. Find the one-per-slot set that completes your build's 18 skill lines.

`; - if(!model.class){root.innerHTML=head+classPicker();return;} + if(!model.class){root.innerHTML=classPicker();return;} if(editing&&!model.items.some(i=>i.id===editing))stopEdit(); const total=model.items.length,dupes=model.items.filter(i=>i.duplicate).length,offclass=model.items.filter(i=>!i.wearable).length; - root.innerHTML=`${head}
${buildPanel()}${scanPanel()}${addPanel()} + root.innerHTML=`
${buildPanel()}${scanPanel()}${addPanel()}

Your pieces (${total})

${total?``:''}
${dupes||offclass?`

${[dupes&&plural(dupes,'duplicate'),offclass&&`${offclass} for another class`].filter(Boolean).join(' · ')}. Fix a misread or delete a piece from its … menu.

`:''}
${renderGear(model,editing,combo,menu)}
@@ -294,3 +293,31 @@ export async function mountQuanah(root){ if(scanning)api.post('/api/scan/cancel',{release:true}).catch(()=>{}); }; } + +// Two views: the set solver and the Dimensional mission tracker. Both stay mounted, so a scan +// keeps running while you tick off missions. +const VIEWS={solver:'Set solver',missions:'Dimensional missions'}; +const SUBTITLE={solver:"Seasonal event equipment. Find the one-per-slot set that completes your build's 18 skill lines.", + missions:'Check off Dimensional missions. Reaching a level, floor, boss difficulty or star force completes every one before it.'}; +export async function mountQuanah(root){ + let view='solver'; + try{view=VIEWS[localStorage.getItem('hascone.quanah.view')]?localStorage.getItem('hascone.quanah.view'):'solver';}catch{} + root.className='quanah-page'; + root.innerHTML=`

Quanah

+ + ${Object.keys(VIEWS).map(key=>`
`).join('')}`; + const cleanups={},panel=key=>root.querySelector('#q-panel-'+key); + async function show(key){ + view=key; + try{localStorage.setItem('hascone.quanah.view',key);}catch{} + root.querySelector('[data-subtitle]').textContent=SUBTITLE[key]; + for(const k of Object.keys(VIEWS)){panel(k).hidden=k!==key;root.querySelector('#q-tab-'+k).setAttribute('aria-selected',String(k===key));} + // Kept as a promise from the start, so a tab clicked again while loading isn't mounted twice. + // A mount that fails is forgotten, so clicking the tab again retries it. + cleanups[key]??=(key==='solver'?mountSolver:mountMissions)(panel(key)).catch(error=>{delete cleanups[key];throw error;}); + await cleanups[key]; + } + root.querySelector('[role="tablist"]').addEventListener('click',e=>{const b=e.target.closest('[data-view]');if(b&&b.dataset.view!==view)show(b.dataset.view).catch(error=>toast(error.message));}); + await show(view); + return ()=>{for(const mounting of Object.values(cleanups))mounting.then(cleanup=>cleanup?.(),()=>{});}; +} diff --git a/web/scanner.css b/web/scanner.css index 1306c09..7f6479d 100644 --- a/web/scanner.css +++ b/web/scanner.css @@ -393,3 +393,23 @@ body{height:100vh;min-height:0;display:flex;flex-direction:column;overflow:hidde .q-hunt p{margin:6px 0 0} @media(max-width:1000px){.q-layout{grid-template-columns:1fr}.q-side{position:static}} @media(max-width:640px){.q-gear-slots{grid-template-columns:1fr}} +/* Quanah: Dimensional missions. */ +.qm-summary{display:grid;grid-template-columns:minmax(180px,240px) minmax(0,1fr) auto;align-items:center;gap:16px 24px} +.qm-grade{display:grid;gap:4px}.qm-grade strong{font-size:40px;line-height:1;color:var(--accent);font-variant-numeric:tabular-nums} +.qm-bar{height:6px;border-radius:3px;background:var(--surface-3);overflow:hidden}.qm-bar i{display:block;height:100%;background:var(--accent)} +.qm-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:12px;margin:0} +.qm-stats dt{font-size:12px;color:var(--text-muted)}.qm-stats dd{margin:2px 0 0;font-size:20px;font-weight:600;font-variant-numeric:tabular-nums}.qm-stats small{font-size:13px;font-weight:400;color:var(--text-muted)} +.qm-groups{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px;align-items:start} +.qm-group h2{display:flex;align-items:center;gap:8px} +.q-pill.qm-round{background:var(--warn-dim);color:var(--warn)}.q-pill.qm-permanent{background:var(--ok-dim);color:var(--ok)} +.qm-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(124px,1fr));gap:6px} +.qm-check{display:flex;align-items:center;gap:6px;padding:5px 8px;border:1px solid var(--border);border-radius:8px;font-size:12px;cursor:pointer;user-select:none} +.qm-check:hover{border-color:var(--accent)}.qm-check input{margin:0;accent-color:var(--accent)} +.qm-check span{white-space:nowrap}.qm-check small{margin-left:auto;padding-left:4px;color:var(--text-muted);font-variant-numeric:tabular-nums} +.qm-check.is-done{border-color:var(--accent);background:var(--accent-dim)} +.qm-rows{display:grid;gap:6px;margin:0;padding:0;list-style:none} +.qm-rows li{display:grid;grid-template-columns:150px minmax(0,1fr);align-items:center;gap:8px}.qm-name{font-size:13px} +.qm-diffs{display:flex;flex-wrap:wrap;gap:6px}.qm-diffs .qm-check{min-width:110px} +.qm-reset-dialog{width:min(460px,90vw)}.qm-reset-confirm{color:var(--danger);border-color:var(--danger)} +@media(max-width:1100px){.qm-groups{grid-template-columns:1fr}} +@media(max-width:760px){.qm-summary{grid-template-columns:1fr}.qm-rows li{grid-template-columns:1fr}}