/** * 战斗扣血链路诊断(Release 真机用 console.warn,便于抖音开发者工具截图)。 * 验证完成后可 setCombatDamageTraceEnabled(false) 或删本模块。 */ const TAG = '[DMG-TRACE]'; let _enabled = false; let _logCount = 0; const MAX_LOGS = 120; const THROTTLE_MS = 250; const _throttle = new Map(); export function setCombatDamageTraceEnabled(enabled: boolean): void { _enabled = enabled; if (!enabled) _throttle.clear(); } export function resetCombatDamageTrace(): void { _logCount = 0; _throttle.clear(); } export function traceCombatDamage(stage: string, detail?: Record): void { if (!_enabled || _logCount >= MAX_LOGS) return; const entityKey = String( detail?.target ?? detail?.victim ?? detail?.entity ?? detail?.caster ?? '', ); const throttleKey = `${stage}:${entityKey}`; const now = Date.now(); const last = _throttle.get(throttleKey) ?? 0; if (now - last < THROTTLE_MS) return; _throttle.set(throttleKey, now); _logCount++; console.log(TAG, stage); }