feat(card): 新增卡牌系统核心组件与配置

- 新增 CardComp 组件用于卡牌视图展示
- 新增 CardSet 配置文件,包含卡牌类型、种类枚举和完整卡池配置
- 重构 HSkillComp 组件,优化技能调试面板布局和交互逻辑
- 更新 MissionCardComp 组件,移除旧卡牌类型依赖
- 调整 GameSet 配置文件,移除 CardType 和 CardKind 枚举
- 更新卡牌预制体结构,优化 UI 布局和组件绑定
- 新增特殊卡牌效果系统,支持抽英雄和重复使用等特殊能力
- 实现卡牌按权重抽取算法和卡池等级管理机制
This commit is contained in:
walkpan
2026-03-13 23:15:21 +08:00
parent 45ba5b72f5
commit c8c3dde2e4
10 changed files with 1179 additions and 1367 deletions

View File

@@ -0,0 +1,163 @@
/** 卡牌大类定义 */
export enum CardType {
Hero = 1,
Skill = 2,
Potion = 3,
Special = 4,
Buff = 5,
Debuff = 6,
}
/** 卡池等级定义 */
export enum CardKind {
LV1 = 1,
LV2 = 2,
LV3 = 3,
LV4 = 4,
LV5 = 5,
LV6 = 6,
}
/** 通用卡牌配置 */
export interface CardConfig {
uuid: number
type: CardType
cost: number
weight: number
lv: CardKind
}
/** 特殊卡效果类型 */
export enum SpecialEffectType {
DrawHero = 1,
RepeatNextUse = 2,
}
/** 特殊卡效果参数 */
export interface SpecialCardEffect {
type: SpecialEffectType
drawHeroCount?: number
drawHeroLv?: CardKind
repeatNextUseTimes?: number
}
/** 特殊卡完整配置 */
export interface SpecialCardConfig extends CardConfig {
effect: SpecialCardEffect
}
/** 卡池默认初始等级 */
export const CARD_POOL_INIT_LEVEL = CardKind.LV1
/** 卡池等级上限 */
export const CARD_POOL_MAX_LEVEL = CardKind.LV6
/** 基础卡池英雄、技能、Buff、Debuff */
export const CardPoolList: CardConfig[] = [
{ uuid: 5001, type: CardType.Hero, cost: 3, weight: 20, lv: 1 },
{ uuid: 5003, type: CardType.Hero, cost: 3, weight: 20, lv: 1 },
{ uuid: 5002, type: CardType.Hero, cost: 3, weight: 25, lv: 2 },
{ uuid: 5005, type: CardType.Hero, cost: 3, weight: 25, lv: 2 },
{ uuid: 5004, type: CardType.Hero, cost: 3, weight: 30, lv: 3 },
{ uuid: 5006, type: CardType.Hero, cost: 3, weight: 35, lv: 4 },
{ uuid: 5007, type: CardType.Hero, cost: 3, weight: 40, lv: 5 },
{ uuid: 6001, type: CardType.Skill, cost: 1, weight: 20, lv: 1 },
{ uuid: 6002, type: CardType.Skill, cost: 1, weight: 20, lv: 1 },
{ uuid: 6003, type: CardType.Skill, cost: 2, weight: 25, lv: 2 },
{ uuid: 6100, type: CardType.Skill, cost: 4, weight: 25, lv: 2 },
{ uuid: 6004, type: CardType.Skill, cost: 3, weight: 30, lv: 3 },
{ uuid: 6102, type: CardType.Skill, cost: 4, weight: 35, lv: 4 },
{ uuid: 6101, type: CardType.Skill, cost: 5, weight: 40, lv: 5 },
{ uuid: 6103, type: CardType.Skill, cost: 6, weight: 45, lv: 6 },
{ uuid: 10001, type: CardType.Buff, cost: 2, weight: 30, lv: 1 },
{ uuid: 10101, type: CardType.Buff, cost: 3, weight: 26, lv: 2 },
{ uuid: 10011, type: CardType.Buff, cost: 3, weight: 24, lv: 3 },
{ uuid: 10311, type: CardType.Buff, cost: 4, weight: 20, lv: 4 },
{ uuid: 10302, type: CardType.Buff, cost: 5, weight: 18, lv: 5 },
{ uuid: 10201, type: CardType.Debuff, cost: 3, weight: 24, lv: 2 },
{ uuid: 10211, type: CardType.Debuff, cost: 4, weight: 20, lv: 3 },
{ uuid: 10312, type: CardType.Debuff, cost: 4, weight: 18, lv: 4 },
{ uuid: 20001, type: CardType.Debuff, cost: 5, weight: 14, lv: 5 },
{ uuid: 20011, type: CardType.Debuff, cost: 6, weight: 12, lv: 6 },
]
/** 特殊卡定义表 */
export const SpecialCardList: Record<number, SpecialCardConfig> = {
7001: {
uuid: 7001,
type: CardType.Special,
cost: 6,
weight: 20,
lv: CardKind.LV3,
effect: {
type: SpecialEffectType.DrawHero,
drawHeroCount: 4,
drawHeroLv: CardKind.LV3,
},
},
7002: {
uuid: 7002,
type: CardType.Special,
cost: 5,
weight: 20,
lv: CardKind.LV4,
effect: {
type: SpecialEffectType.RepeatNextUse,
repeatNextUseTimes: 1,
},
},
}
/** 规范等级到合法区间 [LV1, LV6] */
const clampCardLv = (lv: number): CardKind => {
const value = Math.floor(lv)
if (value < CARD_POOL_INIT_LEVEL) return CARD_POOL_INIT_LEVEL
if (value > CARD_POOL_MAX_LEVEL) return CARD_POOL_MAX_LEVEL
return value as CardKind
}
/** 单次按权重抽取一张卡 */
const weightedPick = (cards: CardConfig[]): CardConfig | null => {
if (cards.length === 0) return null
const totalWeight = cards.reduce((total, card) => total + card.weight, 0)
let random = Math.random() * totalWeight
for (const card of cards) {
random -= card.weight
if (random <= 0) return card
}
return cards[cards.length - 1]
}
/** 连续抽取 count 张卡,允许重复 */
const pickCards = (cards: CardConfig[], count: number): CardConfig[] => {
if (cards.length === 0 || count <= 0) return []
const selected: CardConfig[] = []
while (selected.length < count) {
const pick = weightedPick(cards)
if (!pick) break
selected.push(pick)
}
return selected
}
/** 获取指定等级可出现的基础卡池(英雄+技能) */
export const getCardPoolByLv = (lv: number): CardConfig[] => {
const cardLv = clampCardLv(lv)
return CardPoolList.filter(card => card.lv <= cardLv)
}
/** 常规发牌:前 2 英雄 + 后 2 其他 */
export const getCardsByLv = (lv: number): CardConfig[] => {
const pool = getCardPoolByLv(lv)
const heroPool = pool.filter(card => card.type === CardType.Hero)
const otherPool = pool.filter(card => card.type !== CardType.Hero)
const heroes = pickCards(heroPool, 2)
const others = pickCards(otherPool, 2)
return [...heroes, ...others]
}

View File

@@ -22,24 +22,6 @@ export enum BoxSet {
//攻击距离
}
export enum CardType {
Talent = 1,
Skill = 2,
Potion = 3,
Partner = 4,
Attr = 5,
}
export enum CardKind {
Atk = 1,
Atted = 2,
Buff = 3,
Attr = 4,
Skill = 5,
Hp = 6,
Dead = 7,
Partner = 8,
}
export enum FacSet {

View File

@@ -232,7 +232,7 @@ export const SkillSet: Record<number, SkillConfig> = {
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
},
// ========== 基础buff ========== 6100-6199
//============================= ====== 基础buff ====== ========================== 6100-6199
6100: {
uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Self,TType:TType.LowestHP,act:"atk",DTType:DTType.single,
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,