타자 대결: 서바이벌이 반드시 끝나게(모두 동시 탈락·동점 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:
EJClaw
2026-11-12 12:53:45 +09:00
parent fffb860282
commit 122cf5ed1f
5 changed files with 119 additions and 9 deletions

View File

@@ -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,