fix(map): 新增重复召唤英雄拦截与抽卡过滤逻辑

新增英雄召唤重复校验,防止已召唤英雄被再次召唤;同时优化抽卡逻辑,不再刷出已召唤英雄的普通卡牌,仅可通过升级卡升级已召唤英雄。
This commit is contained in:
panFD
2026-07-21 08:09:52 +08:00
parent 8818ec9c3f
commit 89e8f2b091
2 changed files with 50 additions and 4 deletions

View File

@@ -758,9 +758,12 @@ export class MissionCardComp extends CCComp {
}
const heroCards = CardPoolList.filter(c => c.type === CardType.Hero);
// 过滤掉场上已召唤英雄的普通英雄卡:已召唤的英雄只能通过升级卡升级,不再刷出普通卡
const aliveHeroUuids = this.getAliveHeroUuids();
const availableHeroCards = heroCards.filter(c => !aliveHeroUuids.has(c.uuid));
// 英雄池只刷英雄卡(含动态升级卡),不再混入刷新功能卡
const mixedPool: CardConfig[] = [...upgradeCards, ...heroCards];
// 英雄池只刷英雄卡(含动态升级卡 + 未召唤英雄的普通卡)
const mixedPool: CardConfig[] = [...upgradeCards, ...availableHeroCards];
if (mixedPool.length === 0) return [];
const result: CardConfig[] = [];
@@ -905,9 +908,12 @@ export class MissionCardComp extends CCComp {
type: CardType.Hero,
heroType,
});
if (cards.length <= 0) return false;
// 过滤掉场上已召唤英雄的普通英雄卡(已召唤的英雄不再重复刷出)
const aliveHeroUuids = this.getAliveHeroUuids();
const available = cards.filter(c => !aliveHeroUuids.has(c.uuid));
if (available.length <= 0) return false;
this.layoutCardSlots();
this.dispatchCardsToSlots(cards.slice(0, 3));
this.dispatchCardsToSlots(available.slice(0, 3));
return true;
}
@@ -1081,6 +1087,22 @@ export class MissionCardComp extends CCComp {
return actors;
}
/**
* 获取场上所有存活英雄的 hero_uuid 集合。
* 用于抽卡时过滤:已召唤的英雄不再从普通英雄卡池中刷出,只能通过升级卡升级。
*/
private getAliveHeroUuids(): Set<number> {
const uuids = new Set<number>();
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
const model = entity.get(HeroAttrsComp);
if (!model) return;
if (model.fac !== FacSet.HERO) return;
if (model.is_dead) return;
uuids.add(model.hero_uuid);
});
return uuids;
}
/**
* 按 eid 精确升级场上对应英雄实体。
*