Files
threshing-atlas/scripts/qa/mapcheck.js
T
ekcSchianoandClaude Opus 5.5 68587a55f0 Valley map: start from any place and see every dragon's best route from there
Click a place name before choosing a dragon to see your chance of each dragon
from that point on, one coloured route per dragon, with a panel that ranks them
and links into each route kept through that place. Deep link: #valley/at/<place>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 19:24:27 +00:00

43 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Valley map QA: for idle and every dragon/route, find text or labels that overlap, fall outside the map, or are too faint.
const { chromium } = require("playwright");
const OUT = process.argv[2];
(async () => {
const b = await chromium.launch();
const p = await b.newPage({ viewport: { width: 1440, height: 1000 } });
const states = [["idle", "#valley"]];
for (const c of ["red", "orange", "brown", "green", "blue", "black"]) states.push([c, "#valley/" + c]);
const extra = { blue: ["shadow-Blue"], red: ["tree-Red"], orange: ["tree-Greens"], brown: ["tree-Greens"] };
for (const id of (process.env.POINTS || "dir:Center,comp:Alone,scream,bully,wounded,hour,tree,valley,stream,meadow").split(",")) states.push(["at-" + id, "#valley/at/" + encodeURIComponent(id)]);
for (const [c, encs] of Object.entries(extra)) encs.forEach((e) => states.push([c + "/" + e, `#valley/${c}/${e}`]));
for (const [name, hash] of states) {
await p.goto("http://localhost:8765/" + hash); await p.waitForTimeout(1800);
const res = await p.evaluate(() => {
const svg = document.querySelector("#ex-map"), S = svg.getBoundingClientRect();
const items = [];
svg.querySelectorAll("text").forEach((t) => {
const r = t.getBoundingClientRect();
if (!r.width) return;
// walk up for opacity
let op = 1; for (let e = t; e && e !== svg; e = e.parentElement) op *= parseFloat(getComputedStyle(e).opacity || 1) * parseFloat(e.getAttribute("fill-opacity") || 1);
items.push({ kind: "text", txt: t.textContent.trim(), r: { l: r.left, t: r.top, rr: r.right, b: r.bottom }, op });
});
const out = [], over = [];
items.forEach((a) => { if (a.r.l < S.left - 1 || a.r.rr > S.right + 1 || a.r.t < S.top - 1 || a.r.b > S.bottom + 1) out.push(a.txt); });
for (let i = 0; i < items.length; i++) for (let j = i + 1; j < items.length; j++) {
const A = items[i].r, B = items[j].r;
const ix = Math.min(A.rr, B.rr) - Math.max(A.l, B.l), iy = Math.min(A.b, B.b) - Math.max(A.t, B.t);
if (ix > 3 && iy > 3 && items[i].txt !== items[j].txt) over.push(`"${items[i].txt}" × "${items[j].txt}"`);
}
const dragons = [...svg.querySelectorAll(".ex-dragon")].map((d) => ({ l: d.getAttribute("aria-label") || "twin", op: +d.getAttribute("opacity") })).filter((d) => d.op < 0.3);
const card = document.querySelector(".ex-route-card.on") || (document.querySelector(".ex-from") && document.querySelector(".ex-from"));
return { out, over, faint: dragons.map((d) => `${d.l.split(".")[0]} ${d.op}`), focus: card ? card.innerText.replace(/\s+/g, " ").slice(0, 160) : "" };
});
console.log(`\n[${name}] ${res.focus}`);
if (res.out.length) console.log(" outside:", res.out.join(" | "));
if (res.over.length) console.log(" overlaps:", [...new Set(res.over)].join(" | "));
if (res.faint.length) console.log(" faint (<0.3):", res.faint.join(" | "));
await p.locator("#ex-map").screenshot({ path: `${OUT}/map-${name.replace(/[/:]/g, "_")}.png` });
}
await b.close();
})();