Files
SodiumPet/tools/patch-rich1.cjs
T

96 lines
3.5 KiB
JavaScript
Raw 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')
}
// ---- 共享:物品经验 + 喜好加成 + eyeFollow 配置 + 每日礼包字段
patch('shared/petState.ts', [
[
` effects: Partial<Stats>
/** 教材类:使用后直接加经验 */
exp?: number
}`,
` effects: Partial<Stats>
/** 教材类:使用后直接加经验;其它物品按价格折算少量经验 */
exp?: number
/** 小钠喜欢的:效果 +20% */
liked?: boolean
}`
],
[
` save.inventory[itemId] = count - 1
for (const [k, v] of Object.entries(item.effects) as [StatKey, number][]) {
save.stats[k] = clamp(save.stats[k] + v)
}
if (item.exp) save.exp += item.exp
return { ok: true, message: \`用了 \${item.name}\` }`,
` save.inventory[itemId] = count - 1
const factor = item.liked ? 1.2 : 1
for (const [k, v] of Object.entries(item.effects) as [StatKey, number][]) {
save.stats[k] = clamp(save.stats[k] + Math.round(v * factor))
}
save.exp += item.exp ?? Math.min(15, Math.max(2, Math.round(item.price / 4)))
return { ok: true, message: item.liked ? \`用了 \${item.name}(她很喜欢!效果 +20%)\` : \`用了 \${item.name}\` }`
],
[
` sleeping: boolean
inventory: Record<string, number>`,
` sleeping: boolean
dailyGiftDay: string
inventory: Record<string, number>`
],
[
` sleeping: false,
inventory: { riceball: 2, oil: 2 },`,
` sleeping: false,
dailyGiftDay: '',
inventory: { riceball: 2, oil: 2 },`
],
[
` theme: 'day' | 'night'
accent: string`,
` theme: 'day' | 'night'
accent: string
/** Live2D 视线跟随鼠标 */
eyeFollow: boolean`
],
[
` scale: 1,
theme: 'night',
accent: '#ffd54a',`,
` scale: 1,
theme: 'night',
accent: '#ffd54a',
eyeFollow: false,`
],
// 喜好标记:石蜡油、蔗糖结晶、奶茶、小苏打汽水
[
`{ id: 'oil', name: '石蜡油', category: 'drink', price: 6, desc: '日常保养,必须喝', effects: { paraffin: 30 } },`,
`{ id: 'oil', name: '石蜡油', category: 'drink', price: 6, desc: '日常保养,必须喝', effects: { paraffin: 30 }, liked: true },`
],
[
`{ id: 'cake', name: '蔗糖结晶', category: 'meal', price: 40, desc: 'C₁₂H₂₂O₁₁,甜的东西最好了', effects: { satiety: 30, mood: 25 } },`,
`{ id: 'cake', name: '蔗糖结晶', category: 'meal', price: 40, desc: 'C₁₂H₂₂O₁₁,甜的东西最好了', effects: { satiety: 30, mood: 25 }, liked: true },`
],
[
`{ id: 'milktea', name: '乳浊液(三分糖)', category: 'drink', price: 22, desc: '稳定分散体系', effects: { electron: 15, mood: 12 } },`,
`{ id: 'milktea', name: '乳浊液(三分糖)', category: 'drink', price: 22, desc: '稳定分散体系', effects: { electron: 15, mood: 12 }, liked: true },`
],
[
`{ id: 'sodapop', name: '小苏打汽水', category: 'drink', price: 14, desc: 'NaHCO₃ + 柠檬酸,冒泡', effects: { electron: 10, mood: 8 } },`,
`{ id: 'sodapop', name: '小苏打汽水', category: 'drink', price: 14, desc: 'NaHCO₃ + 柠檬酸,冒泡', effects: { electron: 10, mood: 8 }, liked: true },`
]
])
console.log('shared patched')