A table may ask each seat to rank its choices before the deal, in secret; the start line keeps the rankings and create reads them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
1 parent
eca8c92964
commit
8c99126aee
12 files changed
+186
-9
No files matched your search
@@ -90,4 +90,38 @@ describe('rooms', () => {
|
||||
expect(rooms.view(room, 'B').chat[1]).toMatchObject({ id: 'A', to: ['B'], turn: 1 });
|
||||
expect(() => rooms.say(room, bo, 'Anyone?', ['Q'])).toThrow(/Nobody at this table/);
|
||||
});
|
||||
|
||||
it('keeps each ranking secret until the deal, which reads them all from the start line', () => {
|
||||
const dealt: Record<string, string[]>[] = [];
|
||||
const ranked: GameSpec<State, Input> = {
|
||||
...game,
|
||||
rankable: () => [
|
||||
{ value: 'red', label: 'Red' },
|
||||
{ value: 'blue', label: 'Blue' }
|
||||
],
|
||||
create: (names, seed, rules, options, rankings) => {
|
||||
dealt.push(rankings ?? {});
|
||||
return game.create(names, seed, rules, options);
|
||||
}
|
||||
};
|
||||
const rooms = new Rooms(ranked, new Store(dir));
|
||||
const host = rooms.create('Ann', 2);
|
||||
const guest = rooms.join(host.room, 'Bo');
|
||||
const room = host.room;
|
||||
expect(() => rooms.rank(room, host.token, ['red'])).toThrow(/every choice once/);
|
||||
rooms.rank(room, host.token, ['blue', 'red']);
|
||||
expect(rooms.view(room, 'A').yourRanking).toEqual(['blue', 'red']);
|
||||
expect(rooms.view(room, 'B')).toMatchObject({ yourRanking: null, ranked: 1 });
|
||||
rooms.begin(room, host.token);
|
||||
expect(dealt).toEqual([{ A: ['blue', 'red'] }]);
|
||||
expect(() => rooms.rank(room, guest.token, ['red', 'blue'])).toThrow(/ranking is closed/);
|
||||
new Rooms(ranked, new Store(dir));
|
||||
expect(dealt[1]).toEqual({ A: ['blue', 'red'] });
|
||||
});
|
||||
|
||||
it('refuses a ranking at a table that asks for none', () => {
|
||||
const rooms = new Rooms(game, new Store(dir));
|
||||
const host = rooms.create('Ann', 2);
|
||||
expect(() => rooms.rank(host.room, host.token, ['A'])).toThrow(/asks for no ranking/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user