Imported from q-lsn/sword-of-justice-pvp-calculator (
AGENTS.md). Install upstream withnpx skills add q-lsn/sword-of-justice-pvp-calculator. Copyright stays with the author.
AGENTS.md
Repo shape
- Static browser SPA: no bundler, framework, TypeScript, or build step.
index.htmlis the app shell/router and loads plain global scripts fromtools/. - UI/content is primarily Traditional Chinese (
zh-TW); preserve existing labels and route copy unless the task asks otherwise. - Hash routes are defined in
index.html:#/,#/calculator,#/attribute-planner,#/crafting,#/league. - Script order matters: Chart.js CDN, then
tools/pvp-config.js,tools/combat-formulas.js,tools/calculator.js,tools/league.js,tools/crafting.js,tools/sync-bridge.js,tools/attribute-planner.js,tools/ocr-demo.js. tools/calculator.htmlonly redirects to../#/calculator; the production calculator UI lives inindex.html+tools/calculator.js.demo/contains standalone design prototypes/screenshots, not the production app path unless a task explicitly targets it.
Commands
- Install JS deps with npm only:
npm cifor CI-equivalent clean installs,npm installfor local updates. Keeppackage-lock.json. - Manual app server:
npm startserves the repo root onhttp://localhost:3099. - Playwright test server:
npm run start:testserves the repo root onhttp://localhost:3101;npm testuses/reuses this port. - Main verification:
npm test(playwright test, Chromium,tests/e2e). - Focused checks:
npm run test:single -- league, or pass any Playwright grep string after--. - Debug UI tests:
npm run test:headedornpm run test:debug. - Real OCR baseline is opt-in/manual:
npm run test:ocr-real. - CI uses Node 20,
npm ci,npx playwright install --with-deps chromium, thennpx playwright test.
Testing gotchas
- Do not use
file://; tests and app behavior expect HTTP. Manual servers:npx serve .orpython -m http.server 8000. - If local Playwright behavior is odd, check for an existing
localhost:3101server; local test runs reuse it while CI starts fresh. playwright.config.jsintentionally hasfullyParallel: false; CI uses one worker and one retry.- Default tests ignore
tests/e2e/ocr-real.spec.js. The real OCR spec uses the base server plus its ownlocalhost:3100, has a 180s timeout, depends on real Tesseract/CDN/runtime behavior, and skips whenCIis truthy. - For OCR integration tests, mock
window.pvpOcr.recognizeFromFileunless explicitly validating the real-image baseline underocr_example/. - Prefer stable selectors already present in markup: ids, explicit route ids, and fixed button ids.
Architecture notes
tools/combat-formulas.jsexposeswindow.pvpCombatand is the single source for calculator/planner combat math. When changing formulas, update and runtests/e2e/formulas.spec.js; golden values are intentional.tools/pvp-config.jsexposeswindow.pvpConfigfor shared attack/defense fields, planner attributes, and calculator→planner bridge mapping.tools/sync-bridge.jsexposeswindow.pvpSyncBridgeand dispatchespvp-sync:updatefor calculator/planner synchronization; avoid direct cross-feature DOM writes when extending sync.index.htmldispatchespvp:routechangeandpvp:themechange; feature modules should hook these events instead of coupling directly to shell controls.- Calculator/planner/league/theme/OCR sample state persists in
localStorage; preserve existing keys or update restore/import-export tests with the migration. index.html,tools/ocr-demo.js, andtools/league.jsare high-coupling/high-complexity areas. Prefer small behavior-preserving changes over broad rewrites.- Keep the static SPA architecture; existing docs explicitly discourage premature React/Vue/Vite/framework conversion.
Deployment and artifacts
- GitHub Pages deploy workflow uploads the repo root
'.'on pushes tomain/master; anything committed can ship, so do not add generated reports, debug captures, or screenshots unless intended. - Ignored local artifacts include
node_modules/,playwright-report/,test-results/, andwiki/. Treatwiki/as local ignored content unless the user explicitly asks about it.