refactor(hero skill): 重构英雄技能描述生成逻辑

1.  抽离原HeroSkillDesc工具函数为独立HeroSkillText模块
2.  简化英雄局外技能描述生成逻辑,移除冗余的数据源构造步骤
3.  新增结构化技能档位数据接口,拆分整段文本输出与结构化输出能力
4.  优化默认隐藏普攻技能展示,减少冗余信息
This commit is contained in:
pan
2026-08-27 21:06:34 +08:00
parent d929a99172
commit 39cbb2eed4
3 changed files with 97 additions and 67 deletions

View File

@@ -20,7 +20,7 @@ import { _decorator, Node, Sprite, Label, RichText, NodeEventType, Vec3, Tween,
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroInfo, HeroCardConfig } from "../common/config/heroSet";
import { buildSkillDescMoreRich, ISkillDescSource } from "../common/config/HeroSkillDesc";
import { buildHeroSkillDesc } from "../common/HeroSkillText";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { outlineRich } from "../common/RichOutline";
@@ -270,11 +270,11 @@ export class CHeroComp extends CCComp {
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
this.updateBgNode();
// 描述富文本:展示英雄当前局外等级的能力(buildSkillDescMoreRich)
// 与英雄信息弹窗同一套文案规则,杜绝手写文案与数值漂移
// 描述富文本:展示英雄当前局外等级的能力(buildHeroSkillDesc 文本一)
// 行首「技能名」: + 效果文本;heroInfo 内联 desc 模板驱动,数值实时取合并后配置
// outlineRich 为整段富文本包裹描边,提升深色面板可读性
if (this.info_rich) {
const desc = hero ? buildSkillDescMoreRich(this.buildHeroDescSource(hero), false) : (this.cardData.info || "");
const desc = hero ? buildHeroSkillDesc(this.cardData.uuid) : (this.cardData.info || "");
this.info_rich.string = outlineRich(desc);
this.info_rich.node.active = !!desc;
}
@@ -451,30 +451,6 @@ export class CHeroComp extends CCComp {
return model.hero_uuid ?? null;
}
/**
* 构造英雄当前能力描述数据源(ISkillDescSource)。
* lv 取英雄局外等级(与 level_label 同口径),由各 resolver 取当前等级生效档,
* 展示英雄当前实际能力信息。
* @param hero HeroInfo 静态配置项
* @returns 描述数据源
*/
private buildHeroDescSource(hero: typeof HeroInfo[number]): ISkillDescSource {
return {
lv: Math.max(1, smc.getHeroOuterLv(hero.uuid)),
skills: hero.skills,
call: hero.call,
dead: hero.dead,
fstart: hero.fstart,
atking: hero.atking,
atked: hero.atked,
field: hero.field,
revive: hero.revive,
grow_type: hero.grow_type,
ap: hero.ap,
hp: hero.hp,
};
}
/**
* 为英雄图标加载 idle 动画剪辑,提取首帧 SpriteFrame 静止展示,零运行时开销。
* @param node 图标节点