fix(map): 新增重复召唤英雄拦截与抽卡过滤逻辑
新增英雄召唤重复校验,防止已召唤英雄被再次召唤;同时优化抽卡逻辑,不再刷出已召唤英雄的普通卡牌,仅可通过升级卡升级已召唤英雄。
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
// ======================== 英雄生成 ========================
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user