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>
187 lines
9.0 KiB
TypeScript
187 lines
9.0 KiB
TypeScript
/**
|
||
* PLACEHOLDER loaner cards and starter decks (DESIGN §2) so the engine, UI and
|
||
* sims can run before council-data's docs/game/starter-cards.json lands.
|
||
* Loaners are off-chain preview cards: not NFTs, never minted or moved.
|
||
* engine-b / council-data replace STARTER_POOL with derived cards (cards.ts).
|
||
*/
|
||
import { CARD_SAMPLE_PERCENTILES, LOANER_SNAPSHOTS } from './card-data.ts';
|
||
import { DEFAULT_DERIVATION, deriveCard, type CardInput, type DerivationRules } from './derive.ts';
|
||
import { Rng } from './rng.ts';
|
||
import type { Faction, GameCard, Stat } from './types.ts';
|
||
|
||
type Spec = [pageId: number, title: string, faction: Faction, cost: number, home: Stat];
|
||
|
||
/** DESIGN §1.3 powerByCost and §10.1 keyword choice (cost 1 = vanilla +vanillaBonus). pageIds outside shared/catalog.ts are unverified. */
|
||
const POWER_BY_COST = [0, 1, 2, 4, 6, 8, 10];
|
||
const VANILLA_BONUS = 1;
|
||
const FACTION_KEYWORD: Record<Faction, string> = {
|
||
Culture: 'viral', Nature: 'rising', People: 'local', Science: 'encyclopedic', History: 'nostalgic', Space: 'translated',
|
||
};
|
||
|
||
export const STARTER_POOL: readonly Spec[] = [
|
||
[22780, 'Octopus', 'Nature', 1, 'depth'],
|
||
[19331, 'Moon', 'Space', 1, 'reach'],
|
||
[23053, 'Periodic table', 'Science', 1, 'depth'],
|
||
[3383, 'Bronze Age', 'History', 1, 'depth'],
|
||
[5843419, 'Chess', 'Culture', 2, 'attention'],
|
||
[9228, 'Earth', 'Space', 2, 'reach'],
|
||
[2008, 'Ada Lovelace', 'People', 2, 'attention'],
|
||
[21830, 'Honey bee', 'Nature', 2, 'depth'],
|
||
[736, 'Albert Einstein', 'People', 3, 'reach'],
|
||
[10979, 'Fungus', 'Nature', 3, 'depth'],
|
||
[26903, 'Solar System', 'Space', 3, 'reach'],
|
||
[30758, 'Roman Empire', 'History', 3, 'depth'],
|
||
[9649, 'Evolution', 'Science', 4, 'depth'],
|
||
[8424, 'Jazz', 'Culture', 4, 'attention'],
|
||
[12898, 'Marie Curie', 'People', 4, 'reach'],
|
||
[14533, 'Silk Road', 'History', 4, 'reach'],
|
||
[19468, 'Mount Everest', 'Nature', 5, 'attention'],
|
||
[22936, 'Photosynthesis', 'Science', 5, 'depth'],
|
||
[18110, 'Leonardo da Vinci', 'People', 5, 'reach'],
|
||
[14627, 'Ancient Egypt', 'History', 5, 'attention'],
|
||
[4177, 'Black hole', 'Space', 6, 'attention'],
|
||
[25443, 'Quantum mechanics', 'Science', 6, 'depth'],
|
||
[17867, 'Library of Alexandria', 'History', 6, 'depth'],
|
||
[20217, 'Music', 'Culture', 6, 'reach'],
|
||
];
|
||
|
||
export function loanerCard(spec: Spec, copy = 0): GameCard {
|
||
const [pageId, title, faction, cost, home] = spec;
|
||
const keyword = cost === 1 ? null : FACTION_KEYWORD[faction];
|
||
return {
|
||
cardId: `loaner:${pageId}:${copy}`, pageId, title, faction, rarity: 'Common', cost,
|
||
power: POWER_BY_COST[cost] + (keyword ? 0 : VANILLA_BONUS), home, trend: 0, keyword, source: 'loaner', check: 'loaner',
|
||
};
|
||
}
|
||
|
||
/**
|
||
* The frozen loaner pool (DESIGN §2): council-data's docs/game/starter-cards.json snapshots, derived by §1
|
||
* against the card-sample percentile table. For filling loaner slots and draft modes; not the starter decks.
|
||
* Ids are `loaner:<pageId>`. `rules` lets a mode's curve apply to loaners exactly as to owned cards.
|
||
*/
|
||
export function previewPool(rules: DerivationRules = DEFAULT_DERIVATION): GameCard[] {
|
||
return LOANER_SNAPSHOTS.map(l => deriveCard({
|
||
cardId: `loaner:${l.pageId}`, pageId: l.pageId, title: l.title, category: l.category, rarity: 'Common',
|
||
snapshot: { stats: l.stats }, live: { trendPercent: l.trendPercent, dailyAverage: l.dailyAverage }, check: 'loaner',
|
||
}, CARD_SAMPLE_PERCENTILES, rules));
|
||
}
|
||
|
||
/** A deterministic 12-card loaner deck: 2 cards of each cost 1–6, chosen by `seed`. */
|
||
export function starterDeck(seed: number | string): GameCard[] {
|
||
const rng = Rng.fromSeed(`starter:${seed}`);
|
||
const deck: GameCard[] = [];
|
||
for (let cost = 1; cost <= 6; cost++) {
|
||
deck.push(...rng.shuffle(STARTER_POOL.filter(spec => spec[3] === cost)).slice(0, 2).map(spec => loanerCard(spec)));
|
||
}
|
||
return deck;
|
||
}
|
||
|
||
// ---------- DESIGN §2.1 starter decks v1 (PR #18) ----------
|
||
|
||
type Pin = [cost: number, title: string, faction: Faction, home: Stat];
|
||
|
||
/** Real pageIds for every §2.1 starter card (council-data, docs/game/starter-cards.json `starterDeckPageIds`, #28). */
|
||
const CATALOG_PAGE_IDS: Record<string, number> = {
|
||
"Moon": 19331,
|
||
"Electron": 9476,
|
||
"Mars": 14640471,
|
||
"Periodic table": 23053,
|
||
"Saturn": 44474,
|
||
"Photosynthesis": 24544,
|
||
"Black hole": 4650,
|
||
"Quantum mechanics": 25202,
|
||
"Milky Way": 2589714,
|
||
"DNA": 7955,
|
||
"Sun": 26751,
|
||
"Theory of relativity": 30001,
|
||
"Octopus": 22780,
|
||
"Stonehenge": 27633,
|
||
"Axolotl": 235589,
|
||
"Rosetta Stone": 26428,
|
||
"Coral reef": 87410,
|
||
"Roman Empire": 25507,
|
||
"Honey bee": 58261,
|
||
"Ancient Egypt": 874,
|
||
"Amazon rainforest": 48139,
|
||
"Blue whale": 4925,
|
||
"Great Wall of China": 5094570,
|
||
"World War II": 32927,
|
||
"Haiku": 13217,
|
||
"Ada Lovelace": 974,
|
||
"Jazz": 15613,
|
||
"Marie Curie": 20408,
|
||
"Mona Lisa": 70889,
|
||
"Frida Kahlo": 162276,
|
||
"Chess": 5134,
|
||
"Leonardo da Vinci": 18079,
|
||
"The Beatles": 29812,
|
||
"William Shakespeare": 32897,
|
||
"Olympic Games": 22576,
|
||
"Wolfgang Amadeus Mozart": 33163,
|
||
"Sputnik 1": 28484,
|
||
"Nikola Tesla": 21473,
|
||
"Hubble Space Telescope": 40203,
|
||
"Isaac Newton": 14627,
|
||
"Neil Armstrong": 21247,
|
||
"Jupiter": 38930,
|
||
"Galileo Galilei": 29688374,
|
||
"Albert Einstein": 736,
|
||
"International Space Station": 15043,
|
||
"Apollo 11": 662,
|
||
"Charles Darwin": 8145410,
|
||
"Solar System": 26903,
|
||
};
|
||
|
||
export interface StarterDeckDef { id: string; name: string; cards: readonly Pin[] }
|
||
|
||
/** Four 12-card loaner decks, each with the curve 1,1,2,2,3,3,3,4,4,5,5,6, 6+6 factions and 4 cards per home stat. */
|
||
export const STARTER_DECKS: readonly StarterDeckDef[] = [
|
||
{ id: 'stargazers', name: 'Stargazers', cards: [
|
||
[1, 'Moon', 'Space', 'reach'], [1, 'Electron', 'Science', 'depth'], [2, 'Mars', 'Space', 'attention'],
|
||
[2, 'Periodic table', 'Science', 'depth'], [3, 'Saturn', 'Space', 'reach'], [3, 'Photosynthesis', 'Science', 'attention'],
|
||
[3, 'Black hole', 'Space', 'depth'], [4, 'Quantum mechanics', 'Science', 'reach'], [4, 'Milky Way', 'Space', 'attention'],
|
||
[5, 'DNA', 'Science', 'attention'], [5, 'Sun', 'Space', 'reach'], [6, 'Theory of relativity', 'Science', 'depth'],
|
||
] },
|
||
{ id: 'field-guide', name: 'Field Guide', cards: [
|
||
[1, 'Octopus', 'Nature', 'depth'], [1, 'Stonehenge', 'History', 'attention'], [2, 'Axolotl', 'Nature', 'attention'],
|
||
[2, 'Rosetta Stone', 'History', 'reach'], [3, 'Coral reef', 'Nature', 'depth'], [3, 'Roman Empire', 'History', 'reach'],
|
||
[3, 'Honey bee', 'Nature', 'attention'], [4, 'Ancient Egypt', 'History', 'depth'], [4, 'Amazon rainforest', 'Nature', 'reach'],
|
||
[5, 'Blue whale', 'Nature', 'attention'], [5, 'Great Wall of China', 'History', 'reach'], [6, 'World War II', 'History', 'depth'],
|
||
] },
|
||
{ id: 'headliners', name: 'Headliners', cards: [
|
||
[1, 'Haiku', 'Culture', 'attention'], [1, 'Ada Lovelace', 'People', 'depth'], [2, 'Jazz', 'Culture', 'attention'],
|
||
[2, 'Marie Curie', 'People', 'reach'], [3, 'Mona Lisa', 'Culture', 'reach'], [3, 'Frida Kahlo', 'People', 'attention'],
|
||
[3, 'Chess', 'Culture', 'depth'], [4, 'Leonardo da Vinci', 'People', 'reach'], [4, 'The Beatles', 'Culture', 'attention'],
|
||
[5, 'William Shakespeare', 'People', 'depth'], [5, 'Olympic Games', 'Culture', 'reach'], [6, 'Wolfgang Amadeus Mozart', 'People', 'depth'],
|
||
] },
|
||
{ id: 'pioneers', name: 'Pioneers', cards: [
|
||
[1, 'Sputnik 1', 'Space', 'reach'], [1, 'Nikola Tesla', 'People', 'attention'], [2, 'Hubble Space Telescope', 'Space', 'depth'],
|
||
[2, 'Isaac Newton', 'People', 'reach'], [3, 'Neil Armstrong', 'People', 'attention'], [3, 'Jupiter', 'Space', 'reach'],
|
||
[3, 'Galileo Galilei', 'People', 'depth'], [4, 'Albert Einstein', 'People', 'attention'], [4, 'International Space Station', 'Space', 'depth'],
|
||
[5, 'Apollo 11', 'Space', 'attention'], [5, 'Charles Darwin', 'People', 'reach'], [6, 'Solar System', 'Space', 'depth'],
|
||
] },
|
||
];
|
||
|
||
const kebab = (title: string) => title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
||
|
||
/** §2.1: the card's real pageId; null only if council-data has none (copies then count per cardId). */
|
||
export function loanerPageId(title: string): number | null {
|
||
return Object.hasOwn(CATALOG_PAGE_IDS, title) ? CATALOG_PAGE_IDS[title] : null;
|
||
}
|
||
|
||
/** The §1 CardInput for a pinned loaner. Snapshot stats are unused (pinned replaces §1.1–1.5). */
|
||
export function loanerInput([cost, title, faction, home]: Pin): CardInput {
|
||
return { cardId: `loaner:${kebab(title)}`, pageId: loanerPageId(title), title, category: faction, rarity: 'Common',
|
||
snapshot: { stats: { attention: null, depth: 0, reach: 0 } }, live: { trendPercent: null, dailyAverage: null },
|
||
check: 'loaner', pinned: { cost, home, faction } };
|
||
}
|
||
|
||
const NO_TABLE = { attention: [], depth: [], reach: [] };
|
||
|
||
/** A §2.1 starter deck by id, derived with the given rules (modes that change the curve change loaners too). */
|
||
export function starterDeckById(id: string, rules: DerivationRules = DEFAULT_DERIVATION): GameCard[] {
|
||
const def = STARTER_DECKS.find(deck => deck.id === id);
|
||
if (!def) throw new RangeError(`Unknown starter deck: ${id}`);
|
||
return def.cards.map(pin => deriveCard(loanerInput(pin), NO_TABLE, rules));
|
||
}
|