The tally: what the ledgers add up to, in the about panel
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
This commit is contained in:
1 parent
66dd3bc10e
commit
7c60d19ad3
6 files changed
+205
-1
No files matched your search
@@ -0,0 +1,16 @@
|
||||
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 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user