Files

157 lines
5.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fs = require('fs')
const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/'
function patch(file, pairs) {
const p = base + file
let c = fs.readFileSync(p, 'utf8')
for (const [from, to] of pairs) {
if (!c.includes(from)) {
console.log('MISS in', file, '::', from.slice(0, 70).replace(/\n/g, '\\n'))
continue
}
c = c.replace(from, to)
}
fs.writeFileSync(p, c, 'utf8')
}
// 1) 增加 4 条化学 + 4 条普通预设(带增益/减益分支)
{
const p = base + 'shared/dialogue.ts'
let c = fs.readFileSync(p, 'utf8')
const extraChem = `
{
id: 'c9',
text: '摸了摸你的头',
textNormal: '摸了摸你的头',
kind: 'buff',
replyGood: '(眯起眼睛)唔……手法越来越熟练了嘛 (๑•̀ㅂ•́)و✧',
replyBad: '(别过头)头发会乱的啦……',
good: { mood: 4, bond: 2, toast: '心情 +4 · 亲和 +2' },
bad: { mood: -1, toast: '心情 −1' }
},
{
id: 'c10',
text: '给你递了块抛光砂纸',
textNormal: '给你递了块湿巾',
kind: 'buff',
replyGood: '(接过来)谢谢!这个刚好能擦掉表层氧化膜~',
replyBad: '(看了看)这个好像太粗了,会把我磨花的……',
good: { mood: 3, bond: 1, toast: '心情 +3 · 亲和 +1' },
bad: { electron: -2, mood: -2, toast: '精力 −2 · 心情 −2' }
},
{
id: 'c11',
text: '听说你今天实验做得很好',
textNormal: '听说你今天做得很好',
kind: 'buff',
replyGood: '(耳朵发红)诶、被夸了……嘿嘿',
replyBad: '(低头)其实有个步骤我搞错了……',
good: { mood: 6, bond: 2, toast: '心情 +6 · 亲和 +2' },
bad: { mood: -3, toast: '心情 −3' }
},
{
id: 'c12',
text: '(神秘)发现一瓶不明溶液',
textNormal: '(神秘)发现一瓶不明饮料',
kind: 'random',
replyGood: '(小心尝了一口)……哇,电子好像活跃起来了!',
replyBad: '(表情凝固)呜……这反应不对劲,胃里在冒泡……',
good: { electron: 7, mood: 3, toast: '精力 +7 · 心情 +3' },
bad: { electron: -5, mood: -5, satiety: -3, toast: '精力 −5 · 心情 −5 · 饱食 −3' }
}
`
const extraNormal = `
{
id: 'n9',
text: '给你倒了杯温水',
textNormal: '给你倒了杯温水',
kind: 'buff',
replyGood: '(捧着杯子)谢谢~ 暖暖的很舒服',
replyBad: '(小口喝了一点)谢谢……不过我现在还不渴',
good: { paraffinFix: 0, mood: 3, toast: '心情 +3' },
bad: { mood: 1, toast: '心情 +1' }
},
{
id: 'n10',
text: '陪你坐了一会儿',
textNormal: '陪你坐了一会儿',
kind: 'buff',
replyGood: '(靠过来)就这样安静待着也挺好的',
replyBad: '(有点坐不住)嗯……今天想一个人待会儿',
good: { mood: 4, bond: 3, toast: '心情 +4 · 亲和 +3' },
bad: { mood: -1, toast: '心情 −1' }
},
{
id: 'n11',
text: '给你看了个搞笑的视频',
textNormal: '给你看了个搞笑的视频',
kind: 'random',
replyGood: '(笑到拍桌)哈哈哈哈这个也太蠢了吧!',
replyBad: '(一脸茫然)……嗯?笑点在哪?',
good: { mood: 7, toast: '心情 +7' },
bad: { mood: -2, toast: '心情 −2' }
},
{
id: 'n12',
text: '把外套披在你肩上',
textNormal: '把外套披在你肩上',
kind: 'buff',
replyGood: '(裹紧外套)嘿嘿,很暖和,谢谢你',
replyBad: '(缩了缩)唔……我不太喜欢被盖住',
good: { mood: 5, bond: 2, electron: 3, toast: '心情 +5 · 亲和 +2 · 精力 +3' },
bad: { mood: -2, toast: '心情 −2' }
}
`
// 插入到数组末尾(在最后的 } 之前)
const chemEnd = c.indexOf("const NORMAL_PRESETS")
if (chemEnd > 0) {
const before = c.slice(0, chemEnd)
const closeIdx = before.lastIndexOf(']\n\n')
c = before.slice(0, closeIdx) + extraChem + ']\n\n' + c.slice(chemEnd)
}
const normEnd = c.indexOf('export function presetsFor')
if (normEnd > 0) {
const before = c.slice(0, normEnd)
const closeIdx = before.lastIndexOf(']\n\n')
c = before.slice(0, closeIdx) + extraNormal + ']\n\n' + c.slice(normEnd)
}
// good/bad 类型加 paraffin/oxidation 字段兼容
c = c.replace(
" good: { mood?: number; bond?: number; electron?: number; satiety?: number; toast: string }",
" good: { mood?: number; bond?: number; electron?: number; satiety?: number; paraffin?: number; oxidation?: number; toast: string }"
)
c = c.replace("paraffinFix: 0,", "paraffin: 6,")
fs.writeFileSync(p, c, 'utf8')
console.log('presets extended')
}
// 2) ChatBar:显示数值反馈
patch('renderer/src/chat/ChatBar.tsx', [
[
" const [flavor, setFlavor] = useState<'chemistry' | 'normal'>('chemistry')",
" const [flavor, setFlavor] = useState<'chemistry' | 'normal'>('chemistry')\n const [feedback, setFeedback] = useState('')"
],
[
` setOpen(false)
void api()?.chatPreset(p.id)`,
` setOpen(false)
api()?.setChatExpanded(false)
void api()
?.chatPreset(p.id)
.then((r) => {
if (r?.message) {
setFeedback(r.message)
window.setTimeout(() => setFeedback(''), 2800)
}
})`
],
[
` {open && (
<div className="chat-suggest">`,
` {feedback && <div className="chat-feedback">{feedback}</div>}
{open && (
<div className="chat-suggest">`
]
])
console.log('chat feedback patched')