refactor(heroComp): 拆分精简英雄卡配置接口
将原本CardConfig中的英雄卡必要字段抽离为HeroCardConfig, 仅保留CHeroComp组件需要的渲染交互字段,减少不必要的依赖和字段。
This commit is contained in:
@@ -325,6 +325,20 @@ export interface heroInfo {
|
||||
/** 分级能力说明,索引0=1级,依次递增;信息面板逐条展示各等级技能与能力 */
|
||||
infos?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 英雄卡配置(CHeroComp 专用,从 CardConfig 精简)
|
||||
* 仅保留英雄卡渲染和交互必需的字段
|
||||
*/
|
||||
export interface HeroCardConfig {
|
||||
uuid: number;
|
||||
name?: string;
|
||||
info?: string;
|
||||
cost: number;
|
||||
card_lv: number;
|
||||
base_card_lv?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 技能基础信息接口
|
||||
*/
|
||||
|
||||
@@ -19,8 +19,7 @@ import { mLogger } from "../common/Logger";
|
||||
import { _decorator, Node, Sprite, Label, RichText, NodeEventType, Vec3, Tween, tween, UIOpacity, SpriteFrame, resources, AnimationClip } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { CardConfig } from "../common/config/CardSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroInfo, HeroCardConfig } from "../common/config/heroSet";
|
||||
import { buildSkillDescMoreRich, ISkillDescSource } from "../common/config/HeroSkillDesc";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
@@ -83,7 +82,7 @@ export class CHeroComp extends CCComp {
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
/** 当前槽位承载的卡牌配置,null 表示空槽 */
|
||||
private cardData: CardConfig | null = null;
|
||||
private cardData: HeroCardConfig | null = null;
|
||||
/** 是否已购买 */
|
||||
private isPurchased: boolean = false;
|
||||
/** 是否已缓存基准 Y/Z 坐标(首次 setSlotPosition 时确定) */
|
||||
@@ -153,17 +152,14 @@ export class CHeroComp extends CCComp {
|
||||
*
|
||||
* @param data 卡牌配置,传 null 时清空显示
|
||||
*/
|
||||
applyCardData(data: CardConfig | null): void {
|
||||
applyCardData(data: HeroCardConfig | null): void {
|
||||
mLogger.log(this.debugMode, "CHeroComp", "applyCardData", {
|
||||
nodeName: this.node?.name,
|
||||
nodeUuid: this.node?.uuid,
|
||||
uuid: data?.uuid ?? null,
|
||||
type: data?.type ?? null,
|
||||
name: data?.name ?? null,
|
||||
card_lv: data?.card_lv ?? null,
|
||||
hero_lv: data?.hero_lv ?? null,
|
||||
cost: data?.cost ?? null,
|
||||
icon: data?.icon ?? null,
|
||||
nodeActiveBefore: this.node?.active
|
||||
});
|
||||
|
||||
@@ -595,8 +591,7 @@ export class CHeroComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.CardUsed, this);
|
||||
|
||||
mLogger.log(this.debugMode, "CHeroComp", "hero card purchased", {
|
||||
uuid: used.uuid,
|
||||
type: used.type
|
||||
uuid: used.uuid
|
||||
});
|
||||
}
|
||||
|
||||
@@ -613,7 +608,7 @@ export class CHeroComp extends CCComp {
|
||||
* @param data 卡牌配置,null 时清空显示
|
||||
* @returns 是否成功接收(true = 接收并刷新 UI)
|
||||
*/
|
||||
applyDrawCard(data: CardConfig | null): boolean {
|
||||
applyDrawCard(data: HeroCardConfig | null): boolean {
|
||||
this.applyCardData(data);
|
||||
return !!data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user