refactor(config): 拆分英雄卡池到独立配置文件

将原CardPoolList中的英雄卡池逻辑迁移至heroSet.ts,统一管理英雄抽卡配置,简化主配置文件内容,同时更新MissionCardComp以使用新的英雄卡池数据源
This commit is contained in:
panFD
2026-08-23 18:03:44 +08:00
parent 0d7f53b463
commit fce401bcf9
3 changed files with 60 additions and 46 deletions

View File

@@ -44,6 +44,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { GameEvent } from "../common/config/GameEvent";
import { CardConfig, CardPoolList, CardType, SpecialRefreshCardList, SpecialRefreshHeroType } from "../common/config/CardSet";
import { HeroCardPoolList, HeroCardPoolEntry } from "../common/config/heroSet";
import { drawEquipCards } from "../common/config/EquipSet";
import { drawItemCards } from "../common/config/ICardSet";
import { drawSkillCards } from "../common/config/SCardSet";
@@ -344,7 +345,7 @@ export class MissionCardComp extends CCComp {
const cards = this.buildDrawCards();
mLogger.log(this.debugMode, "MissionCardComp", "onMissionStart buildDrawCards", {
cardsLength: cards.length,
cards: cards.map(c => ({ uuid: c.uuid, type: c.type, name: c.name }))
cards: cards.map(c => ({ uuid: c.uuid }))
});
this.dispatchCardsToSlots(cards);
@@ -1723,8 +1724,8 @@ export class MissionCardComp extends CCComp {
* 构建随机召唤卡池:全英雄卡。
* @returns 卡配置数组
*/
private buildRandomSummonPool(): CardConfig[] {
return CardPoolList.filter(c => c.type === CardType.Hero);
private buildRandomSummonPool(): HeroCardPoolEntry[] {
return HeroCardPoolList;
}
// ======================== 阶段切换 ========================
@@ -1797,8 +1798,8 @@ export class MissionCardComp extends CCComp {
*
* 注:升级卡机制已移除,英雄卡池只出普通英雄卡。
*/
private buildDrawCards(): CardConfig[] {
const allHeroCards = CardPoolList.filter(c => c.type === CardType.Hero);
private buildDrawCards(): HeroCardPoolEntry[] {
const allHeroCards = HeroCardPoolList;
if (allHeroCards.length === 0) return [];
// 优先从“未上场英雄”子池抽取;子池不足 3 张时回退到全量池,避免凑不齐 3 张
@@ -1810,7 +1811,7 @@ export class MissionCardComp extends CCComp {
}
/** 单次按权重抽取一张卡 */
private weightedPick(cards: CardConfig[]): CardConfig | null {
private weightedPick(cards: HeroCardPoolEntry[]): HeroCardPoolEntry | null {
if (cards.length === 0) return null;
const totalWeight = cards.reduce((total, card) => total + (card.weight ?? 0), 0);
let random = Math.random() * totalWeight;
@@ -1829,8 +1830,8 @@ export class MissionCardComp extends CCComp {
* @param count 目标张数
* @returns 不重复的卡配置数组0 ~ count 张)
*/
private pickUniqueHeroCards(pool: CardConfig[], count: number): CardConfig[] {
const result: CardConfig[] = [];
private pickUniqueHeroCards(pool: HeroCardPoolEntry[], count: number): HeroCardPoolEntry[] {
const result: HeroCardPoolEntry[] = [];
const usedUuids = new Set<number>();
while (result.length < count) {
const rest = pool.filter(c => !usedUuids.has(c.uuid));
@@ -1849,7 +1850,7 @@ export class MissionCardComp extends CCComp {
* 子池不足 3 张时回退到该类型的全量池,仍抽不齐则如实返回(不重复补位)。
*/
private tryRefreshHeroCards(heroType?: HType): boolean {
let pool = CardPoolList.filter(c => c.type === CardType.Hero);
let pool = HeroCardPoolList;
if (heroType !== undefined) {
pool = pool.filter(c => HeroInfo[c.uuid]?.type === heroType);
}
@@ -1878,7 +1879,7 @@ export class MissionCardComp extends CCComp {
}
/** 全量分发给 3 槽;每个槽位是否接收由 CHeroComp 自己判断(锁定可跳过) */
private dispatchCardsToSlots(cards: CardConfig[]) {
private dispatchCardsToSlots(cards: HeroCardPoolEntry[]) {
if (!this.cardComps) return;
for (let i = 0; i < this.cardComps.length; i++) {
if (this.cardComps[i]) {