feat: SodiumPet 小钠桌宠 v0.1.0(Live2D 桌宠 / 经济任务 / 音乐 / 成就 / 编辑器 / MOD)
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
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')
|
||||
}
|
||||
|
||||
// elements.ts:分类 + 配色方案
|
||||
{
|
||||
const p = base + 'shared/elements.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
c += `
|
||||
|
||||
export type ElementCategory =
|
||||
| 'alkali'
|
||||
| 'alkaline'
|
||||
| 'transition'
|
||||
| 'postmetal'
|
||||
| 'metalloid'
|
||||
| 'nonmetal'
|
||||
| 'halogen'
|
||||
| 'noble'
|
||||
| 'lanthanide'
|
||||
| 'actinide'
|
||||
|
||||
export const CATEGORY_LABEL: Record<ElementCategory, string> = {
|
||||
alkali: '碱金属',
|
||||
alkaline: '碱土金属',
|
||||
transition: '过渡金属',
|
||||
postmetal: '主族金属',
|
||||
metalloid: '类金属',
|
||||
nonmetal: '非金属',
|
||||
halogen: '卤素',
|
||||
noble: '稀有气体',
|
||||
lanthanide: '镧系',
|
||||
actinide: '锕系'
|
||||
}
|
||||
|
||||
export const CATEGORY_COLORS: Record<ElementCategory, string> = {
|
||||
alkali: '#ff9d76',
|
||||
alkaline: '#ffcf6b',
|
||||
transition: '#8ee6c8',
|
||||
postmetal: '#7fc7ff',
|
||||
metalloid: '#b9e07a',
|
||||
nonmetal: '#8fe1b0',
|
||||
halogen: '#ffcf8a',
|
||||
noble: '#c9a8ff',
|
||||
lanthanide: '#ffb0d0',
|
||||
actinide: '#f4a6a6'
|
||||
}
|
||||
|
||||
const CATEGORY_SETS: Array<[ElementCategory, number[]]> = [
|
||||
['alkali', [3, 11, 19, 37, 55, 87]],
|
||||
['alkaline', [4, 12, 20, 38, 56, 88]],
|
||||
['transition', [
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
||||
72, 73, 74, 75, 76, 77, 78, 79, 80,
|
||||
104, 105, 106, 107, 108, 109, 110, 111, 112
|
||||
]],
|
||||
['postmetal', [13, 31, 49, 50, 81, 82, 83, 84, 113, 114, 115, 116]],
|
||||
['metalloid', [5, 14, 32, 33, 51, 52]],
|
||||
['nonmetal', [1, 6, 7, 8, 15, 16, 34]],
|
||||
['halogen', [9, 17, 35, 53, 85, 117]],
|
||||
['noble', [2, 10, 18, 36, 54, 86, 118]],
|
||||
['lanthanide', [57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71]],
|
||||
['actinide', [89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103]]
|
||||
]
|
||||
|
||||
export function categoryOf(z: number): ElementCategory {
|
||||
for (const [cat, list] of CATEGORY_SETS) {
|
||||
if (list.includes(z)) return cat
|
||||
}
|
||||
return 'transition'
|
||||
}
|
||||
|
||||
/** 周期表配色方案:block = 按能级块,category = 按元素分类 */
|
||||
export type PeriodicScheme = 'block' | 'category'
|
||||
|
||||
export interface PeriodicStyle {
|
||||
scheme: PeriodicScheme
|
||||
/** 自定义颜色覆盖:block 用 s/p/d/f,category 用分类 key */
|
||||
colors?: Record<string, string>
|
||||
/** 底图背景色 */
|
||||
bg?: string
|
||||
}
|
||||
|
||||
export const DEFAULT_PERIODIC_STYLE: PeriodicStyle = {
|
||||
scheme: 'block',
|
||||
colors: {},
|
||||
bg: '#0e1420'
|
||||
}
|
||||
|
||||
export function periodicCellColor(
|
||||
el: { z: number; block: string },
|
||||
style: PeriodicStyle
|
||||
): string {
|
||||
const custom = style.colors ?? {}
|
||||
if (style.scheme === 'category') {
|
||||
const cat = categoryOf(el.z)
|
||||
return custom[cat] ?? CATEGORY_COLORS[cat]
|
||||
}
|
||||
return custom[el.block] ?? BLOCK_COLOR[el.block] ?? '#8b98ad'
|
||||
}
|
||||
`
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
}
|
||||
|
||||
// catalog:periodic 字段
|
||||
patch('shared/catalog.ts', [
|
||||
[
|
||||
"import { ITEMS, JOBS, type Item, type JobDef } from './petState'",
|
||||
"import { ITEMS, JOBS, type Item, type JobDef } from './petState'\nimport { DEFAULT_PERIODIC_STYLE, type PeriodicStyle } from './elements'"
|
||||
],
|
||||
[
|
||||
`export interface CatalogData {
|
||||
items?: Item[]
|
||||
jobs?: JobDef[]
|
||||
levels?: CatalogLevels
|
||||
}`,
|
||||
`export interface CatalogData {
|
||||
items?: Item[]
|
||||
jobs?: JobDef[]
|
||||
levels?: CatalogLevels
|
||||
periodic?: PeriodicStyle
|
||||
}`
|
||||
],
|
||||
[
|
||||
`let CURRENT_LEVELS: CatalogLevels = {}`,
|
||||
`let CURRENT_LEVELS: CatalogLevels = {}
|
||||
let CURRENT_PERIODIC: PeriodicStyle = { ...DEFAULT_PERIODIC_STYLE }
|
||||
|
||||
export function getPeriodicStyle(): PeriodicStyle {
|
||||
return CURRENT_PERIODIC
|
||||
}`
|
||||
],
|
||||
[
|
||||
" if (data.levels) CURRENT_LEVELS = data.levels",
|
||||
" if (data.levels) CURRENT_LEVELS = data.levels\n if (data.periodic) CURRENT_PERIODIC = data.periodic"
|
||||
],
|
||||
[
|
||||
` levels: JSON.parse(JSON.stringify(CURRENT_LEVELS))
|
||||
}`,
|
||||
` levels: JSON.parse(JSON.stringify(CURRENT_LEVELS)),
|
||||
periodic: JSON.parse(JSON.stringify(CURRENT_PERIODIC))
|
||||
}`
|
||||
]
|
||||
])
|
||||
|
||||
console.log('periodic schemes patched')
|
||||
Reference in New Issue
Block a user