Repository navigation
Architecture and Development
-
No framework, no bundler, no runtime npm packages. The game is vanilla JavaScript drawing on one
<canvas>. Vendored libraries are onlyassets/peerjs.min.js(handshake) andassets/three.min.js(青锋行). -
Sources in
src/, generated pages at the root.tools/build.py(Python standard library only) joins the sources intoindex.htmlandrenying-offline.html. GitHub Pages servesindex.html. - Optional server. A Cloudflare Worker with D1 handles accounts, saves, the armory economy, leaderboards, matchmaking, TURN credentials and the open world. The game works without it.
| Path | Contents |
|---|---|
src/page.html |
Page markup with build markers |
src/style.css |
All styles; design tokens are documented in docs/design-tokens.md
|
src/data/ |
Data tables, built before src/game/
|
src/data/heroes/ |
One file per hero (NN-<id>.js) |
src/data/10-modes.js, 11-bp-orders.js
|
Local and online modes, draft orders |
src/data/12-maps.js, 13-chron.js, 14-dummy.js, 20-levels.js
|
Terrain maps, world story, dummy options, AI levels |
src/data/30-ui-copy.js, 31-hero-copy.js
|
Chinese → English text for the interface and heroes |
src/game/ |
The game, numbered files joined in order (01-core.js constants and RNG, 02-heroes.js, 03-skills.js, 04-ults.js, … 26-kbnav.js keyboard navigation) |
src/ai.js, models/ai-brain.json
|
Computer opponents and the trained model behind the top level |
src/net-p2p.js, src/social.js
|
Peer-to-peer connection, community features |
src/cloud.js, src/errlog.js
|
Accounts, sync, error reports |
src/armory-core.js, src/armory.js
|
Armory rules (shared with the Worker) and screens |
src/anticheat.js |
Client-side integrity checks |
src/i18n.js |
Translation lookup (the text itself is in src/data/30-ui-copy.js) |
src/qfx/ |
青锋行 mini-game, built into assets/qingfengxing.html
|
cloudflare/ |
worker.js, admin.html, schema.sql, migrations/, wrangler.toml; worker.bundle.js and migrations.gen.js are generated |
tools/ |
Build, tests, audits, AI training (trainer.mjs, ai-train.mjs), frame data, music tools |
docs/ |
Design notes, deploy runbook, admin guide, frame data, AI benchmark, and a copy of this wiki in docs/wiki/
|
python3 tools/build.pyRegenerates every generated file: both game pages, the mini-game page, the Worker bundle and the migration list. It also runs tools/data-check.mjs, which fails the build if a hero file or data table has a missing, unknown or wrong field, or if a story breaks the story template.
python3 tools/build.py --checkFails if any generated file is out of date. CI runs it on every push.
Never edit index.html, renying-offline.html, assets/qingfengxing.html, cloudflare/worker.bundle.js or cloudflare/migrations.gen.js by hand.
- Create
src/data/heroes/NN-<id>.jswithdefHero({...}), following the field reference insrc/data/00-heroes.js. - Add the skill to
src/game/03-skills.js, the ultimate tosrc/game/04-ults.js, skins and weapon looks insrc/game/13-skins.jsto15-skin-weapons.js, and the AI profile insrc/ai.js. - Add the English text to
src/data/31-hero-copy.js, the id toC.HERO_IDSinsrc/armory-core.js. - Rebuild, then run
node tools/combat-test.mjs --simandnode tools/frame-data.mjs.
Add one line to MODES (local) or ROOM_MODES (online) in src/data/10-modes.js; draft orders are in src/data/11-bp-orders.js.
Add the next numbered file in cloudflare/migrations/, update cloudflare/schema.sql, rebuild and run node tools/econ-test.mjs. Migrations run inside the Worker on its first request; never use wrangler d1 migrations apply. Details: cloudflare/migrations/readme.md.
-
cloudflare/worker.jshandles HTTP routes under/api/…and the admin page at/admin. -
WorldLineDurable Objects run the open world lines. - Big changes can ship behind server feature flags (admin page → 功能开关), off, Dev-only or on for everyone.
- CORS only allows the game's own page and local development.
- The Worker is deployed by the maintainer. Deploy, backup and rollback steps are in
docs/deploy-runbook.md; admin roles indocs/admin.md.
Online play depends on both browsers computing the same match. In match logic:
- use
grnd(), neverMath.random()(visual effects may userand()), - keep every piece of match state inside the rollback snapshot,
- never read the wall clock or the frame rate.
node tools/rollback-test.mjs --rollback and node tools/netplay-test.mjs catch most mistakes.
刃影 RenYing 1.0.1 · Play / 游玩 · Repository / 仓库 · Report a bug / 报告问题 · MIT License