#!/usr/bin/env node // verifySolitaireTour.js — headless checks for the five-stop Solitaire Tour: // each engine's rules (Golf, Klondike, Pyramid, Take Fourteen, Three Shuffles // and a Draw), random play (every listed move applies, 52 cards conserved, // snapshots + save/load round-trip), the seeded reshuffle (undo can't re-roll // it), Klondike's stuck test, the leg controllers (layout, picking, targets, // smart-click ranking, partners, reasons, auto-play) and the room layouts // (cards on the table, never under the scorecard / plate / dock). // Usage: node tools/verifySolitaireTour.js [--quick] import { TOUR, GAME_META, createEngine, engineFromSave, encode, decode, cardById, freshDeck, GolfEngine, KlondikeEngine, PyramidEngine, FourteenEngine, ThreeShufflesEngine, } from '../src/games/solitairetour/SolitaireTourLogic.js'; import { legFor, remainingCards, homeStacks } from '../src/games/solitairetour/SolitaireTourLegs.js'; import { hudRects, PLAY, W, H, KLON, PYR, THREE, GOLF } from '../src/games/solitairetour/SolitaireTourTable.js'; import { cardBounds } from '../src/ui/solitaire/SolitaireGeometry.js'; import { bumpCount, loadStats, recordBest } from '../src/ui/solitaire/SolitaireStats.js'; import { mulberry32 } from '../src/ui/cardtable/AITiming.js'; import { MAP, STOPS, mapXY, THEMES } from '../src/games/solitairetour/SolitaireTourArt.js'; const QUICK = process.argv.includes('--quick'); let pass = 0, fail = 0; function ok(label, cond, detail = '') { if (cond) pass++; else { console.error(` ✗ ${label}${detail ? ` — ${detail}` : ''}`); fail++; } } const section = (n) => console.log(`\n${n}`); const C = (key) => { const RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']; const SUITS = ['s', 'h', 'd', 'c']; return cardById(SUITS.indexOf(key[1]) * 13 + RANKS.indexOf(key[0])); }; const cs = (s) => (s ? s.split(' ').map(C) : []); const FULL = freshDeck(() => 0.5).map(c => c.id).sort((a, b) => a - b).join(); const idsOf = (e) => e.allCards().map(c => c.id).sort((a, b) => a - b).join(); const rectsOverlap = (a, b) => a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1; // ── Cards + saves ──────────────────────────────────────────────────────────── section('Cards + saves'); { ok('52 canonical cards', new Set(Array.from({ length: 52 }, (_, i) => cardById(i).key)).size === 52); ok('ids are stable per card', C('Ah').id === cardById(C('Ah').id).id && C('As').id !== C('Ah').id); ok('point values A=1 … K=13', C('As').pval === 1 && C('Ts').pval === 10 && C('Ks').pval === 13); const d1 = freshDeck(mulberry32(5)).map(c => c.key).join(), d2 = freshDeck(mulberry32(5)).map(c => c.key).join(); ok('seeded decks repeat', d1 === d2); const snap = { a: [C('Qh'), { card: C('2c'), faceUp: false }], n: 3, inf: null }; const back = decode(JSON.parse(JSON.stringify(encode(snap)))); ok('encode/decode round trip', back.a[0] === C('Qh') && back.a[1].card === C('2c') && back.a[1].faceUp === false && back.n === 3); ok('every leg has its meta', TOUR.every(t => GAME_META[t]?.name && GAME_META[t].venue && GAME_META[t].blurb && GAME_META[t].greet)); } // ── Golf ───────────────────────────────────────────────────────────────────── section('Golf'); { const e = createEngine('golf', mulberry32(1)); ok('7 columns of 5, 1 on the foundation, 16 in stock', e.tableau.every(p => p.length === 5) && e.foundation.length === 1 && e.stock.length === 16); e.restore({ tableau: [cs('2s 9h'), cs('Ks'), cs('Qd'), [], [], [], []], foundation: cs('8c'), stock: cs('5d'), run: 0, moveCount: 0 }); ok('one rank away plays', e.canPlay(C('9h'))); ok('two away does not', !e.canPlay(C('Qd'))); e.apply({ t: 'gplay', col: 0 }); ok('run counts tableau plays', e.run === 1); e.restore({ ...e.snapshot(), foundation: cs('Ac') }); ok('no wrap: K doesn\'t play on A', !e.canPlay(C('Ks'))); ok('…and 2 does', e.canPlay(C('2s'))); e.apply({ t: 'gstock' }); ok('stock resets the run', e.run === 0 && e.foundationTop().key === '5d'); ok('cleared columns win even with stock left', new GolfEngine(freshDeck()).isWon() === false); } // ── Klondike ───────────────────────────────────────────────────────────────── section('Klondike'); { const e = createEngine('klondike', mulberry32(2)); ok('1…7 dealt, tops face up', e.tableau.every((p, c) => p.length === c + 1 && p.every((x, k) => x.faceUp === (k === c)))); ok('24 in stock', e.stock.length === 24 && e.waste.length === 0); const T = (spec) => spec.split('|').map(col => (col ? col.split(' ').map(t => ({ card: C(t.replace('*', '')), faceUp: !t.endsWith('*') })) : [])); e.restore({ tableau: T('4c* 9h|8s|Kd|||Ts|'), stock: [], waste: cs('Qs'), foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('black 8 goes on red 9', e.canStack(C('8s'), 0) && !e.canStack(C('8s'), 2)); ok('only a King fills an empty column', e.canStack(C('Kd'), 3) && !e.canStack(C('Qs'), 3)); ok('moving a run flips the card underneath', e.apply({ t: 'krun', col: 0, idx: 1, to: 2 }).length === 0 && e.apply({ t: 'krun', col: 1, idx: 0, to: 0 }).length === 1); e.apply({ t: 'krun', col: 0, idx: 1, to: 5 }); ok('…and the covered 4♣ turns face up', e.tableau[0][0].faceUp === true); e.restore({ tableau: T('|||||||'), stock: cs('3d 2d'), waste: [], foundations: { s: [], h: [], d: cs('Ad'), c: [] }, recyclesLeft: Infinity, moveCount: 0 }); e.apply({ t: 'kstock' }); ok('turning the stock puts its top on the waste', e.wasteTop().key === '2d'); ok('waste plays home', e.apply({ t: 'kwf' }).length === 1); e.apply({ t: 'kstock' }); e.apply({ t: 'kstock' }); ok('empty stock recycles the waste', e.stock.length === 1 && e.waste.length === 0 && e.stock[0].key === '3d'); // stuck detection with unlimited recycling e.restore({ tableau: T('Ks||||||'), stock: cs('5h 9c'), waste: cs('3s'), foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('stuck when no stock/waste card can ever play', e.isStuck() === true && e.hasMoves() === true); e.restore({ ...e.snapshot(), stock: cs('5h As') }); ok('not stuck while an ace waits in the stock', e.isStuck() === false); // auto-finish + safe home e.restore({ tableau: T('2s|Ah 2h||||||'.replace('|||||||', '||||')), stock: [], waste: [], foundations: { s: cs('As'), h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('a buried ace blocks auto-finish', !e.canAutoFinish()); e.restore({ tableau: T('2s|2h|Ah||||'), stock: [], waste: [], foundations: { s: cs('As'), h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('auto-finish when everything can go home', e.canAutoFinish() === true); e.restore({ tableau: T('3h|||||||'), stock: [], waste: [], foundations: { s: cs('As 2s'), h: cs('Ah 2h'), d: [], c: cs('Ac') }, recyclesLeft: Infinity, moveCount: 0 }); ok('3♥ not safe until both black twos are home', !e.isSafeHome(C('3h'))); e.restore({ ...e.snapshot(), foundations: { s: cs('As 2s'), h: cs('Ah 2h'), d: [], c: cs('Ac 2c') } }); ok('…then it is', e.isSafeHome(C('3h'))); } // ── Pyramid ────────────────────────────────────────────────────────────────── section('Pyramid'); { const e = createEngine('pyramid', mulberry32(3)); ok('28 in the pyramid, 24 in stock, 3 passes', e.rows.flat().length === 28 && e.stock.length === 24 && e.passesLeft === 3); ok('only the bottom row is uncovered at the start', e.availableLocs().filter(l => l.area === 'pyramid').every(l => l.r === 6)); const rows = Array.from({ length: 7 }, (_, r) => Array(r + 1).fill(null)); rows[6][0] = C('5s'); rows[6][1] = C('8h'); rows[5][0] = C('Kd'); e.restore({ rows, stock: [], waste: cs('Qc'), discard: [], passesLeft: 3, moveCount: 0 }); ok('covered card isn\'t available', !e.available(5, 0)); const partners = e.partnersOf({ area: 'pyramid', r: 6, i: 0 }); ok('5 + 8 = 13 partners', partners.length === 1 && partners[0].i === 1); ok('the waste card counts', e.availableLocs().some(l => l.area === 'waste')); e.apply({ t: 'ppair', a: { area: 'pyramid', r: 6, i: 0 }, b: { area: 'pyramid', r: 6, i: 1 } }); ok('pair goes to the discard', e.discard.length === 2 && e.available(5, 0)); ok('kings clear alone', e.apply({ t: 'pking', loc: { area: 'pyramid', r: 5, i: 0 } }).length === 1); ok('pyramid gone → won (stock doesn\'t matter)', e.isWon()); const f = createEngine('pyramid', mulberry32(4)); let n = 0; while (f.apply({ t: 'pstock' }).length && n < 500) n++; ok('stock: 4 times through (3 recycles), then done', n === 24 * 4 + 3 && f.passesLeft === 0, `${n}`); } // ── Take Fourteen ──────────────────────────────────────────────────────────── section('Take Fourteen'); { const e = createEngine('fourteen', mulberry32(5)); ok('12 piles: four of 5, eight of 4', e.piles.map(p => p.length).join() === '5,5,5,5,4,4,4,4,4,4,4,4'); e.restore({ piles: [cs('Ah'), cs('Ks'), cs('7c'), cs('7d'), cs('6h'), [], [], [], [], [], [], []], discard: [], moveCount: 0 }); ok('A + K = 14', e.partnersOf(0).join() === '1'); ok('7 + 7 = 14', e.partnersOf(2).join() === '3'); ok('6 has no partner here', e.partnersOf(4).length === 0); e.apply({ t: 'fpair', a: 2, b: 3 }); ok('pair goes to the discard', e.discard.length === 2 && !e.piles[2].length); ok('a non-pair is refused', e.apply({ t: 'fpair', a: 0, b: 4 }).length === 0); } // ── Three Shuffles and a Draw ──────────────────────────────────────────────── section('Three Shuffles and a Draw'); { const e = createEngine('threeshuffles', mulberry32(6)); ok('17 fans of 3 + 1 single', e.piles.length === 18 && e.piles.slice(0, 17).every(p => p.length === 3) && e.piles[17].length === 1); e.restore({ piles: [cs('9s 8s'), cs('7s'), cs('7h'), [], cs('As')], foundations: { s: [], h: [], d: [], c: [] }, shufflesLeft: 2, drawsLeft: 1, seed: 99, moveCount: 0 }); ok('builds down in suit', e.canStack(C('7s'), 0) && !e.canStack(C('7h'), 0)); ok('empty spaces stay empty', !e.canStack(C('7h'), 3)); ok('ace goes home', e.apply({ t: 'tfound', p: 4 }).length === 1); ok('no Draw before the shuffles are spent', !e.canDraw()); // the reshuffle is seeded: undo + shuffle again gives the same fans const g = createEngine('threeshuffles', mulberry32(7)); const s0 = g.snapshot(); g.apply({ t: 'tredeal' }); const after1 = g.piles.map(p => p.map(c => c.key).join()).join('|'); g.restore(s0); g.apply({ t: 'tredeal' }); const after2 = g.piles.map(p => p.map(c => c.key).join()).join('|'); ok('undo can\'t re-roll a shuffle', after1 === after2); ok('a shuffle keeps all the cards', idsOf(g) === FULL); g.apply({ t: 'tredeal' }); ok('two reshuffles, then none', g.shufflesLeft === 0 && g.apply({ t: 'tredeal' }).length === 0); ok('then the Draw is open', g.canDraw()); const buried = g.piles.find(p => p.length > 1)[0]; ok('the Draw lifts a buried card into its own fan', g.apply({ t: 'tdraw', id: buried.id }).length === 1 && g.piles[g.piles.length - 1][0] === buried); ok('only one Draw', !g.canDraw()); e.restore({ piles: [cs('2s'), cs('As')], foundations: { s: [], h: [], d: [], c: [] }, shufflesLeft: 0, drawsLeft: 0, seed: 1, moveCount: 0 }); ok('foundation-only finish detected', e.canAutoFinish()); } // ── Random play: legality, conservation, snapshots, saves ─────────────────── section('Random play (all five games)'); { const games = QUICK ? 40 : 150; for (const type of TOUR) { let legal = true, conserved = true, trips = true, saveOk = true, layoutOk = true, valueOk = true; for (let gi = 0; gi < games; gi++) { const rng = mulberry32(gi * 31 + type.length); const e = createEngine(type, rng); const leg = legFor(e); const snaps = []; for (let k = 0; k < 300; k++) { let ms = e.legalMoves().filter(m => m.t !== 'tdraw'); if (e.canDraw?.() && rng() < 0.3) { const p = e.piles.find(x => x.length > 1); ms.push({ t: 'tdraw', id: p[0].id }); } if (!ms.length) break; const prog = ms.filter(m => !['gstock', 'kstock', 'pstock', 'tredeal'].includes(m.t)); const pool = prog.length && rng() < 0.85 ? prog : ms; const m = pool[Math.floor(rng() * pool.length)]; snaps.push(JSON.stringify(encode(e.snapshot()))); if (!e.apply(m).length) { legal = false; break; } if (idsOf(e) !== FULL) conserved = false; if (leg.layout().size !== 52) layoutOk = false; if (e.remainingValue() !== remainingCards(e).reduce((t, c) => t + c.pval, 0)) valueOk = false; if (k % 20 === 0) { const saved = JSON.stringify(encode(e.snapshot())); const e2 = engineFromSave(type, JSON.parse(saved)); if (JSON.stringify(encode(e2.snapshot())) !== saved) saveOk = false; } if (e.isWon()) break; } for (let i = snaps.length - 1; i >= 0; i--) { e.restore(decode(JSON.parse(snaps[i]))); if (JSON.stringify(encode(e.snapshot())) !== snaps[i]) { trips = false; break; } } } ok(`${type}: every listed move applies`, legal); ok(`${type}: 52 cards conserved`, conserved); ok(`${type}: layout places all 52`, layoutOk); ok(`${type}: score = value of the cards left`, valueOk); ok(`${type}: snapshots restore exactly (undo)`, trips); ok(`${type}: saves reload exactly`, saveOk); } } // ── Leg controllers ────────────────────────────────────────────────────────── section('Leg controllers'); { // Golf let e = createEngine('golf', mulberry32(8)); e.restore({ tableau: [cs('2s 9h'), cs('Qd'), [], [], [], [], []], foundation: cs('8c'), stock: cs('5d 6d'), run: 0, moveCount: 0 }); let leg = legFor(e); let lay = leg.layout(); const top = lay.get(C('9h').id).pose; let src = leg.pickAt(top); ok('golf: pressing a top card picks it', src?.kind === 'gcol' && src.col === 0); ok('golf: buried cards aren\'t pickable', leg.pickAt({ x: lay.get(C('2s').id).pose.x, y: lay.get(C('2s').id).pose.y - 55 }) === null); ok('golf: a playable card targets the foundation', leg.movesFor(src)[0]?.move.t === 'gplay'); ok('golf: unplayable says what it needs', /7 or 9/.test(leg.noMoveReason(leg.pickAt(lay.get(C('Qd').id).pose)))); ok('golf: playable tops glow', leg.playableIds().has(C('9h').id) && !leg.playableIds().has(C('Qd').id)); ok('golf: stock press turns a card', leg.pickAt(GOLF.STOCK)?.tapMove?.t === 'gstock'); // Klondike ranking + reasons e = createEngine('klondike', mulberry32(9)); const T = (spec) => spec.split('|').map(col => (col ? col.split(' ').map(t => ({ card: C(t.replace('*', '')), faceUp: !t.endsWith('*') })) : [])); e.restore({ tableau: T('3c* 9h|Ts|Ah||Kd|Js|'), stock: [], waste: cs('8s'), foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); leg = legFor(e); lay = leg.layout(); const pick = (key) => leg.pickAt(lay.get(C(key).id).pose); const best = (s) => leg.movesFor(s).reduce((a, b) => (b.score > a.score ? b : a), { score: -1 }).move; ok('klondike: ace goes home first', best(pick('Ah'))?.t === 'kcf'); ok('klondike: 9♥ onto 10♠, revealing the 3♣', best(pick('9h'))?.t === 'krun' && best(pick('9h')).to === 1); ok('klondike: waste 8♠ onto 9♥', leg.movesFor(pick('8s')).some(t => t.move.t === 'kwc' && t.move.to === 0)); ok('klondike: a King at a column\'s base doesn\'t hop between empty columns', leg.movesFor(pick('Kd')).length === 0 && !e.legalMoves().some(m => m.t === 'krun' && m.col === 4)); ok('klondike: reason for a Queen', /red Queen|black Queen|Needs a/.test(leg.noMoveReason(pick('Js')))); ok('klondike: dropping a non-King on an empty column explains', /King/.test(leg.dropBlocker(pick('Js'), { x: KLON.colX(3), y: KLON.TOP }) ?? '')); ok('klondike: face-down cards aren\'t pickable', !leg.pickables().some(p => p.src.ids[0] === C('3c').id && p.src.kind === 'krun' && p.src.idx === 0)); e.restore({ tableau: T('|||||||'), stock: [], waste: cs('9c'), foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('klondike: tapping the empty stock recycles', leg.tapEmpty(KLON.STOCK)?.t === 'kstock'); e.restore({ tableau: T('Ac|||||||'.slice(0, 9)), stock: [], waste: [], foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); ok('klondike: safe auto-play sends an ace', leg.autoMove({ autoPlay: true })?.t === 'kcf'); ok('klondike: auto-play off still finishes a foregone board', leg.autoMove({ autoPlay: false })?.t === 'kcf'); // Pyramid partners + dimming e = createEngine('pyramid', mulberry32(10)); leg = legFor(e); const bottom = e.rows[6].map((c, i) => ({ c, i })); const covered = e.rows[5][0]; ok('pyramid: covered cards are dimmed', leg.dimmed(covered.id) && !leg.dimmed(e.rows[6][0].id)); const s6 = leg.pickAt(PYR.pos(6, 0)); ok('pyramid: a bottom card is pickable', s6?.kind === 'ploc' && s6.loc.r === 6); ok('pyramid: covered cards aren\'t pickable', leg.pickAt({ x: PYR.pos(5, 0).x, y: PYR.pos(5, 0).y - 50 }) === null); ok('pyramid: partner targets are real pairs', bottom.every(({ i }) => leg.movesFor(leg.srcFor({ area: 'pyramid', r: 6, i })).every(t => t.move.t === 'pking' || e.cardAt(t.move.a).pval + e.cardAt(t.move.b).pval === 13))); ok('pyramid: partner ids line up with moves', bottom.every(({ i }) => { const s = leg.srcFor({ area: 'pyramid', r: 6, i }); return leg.isKing(s) || leg.partnerIds(s).length === leg.movesFor(s).length; })); // Take Fourteen e = createEngine('fourteen', mulberry32(11)); leg = legFor(e); const pairs = e.legalMoves(); ok('fourteen: moves agree with partners', e.piles.every((p, i) => !p.length || leg.partnerIds(leg.srcFor(i)).length === e.partnersOf(i).length)); ok('fourteen: pair count shown', leg.status().some(l => l.includes(String(pairs.length)))); // Three Shuffles e = createEngine('threeshuffles', mulberry32(12)); leg = legFor(e); ok('three: only fan tops pickable normally', leg.pickables().every(p => e.piles[p.src.p][e.piles[p.src.p].length - 1].id === p.src.ids[0])); ok('three: draw mode offers only buried cards', leg.pickables({ drawMode: true }).every(p => p.src.tapMove?.t === 'tdraw')); ok('three: targets are legal', e.piles.every((_, p) => leg.movesFor({ kind: 'tpile', p }).every(t => { const g = engineFromSave('threeshuffles', encode(e.snapshot())); return g.apply(t.move).length > 0; }))); // homes + remaining for (const type of TOUR) { const g = createEngine(type, mulberry32(13)); ok(`${type}: home stacks + remaining cards cover the deck at the start`, homeStacks(g).reduce((t, s) => t + s.cards.length, 0) + remainingCards(g).length === (type === 'golf' ? 52 : 52)); } } // ── Room layouts ───────────────────────────────────────────────────────────── section('Room layouts'); { const huds = hudRects(); for (const type of TOUR) { let onTable = true, clear = true; for (let gi = 0; gi < (QUICK ? 15 : 40); gi++) { const rng = mulberry32(gi + 500); const e = createEngine(type, rng); const leg = legFor(e); for (let k = 0; k < 200; k++) { for (const v of leg.layout().values()) { const b = cardBounds(v.pose); if (b.x0 < PLAY.x0 - 2 || b.x1 > PLAY.x1 + 2 || b.y0 < PLAY.y0 - 2 || b.y1 > PLAY.y1 + 2) onTable = false; for (const h of huds) if (rectsOverlap(b, h.r)) clear = false; } const ms = e.legalMoves().filter(m => m.t !== 'tdraw'); if (e.canDraw?.() && rng() < 0.5) { const p = e.piles.find(x => x.length > 1); e.apply({ t: 'tdraw', id: p[0].id }); continue; } if (!ms.length || e.isWon()) break; e.apply(ms[Math.floor(rng() * ms.length)]); } } ok(`${type}: every card stays on the table`, onTable); ok(`${type}: no card under the scorecard, plate or dock`, clear); } // Klondike worst case: 6 face-down + a 13-card run const e = createEngine('klondike', mulberry32(1)); const deck = freshDeck(mulberry32(2)); const tab = Array.from({ length: 7 }, () => []); tab[6] = [...deck.slice(0, 6).map(card => ({ card, faceUp: false })), ...deck.slice(6, 19).map(card => ({ card, faceUp: true }))]; e.restore({ tableau: tab, stock: deck.slice(19), waste: [], foundations: { s: [], h: [], d: [], c: [] }, recyclesLeft: Infinity, moveCount: 0 }); const last = cardBounds(legFor(e).layout().get(tab[6][18].card.id).pose); ok('klondike: a 19-card column fits on the table', last.y1 <= PLAY.y1 + 1); // Three Shuffles with 19 fans (after a Draw) still fits const t = createEngine('threeshuffles', mulberry32(3)); t.shufflesLeft = 0; t.apply({ t: 'tdraw', id: t.piles[0][0].id }); const ok19 = [...legFor(t).layout().values()].every(v => cardBounds(v.pose).y1 <= PLAY.y1); ok('three: 19 fans fit', t.piles.length === 19 && ok19); // the map has every stop on it ok('route map has all five stops inside it', TOUR.every(l => { const p = mapXY(STOPS[l].lon, STOPS[l].lat); return p.x > 0 && p.x < MAP.w && p.y > 0 && p.y < MAP.h; })); ok('every leg has a room theme', TOUR.every(l => THEMES[l]?.surface && THEMES[l].life)); ok('pyramid apex below the wall strip', cardBounds(PYR.pos(0, 0)).y0 >= PLAY.y0); ok('three foundations clear of the fans', cardBounds(THREE.found(0)).y1 < cardBounds(THREE.fanPose(0, 0, 3)).y0); ok('screen size', W === 1920 && H === 1080); } // ── Records ────────────────────────────────────────────────────────────────── section('Records'); { const mem = new Map(); const store = { getItem: (k) => mem.get(k) ?? null, setItem: (k, v) => mem.set(k, v) }; ok('bumpCount counts', bumpCount('t', 'clear-golf', { mode: 'casual' }, store) === 1 && bumpCount('t', 'clear-golf', { mode: 'casual' }, store) === 2); ok('counts are per mode', loadStats('t', 'tournament', store).counts['clear-golf'] === undefined); recordBest('t', 'tour', 80, { mode: 'casual' }, store); ok('lower tour beats it', recordBest('t', 'tour', 61, { mode: 'casual' }, store) === true); ok('higher run (lower: false) beats it', recordBest('t', 'run', 4, { lower: false, mode: 'casual' }, store) === false && recordBest('t', 'run', 7, { lower: false, mode: 'casual' }, store) === true); } console.log(`\n${pass} passed, ${fail} failed`); process.exit(fail ? 1 : 0);