网页
综合
更新时间 2026-10-03 01:13:14
I built a game so my family could see who always gets skipped - DEV Community
自动蜘蛛
dev.to
正文约 6000 字
Posted on Oct 3 • Edited on Oct 3
I built Emberwake for the person I will name: my family.
Every few weeks we play something together. Diwali, a birthday, someone's visiting. And every single time, the same thing happens without anyone saying it out loud — the same two people take most of the turns. Somebody has to explain the rules, so somebody always gets to play. My grandfather, who genuinely loves these evenings, gets skipped for most of them. And because nobody ever wrote down who played, the exact same round happens again next month with the exact same imbalance.
That last part is the real problem. It is not that the imbalance happens. It is that it is invisible, unwritten, and therefore unfixable.
Emberwake is a small game that makes it visible.
Everyone joins by scanning one QR code — no account, no install, any phone or laptop. Each person gets a Spark on a 3D headland at night. Lighting the shared Beacon is a turn-based cooperative round. When you light a facet, your spark flies in and that facet of the tower brightens.
Then it tells you the truth: a deterministic engine scores Reach (who actually played), Balance (how evenly the fuel was shared, via Gini), Glow, Rhythm, and Golden hour (whether there was enough real daylight to be outside) — and it names the people who never got a turn.
The part I care about most: the beacon's geometry is generated from the same array of numbers the report prints. Not "inspired by" it. The same twelve numbers. If the tower looks lopsided, the fuel genuinely is lopsided. I could not make the unfairness disappear with a nicer render, and that was deliberate.
Here is the seeded demo round, analysed live on the production deployment — two elders on the roster who never lit a facet, which is exactly the gap in my own family:
The takeaway is a plain-text report you can paste straight into a family group chat: who played, who did not, how the light was shared, and what to do about it next time.
Live app: https://emberwake-lyart.vercel.app
It is a Progressive Web App, so you can open it on any phone — Android, iPhone, Windows, Mac — and install it. Scan the QR code on the landing page and you are there; no app store, no install step. The repository also ships a real Capacitor configuration so the same build wraps into native Android and iOS apps, though no store binary is published from this repo and I do not pretend otherwise.
Things worth clicking:
https://github.com/aniruddhaadak80/emberwake — MIT licensed.
Local development needs zero environment variables. Clone, install, npm run dev. An embedded Postgres creates its own schema and seeds a demo round on first request.
There are no API keys anywhere in the product. Sunrise, sunset and place names come from Open-Meteo, which needs none.
Next.js 16 (App Router), TypeScript in strict mode, Tailwind v4, Three.js for the arena, Neon Postgres in production, and Transformers.js for on-device speech recognition.
Five decisions I would defend in review:
1. The 3D is the data, not decoration. The beacon is twelve facet meshes whose emissive intensity and radial recession come straight from report.facets[i] — the same per-facet fuel totals that produce the report. An unlit facet is physically recessed, leaving a real gap in the tower. This is why I did not add a globe, particles, or ambient gradient: the scene has to be doing work.
2. The engine is pure, and shared. analyzeRound() takes stored data and returns a versioned, itemized result. It is called by the 3D HUD, by POST /api/rounds/[id]/analyze, and by the agent tool. There is no second implementation anywhere. It takes the clock as an injected argument, so it never reads the wall clock, which is what lets an analysis be a hashable fact.
3. Every change is sealed. Each mutation appends to a per-round chain:
Canonical JSON recursively sorts object keys, so the same logical event always hashes identically. Because each seal covers the previous one, editing a historical row directly in the database breaks every seal after it — and /verify tells you exactly which event broke. Deletions keep tombstones so the history stays replayable.
The tests check the seal against an independently implemented oracle of that formula, not against the code that produced it.
4. The agent is not a mock-up. POST /api/mcp speaks JSON-RPC 2.0 with initialize, tools/list and tools/call, and seven typed tools. The mutating ones call the same repository functions as the UI — an agent cannot reach state the product cannot. They accept an idempotencyKey, and the key is stored inside the audit event, so even the replay guard is covered by the hash chain. Run the same call twice and the second returns {"replayed": true} and writes nothing.
5. Host and guest are different capabilities. The host owns a round. Someone who scans the QR is a player: they can read the round and light facets, but they cannot rename it, remove people, delete it, or append audit events. This sounds like over-engineering until you try the alternative — without it, the QR lets someone join and then be unable to take a turn, which makes the QR the least useful control in the product.
Things that were wrong, and how I found out:
The engine tests caught two real defects I would not have caught by reading the code. The overall score was 100× too large because I rescaled a weighted mean that was already on a 0–100 scale. And the daylight model labelled the evening dawn, so the scene lit the wrong way at dusk. Both were invisible on inspection and obvious to a boundary test.
A third bug was subtler and more embarrassing: the QR join path passed a join code into a query against a uuid column, so Postgres raised 22P02 invalid input syntax and the single most important feature in the product returned a 500. My live verifier caught it because it joins as a genuinely separate session with a separate cookie jar, exactly like a real guest scanning a phone. It now checks the shape before it reaches the database and answers 404.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。