Ported from the game kit (7aa0553). GET /api/tally scans the ledgers, replays each duel, and returns the counts, cached a minute; the duel's own lines come from tallyOf on the final state (wins by slaying or by surrender, draws, wizards slain and yielded, stopped moments). The hall fetches it when the about panel opens. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
17 lines
632 B
TypeScript
17 lines
632 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { createGame } from './state';
|
|
import { play } from './test-helpers';
|
|
import { tallyOf } from './tally';
|
|
|
|
describe('the tally of a finished duel', () => {
|
|
it('counts nothing for a duel still in play', () => {
|
|
expect(tallyOf(createGame({ A: 'Ann', B: 'Bo' }, 1))).toEqual({});
|
|
});
|
|
|
|
it('counts a surrender as a win by surrender', () => {
|
|
const s = play(createGame({ A: 'Ann', B: 'Bo' }, 1), { left: 'P', right: 'P' });
|
|
expect(s.over?.winner).toBe('B');
|
|
expect(tallyOf(s)).toEqual({ "duels won by a rival's surrender": 1, 'wizards who yielded, all told': 1 });
|
|
});
|
|
});
|