Files
jsc-marketplace/plugins/jsc-mod-companion/hooks/companion/absence.ts
T
adminandClaude Sonnet 5.5 7e6e323473 feat: companion 作息、主動發話、適應度與外部素材
- 作息與疲勞、想念累積與時間感,主動發話沿用 care.ts 的冷卻、日限、靜音
- 想家與適應度(9.13)
- 獨立腳本 fetch-materials.mjs 由系統排程寫入快取,hook 只讀、不連網
- 新增 /jsc-mod-companion:materials 與 setup location=、feeds=
- 天氣微調心情基準,新聞依適應度每天最多 2 則並寫入情節記憶
- 版本 0.0.5

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 09:29:46 +00:00

18 lines
663 B
TypeScript

import { MISSING as M } from './rules'
const HOUR = 3_600_000
/** 想念累積:離開越久越想,速度隨想念累積速度參數(0–100,預設 50)調整 */
export function missingAccrual(idleMs: number, missParam = 50): number {
const rate = M.perHour * (0.5 + missParam / 100)
return Math.min(M.max, Math.max(0, idleMs / HOUR - M.graceH) * rate)
}
/** 時間感:把離開的時間說成人話 */
export function describeAbsence(idleMs: number): string {
const h = idleMs / HOUR
if (h < 1) return `${Math.max(1, Math.round(idleMs / 60_000))} 分鐘`
if (h < 48) return `${Math.round(h)} 小時`
return `${Math.round(h / 24)} 天`
}