refactor(config,map): 统一抽离卡片背景颜色配置

将多处硬编码的卡片等级背景颜色数组移至公共配置文件,
同时重构英雄列表组件的等级显示逻辑,替换为标签直接赋值。
This commit is contained in:
panFD
2026-08-23 23:52:20 +08:00
parent bef521683c
commit 41842f2b67
5 changed files with 25 additions and 37 deletions

View File

@@ -26,13 +26,12 @@ import { CardConfig, CardType, SpecialRefreshCardList, SpecialUpgradeCardList, C
import { SkillCardList } from "../common/config/SCardSet";
import { HeroInfo } from "../common/config/heroSet";
import { SkillSet } from "../common/config/SkillSet";
import { getLvColor } from "../common/config/GameSet";
import { getLvColor, CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** card_lv → BG_node 子节点(颜色)名映射1=green 2=blue 3=purple 4=yellow 5=red */
const BG_COLORS = ["green", "blue", "purple", "yellow", "red"];
/** card_lv → BG_node 子节点(颜色)名映射已移至 GameSet.CARD_LV_BG_COLORS */
/**
* CardLiteComp —— 单张卡牌简单视图组件
@@ -225,7 +224,7 @@ export class CardLiteComp extends CCComp {
// 背景:按 card_lv 切换颜色底框BG_node 下为 green/blue/purple/yellow/red 子节点)
if (this.BG_node) {
const bgLv = Math.min(Math.max(this.cardData.base_card_lv ?? this.cardData.card_lv ?? 1, 1), 5);
const color = BG_COLORS[bgLv - 1];
const color = CARD_LV_BG_COLORS[bgLv - 1];
this.BG_node.children.forEach(child => child.active = (child.name === color));
}