fix(map,card): 优化卡牌抽取逻辑,新增去重机制

1. 为drawCardsByRule新增unique参数,实现抽取卡牌不重复
2. 修复 fallback 抽取时的重复问题,优先选择未抽到过的卡牌
3. 修复驻场技能卡的图标显示逻辑,使用FieldSkillSet配置
This commit is contained in:
panFD
2026-06-18 22:18:05 +08:00
parent e0c6622bec
commit 9f738ab881
3 changed files with 31 additions and 9 deletions

View File

@@ -290,14 +290,19 @@ const weightedPick = (cards: CardConfig[]): CardConfig | null => {
return cards[cards.length - 1]
}
/** 连续抽取 count 张卡,允许重复 */
const pickCards = (cards: CardConfig[], count: number): CardConfig[] => {
/** 连续抽取 count 张卡,允许重复或通过 unique 剔除重复 */
const pickCards = (cards: CardConfig[], count: number, unique: boolean = false): CardConfig[] => {
if (cards.length === 0 || count <= 0) return []
const selected: CardConfig[] = []
let available = [...cards]
while (selected.length < count) {
const pick = weightedPick(cards)
if (available.length === 0) break
const pick = weightedPick(available)
if (!pick) break
selected.push(pick)
if (unique) {
available = available.filter(c => c.uuid !== pick.uuid)
}
}
return selected
}
@@ -345,6 +350,7 @@ export const drawCardsByRule = (
heroLv?: number
targetPoolLv?: number
wave?: number
unique?: boolean
} = {}
): CardConfig[] => {
const count = Math.max(0, Math.floor(options.count ?? 4))
@@ -394,6 +400,6 @@ export const drawCardsByRule = (
})
}
const picked = pickCards(pool, count)
const picked = pickCards(pool, count, options.unique)
return picked
}