fix(map): 新增重复召唤英雄拦截与抽卡过滤逻辑
新增英雄召唤重复校验,防止已召唤英雄被再次召唤;同时优化抽卡逻辑,不再刷出已召唤英雄的普通卡牌,仅可通过升级卡升级已召唤英雄。
This commit is contained in:
@@ -758,9 +758,12 @@ export class MissionCardComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const heroCards = CardPoolList.filter(c => c.type === CardType.Hero);
|
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 [];
|
if (mixedPool.length === 0) return [];
|
||||||
|
|
||||||
const result: CardConfig[] = [];
|
const result: CardConfig[] = [];
|
||||||
@@ -905,9 +908,12 @@ export class MissionCardComp extends CCComp {
|
|||||||
type: CardType.Hero,
|
type: CardType.Hero,
|
||||||
heroType,
|
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.layoutCardSlots();
|
||||||
this.dispatchCardsToSlots(cards.slice(0, 3));
|
this.dispatchCardsToSlots(available.slice(0, 3));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,6 +1087,22 @@ export class MissionCardComp extends CCComp {
|
|||||||
return actors;
|
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 精确升级场上对应英雄实体。
|
* 按 eid 精确升级场上对应英雄实体。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ export class MissionHeroComp extends CCComp {
|
|||||||
/**
|
/**
|
||||||
* 召唤请求入口:
|
* 召唤请求入口:
|
||||||
* 从事件参数中提取 uuid / hero_lv / pool_lv,放入串行队列。
|
* 从事件参数中提取 uuid / hero_lv / pool_lv,放入串行队列。
|
||||||
|
* 防御:已召唤的英雄 uuid 拒绝重复召唤(只能通过升级卡升级)。
|
||||||
*
|
*
|
||||||
* @param event 事件名
|
* @param event 事件名
|
||||||
* @param args { uuid, hero_lv, pool_lv }
|
* @param args { uuid, hero_lv, pool_lv }
|
||||||
@@ -151,10 +152,33 @@ export class MissionHeroComp extends CCComp {
|
|||||||
const uuid = Number(payload?.uuid ?? 1001);
|
const uuid = Number(payload?.uuid ?? 1001);
|
||||||
const hero_lv = Math.max(1, Number(payload?.hero_lv ?? 1));
|
const hero_lv = Math.max(1, Number(payload?.hero_lv ?? 1));
|
||||||
const pool_lv = Math.max(1, Number(payload?.pool_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.summon_queue.push({ uuid, hero_lv, pool_lv });
|
||||||
this.processSummonQueue();
|
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