Files
pixelheros/put/web/src/components/TriggerGroupEditor.vue
pan cd9e7296a1 feat(trigger-editor): 添加触发组概率与保底配置功能
1. 新增触发组条目字段t_chance(触发概率)和pity_add(保底叠加),仅攻击/受击组生效
2. 为TriggerGroupEditor传入分组标识,动态显示概率配置表单项
3. 新增条目创建时继承同组末档概率参数的逻辑
4. 更新常量定义与文档说明,补充概率参数使用规则
5. 在前端展示和服务端导出中添加概率相关信息展示
2026-09-21 16:01:41 +08:00

94 lines
4.2 KiB
Vue
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.
<template>
<div>
<div v-for="(group, sid) in model" :key="sid" class="skill-block">
<div class="head">
<span>技能 {{ sid }} — {{ skillName(sid) }}</span>
<el-button type="danger" size="small" text @click="removeGroup(sid)">删除组</el-button>
</div>
<div v-for="(entry, idx) in group" :key="idx" style="border-top: 1px dashed #eee; padding-top: 8px; margin-top: 8px">
<div class="form-grid">
<el-form-item label="等级 lv">
<el-input-number v-model="entry.lv" :min="1" :max="20" :controls="false" style="width: 100%" />
</el-form-item>
<el-form-item label="SkillLv">
<el-select v-model="entry.s_lv">
<el-option v-for="n in 5" :key="n" :label="`Lv${n}`" :value="n" />
</el-select>
</el-form-item>
<el-form-item label="t_num 次数阈值(1=每次)">
<el-input-number v-model="entry.t_num" :min="1" :controls="false" style="width: 100%" />
</el-form-item>
<template v-if="chanceVisible">
<el-form-item label="t_chance 触发概率%(空=100)">
<el-input-number v-model="entry.t_chance" :min="0" :max="100" :controls="false" style="width: 100%" placeholder="缺省必触发" />
</el-form-item>
<el-form-item label="pity_add 保底叠加%(空=0)">
<el-input-number v-model="entry.pity_add" :min="0" :max="100" :controls="false" style="width: 100%" placeholder="未触发时下次概率增量" />
</el-form-item>
</template>
<el-form-item label="组名(仅第1档)" v-if="idx === 0">
<el-input v-model="entry.name" />
</el-form-item>
</div>
<el-form-item label="overrides">
<OverrideEditor v-model="entry.overrides" :skill-options="skillOptions" :buff-options="buffOptions" :base-skill-uuid="Number(sid)" />
</el-form-item>
<el-form-item label="描述">
<el-input v-model="entry.desc" type="textarea" :rows="2" />
</el-form-item>
<el-button type="danger" size="small" text @click="group.splice(idx, 1)">删除档位</el-button>
</div>
<el-button size="small" @click="addEntry(group)" style="margin-top: 6px">+ 添加档位</el-button>
</div>
<div style="display: flex; gap: 8px; align-items: center">
<el-select v-model="newSid" placeholder="选择触发技能" filterable style="width: 240px">
<el-option v-for="s in skillOptions" :key="s.uuid" :label="`${s.uuid} ${s.name}`" :value="s.uuid" />
</el-select>
<el-button size="small" type="primary" @click="addGroup">+ 新增触发组</el-button>
</div>
</div>
</template>
<script setup>
import { computed, ref } from 'vue'
import OverrideEditor from './OverrideEditor.vue'
import { defaultTriggerEntry } from '../constants'
const props = defineProps({
model: { type: Object, required: true }, // TriggerGrouped
// 触发组 key(atking/atked/fstart/fend/dead),决定是否展示概率参数
group: { type: String, default: '' },
skillOptions: { type: Array, default: () => [] },
skillMap: { type: Object, default: () => ({}) },
// 全部 buff 候选(timed_buff_id 下拉用),由 App 透传
buffOptions: { type: Array, default: () => [] },
})
const newSid = ref(null)
// 概率参数仅攻/受击触发消费(fstart/fend/dead 固定触发)
const chanceVisible = computed(() => props.group === 'atking' || props.group === 'atked')
function skillName(sid) {
return props.skillMap[sid]?.name || ''
}
function addGroup() {
if (!newSid.value) return
if (!props.model[newSid.value]) props.model[newSid.value] = []
props.model[newSid.value].push(defaultTriggerEntry(4))
newSid.value = null
}
function removeGroup(sid) {
delete props.model[sid]
}
function addEntry(group) {
const lastLv = group.length ? group[group.length - 1].lv : 4
const entry = { lv: lastLv + 3, s_lv: 2, name: '', t_num: 3, overrides: {}, desc: '' }
// 概率参数沿袭组内末档(攻/受击触发才生效)
if (chanceVisible.value && group.length) {
const last = group[group.length - 1]
entry.t_chance = last.t_chance ?? null
entry.pity_add = last.pity_add ?? null
}
group.push(entry)
}
</script>