forked from WikiDeck/wikideck
Overnight build by 17 Claude agents (2026-11-16 22:45 → 01:30 EST), coordinated in [claude/wikideck milestone 63](https://gitea.eom.dev/claude/wikideck/milestone/63). **For Eric's review. Do not merge without it.** The full write-up is in `docs/night/REPORT.md`. **What's in it** (38 reviewed PRs, squash-merged into `night/2026-11-16`): - **Edit War:** - a 3-lane, 6-turn card game built on what WikiDeck cards actually hold - a pure, deterministic, off-chain rules engine (`shared/game/`, with the API in `docs/game/ENGINE_API.md`); rules are data and v1.1 is the default - a mobile-first Play UI with a lobby, deck builder, four loaner starter decks, a match against the AI, results and a tutorial - a landing page (fixes #3) - **Design and balance:** `docs/game/DESIGN.md`, `CARD_DATA.md` (236 sampled articles) and `BALANCE.md` (bot simulations). Starter pairings went from 23–77% on v1 to roughly even on v1.1. - **eom.dev accounts:** Dex OIDC with PKCE, plus off-chain wallet linking, where the client builds the message it signs (`server/account/`, `src/auth/`). - **Peer-hosted game modes:** modes are JSON data, never code. Node API at `/api/game/*`, with host credit and leaderboards. Three example modes (`shared/game/modes.ts`, `server/game/`, `docs/game/HOSTING.md`). - **Mobile:** Capacitor 7 Android app (a debug APK played a full match against the AI in the emulator), and an iOS project waiting on Xcode (`docs/night/ANDROID.md`, `docs/night/IOS.md`). - **Testnet tooling:** `deploy/night/` (LAN-only, 3 nodes) and an optional `WIKIDECK_USER_AGENT` (the default is unchanged). **Not touched:** consensus and protocol (`server/chain.ts`, `shared/protocol.ts`, `server/testnet/{consensus,ledger,…}.ts`, `native/`), the live deployment and mainnet. Matches run off-chain and never move or burn NFTs. **Checks:** the final integration gate passed in `node:24-alpine`: `npm test` 241/242 with 0 fail (1 skipped), and `npm run build` passes. The repo needs Node 24, because Node 20 fails 12 tests falsely. **Decisions for Eric** (see REPORT.md, Known issues and Next steps): 1. whether the live node should set `WIKIDECK_USER_AGENT` 2. the Xcode licence, which you should accept yourself 3. #49 in the fork, a bot change held after the freeze 4. on-chain host rewards (proposal only, in HOSTING.md) 🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: WikiDeck/wikideck#22 Co-authored-by: Claude <claude@eom.dev>
79 lines
4.3 KiB
TypeScript
79 lines
4.3 KiB
TypeScript
// DESIGN §2.1 starter decks (PR #18). Owner: engine-b.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
DEFAULT_DERIVATION, DEFAULT_RULESET, RULESET_V1_0, RULESET_V1_1, keywordFor, STARTER_DECKS, createMatch, starterDeckById, validateDeck,
|
|
} from '../shared/game/index.ts';
|
|
|
|
const countBy = (keys: string[]) => keys.reduce<Record<string, number>>((m, k) => ({ ...m, [k]: (m[k] ?? 0) + 1 }), {});
|
|
|
|
test('four starter decks, each with the frozen curve, 6+6 factions and 4 cards per home stat', () => {
|
|
assert.deepEqual(STARTER_DECKS.map(d => d.id), ['stargazers', 'field-guide', 'headliners', 'pioneers']);
|
|
for (const def of STARTER_DECKS) {
|
|
const deck = starterDeckById(def.id);
|
|
assert.deepEqual(deck.map(c => c.cost), [1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6], def.id);
|
|
const factions = Object.values(countBy(deck.map(c => c.faction)));
|
|
assert.deepEqual(factions, [6, 6], `${def.id} factions`);
|
|
const homes = Object.values(countBy(deck.map(c => c.home)));
|
|
assert.deepEqual(homes, [4, 4, 4], `${def.id} homes`);
|
|
}
|
|
});
|
|
|
|
for (const [label, rules] of [['v1.0', RULESET_V1_0], ['v1.1', RULESET_V1_1]] as const)
|
|
test(`starter cards follow §10.1 and the power curve like owned cards (${label})`, () => {
|
|
for (const def of STARTER_DECKS) for (const card of starterDeckById(def.id, rules)) {
|
|
assert.equal(card.source, 'loaner');
|
|
assert.equal(card.rarity, 'Common');
|
|
assert.equal(card.trend, 0);
|
|
assert.match(card.cardId, /^loaner:[a-z0-9-]+$/);
|
|
if (card.cost === 1) { assert.deepEqual([card.keyword, card.power], [null, 2]); continue; }
|
|
const { keyword } = keywordFor(card.faction, card.cost, false, rules, card.home);
|
|
assert.equal(card.keyword, keyword);
|
|
assert.equal(card.power, rules.powerByCost[card.cost] + (rules.keywordParams[keyword!]?.powerDelta ?? 0));
|
|
}
|
|
});
|
|
|
|
test('all 6 factions covered; every starter card has a real pageId, catalog ones as in shared/catalog.ts', () => {
|
|
const all = STARTER_DECKS.flatMap(d => starterDeckById(d.id));
|
|
assert.equal(new Set(all.map(c => c.faction)).size, 6);
|
|
const ids = Object.fromEntries(all.map(c => [c.title, c.pageId]));
|
|
assert.deepEqual([ids.Moon, ids['Periodic table'], ids.Octopus, ids['Albert Einstein']], [19331, 23053, 22780, 736]);
|
|
for (const c of all) assert.ok(Number.isInteger(c.pageId) && c.pageId! > 0, `${c.title} has a real pageId`);
|
|
assert.equal(new Set(all.map(c => c.pageId)).size, all.length, 'no two starter cards share a pageId');
|
|
});
|
|
|
|
test('every starter deck passes engine deck validation and starts a match against every other', () => {
|
|
for (const a of STARTER_DECKS) {
|
|
assert.deepEqual(validateDeck(DEFAULT_RULESET, starterDeckById(a.id)), [], a.id);
|
|
for (const b of STARTER_DECKS) assert.doesNotThrow(() => createMatch(DEFAULT_RULESET, [starterDeckById(a.id), starterDeckById(b.id)], 1));
|
|
}
|
|
});
|
|
|
|
test('modes changing the curve change loaners too; unknown ids are rejected', () => {
|
|
const flat = starterDeckById('pioneers', { ...DEFAULT_DERIVATION, powerByCost: [0, 3, 3, 3, 3, 3, 3], vanillaBonus: 0 });
|
|
assert.ok(flat.every(c => c.power === 3));
|
|
assert.throws(() => starterDeckById('nope'), RangeError);
|
|
});
|
|
|
|
test('previewPool derives the frozen starter-cards.json loaners through §1', async () => {
|
|
const { previewPool, LOANER_SNAPSHOTS, CARD_SAMPLE_PERCENTILES, DEFAULT_RULESET, validateDeck } = await import('../shared/game/index.ts');
|
|
const pool = previewPool();
|
|
assert.equal(pool.length, LOANER_SNAPSHOTS.length);
|
|
assert.deepEqual(previewPool(), pool, 'deterministic');
|
|
for (const stat of ['attention', 'depth', 'reach'] as const) {
|
|
const cuts = CARD_SAMPLE_PERCENTILES[stat];
|
|
assert.equal(cuts.length, 99);
|
|
assert.ok(cuts.every((v, i) => i === 0 || v >= cuts[i - 1]), `${stat} cuts ascend`);
|
|
}
|
|
assert.equal(new Set(pool.map(c => c.cardId)).size, pool.length);
|
|
for (const c of pool) {
|
|
assert.equal(c.source, 'loaner');
|
|
assert.match(c.cardId, /^loaner:\d+$/);
|
|
assert.ok(c.cost >= 1 && c.cost <= 6);
|
|
const delta = c.keyword ? (DEFAULT_DERIVATION.keywordParams[c.keyword]?.powerDelta ?? 0) : 0;
|
|
assert.equal(c.power, DEFAULT_DERIVATION.powerByCost[c.cost] + (c.keyword === null && c.cost === 1 ? DEFAULT_DERIVATION.vanillaBonus : 0) + delta);
|
|
}
|
|
// 12 of them make a legal loaner deck.
|
|
assert.deepEqual(validateDeck(DEFAULT_RULESET, pool.slice(0, 12)), []);
|
|
});
|