refactor(卡牌系统): 清理废弃的卡池等级相关代码并优化抽卡接口
1. 移除了CardSkillType枚举、废弃的CardLV枚举和相关常量定义 2. 删除了已废弃的getCardPoolByLv、getCardsByLv等兼容旧接口 3. 简化drawCardsByRule接口,移除不再生效的历史参数 4. 调整MissionCardComp中调用drawCardsByRule的传参方式 5. 格式化VictoryComp中的代码格式,统一代码风格
This commit is contained in:
@@ -37,16 +37,6 @@ export enum CKind {
|
||||
Potion = 4, //药水
|
||||
}
|
||||
|
||||
/** 技能卡触发类型 */
|
||||
export enum CardSkillType {
|
||||
Interval = 1, // 间隔定时触发 (战斗中每隔N秒执行)
|
||||
Field = 2, // 驻场技能 (被动光环)
|
||||
BattleStart = 3, // 战斗开始时触发一次
|
||||
BattleEnd = 4, // 战斗结束时触发一次
|
||||
HeroDead = 5, // 场上己方英雄死亡时触发
|
||||
HeroCall = 6, // 场上己方英雄召唤上场时触发
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡牌技能触发类型
|
||||
* - 命名对齐英雄侧 SkillTriggerType,便于跨模块认知统一
|
||||
@@ -62,19 +52,6 @@ export enum CardTriggerType {
|
||||
HeroCall = 7, // 英雄上场时触发(主角召唤 + 技能召唤 + 复活)
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡池等级占位枚举(已废弃分层语义)。
|
||||
* 新机制下所有英雄卡均属 LV1,不再使用卡池升级。
|
||||
* 保留枚举仅为兼容历史代码引用。
|
||||
*/
|
||||
export enum CardLV {
|
||||
LV1 = 1,
|
||||
LV2 = 2,
|
||||
LV3 = 3,
|
||||
LV4 = 4,
|
||||
LV5 = 5,
|
||||
}
|
||||
|
||||
/** 通用卡牌配置 */
|
||||
export interface CardConfig {
|
||||
uuid: number
|
||||
@@ -116,24 +93,6 @@ export interface CardConfig {
|
||||
target_hero_eid?: number;
|
||||
}
|
||||
|
||||
/** 升级卡折扣表(已废弃,保留以兼容历史引用) */
|
||||
export const CardsUpSet: Record<number, number> = {
|
||||
1: 50,
|
||||
2: 100,
|
||||
3: 150,
|
||||
4: 200,
|
||||
5: 250,
|
||||
}
|
||||
|
||||
/** 卡池升级每波减免金额(已废弃,保留以兼容历史引用) */
|
||||
export const CARD_POOL_UPGRADE_DISCOUNT_PER_WAVE = 10
|
||||
/** 卡池默认初始等级(已废弃,所有卡牌统一 LV1) */
|
||||
export const CARD_POOL_INIT_LEVEL = CardLV.LV1
|
||||
/** 卡池等级上限(已废弃,所有卡牌统一 LV1) */
|
||||
export const CARD_POOL_MAX_LEVEL = CardLV.LV1
|
||||
/** 英雄最高等级限制(已废弃,统一由 FightSet.HERO_MAX_LV 控制) */
|
||||
export const CARD_HERO_MAX_LEVEL = 1
|
||||
|
||||
/** 基础卡池(英雄、技能、功能) */
|
||||
export const CardPoolList: CardConfig[] = [];
|
||||
|
||||
@@ -211,11 +170,6 @@ export const SpecialRefreshCardList: Record<number, SpecialRefreshCardConfig> =
|
||||
}
|
||||
|
||||
|
||||
/** 规范等级到合法区间(保留以兼容历史调用,新机制下统一返回 LV1) */
|
||||
const clampCardLv = (lv: number): CardLV => {
|
||||
return CardLV.LV1;
|
||||
}
|
||||
|
||||
// ============ 装备相关语义已迁移至 EquipSet.ts ============
|
||||
// 装备卡池(EquipPoolList)独立管理,不再混入 CardPoolList
|
||||
|
||||
@@ -248,62 +202,27 @@ const pickCards = (cards: CardConfig[], count: number, unique: boolean = false):
|
||||
return selected
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取基础卡池(已废弃 lv 参数,新机制下返回完整卡池)。
|
||||
* @param lv 历史遗留参数,不再生效
|
||||
* @param onlyCurrentLv 历史遗留参数,不再生效
|
||||
*/
|
||||
export const getCardPoolByLv = (lv: number, onlyCurrentLv: boolean = false): CardConfig[] => {
|
||||
return CardPoolList;
|
||||
}
|
||||
|
||||
const normalizeTypeFilter = (type: CardType | CardType[]): Set<CardType> => {
|
||||
const list = Array.isArray(type) ? type : [type]
|
||||
return new Set<CardType>(list)
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规发牌:前 3 英雄 + 后 1 其他;支持按类型过滤。
|
||||
* @param lv 历史遗留参数,不再生效
|
||||
* @param type 限定卡牌类型
|
||||
* @param onlyCurrentLv 历史遗留参数,不再生效
|
||||
*/
|
||||
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, 3)
|
||||
const others = pickCards(otherPool, 1)
|
||||
return [...heroes, ...others]
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用按规则抽卡(已废弃 lv/targetPoolLv/onlyCurrentLv 参数,仅为兼容保留)。
|
||||
* 通用按规则抽卡。
|
||||
* @param options 抽卡选项
|
||||
*/
|
||||
export const drawCardsByRule = (
|
||||
lv: number,
|
||||
options: {
|
||||
count?: number
|
||||
onlyCurrentLv?: boolean
|
||||
type?: CardType | CardType[]
|
||||
heroType?: HType
|
||||
heroLv?: number
|
||||
targetPoolLv?: number
|
||||
wave?: number
|
||||
unique?: boolean
|
||||
} = {}
|
||||
): CardConfig[] => {
|
||||
const count = Math.max(0, Math.floor(options.count ?? 4))
|
||||
let pool = getCardPoolByLv(lv, options.onlyCurrentLv ?? false)
|
||||
let pool = CardPoolList
|
||||
if (options.type !== undefined) {
|
||||
const typeSet = normalizeTypeFilter(options.type)
|
||||
pool = pool.filter(card => typeSet.has(card.type))
|
||||
|
||||
@@ -1473,7 +1473,7 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
|
||||
private tryRefreshHeroCards(heroType?: HType): boolean {
|
||||
const cards = drawCardsByRule(1, {
|
||||
const cards = drawCardsByRule({
|
||||
count: 3,
|
||||
type: CardType.Hero,
|
||||
heroType,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { FacSet } from "../common/config/GameSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { CKind, CardType, CardLV, CardConfig } from "../common/config/CardSet";
|
||||
import { CKind, CardType, CardConfig } from "../common/config/CardSet";
|
||||
import { CardComp } from "./CardComp";
|
||||
import { HighlightSet, HighlightType, HighlightLevel } from "../common/config/HighlightSet";
|
||||
import { LangPrefix, lang, langf } from "../common/LangUtil";
|
||||
|
||||
Reference in New Issue
Block a user