타자 대결: 서바이벌이 반드시 끝나게(모두 동시 탈락·동점 3번 연속이면 남은 사람 공동 1점, 문제 60개 상한), 라운드 끝난 뒤 평균 타수·정확도 중복 합산 고침, 정확도 0%를 100%로 보이던 것 고침
- 남은 사람이 모두 한꺼번에 탈락하게 되어 아무도 안 빠지는 문제(시간별은 모두 동점인 간격)가 SURVIVAL_STALL_LIMIT(3)번 이어지면 라운드를 끝내고 남은 사람이 함께 1점. 누가 치거나 탈락하면 횟수는 0으로. 함께 치기는 SURVIVAL_MAX_ITEMS(60)번째 문제에서도 끝. 라운드 요약 "더 탈락하는 사람이 없어서 남은 사람이 함께 1점을 얻어요". - seatView: 진행 중인 라운드만 누적에 더하고, roundEnd·ended에서는 endRound가 이미 더한 누적만 보여 줌. - SeatView.roundTried·tried(무언가 제출했는지)로 "아직 없음"(-)과 실제 0%를 구분(화면·도움말). - 테스트: 네 탈락 조건 모두 아무도 안 칠 때 200번 안에 끝남, 모두 늘 시간 안에 칠 때 60문제에서 끝, 진짜 탈락이 횟수를 초기화, 라운드 뒤 자리 표시 = 최종 결과, 전부 틀린 답의 정확도 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,7 @@ export function helpNow(v: TypingView, me: string | null, players: Record<string
|
||||
else if (v.flow === 'lane' && mine.finished) lines.push('이번 라운드를 다 쳤어요. 다른 사람이 끝내기를 기다려요.');
|
||||
else lines.push(HOW);
|
||||
lines.push(MODE_LINE[mode]);
|
||||
lines.push(`이번 라운드: ${mine.roundKpm}타, 정확도 ${mine.roundAcc || 100}%${mine.wrong ? `, 틀린 Enter ${mine.wrong}번` : ''}.`);
|
||||
lines.push(`이번 라운드: ${mine.roundKpm}타, 정확도 ${mine.roundTried ? `${mine.roundAcc}%` : '아직 없음'}${mine.wrong ? `, 틀린 Enter ${mine.wrong}번` : ''}.`);
|
||||
if (mode === 'survival' && v.options.elimination === 'wrong') lines.push(`남은 목숨 ${mine.lives}개.`);
|
||||
if (lead) lines.push(lead);
|
||||
lines.push(v.options.lang === 'ko' ? '영어가 쳐지면 한/영 키를 눌러 한글로 바꿔요.' : '한글이 쳐지면 한/영 키를 눌러 영어로 바꿔요.');
|
||||
|
||||
@@ -529,7 +529,7 @@ function TypingBoard({ view: v, me, players, act }: BoardProps<TypingView>) {
|
||||
<div className="ty-stats">
|
||||
<span>지금 {curKpm}타</span>
|
||||
<span>이번 라운드 {mine.roundKpm}타</span>
|
||||
<span>정확도 {mine.roundAcc || 100}%</span>
|
||||
<span>정확도 {mine.roundTried ? `${mine.roundAcc}%` : '-'}</span>
|
||||
{mine.wrong > 0 && <span>틀림 {mine.wrong}번</span>}
|
||||
{item && <span>{keyCount(item.text)}타짜리</span>}
|
||||
</div>
|
||||
@@ -578,7 +578,7 @@ function TypingSide({ view: v, players }: BoardProps<TypingView>) {
|
||||
{s.left ? ' · 나감' : ''}
|
||||
</span>
|
||||
<span className="small muted" style={{ fontVariantNumeric: 'tabular-nums' }}>
|
||||
{s.kpm}타 · {s.acc ? `${s.acc}%` : '-'}
|
||||
{s.kpm}타 · {s.tried ? `${s.acc}%` : '-'}
|
||||
</span>
|
||||
<strong style={{ fontVariantNumeric: 'tabular-nums' }}>
|
||||
{s.points}
|
||||
|
||||
@@ -74,6 +74,9 @@ export const autoRoundMs = (items: readonly string[]) => 10_000 + Math.round((it
|
||||
export const SURVIVAL_SHRINK = 0.9;
|
||||
/** … but never below the time a very fast typist (this many 타 a minute) needs, plus a second to read. */
|
||||
export const SURVIVAL_FLOOR_KPM = 900;
|
||||
/** 서바이벌 always ends: after this many items (or cuts) in a row where nobody could be knocked out, or this many items, the survivors share the round. */
|
||||
export const SURVIVAL_STALL_LIMIT = 3;
|
||||
export const SURVIVAL_MAX_ITEMS = 60;
|
||||
|
||||
/**
|
||||
* The clock of shared item `i`. 서바이벌 always has one (무제한 plays as 자동) and it gets shorter item by item, so a round
|
||||
@@ -183,6 +186,8 @@ function startRound(s: S, round: number, ctx: Ctx): void {
|
||||
s.roundEndsAt = null;
|
||||
s.nextCutAt = null;
|
||||
s.outOrder = [];
|
||||
s.stalls = 0;
|
||||
s.stalled = false;
|
||||
s.last = null;
|
||||
s.cur = 0;
|
||||
s.curOpen = false;
|
||||
@@ -225,10 +230,17 @@ function openItem(s: S, i: number, at: number): void {
|
||||
|
||||
/** Does the shared round end after item `i` (the last item, or survival is decided)? */
|
||||
function sharedOver(s: S, nextIdx: number): boolean {
|
||||
if (isSurvival(s)) return alive(s).length <= 1;
|
||||
if (isSurvival(s)) return alive(s).length <= 1 || survivalStalled(s, nextIdx);
|
||||
return !s.cycle && nextIdx >= s.items.length;
|
||||
}
|
||||
|
||||
/** 서바이벌 undecided: nobody could be knocked out several times in a row, or the item cap is reached. */
|
||||
function survivalStalled(s: S, nextIdx: number): boolean {
|
||||
if ((s.stalls ?? 0) < SURVIVAL_STALL_LIMIT && nextIdx < SURVIVAL_MAX_ITEMS) return false;
|
||||
s.stalled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** The current shared item is decided: remember it, then the next opens after the gap (or the round ends). */
|
||||
function closeItem(s: S, winner: PlayerId | null, out: PlayerId[], ctx: Ctx): void {
|
||||
const text = itemText(s, s.cur);
|
||||
@@ -243,6 +255,8 @@ function closeItem(s: S, winner: PlayerId | null, out: PlayerId[], ctx: Ctx): vo
|
||||
const ms = w && w.solvedAt !== null ? w.solvedAt - s.curAt : 0;
|
||||
s.last = { text, winner, kpm: w ? kpm(keyCount(text), ms) : 0, out } satisfies LastItem;
|
||||
ctx.events.push({ type: 'itemEnd', item: s.cur, winner, out });
|
||||
// Somebody typed it or went out: the survivors are not stuck (only all-at-once misses in a row count as a stall).
|
||||
if (out.length || s.order.some((p) => s.rs[p]!.alive && s.rs[p]!.solvedAt !== null && s.rs[p]!.prog >= keyCount(text))) s.stalls = 0;
|
||||
const next = s.cur + 1;
|
||||
if (sharedOver(s, next)) return endRound(s, ctx);
|
||||
openItem(s, next, ctx.now + GAP_MS);
|
||||
@@ -254,11 +268,13 @@ function knockOut(s: S, ps: PlayerId[], why: OutReason, ctx: Ctx, force = false)
|
||||
const hit = ps.filter((p) => s.rs[p]!.alive);
|
||||
if (!hit.length) return [];
|
||||
if (!force && hit.length >= live.length) {
|
||||
// Everyone left would go: they all stay (a 목숨 rule keeps one life).
|
||||
// Everyone left would go: they all stay (a 목숨 rule keeps one life) — but not for ever (`SURVIVAL_STALL_LIMIT`).
|
||||
for (const p of hit) if (s.rs[p]!.lives <= 0) s.rs[p]!.lives = 1;
|
||||
s.stalls = (s.stalls ?? 0) + 1;
|
||||
ctx.events.push({ type: 'spared', players: hit });
|
||||
return [];
|
||||
}
|
||||
s.stalls = 0;
|
||||
const place = live.length - hit.length + 1;
|
||||
for (const p of hit) {
|
||||
const r = s.rs[p]!;
|
||||
@@ -310,7 +326,7 @@ function intervalCut(s: S, ctx: Ctx): void {
|
||||
'least',
|
||||
ctx,
|
||||
);
|
||||
if (alive(s).length <= 1) endRound(s, ctx);
|
||||
if (alive(s).length <= 1 || survivalStalled(s, 0)) endRound(s, ctx);
|
||||
else s.nextCutAt = (s.nextCutAt ?? ctx.now) + s.options.intervalSec * 1000;
|
||||
}
|
||||
|
||||
@@ -432,7 +448,7 @@ function roundSummary(s: S, winners: PlayerId[]): string {
|
||||
case 'first':
|
||||
return solo ? '라운드 끝!' : `가장 많이 먼저 친 사람이 이 라운드 1등이에요${many}`;
|
||||
case 'survival':
|
||||
return `끝까지 살아남은 사람이 1점을 얻어요${many}`;
|
||||
return s.stalled ? `더 탈락하는 사람이 없어서 남은 사람이 함께 1점을 얻어요${many}` : `끝까지 살아남은 사람이 1점을 얻어요${many}`;
|
||||
case 'speed':
|
||||
return solo ? '라운드 끝! 타수를 확인해요' : `타수가 가장 높은 사람이 1점을 얻어요${many}`;
|
||||
case 'accuracy':
|
||||
@@ -678,13 +694,17 @@ function seatView(s: S, p: PlayerId): SeatView {
|
||||
const r = s.rs[p]!;
|
||||
const t = s.totals[p]!;
|
||||
const shared = flowOf(s.options) === 'shared';
|
||||
const live = s.phase === 'playing';
|
||||
const target = s.phase === 'playing' && s.items.length ? targetOf(s, p) : '';
|
||||
const of = target ? keyCount(target) : 0;
|
||||
return {
|
||||
id: p,
|
||||
points: t.points,
|
||||
kpm: avgKpm({ keys: t.keys + r.keys, ms: t.ms + r.ms }),
|
||||
acc: avgAcc({ accSum: t.accSum + r.accSum, accLen: t.accLen + r.accLen }),
|
||||
// While a round is played its numbers are not in the totals yet; once it ends (`endRound`) they are.
|
||||
kpm: avgKpm(live ? { keys: t.keys + r.keys, ms: t.ms + r.ms } : t),
|
||||
acc: avgAcc(live ? { accSum: t.accSum + r.accSum, accLen: t.accLen + r.accLen } : t),
|
||||
tried: t.accLen + (live ? r.accLen : 0) > 0,
|
||||
roundTried: r.accLen > 0,
|
||||
left: t.left,
|
||||
idx: shared ? s.cur : r.idx,
|
||||
done: r.done,
|
||||
|
||||
@@ -154,6 +154,12 @@ export interface TypingState {
|
||||
last: LastItem | null;
|
||||
/** 서바이벌 시간별: the next cut. */
|
||||
nextCutAt: number | null;
|
||||
/**
|
||||
* 서바이벌: items / cuts in a row where everyone left would have gone out at once (so nobody did), and whether the
|
||||
* round ended undecided (that went on too long, or the item cap) — the survivors then share the point.
|
||||
*/
|
||||
stalls?: number;
|
||||
stalled?: boolean;
|
||||
/** Survivors knocked out so far this round, in order (for places). */
|
||||
outOrder: PlayerId[];
|
||||
rs: Record<PlayerId, RoundSeat>;
|
||||
@@ -184,6 +190,9 @@ export interface SeatView {
|
||||
prog: number;
|
||||
roundKpm: number;
|
||||
roundAcc: number;
|
||||
/** Something was submitted this round / this game (so an accuracy of 0 is a real 0, not "nothing yet"). */
|
||||
roundTried: boolean;
|
||||
tried: boolean;
|
||||
wrong: number;
|
||||
finished: boolean;
|
||||
lives: number;
|
||||
|
||||
@@ -4,12 +4,15 @@ import {
|
||||
COUNTDOWN_MS,
|
||||
GAP_MS,
|
||||
ROUND_END_MS,
|
||||
SURVIVAL_MAX_ITEMS,
|
||||
SURVIVAL_STALL_LIMIT,
|
||||
autoItemMs,
|
||||
itemLimit,
|
||||
ROUND_ITEMS,
|
||||
flowOf,
|
||||
itemText,
|
||||
keyCount,
|
||||
minTypingMs,
|
||||
topicIdsFor,
|
||||
typing,
|
||||
type TypingAction,
|
||||
@@ -38,6 +41,8 @@ const reason = (s: TypingState, p: string, a: TypingAction, now: number) => {
|
||||
const later = (at: number) => at + 4000;
|
||||
/** Shared: the current item, typed right by `p` well after it opened. */
|
||||
const solve = (s: TypingState, p: string, at = later(s.curAt)) => act(s, p, { type: 'submit', item: s.cur, text: itemText(s, s.cur) }, at);
|
||||
/** 서바이벌 문장별, three players, playing. */
|
||||
const surv3 = () => tick(make({ mode: 'survival', elimination: 'sentence', rounds: 1 }, ['A', 'B', 'C']), START);
|
||||
/** Opens the next shared item (after the gap). */
|
||||
const open = (s: TypingState) => tick(s, s.curAt);
|
||||
|
||||
@@ -311,6 +316,82 @@ describe('타수 비교 · 정확도 대결 · 타임어택', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('서바이벌은 반드시 끝나요', () => {
|
||||
/** Fires the server clock until the game ends (nobody types). */
|
||||
const runClock = (s: TypingState, max = 500) => {
|
||||
let n = 0;
|
||||
while (s.phase !== 'ended' && n < max) {
|
||||
s = tick(s, typing.deadline!(s)!);
|
||||
n++;
|
||||
}
|
||||
return { s, n };
|
||||
};
|
||||
test.each(['wrong', 'sentence', 'interval', 'deadline'] as const)('%s: everybody away (all miss / all tie) → the survivors share the round after a few tries', (elimination) => {
|
||||
const { s, n } = runClock(make({ mode: 'survival', elimination, rounds: 2, lives: 3 }, ['A', 'B', 'C']));
|
||||
expect(s.phase).toBe('ended');
|
||||
expect(n).toBeLessThan(200);
|
||||
for (const r of s.rounds) {
|
||||
expect(r.winners.sort()).toEqual(['A', 'B', 'C']);
|
||||
expect(r.summary).toContain('더 탈락하는 사람이 없어서');
|
||||
}
|
||||
expect(typing.result(s)!.ranking).toEqual([['A', 'B', 'C']]);
|
||||
});
|
||||
|
||||
test(`a round where everybody always types in time stops after ${SURVIVAL_MAX_ITEMS} items`, () => {
|
||||
let s = tick(make({ mode: 'survival', elimination: 'deadline', rounds: 1 }, ['A', 'B']), START);
|
||||
let items = 0;
|
||||
while (s.phase === 'playing') {
|
||||
const fast = s.curAt + minTypingMs(keyCount(itemText(s, s.cur))) + 10;
|
||||
s = solve(s, 'A', fast);
|
||||
s = solve(s, 'B', fast + 10);
|
||||
items++;
|
||||
if (s.phase === 'playing') s = open(s);
|
||||
}
|
||||
expect(items).toBe(SURVIVAL_MAX_ITEMS);
|
||||
expect(s.rounds[0]!.winners.sort()).toEqual(['A', 'B']);
|
||||
});
|
||||
|
||||
test('one real knock-out resets the count of all-at-once misses', () => {
|
||||
let s = surv3();
|
||||
for (let i = 0; i < SURVIVAL_STALL_LIMIT - 1; i++) s = open(tick(s, s.curEndsAt!));
|
||||
expect(s.stalls).toBe(SURVIVAL_STALL_LIMIT - 1);
|
||||
s = solve(s, 'A');
|
||||
s = solve(s, 'B');
|
||||
expect(s.rs.C!.alive).toBe(false);
|
||||
expect(s.stalls).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('기록 표시', () => {
|
||||
test('after a round, a seat shows the same 타수 and accuracy as the result (nothing counted twice)', () => {
|
||||
let s = tick(make({ mode: 'speed', rounds: 2, category: 'word' }, ['A']), START);
|
||||
for (let r = 0; r < 2; r++) {
|
||||
const t0 = s.roundStartedAt;
|
||||
for (let i = 0; i < s.items.length; i++) s = act(s, 'A', { type: 'submit', item: i, text: i % 2 ? s.items[i]! : `${s.items[i]}x` }, t0 + (i + 1) * 3000);
|
||||
if (s.phase === 'roundEnd') {
|
||||
const seat = typing.view(s, 'A').seats[0]!;
|
||||
expect(seat.kpm).toBe(Math.round((s.totals.A!.keys * 60_000) / s.totals.A!.ms));
|
||||
s = tick(s, s.phaseEndsAt!);
|
||||
s = tick(s, s.phaseEndsAt!);
|
||||
}
|
||||
}
|
||||
expect(s.phase).toBe('ended');
|
||||
const seat = typing.view(s, 'A').seats[0]!;
|
||||
const fin = s.final!.ranking[0]!;
|
||||
expect(seat.kpm).toBe(fin.kpm);
|
||||
expect(seat.acc).toBe(fin.acc);
|
||||
});
|
||||
|
||||
test('all wrong answers: accuracy 0 is a real 0 (tried), not "nothing yet"', () => {
|
||||
let s = tick(make({ mode: 'speed', rounds: 1 }), START);
|
||||
let seat = typing.view(s, 'A').seats[0]!;
|
||||
expect(seat).toMatchObject({ roundTried: false, tried: false });
|
||||
s = act(s, 'A', { type: 'submit', item: 0, text: 'ㅋㅋㅋ' }, START + 5000);
|
||||
seat = typing.view(s, 'A').seats[0]!;
|
||||
expect(seat).toMatchObject({ roundTried: true, tried: true, roundAcc: 0, acc: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('leaving and clocks', () => {
|
||||
test('when everyone else leaves, the one who stayed wins', () => {
|
||||
let s = tick(make({}, ['A', 'B', 'C']), START);
|
||||
|
||||
Reference in New Issue
Block a user