docs(skillDesc): 优化技能富文本描述高亮规则
1. 调整数值高亮色为亮绿色,更新注释说明 2. 新增技能名蓝色高亮逻辑,自动格式化「技能名」片段 3. 同步更新函数注释与匹配正则规则
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* 输出(双格式,供 UI 按需取用):
|
* 输出(双格式,供 UI 按需取用):
|
||||||
* - buildSkillDesc(source) → 纯文本(Label 用),数值无颜色
|
* - 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]: "最大生命",
|
[Attrs.hp_max]: "最大生命",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 富文本数值高亮色(深绿色,与项目绿色系同源,深色面板上清晰可读) */
|
/** 富文本数值高亮色(亮绿色,与项目绿色系同源,深色面板上清晰可读) */
|
||||||
const RICH_VALUE_COLOR = "#1E8449";
|
const RICH_VALUE_COLOR = "#27AE60";
|
||||||
|
|
||||||
|
/** 富文本技能名高亮色(蓝色,与数值绿色区分,标识技能名「」片段) */
|
||||||
|
const RICH_NAME_COLOR = "#2E86C1";
|
||||||
|
|
||||||
|
/** 技能名「」匹配模式(仅本模块行首/行中技能名片段使用) */
|
||||||
|
const SKILL_NAME_PATTERN = /「([^」]*)」/g;
|
||||||
|
|
||||||
/** 解析目标描述文本(与战斗 SCastSystem 目标选取语义严格一致) */
|
/** 解析目标描述文本(与战斗 SCastSystem 目标选取语义严格一致) */
|
||||||
function buildTargetDesc(skill: SkillConfig): string {
|
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)
|
* @param source 触发技能数据源(同 buildSkillDesc)
|
||||||
* @returns 多行富文本串,数值片段包裹 <color=#1E8449>,用 \n 分隔
|
* @returns 多行富文本串,技能名片段包裹 <color=#2E86C1>、数值片段包裹 <color=#27AE60>,用 \n 分隔
|
||||||
*/
|
*/
|
||||||
export function buildSkillDescRich(source: ISkillDescSource): string {
|
export function buildSkillDescRich(source: ISkillDescSource): string {
|
||||||
return buildSkillLines(source)
|
return buildSkillLines(source)
|
||||||
.map(l => l.value
|
.map(l => {
|
||||||
? `${l.prefix}<color=${RICH_VALUE_COLOR}>${l.value}</color>${l.suffix}`
|
const prefix = l.prefix.replace(SKILL_NAME_PATTERN, `「<color=${RICH_NAME_COLOR}>$1</color>」`);
|
||||||
: `${l.prefix}${l.suffix}`)
|
return l.value
|
||||||
|
? `${prefix}<color=${RICH_VALUE_COLOR}>${l.value}</color>${l.suffix}`
|
||||||
|
: `${prefix}${l.suffix}`;
|
||||||
|
})
|
||||||
.join("\n");
|
.join("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user