refactor: 移除未使用的代码并优化卡牌获取逻辑
- 删除 MissionCardComp 中未使用的接口定义和注释代码 - 移除 MissionComp 中未实现的英雄死亡、升级和复活相关事件处理 - 重构 CardSet 中的 getCardPoolByLv 和 getCardsByLv 方法,增加类型过滤和等级模式参数 - 清理 MissionComp 中的冗余代码和注释,简化局内数据初始化逻辑
This commit is contained in:
@@ -146,15 +146,36 @@ const pickCards = (cards: CardConfig[], count: number): CardConfig[] => {
|
||||
return selected
|
||||
}
|
||||
|
||||
/** 获取指定等级可出现的基础卡池(英雄+技能) */
|
||||
export const getCardPoolByLv = (lv: number): CardConfig[] => {
|
||||
/** 获取指定等级可出现的基础卡池 */
|
||||
export const getCardPoolByLv = (lv: number, onlyCurrentLv: boolean = false): CardConfig[] => {
|
||||
const cardLv = clampCardLv(lv)
|
||||
if (onlyCurrentLv) {
|
||||
return CardPoolList.filter(card => card.lv === cardLv)
|
||||
}
|
||||
return CardPoolList.filter(card => card.lv <= cardLv)
|
||||
}
|
||||
|
||||
/** 常规发牌:前 2 英雄 + 后 2 其他 */
|
||||
export const getCardsByLv = (lv: number): CardConfig[] => {
|
||||
const pool = getCardPoolByLv(lv)
|
||||
const normalizeTypeFilter = (type: CardType | CardType[]): Set<CardType> => {
|
||||
const list = Array.isArray(type) ? type : [type]
|
||||
const hasBuffLike = list.includes(CardType.Buff) || list.includes(CardType.Debuff)
|
||||
if (hasBuffLike) {
|
||||
return new Set<CardType>([...list, CardType.Buff, CardType.Debuff])
|
||||
}
|
||||
return new Set<CardType>(list)
|
||||
}
|
||||
|
||||
/** 常规发牌:前 2 英雄 + 后 2 其他;支持按类型和等级模式过滤 */
|
||||
export const getCardsByLv = (
|
||||
lv: number,
|
||||
type?: CardType | CardType[],
|
||||
onlyCurrentLv: boolean = false
|
||||
): CardConfig[] => {
|
||||
const pool = getCardPoolByLv(lv, onlyCurrentLv)
|
||||
if (type !== undefined) {
|
||||
const typeSet = normalizeTypeFilter(type)
|
||||
const filteredPool = pool.filter(card => typeSet.has(card.type))
|
||||
return pickCards(filteredPool, 4)
|
||||
}
|
||||
const heroPool = pool.filter(card => card.type === CardType.Hero)
|
||||
const otherPool = pool.filter(card => card.type !== CardType.Hero)
|
||||
const heroes = pickCards(heroPool, 2)
|
||||
|
||||
Reference in New Issue
Block a user