타자 대결 연습: 한 사람이 나가도 남은 사람은 끝까지 침(대결만 한 명 남으면 끝)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -690,7 +690,8 @@ function leave(s: S, p: PlayerId, ctx: Ctx): void {
|
||||
const r = s.rs[p]!;
|
||||
ctx.events.push({ type: 'left', player: p });
|
||||
const stayed = s.order.filter((q) => inGame(s, q));
|
||||
if (stayed.length === 0 || (stayed.length === 1 && s.order.length > 1)) {
|
||||
// A contest ends when one is left; 연습 goes on for whoever is still typing.
|
||||
if (stayed.length === 0 || (stayed.length === 1 && s.order.length > 1 && !isPractice(s.options))) {
|
||||
r.alive = false;
|
||||
r.outReason = 'left';
|
||||
r.finishedAt ??= ctx.now;
|
||||
|
||||
@@ -385,6 +385,25 @@ describe('연습', () => {
|
||||
expect(s.final!.ranking.map((r) => r.id)).toEqual(['A', 'B']);
|
||||
expect(s.final!.summary).toContain('연습 끝');
|
||||
});
|
||||
|
||||
test('someone leaves (done or not): the others keep typing until they finish', () => {
|
||||
let s = tick(make({ mode: 'practice', category: 'word' }), START);
|
||||
const n = s.items.length;
|
||||
for (let i = 0; i < n; i++) s = act(s, 'A', { type: 'submit', item: i, text: s.items[i]! }, START + (i + 1) * 3000);
|
||||
s = act(s, 'A', { type: 'leave' }, START + n * 3000 + 100);
|
||||
expect(s.phase).toBe('playing');
|
||||
expect(typing.validate(s, 'B', { type: 'submit', item: 0, text: s.items[0]! }, { now: START + 70_000 }).ok).toBe(true);
|
||||
for (let i = 0; i < n; i++) s = act(s, 'B', { type: 'submit', item: i, text: s.items[i]! }, START + 70_000 + i * 3000);
|
||||
expect(s.phase).toBe('ended');
|
||||
expect(s.final!.ranking.map((r) => [r.id, r.left])).toEqual([['B', false], ['A', true]]);
|
||||
// Leaving midway works the same; the last one leaving ends it.
|
||||
let t = tick(make({ mode: 'practice' }, ['A', 'B', 'C']), START);
|
||||
t = act(t, 'A', { type: 'leave' }, START + 1000);
|
||||
t = act(t, 'B', { type: 'leave' }, START + 2000);
|
||||
expect(t.phase).toBe('playing');
|
||||
t = act(t, 'C', { type: 'leave' }, START + 3000);
|
||||
expect(t.phase).toBe('ended');
|
||||
});
|
||||
});
|
||||
|
||||
describe('서바이벌은 반드시 끝나요', () => {
|
||||
|
||||
Reference in New Issue
Block a user