refactor(game): 拆分装备卡配置与逻辑,独立管理装备系统

1. 将装备卡从原技能卡池拆分至独立的EquipSet.ts配置
2. 新增专用的装备盒实体与事件流程,替换原有技能卡复用逻辑
3. 调整FieldSkillHelper以支持装备卡的属性加成统计
4. 优化装备商店与抽卡逻辑,移除装备卡的抽卡参与
This commit is contained in:
pan
2026-07-22 12:55:57 +08:00
parent e17ffeb2fd
commit fd056b4433
8 changed files with 124 additions and 115 deletions

View File

@@ -39,7 +39,8 @@ import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, Tween, twe
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { GameEvent } from "../common/config/GameEvent";
import { CardConfig, CardPoolList, CardType, drawCardsByRule, isEquipmentCard, SpecialRefreshCardList, SpecialRefreshHeroType, SpecialUpgradeCardList } from "../common/config/CardSet";
import { CardConfig, CardPoolList, CardType, drawCardsByRule, SpecialRefreshCardList, SpecialRefreshHeroType, SpecialUpgradeCardList } from "../common/config/CardSet";
import { EquipPoolList } from "../common/config/EquipSet";
import { CardComp } from "./CardComp";
import { SCardComp } from "./SCardComp";
import { EquipListComp } from "./EquipListComp";
@@ -319,6 +320,8 @@ export class MissionCardComp extends CCComp {
oops.message.on(GameEvent.HeroSell, this.onHeroSell, this);
oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this);
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
// 监听装备购买事件,追踪已购记录
oops.message.on(GameEvent.UseEquipCard, this.onUseEquipCard, this);
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.on(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.on(GameEvent.CardUsed, this.onCardUsed, this);
@@ -475,12 +478,6 @@ export class MissionCardComp extends CCComp {
// 由 onCardUsed 立即向被使用的槽位补充一张新技能卡。
// 弹窗由外部(按钮/阶段切换)控制显隐。
// 追踪装备购买记录EquipListComp 购买后也会派发此事件)
const usedCard = args as CardConfig;
if (usedCard && isEquipmentCard(usedCard)) {
this.purchasedEquipUuids.add(usedCard.uuid);
}
// 修复:独立判断 guide2 的关闭 和 guide3 的开启
if (!smc.finish_guides.includes(2)) {
smc.finish_guides.push(2);
@@ -495,6 +492,14 @@ export class MissionCardComp extends CCComp {
this.scheduleOnce(() => this.updateCoinAndCostUI(), 0);
}
/** 装备购买事件回调:记录已购 UUID防止重复购买 */
private onUseEquipCard(event: string, args: any) {
const usedCard = args as CardConfig;
if (usedCard) {
this.purchasedEquipUuids.add(usedCard.uuid);
}
}
/** 解除按钮监听,避免节点销毁后回调泄漏 */
private unbindEvents() {
oops.message.off(GameEvent.CoinAdd, this.onCoinAdd, this);
@@ -503,6 +508,7 @@ export class MissionCardComp extends CCComp {
oops.message.off(GameEvent.HeroSell, this.onHeroSell, this);
oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this);
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
oops.message.off(GameEvent.UseEquipCard, this.onUseEquipCard, this);
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.off(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.off(GameEvent.CardUsed, this.onCardUsed, this);
@@ -744,10 +750,8 @@ export class MissionCardComp extends CCComp {
// 清空旧列表
this.equipsBoxNode.removeAllChildren();
// 获取所有装备
const equipments = CardPoolList.filter(c => isEquipmentCard(c));
for (const equip of equipments) {
// 从独立装备卡池获取所有装备
for (const equip of EquipPoolList) {
const node = instantiate(this.equipPrefab);
this.equipsBoxNode.addChild(node);
const comp = node.getComponent(EquipListComp) || node.addComponent(EquipListComp);
@@ -765,7 +769,7 @@ export class MissionCardComp extends CCComp {
}
mLogger.log(this.debugMode, "MissionCardComp", "populate equipments", {
count: equipments.length
count: EquipPoolList.length
});
}
@@ -1082,13 +1086,11 @@ export class MissionCardComp extends CCComp {
private buildSkillDrawCards(): CardConfig[] {
const currentWave = this.getCurrentWave();
// 使用明确规则的 drawCardsByRule指定只要 3 张技能卡,并且过滤对应 wave
// 装备卡已改为商店直购,不再参与抽卡
const cards = drawCardsByRule(1, {
count: 3,
type: CardType.Skill,
wave: currentWave,
unique: true, // 保证技能牌不重复
excludeEquipment: true, // 排除装备卡
});
if (cards.length >= 3) return cards.slice(0, 3);
@@ -1099,7 +1101,6 @@ export class MissionCardComp extends CCComp {
type: CardType.Skill,
wave: currentWave,
unique: true,
excludeEquipment: true,
});
if (fallback.length === 0) break;