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:
@@ -1,14 +1,61 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-for="(b, idx) in model" :key="idx" style="display: flex; gap: 8px; margin-bottom: 6px">
|
||||
<el-input-number v-model="b.lv" :min="1" :max="20" :controls="false" style="width: 100px" placeholder="lv" />
|
||||
<el-input-number v-model="b.value" :controls="false" style="width: 140px" placeholder="value" />
|
||||
<el-button type="danger" size="small" text @click="model.splice(idx, 1)">删除</el-button>
|
||||
<div v-for="(b, idx) in model" :key="idx" class="skill-block">
|
||||
<div class="head">
|
||||
<span>加成档位 lv {{ b.lv }}</span>
|
||||
<el-button type="danger" size="small" text @click="model.splice(idx, 1)">删除档位</el-button>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<el-form-item label="等级 lv">
|
||||
<el-input-number v-model="b.lv" :min="1" :max="20" :controls="false" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="属性加成">
|
||||
<div style="width: 100%">
|
||||
<div v-for="(a, i) in attrList(b)" :key="i" style="display: flex; gap: 8px; margin-bottom: 6px">
|
||||
<el-select :model-value="a.key" placeholder="属性" style="width: 220px" @update:model-value="(k) => renameKey(b, a.key, k)">
|
||||
<el-option v-for="opt in BONUS_ATTR_KEYS" :key="opt.key" :label="opt.label" :value="opt.key" :disabled="hasKey(b, opt.key, a.key)" />
|
||||
</el-select>
|
||||
<el-input-number v-model="b.attrs[a.key]" :controls="false" style="width: 140px" placeholder="value" />
|
||||
<el-button type="danger" size="small" text @click="removeKey(b, a.key)">删除</el-button>
|
||||
</div>
|
||||
<el-button size="small" @click="addKey(b)">+ 添加属性</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-button size="small" @click="model.push({ lv: 12, value: 0 })">+ 添加</el-button>
|
||||
<el-button size="small" type="primary" @click="model.push({ lv: 9, attrs: {} })">+ 添加加成档位</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { BONUS_ATTR_KEYS } from '../constants'
|
||||
|
||||
defineProps({ model: { type: Array, required: true } })
|
||||
|
||||
// attrs 对象为键值对,转列表渲染(保持键序稳定)
|
||||
function attrList(b) {
|
||||
return Object.keys(b.attrs).map((key) => ({ key }))
|
||||
}
|
||||
function hasKey(b, key, except) {
|
||||
return key !== except && b.attrs[key] !== undefined
|
||||
}
|
||||
function addKey(b) {
|
||||
const free = BONUS_ATTR_KEYS.find((o) => b.attrs[o.key] === undefined)
|
||||
if (free) b.attrs[free.key] = 0
|
||||
}
|
||||
function removeKey(b, key) {
|
||||
delete b.attrs[key]
|
||||
}
|
||||
// 换键:删旧键、写新键(保留原值)
|
||||
function renameKey(b, oldKey, newKey) {
|
||||
const v = b.attrs[oldKey]
|
||||
delete b.attrs[oldKey]
|
||||
b.attrs[newKey] = v
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.skill-block { border: 1px solid var(--el-border-color); border-radius: 4px; padding: 10px; margin-bottom: 10px; }
|
||||
.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
|
||||
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user