docs(skillDesc): 优化技能富文本描述高亮规则

1. 调整数值高亮色为亮绿色,更新注释说明
2. 新增技能名蓝色高亮逻辑,自动格式化「技能名」片段
3. 同步更新函数注释与匹配正则规则
This commit is contained in:
pan
2026-07-31 09:35:22 +08:00
parent 7683a5c6c0
commit 8f3cd4777f

View File

@@ -10,7 +10,7 @@
*
* 输出(双格式,供 UI 按需取用):
* - buildSkillDesc(source) → 纯文本Label 用),数值无颜色
* - buildSkillDescRich(source) → 富文本RichText 用BBCode数值用 <color> 高亮
* - buildSkillDescRich(source) → 富文本RichText 用BBCode技能名蓝色、数值绿色高亮
* 两者共用同一套结构化行构建逻辑,仅渲染阶段区分,保证纯/富文本内容严格一致。
*
* 通用性(纯配置驱动):
@@ -82,8 +82,14 @@ const ATTR_NAME: Partial<Record<Attrs, string>> = {
[Attrs.hp_max]: "最大生命",
};
/** 富文本数值高亮色(绿色,与项目绿色系同源,深色面板上清晰可读) */
const RICH_VALUE_COLOR = "#1E8449";
/** 富文本数值高亮色(绿色,与项目绿色系同源,深色面板上清晰可读) */
const RICH_VALUE_COLOR = "#27AE60";
/** 富文本技能名高亮色(蓝色,与数值绿色区分,标识技能名「」片段) */
const RICH_NAME_COLOR = "#2E86C1";
/** 技能名「」匹配模式(仅本模块行首/行中技能名片段使用) */
const SKILL_NAME_PATTERN = /「([^」]*)」/g;
/** 解析目标描述文本(与战斗 SCastSystem 目标选取语义严格一致) */
function buildTargetDesc(skill: SkillConfig): string {
@@ -308,14 +314,17 @@ export function buildSkillDesc(source: ISkillDescSource): string {
}
/**
* 富文本描述RichText 用BBCode数值用 <color> 高亮。
* 富文本描述RichText 用BBCode技能名用 <color=#2E86C1> 蓝色、数值用 <color=#27AE60> 亮绿色高亮。
* @param source 触发技能数据源(同 buildSkillDesc
* @returns 多行富文本串,数值片段包裹 <color=#1E8449>,用 \n 分隔
* @returns 多行富文本串,技能名片段包裹 <color=#2E86C1>、数值片段包裹 <color=#27AE60>,用 \n 分隔
*/
export function buildSkillDescRich(source: ISkillDescSource): string {
return buildSkillLines(source)
.map(l => l.value
? `${l.prefix}<color=${RICH_VALUE_COLOR}>${l.value}</color>${l.suffix}`
: `${l.prefix}${l.suffix}`)
.map(l => {
const prefix = l.prefix.replace(SKILL_NAME_PATTERN, `<color=${RICH_NAME_COLOR}>$1</color>`);
return l.value
? `${prefix}<color=${RICH_VALUE_COLOR}>${l.value}</color>${l.suffix}`
: `${prefix}${l.suffix}`;
})
.join("\n");
}