feat(card): add wave filter for skill card draws

1. 新增卡牌配置wave字段,标记技能卡可抽取的波次
2. 重构抽卡逻辑,新增drawCardsByRule规则支持按波次过滤技能卡
3. 优化任务面板的技能卡抽取逻辑,使用新的抽卡规则获取对应波次的技能卡
4. 更新示例技能卡牌配置,添加wave和overrides配置示例
This commit is contained in:
pan
2026-06-04 11:02:19 +08:00
parent 1855bcec4c
commit 27cd20c70d
2 changed files with 40 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ import * as exp from "constants"
import { HeroInfo, HeroList, HType } from "./heroSet"
import { FightSet } from "./GameSet"
import { oops } from "db://oops-framework/core/Oops"
import { SkillOverrides } from "./SkillSet"
import { SkillOverrides, TGroup } from "./SkillSet"
class I18nString {
constructor(private key: string, private params?: any[]) { }
@@ -52,6 +52,7 @@ export interface CardConfig {
weight: number
kind: CKind
pool_lv: CardLV
wave?: number // 针对技能卡:仅在指定波次(wave)才能抽到
hero_lv?: number
card_lv?: number
base_pool_lv?: number
@@ -129,14 +130,19 @@ HeroList.forEach(uuid => {
// 添加非英雄卡牌 (技能、功能卡)
CardPoolList.push(
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
{ uuid: 6401, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6401"), info: t("skill_info_6401"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15},
{ uuid: 6402, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6402"), info: t("skill_info_6402"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6403, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6403"), info: t("skill_info_6403"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6404, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6404"), info: t("skill_info_6404"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6405, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6405"), info: t("skill_info_6405"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6406, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6406"), info: t("skill_info_6406"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6304, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6304"), info: t("skill_info_6304"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6305, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6305"), info: t("skill_info_6305"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
{ uuid: 6304, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, wave: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6304"), info: t("skill_info_6304"), is_inst: true, t_times: 1, t_inv: 0, keep_waves: 15 },
{ uuid: 6305, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, wave: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6305"), info: t("skill_info_6305"), is_inst: true, t_times: 1, t_inv: 0, keep_waves: 15 },
// 自定义 overrides 示例卡牌
{
uuid: 6401, type: CardType.Skill, cost: 0, weight: 10, pool_lv: 1, wave: 1, kind: CKind.Skill, card_lv: 1,
name: "超强攻击强化", info: "使场上英雄增加50点攻击力",
is_inst: true, t_times: 1, t_inv: 0, keep_waves: 15, overrides: { ap: 50 }
},
{
uuid: 6101, type: CardType.Skill, cost: 5, weight: 10, pool_lv: 1, wave: 1, kind: CKind.Skill, card_lv: 1,
name: "持续天降火球", info: "战斗中每隔3秒释放一个火球造成300%伤害持续2波次",
is_inst: false, t_times: 999, t_inv: 3, keep_waves: 15, overrides: { TGroup: TGroup.Enemy, ap: 300, hit_count: 2 }
}
);
@@ -268,6 +274,7 @@ export const drawCardsByRule = (
heroType?: HType
heroLv?: number
targetPoolLv?: number
wave?: number
} = {}
): CardConfig[] => {
const count = Math.max(0, Math.floor(options.count ?? 4))
@@ -295,6 +302,18 @@ export const drawCardsByRule = (
return true
})
}
// 如果传入了波次并且是技能卡,则根据 wave 过滤
if (options.wave !== undefined) {
pool = pool.filter(card => {
if (card.type === CardType.Skill) {
// 只有 wave 值严格等于当前 wave 的技能卡才会留在池中
return card.wave === options.wave;
}
return true;
})
}
const picked = pickCards(pool, count)
return picked
}

View File

@@ -778,12 +778,22 @@ export class MissionCardComp extends CCComp {
private buildSkillDrawCards(): CardConfig[] {
const targetType = CardType.Skill;
const cards = getCardsByLv(this.poolLv, targetType);
const currentWave = this.getCurrentWave();
// 使用明确规则的 drawCardsByRule指定只要 3 张技能卡,并且过滤对应 wave
const cards = drawCardsByRule(this.poolLv, {
count: 3,
type: targetType,
wave: currentWave
});
if (cards.length >= 3) return cards.slice(0, 3);
const filled = [...cards];
while (filled.length < 3) {
const fallback = getCardsByLv(this.poolLv, targetType);
const fallback = drawCardsByRule(this.poolLv, {
count: 3,
type: targetType,
wave: currentWave
});
if (fallback.length === 0) break;
filled.push(fallback[filled.length % fallback.length]);
}