타자 대결 연습 모드: 한컴 타자연습처럼 짧은글 10문장·단어 20개·긴글 한 편 전체를 제한 시간·점수 없이

- 대결 방식에 "연습" 추가(각자 치기, 라운드 1번, 시계·점수 없음). 긴글은 고른 주제 중 한 편을 처음부터 끝까지(8줄 단락이 아님).
- 줄마다 첫 타부터 시간을 재서 줄 사이에 쉬어도 타수가 안 떨어짐(첫 타 몫 0.15초 앞당김 → 붙여 넣기 막기 그대로).
  줄 최고 타수(best) 기록. 컴퓨터도 연습에서는 첫 타를 바로 보냄.
- 화면: 라운드 대신 걸린 시간, 지금·평균·최고 타수·정확도·진행 %, 끝나면 평균·최고·정확도·틀린 줄, 참가자 옆은 타수.
  설정에서 라운드·제한 시간 숨김, 종목 이름 "연습 종목", 도움말·규칙·요약 카드·docs.
- 테스트: 연습 4개(엔진), 무작위 대국 2가지, 컴퓨터 1가지, 도움말 1개, e2e typingPractice·typingPracticeLong.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-12 17:09:23 +09:00
parent 122cf5ed1f
commit 943e4be3fd
11 changed files with 321 additions and 51 deletions

View File

@@ -3746,6 +3746,103 @@ const PLANS: Record<string, Plan> = {
console.log(` typingSurvival: result: ${text.replace(/\n/g, ' ').slice(0, 120)}`);
},
},
typingPractice: {
// 2026-11-12 연습 · 짧은글: like 한컴 타자연습 — no round, no clock, no points; 10 sentences one after another. The
// stats show 지금·평균·최고 타수, 정확도, 진행 %, and a running ⏱. The host rests 3 s before a sentence: its 타수 is
// timed from the first key, so the rest does not pull it down. Both finish; the result has 타수 and 정확도 only.
game: 'typing',
lobby: async (host) => {
await host.getByRole('group', { name: '대결 방식' }).getByRole('button', { name: '연습' }).click();
if (await host.getByRole('group', { name: '라운드' }).count()) throw new Error('연습 should not ask for rounds');
await host.getByText(/한국어 · 연습 · 짧은글\(전체 주제\)(?! · )/).first().waitFor();
},
drive: async (pages) => {
const [host, guest] = pages as [Page, Page];
const lines: Record<string, number> = { host: 0, guest: 0 };
const over = () => host.getByRole('dialog', { name: '게임 결과' }).count();
const until = Date.now() + 150_000;
let rested = false;
while (Date.now() < until && !(await over())) {
let acted = false;
for (const [who, p] of [['host', host], ['guest', guest]] as const) {
const text = await typingTarget(p);
if (!text) continue;
if (who === 'host' && lines.host === 0) {
const top = await host.locator('.ty-top').innerText();
if (/라운드/.test(top) || !/연습/.test(top) || !/⏱/.test(top)) throw new Error(`top bar: ${top.replace(/\n/g, ' ')}`);
const stats = await host.locator('.ty-stats').innerText();
if (!/최고 0타/.test(stats) || !/진행 0%/.test(stats)) throw new Error(`stats: ${stats.replace(/\n/g, ' ')}`);
}
if (who === 'host' && lines.host === 1 && !rested) {
rested = true;
await host.waitForTimeout(3000);
}
// A Hangul syllable is 2~3 keys: about 1,200타 at this pace (under the paste guard).
await typeLine(p, text, 120);
lines[who]!++;
acted = true;
if (who === 'host' && lines.host === 2) {
// A 3 s rest before the second sentence would have made it < 150타 if it counted.
await host.waitForFunction(() => /최고 (\d+)타/.test(document.querySelector('.ty-stats')?.textContent ?? ''));
const stats = await host.locator('.ty-stats').innerText();
const avg = Number(/평균 (\d+)타/.exec(stats)?.[1] ?? 0);
if (avg < 250 || !/진행 20%/.test(stats)) throw new Error(`after the rest: ${stats.replace(/\n/g, ' ')}`);
await host.screenshot({ path: join(SHOTS, 'typing-practice-pc.png') });
await guest.screenshot({ path: join(SHOTS, 'typing-practice-phone.png') });
}
}
if (!acted) await host.waitForTimeout(200);
}
for (const p of pages) await p.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 20_000 });
await host.waitForTimeout(600);
await host.screenshot({ path: join(SHOTS, 'typing-practice-result-pc.png') });
const text = await host.getByRole('dialog', { name: '게임 결과' }).innerText();
if (lines.host !== 10 || lines.guest !== 10 || !/정확도 100%/.test(text) || !/방장\s*평균 \d+타/.test(text) || /방장\s*\d+승/.test(text)) throw new Error(`lines ${JSON.stringify(lines)}; result: ${text.replace(/\n/g, ' ')}`);
console.log(` typingPractice: lines ${JSON.stringify(lines)}; result: ${text.replace(/\n/g, ' ').slice(0, 160)}`);
},
},
typingPracticeLong: {
// 연습 · 긴글 · 애국가: the whole text from the first line to the last (not one 8-line passage), shown as one
// passage with the line I am on; the phone just watches the host's bar after typing one line.
game: 'typing',
lobby: async (host) => {
await host.getByRole('group', { name: '대결 방식' }).getByRole('button', { name: '연습' }).click();
await host.getByRole('group', { name: '연습 종목' }).getByRole('button', { name: '긴글' }).click();
await host.getByRole('group', { name: '주제' }).getByRole('button', { name: '애국가' }).click();
await host.getByText(/연습 · 긴글\(애국가\)(?! · )/).first().waitFor();
},
drive: async (pages) => {
const [host, guest] = pages as [Page, Page];
let total = 0;
let typed = 0;
const until = Date.now() + 150_000;
while (Date.now() < until && !(await host.getByRole('dialog', { name: '게임 결과' }).count())) {
const text = await typingTarget(host);
if (!text) {
if (typed && (await host.getByText('다 쳤어요! 다른 사람을 기다려요').count())) break;
await host.waitForTimeout(200);
continue;
}
if (!total) total = await host.locator('.ty-passage li').count();
await host.locator('.ty-passage li[data-s="cur"]').filter({ hasText: text }).first().waitFor({ timeout: 3000 });
await typeLine(host, text, 110);
typed++;
}
// The guest has not finished: the game waits for them.
if (await host.getByRole('dialog', { name: '게임 결과' }).count()) throw new Error('ended before the guest finished');
await host.getByText('다 쳤어요! 다른 사람을 기다려요').waitFor();
await host.screenshot({ path: join(SHOTS, 'typing-practice-long-pc.png') });
for (let n = 0; n < 100; n++) {
const text = await typingTarget(guest);
if (text) await typeLine(guest, text, 110);
else if (await guest.getByRole('dialog', { name: '게임 결과' }).count()) break;
else await guest.waitForTimeout(200);
}
for (const p of pages) await p.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 20_000 });
if (total <= 8 || typed !== total) throw new Error(`passage ${total} lines, typed ${typed}`);
console.log(` typingPracticeLong: the whole 애국가, ${typed} lines`);
},
},
appleUnlimited: {
// 2026-10-14: 무제한 — the stopwatch runs (tenths) and stops when I finish; 💡 힌트 shows a glowing box that adds up
// to 10 (button off while it shows), using it clears the box; the result shows 걸린 시간 and 힌트 N번.