refactor(heroBox,skillDesc): 优化英雄面板技能描述显示

1. 新增showName参数控制技能描述是否显示技能名
2. 英雄盒面板隐藏技能名仅保留效果描述
3. 新增英雄强度评分公式设计文档
This commit is contained in:
panFD
2026-08-01 19:55:14 +08:00
parent 74860c6bf9
commit 096cae527b
5 changed files with 8900 additions and 8480 deletions

View File

@@ -229,7 +229,7 @@ function buildFieldLine(head: string, uuid: number, showName: boolean = true): I
* 复活revive结构化行复刻战斗公式高亮复活次数与回血百分比
* 复活次数 = r_num + floor((lv - 1) * upr);回血百分比 = SkillSet[s_uuid].ap
*/
function buildReviveLine(source: ISkillDescSource): ISkillLine | null {
function buildReviveLine(source: ISkillDescSource, showName: boolean = true): ISkillLine | null {
const revive = source.revive;
if (!revive) return null;
const base = SkillSet[revive.s_uuid];
@@ -238,9 +238,10 @@ function buildReviveLine(source: ISkillDescSource): ISkillLine | null {
const maxCount = revive.r_num + Math.floor((lv - 1) * revive.upr);
const hpPct = base.ap ?? 0;
const tpl = SkillTriggerName[SkillTriggerType.Revive] ?? "复活";
const nameSeg = showName ? `${base.name}` : "";
// 高亮片段选回血百分比(数值中最关键的收益指标)
return {
prefix: `${tpl}:${base.name}可复活${maxCount}次,每次恢复`,
prefix: `${tpl}:${nameSeg}可复活${maxCount}次,每次恢复`,
value: `${hpPct}%`,
suffix: "生命",
};
@@ -268,8 +269,9 @@ function buildEvolveBonusLines(source: ISkillDescSource): ISkillLine[] {
/**
* 构建全部能力结构化行(触发技能 + 驻场光环 + 复活 + evolve 加成)。
* 纯文本与富文本两个公开接口共用此结果,仅渲染阶段不同。
* @param showName 是否在行中包含「技能名」片段(英雄盒面板传 false 隐藏技能名)
*/
function buildSkillLines(source: ISkillDescSource): ISkillLine[] {
function buildSkillLines(source: ISkillDescSource, showName: boolean = true): ISkillLine[] {
const lines: ISkillLine[] = [];
// ---- 6 种标准触发技能 ----
@@ -285,7 +287,8 @@ function buildSkillLines(source: ISkillDescSource): ISkillLine[] {
if (!base) continue;
const skill = mergeSkillParams(base, item.overrides);
const trigger = needCount ? `${name}×${item.t_num}` : name;
lines.push(buildEffectLine(`${trigger}:${base.name}`, skill));
const nameSeg = showName ? `${base.name}` : "";
lines.push(buildEffectLine(`${trigger}:${nameSeg}`, skill));
}
}
@@ -294,13 +297,13 @@ function buildSkillLines(source: ISkillDescSource): ISkillLine[] {
if (fieldUuids?.length) {
const tpl = SkillTriggerName[SkillTriggerType.Field] ?? "光环";
for (const uuid of fieldUuids) {
const line = buildFieldLine(`${tpl}:`, uuid, true);
const line = buildFieldLine(`${tpl}:`, uuid, showName);
if (line) lines.push(line);
}
}
// ---- 复活revive----
const reviveLine = buildReviveLine(source);
const reviveLine = buildReviveLine(source, showName);
if (reviveLine) lines.push(reviveLine);
// ---- evolve 额外属性加成ap/hp----
@@ -322,11 +325,12 @@ export function buildSkillDesc(source: ISkillDescSource): string {
/**
* 富文本描述RichText 用BBCode技能名用 <color=#2E86C1> 蓝色、数值用 <color=#27AE60> 亮绿色高亮。
* @param source 触发技能数据源(同 buildSkillDesc
* @returns 多行富文本串,技能名片段包裹 <color=#2E86C1>、数值片段包裹 <color=#27AE60>,用 \n 分隔
* @param source 触发技能数据源(同 buildSkillDesc
* @param showName 是否包含「技能名片段(英雄盒面板传 false 隐藏技能名,默认 true
* @returns 多行富文本串,技能名片段包裹 <color=#2E86C1>、数值片段包裹 <color=#27AE60>,用 \n 分隔
*/
export function buildSkillDescRich(source: ISkillDescSource): string {
return buildSkillLines(source)
export function buildSkillDescRich(source: ISkillDescSource, showName: boolean = true): string {
return buildSkillLines(source, showName)
.map(l => {
const prefix = l.prefix.replace(SKILL_NAME_PATTERN, `「<color=${RICH_NAME_COLOR}>$1</color>」`);
const text = l.value

View File

@@ -401,8 +401,8 @@ export class HeroBoxComp extends CCComp {
// ---- 技能描述(当前等级触发技能,读运行时 model 最终配置;数值富文本高亮) ----
if (this.skill_label && this.skill_label.isValid) {
// 缓存未变则跳过重设,避免 refresh 降频内 RichText 重复重解析排版
const desc = buildSkillDescRich(this.model);
// 缓存未变则跳过重设,避免 refresh 降频内 RichText 重复重解析排版;隐藏「技能名」仅保留效果描述
const desc = buildSkillDescRich(this.model, false);
if (desc !== this.skillDescCache) {
this.skillDescCache = desc;
this.skill_label.string = desc;