feat: 拆分特殊卡类型并实现升级和刷新功能
- 将 CardType.Special 拆分为 SpecialUpgrade 和 SpecialRefresh - 新增特殊卡使用逻辑:升级功能卡可随机升级场上英雄,刷新功能卡可筛选卡池 - 添加 drawCardsByRule 函数支持按类型、英雄类型和等级抽取卡牌 - 在 MissionCardComp 中处理特殊卡使用事件并更新UI
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import * as exp from "constants"
|
||||
import { HeroInfo, HType } from "./heroSet"
|
||||
|
||||
/** 卡牌大类定义 */
|
||||
export enum CardType {
|
||||
Hero = 1,
|
||||
Skill = 2,
|
||||
Special = 3,
|
||||
SpecialUpgrade = 3,
|
||||
SpecialRefresh = 4,
|
||||
}
|
||||
|
||||
/** 卡池等级定义 */
|
||||
@@ -89,41 +91,58 @@ export const CardPoolList: CardConfig[] = [
|
||||
|
||||
{ uuid: 5304, type: CardType.Hero, cost: 3, weight: 25, lv: 6, hero_lv: 1 },
|
||||
|
||||
{ uuid: 7001, type: CardType.Special, cost: 1, weight: 20, lv: 1 },
|
||||
{ uuid: 7001, type: CardType.SpecialUpgrade, cost: 6, weight: 16, lv: 1 },
|
||||
{ uuid: 7002, type: CardType.SpecialUpgrade, cost: 6, weight: 14, lv: 2 },
|
||||
{ uuid: 7101, type: CardType.SpecialRefresh, cost: 4, weight: 14, lv: 1 },
|
||||
{ uuid: 7102, type: CardType.SpecialRefresh, cost: 4, weight: 14, lv: 1 },
|
||||
{ uuid: 7103, type: CardType.SpecialRefresh, cost: 5, weight: 12, lv: 2 },
|
||||
]
|
||||
|
||||
|
||||
/** 功能卡效果类型 */
|
||||
export enum SpecialEffectType {
|
||||
DrawHero = 1,
|
||||
RepeatNextUse = 2,
|
||||
export enum SpecialRefreshHeroType {
|
||||
Any = 0,
|
||||
Melee = 1,
|
||||
Ranged = 2,
|
||||
}
|
||||
|
||||
/** 功能卡效果参数 */
|
||||
export interface SpecialCardEffect {
|
||||
type: SpecialEffectType
|
||||
drawHeroCount?: number
|
||||
drawHeroLv?: CardKind
|
||||
repeatNextUseTimes?: number
|
||||
}
|
||||
|
||||
/** 功能卡完整配置 */
|
||||
export interface SpecialCardConfig extends CardConfig {
|
||||
/** 升级功能卡完整配置 */
|
||||
export interface SpecialUpgradeCardConfig extends CardConfig {
|
||||
name: string
|
||||
info: string
|
||||
effect: SpecialCardEffect
|
||||
currentLv: number
|
||||
targetLv: number
|
||||
}
|
||||
|
||||
/** 刷新功能卡完整配置 */
|
||||
export interface SpecialRefreshCardConfig extends CardConfig {
|
||||
name: string
|
||||
info: string
|
||||
refreshLv: number
|
||||
refreshHeroType: SpecialRefreshHeroType
|
||||
}
|
||||
|
||||
/** 功能卡定义表 */
|
||||
|
||||
|
||||
|
||||
export const SpecialCardList: Record<number, SpecialCardConfig> = {
|
||||
7001: { uuid: 7001,type: CardType.Special,cost: 6,weight: 20,lv: CardKind.LV1,name:"哈哈",info: "抽取4张等级3的英雄",
|
||||
effect: {type: SpecialEffectType.DrawHero,drawHeroCount: 4,drawHeroLv: CardKind.LV3,},
|
||||
export const SpecialUpgradeCardList: Record<number, SpecialUpgradeCardConfig> = {
|
||||
7001: { uuid: 7001,type: CardType.SpecialUpgrade,cost: 6,weight: 16,lv: CardKind.LV1,name:"战术晋升",info: "升级场上随机1个1级英雄到2级",
|
||||
currentLv: 1, targetLv: 2,
|
||||
},
|
||||
7002: { uuid: 7002,type: CardType.Special,cost: 5,weight: 20,lv: CardKind.LV2,name:"哈哈哈", info: "重复使用下一张卡1次",
|
||||
effect: {type: SpecialEffectType.RepeatNextUse,repeatNextUseTimes: 1,},
|
||||
7002: { uuid: 7002,type: CardType.SpecialUpgrade,cost: 6,weight: 14,lv: CardKind.LV2,name:"进阶战术",info: "升级场上随机1个2级英雄到3级",
|
||||
currentLv: 2, targetLv: 3,
|
||||
},
|
||||
}
|
||||
|
||||
export const SpecialRefreshCardList: Record<number, SpecialRefreshCardConfig> = {
|
||||
7101: { uuid: 7101,type: CardType.SpecialRefresh,cost: 4,weight: 14,lv: CardKind.LV1,name:"近战征召",info: "刷新卡池,都是近战英雄",
|
||||
refreshLv: 0, refreshHeroType: SpecialRefreshHeroType.Melee,
|
||||
},
|
||||
7102: { uuid: 7102,type: CardType.SpecialRefresh,cost: 4,weight: 14,lv: CardKind.LV1,name:"远程征召",info: "刷新卡池,都是远程英雄",
|
||||
refreshLv: 0, refreshHeroType: SpecialRefreshHeroType.Ranged,
|
||||
},
|
||||
7103: { uuid: 7103,type: CardType.SpecialRefresh,cost: 5,weight: 12,lv: CardKind.LV2,name:"精英筛选",info: "刷新卡池,都是3级卡池等级英雄",
|
||||
refreshLv: 3, refreshHeroType: SpecialRefreshHeroType.Any,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -193,3 +212,33 @@ export const getCardsByLv = (
|
||||
const others = pickCards(otherPool, 2)
|
||||
return [...heroes, ...others]
|
||||
}
|
||||
|
||||
export const drawCardsByRule = (
|
||||
lv: number,
|
||||
options: {
|
||||
count?: number
|
||||
onlyCurrentLv?: boolean
|
||||
type?: CardType | CardType[]
|
||||
heroType?: HType
|
||||
heroLv?: number
|
||||
} = {}
|
||||
): CardConfig[] => {
|
||||
const count = Math.max(0, Math.floor(options.count ?? 4))
|
||||
const onlyCurrentLv = options.onlyCurrentLv ?? false
|
||||
let pool = getCardPoolByLv(lv, onlyCurrentLv)
|
||||
if (options.type !== undefined) {
|
||||
const typeSet = normalizeTypeFilter(options.type)
|
||||
pool = pool.filter(card => typeSet.has(card.type))
|
||||
}
|
||||
if (options.heroType !== undefined || options.heroLv !== undefined) {
|
||||
pool = pool.filter(card => {
|
||||
if (card.type !== CardType.Hero) return false
|
||||
const hero = HeroInfo[card.uuid]
|
||||
if (!hero) return false
|
||||
if (options.heroType !== undefined && hero.type !== options.heroType) return false
|
||||
if (options.heroLv !== undefined && card.hero_lv !== options.heroLv) return false
|
||||
return true
|
||||
})
|
||||
}
|
||||
return pickCards(pool, count)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user