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

@@ -142,6 +142,7 @@ export class MissionHeroComp extends CCComp {
/**
* 召唤请求入口:
* 从事件参数中提取 uuid / hero_lv / pool_lv放入串行队列。
* 防御:已召唤的英雄 uuid 拒绝重复召唤(只能通过升级卡升级)。
*
* @param event 事件名
* @param args { uuid, hero_lv, pool_lv }
@@ -151,10 +152,33 @@ export class MissionHeroComp extends CCComp {
const uuid = Number(payload?.uuid ?? 1001);
const hero_lv = Math.max(1, Number(payload?.hero_lv ?? 1));
const pool_lv = Math.max(1, Number(payload?.pool_lv ?? 1));
// 防御:场上已有同 uuid 的存活英雄时,拒绝重复召唤
if (this.isHeroAlreadySummoned(uuid)) {
oops.gui.toast(`该英雄已召唤,只能通过升级卡升级`);
return;
}
this.summon_queue.push({ uuid, hero_lv, pool_lv });
this.processSummonQueue();
}
/**
* 检查场上是否已存在指定 uuid 的存活英雄。
* @param uuid 英雄模板 uuid
* @returns true 表示场上已有该英雄,不可重复召唤
*/
private isHeroAlreadySummoned(uuid: number): boolean {
let exists = false;
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
if (exists) return;
const model = entity.get(HeroAttrsComp);
if (!model || model.fac !== FacSet.HERO || model.is_dead) return;
if (model.hero_uuid === uuid) exists = true;
});
return exists;
}
// ======================== 英雄生成 ========================
/**