From 987ad74de0d3a0a579a134ae84908e57a8a44334 Mon Sep 17 00:00:00 2001 From: dahyeon Date: Wed, 12 Aug 2026 10:27:14 -0700 Subject: [PATCH] . --- src/components/AutomationPanel.tsx | 47 ++++++++++++++++++++--------- test/salvo-offsets.test.ts | 18 +++++++++++ test/screenshots/e2e.png | Bin 92333 -> 92674 bytes 3 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 test/salvo-offsets.test.ts diff --git a/src/components/AutomationPanel.tsx b/src/components/AutomationPanel.tsx index e40158e..d7104bc 100644 --- a/src/components/AutomationPanel.tsx +++ b/src/components/AutomationPanel.tsx @@ -14,9 +14,12 @@ import { CLOCK_CALIBRATION_DEFAULTS } from '../type/reservation' const MAX_SALVO_ATTEMPTS = 8 -// n개의 토큰을 목표 시각 0을 중심으로 stepMs 간격으로 대칭 배치한 오프셋 목록을 만든다. -function symmetricOffsets(count: number, stepMs: number) { - return Array.from({ length: count }, (_, index) => Math.round((index - (count - 1) / 2) * stepMs)) +// 토큰 수별 기본 오프셋: 1개는 +0, 그 이상은 -50 헤지 하나 뒤로 0부터 +50씩 증가. +// 1→[0] · 2→[-50,0] · 3→[-50,0,50] · 4→[-50,0,50,100] · … +export function defaultSalvoOffsets(count: number) { + if (count <= 0) return [] + if (count === 1) return [0] + return [-50, ...Array.from({ length: count - 1 }, (_, index) => index * 50)] } const KST_OFFSET_MS = 9 * 60 * 60 * 1_000 @@ -135,7 +138,7 @@ export default function AutomationPanel({ const [settingsOpen, setSettingsOpen] = useState(false) const [clockSettings, setClockSettings] = useState(loadClockSettings) const [tokens, setTokens] = useState([]) - const [salvoStepMs, setSalvoStepMs] = useState(300) + const [offsets, setOffsets] = useState([]) const [stopOnSuccess, setStopOnSuccess] = useState(true) const [salvoState, setSalvoState] = useState({ status: 'idle', stopOnSuccess: true, attempts: [] }) const [salvoBusy, setSalvoBusy] = useState<'token' | 'arm' | null>(null) @@ -157,13 +160,13 @@ export default function AutomationPanel({ const armed = autoState.status === 'armed' || autoState.status === 'firing' const salvoArmed = salvoState.status === 'armed' || salvoState.status === 'firing' const attemptCount = Math.min(tokens.length, MAX_SALVO_ATTEMPTS) - const salvoOffsets = useMemo(() => symmetricOffsets(attemptCount, salvoStepMs), [attemptCount, salvoStepMs]) const salvoTokenState = tokens.slice(0, attemptCount).map((token, index) => { - const effectiveTargetServerMs = targetServerTimeMs + userOffsetMs + salvoOffsets[index] + const offsetMs = offsets[index] ?? 0 + const effectiveTargetServerMs = targetServerTimeMs + userOffsetMs + offsetMs const ageAtTargetMs = Number.isFinite(effectiveTargetServerMs) ? effectiveTargetServerMs - (token.solvedAtMs + (clock?.offsetMs ?? 0)) : Number.POSITIVE_INFINITY - return { token, offsetMs: salvoOffsets[index], ageAtTargetMs, ready: ageAtTargetMs >= 0 && ageAtTargetMs <= 90_000 } + return { token, offsetMs, ageAtTargetMs, ready: ageAtTargetMs >= 0 && ageAtTargetMs <= 90_000 } }) const salvoReady = attemptCount > 0 && salvoBaseRequest !== null && Number.isFinite(targetServerTimeMs) && salvoTokenState.every((item) => item.ready) @@ -219,6 +222,15 @@ export default function AutomationPanel({ } }, [autoState, onResult, onTokenConsumed]) + useEffect(() => { + // 토큰 수가 바뀌면 오프셋 배열 길이를 맞춘다. 기존 편집값은 유지하고, 새로 늘어난 칸만 기본 패턴으로 채운다. + setOffsets((current) => { + if (current.length === attemptCount) return current + const fallback = defaultSalvoOffsets(attemptCount) + return Array.from({ length: attemptCount }, (_, index) => current[index] ?? fallback[index]) + }) + }, [attemptCount]) + useEffect(() => { if (previousSalvoStatus.current !== salvoState.status) { if (salvoState.status === 'succeeded' && salvoState.result) { @@ -468,10 +480,15 @@ export default function AutomationPanel({

토큰이 없습니다. ‘토큰 생성’을 눌러 인증 창에서 캡차를 풀면 토큰이 하나씩 쌓입니다.

) : (