refactor(hero): 重构额外属性加成系统,统一为bonus字段

1.  将原ap_bonus/hp_bonus/def_bonus三个字段合并为通用的bonus数组结构
2.  新增多属性同时配置能力,支持hp/ap/def百分比加成与crt/frz/stun/para固定百分点加成
3.  更新所有前端编辑器、服务端渲染与游戏运行时逻辑适配新配置格式
4.  添加数据兼容迁移逻辑,自动处理旧版英雄配置数据
This commit is contained in:
panFD
2026-09-07 23:05:30 +08:00
parent a1c8f46c50
commit ed738d2e30
10 changed files with 180 additions and 94 deletions

View File

@@ -202,11 +202,13 @@ function renderSingleHero(h) {
// 复活已纳入 dead 触发组,通过 dead 编辑器的 overrides 配置 revive_hp / revive_count
// 不再导出独立的 revive 字段
// bonuses
for (const bk of ['ap_bonus', 'hp_bonus', 'def_bonus']) {
if (!h[bk]?.length) continue
push(` ${bk}: [`)
for (const b of h[bk]) push(` { lv: ${b.lv}, value: ${b.value} },`)
// bonus(统一额外属性加成:hp/ap/def 百分比 + crt/frz/stun/para 百分点;跳过空 attrs 档位)
const bonusList = (h.bonus || []).filter((b) => b.attrs && Object.keys(b.attrs).length)
if (bonusList.length) {
push(` bonus: [`)
for (const b of bonusList) {
push(` { lv: ${b.lv}, attrs: ${JSON.stringify(b.attrs)} },`)
}
push(` ],`)
}
@@ -325,6 +327,18 @@ function csvStatLine(h, key) {
return `${role}${base > 0 ? '+' : ''}${base}`
}
/** bonus 描述行:lv9 ap+20% hp+15%;lv12 crt+10 ap+30% */
function csvBonus(bonus) {
if (!bonus?.length) return '无'
return bonus
.filter((b) => b.attrs && Object.keys(b.attrs).length)
.map((b) => {
const parts = Object.entries(b.attrs).map(([k, v]) => (k === 'hp' || k === 'ap' || k === 'def') ? `${k}+${v}%` : `${k}+${v}`)
return `lv${b.lv} ${parts.join(' ')}`
})
.join(';') || '无'
}
/** 生成英雄设计表 CSV 内容 */
function renderHeroCsv(heroes) {
const sorted = [...heroes].sort((a, b) => a.uuid - b.uuid)
@@ -350,6 +364,7 @@ function renderHeroCsv(heroes) {
rows.push(['fstart[0]_lv4', ...sorted.map((h) => csvTrigger(h.fstart))])
rows.push(['dead[0]_lv4', ...sorted.map((h) => csvTrigger(h.dead))])
rows.push(['field[0]_lv4', ...sorted.map((h) => csvField(h.field))])
rows.push(['bonus', ...sorted.map((h) => csvBonus(h.bonus))])
return rows.map((r) => r.map(csvCell).join(',')).join('\n') + '\n'
}