dsh-pisces 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1
- package/lib/affinity.js +17 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/affinity.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// 口径(与 README 一致,别在这里加系数):
|
|
4
4
|
// - 初始 10;每共同存在一天 +0.5(最多 +15,即 30 天上限);
|
|
5
5
|
// - 他回话 heard +1.5;她开口 utterance +0.5;answer +2;reunion +5;diary +1;grant/grant_offer +1;
|
|
6
|
+
// - **重复型加分各自封顶**(2026-11-10 加):utterance 累计 ≤15、heard ≤20、diary ≤10。
|
|
7
|
+
// 原因:合并旧数据时一次灌进几百条,不封顶会直接把好感顶到 100(5 天就「离不开」)。
|
|
6
8
|
// - 她拒绝 refusal 不扣;他坚持/受伤(react 的 insist / hurt)分别 -3 / -6;
|
|
7
9
|
// - 被回答过的问题(questions 表 status='answered')每条 +2,最多 +10;
|
|
8
10
|
// - 冷落:距最后一条**真人互动**超过 7 天,每多一天 -1(最多 -10);
|
|
@@ -43,6 +45,13 @@ export const GAIN = {
|
|
|
43
45
|
/** 他坚持/受伤的扣分。leave/accept/other 不扣(拒绝本身也不扣)。 */
|
|
44
46
|
export const REACT_LOSS = { insist: 3, hurt: 6 }
|
|
45
47
|
|
|
48
|
+
/** 重复型加分的累计上限:防止一次性导入几百条把好感顶满。 */
|
|
49
|
+
export const GAIN_CAPS = {
|
|
50
|
+
utterance: 15,
|
|
51
|
+
heard: 20,
|
|
52
|
+
diary: 10,
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
/** 五档:min 是这一档的门槛。 */
|
|
47
56
|
export const TIERS = [
|
|
48
57
|
{ min: 0, label: '陌生' },
|
|
@@ -124,11 +133,18 @@ export function computeAffinity({ events = [], questions = [], now = Date.now()
|
|
|
124
133
|
|
|
125
134
|
let earned = dayBonus
|
|
126
135
|
let lastRealTs = null
|
|
136
|
+
const typed = {}
|
|
127
137
|
for (const e of list) {
|
|
128
138
|
if (isMachineEvent(e)) continue
|
|
129
|
-
|
|
139
|
+
const type = String(e.type || '')
|
|
140
|
+
const gain = GAIN[type] || 0
|
|
141
|
+
if (gain) typed[type] = (typed[type] || 0) + gain
|
|
130
142
|
lastRealTs = Number(e.ts)
|
|
131
143
|
}
|
|
144
|
+
for (const [type, sum] of Object.entries(typed)) {
|
|
145
|
+
const cap = GAIN_CAPS[type]
|
|
146
|
+
earned += cap == null ? sum : Math.min(cap, sum)
|
|
147
|
+
}
|
|
132
148
|
|
|
133
149
|
const answered = (Array.isArray(questions) ? questions : []).filter(
|
|
134
150
|
(q) => String(q?.status ?? '') === 'answered',
|