feat(卡牌系统): 重构卡牌选择逻辑并添加属性卡类型支持
- 在GameSet枚举中添加Attr卡牌类型 - 在GameEvent中添加UseAttrCard事件 - 重构CardSet模块,统一使用GameSet中的CardType枚举 - 重构MissionCardComp模块,支持混合模式卡牌选择和强制类型获取 - 添加等级升级事件处理,优化卡牌获取逻辑
This commit is contained in:
@@ -2,16 +2,7 @@ import { AttrCards, AttrInfo, CanSelectAttrs } from "./AttrSet";
|
||||
import { talConf, ItalConf, CanSelectTalents } from "./TalSet";
|
||||
import { SkillSet, SkillConfig, CanSelectSkills } from "./SkillSet";
|
||||
import { HeroInfo, heroInfo, CanSelectHeros } from "./heroSet";
|
||||
|
||||
/**
|
||||
* 卡牌类型枚举
|
||||
*/
|
||||
export enum CardType {
|
||||
Skill = 1, // 技能
|
||||
Talent = 2, // 天赋
|
||||
Attr = 3, // 属性
|
||||
Hero = 4 // 英雄(伙伴)
|
||||
}
|
||||
import { CardType } from "./GameSet";
|
||||
|
||||
/**
|
||||
* 统一卡牌信息接口 (用于UI显示和逻辑处理)
|
||||
@@ -58,7 +49,7 @@ export const LevelPoolConfigs: Record<number, IPoolConfig[]> = {
|
||||
3: [{ type: CardType.Talent, poolWeight: 50 }, { type: CardType.Attr, poolWeight: 50, tag: "special" }], // 天赋或特殊属性
|
||||
4: [{ type: CardType.Attr, poolWeight: 100 }],
|
||||
5: [{ type: CardType.Talent, poolWeight: 100 }],
|
||||
6: [{ type: CardType.Hero, poolWeight: 100 }], // 伙伴节点
|
||||
6: [{ type: CardType.Partner, poolWeight: 100 }], // 伙伴节点
|
||||
7: [{ type: CardType.Attr, poolWeight: 80 }, { type: CardType.Skill, poolWeight: 20 }],
|
||||
8: [{ type: CardType.Attr, poolWeight: 80 }, { type: CardType.Skill, poolWeight: 20 }],
|
||||
9: [{ type: CardType.Attr, poolWeight: 50, tag: "special" }, { type: CardType.Talent, poolWeight: 50 }],
|
||||
@@ -110,7 +101,7 @@ function getCardBaseInfo(type: CardType, uuid: number): ICardInfo | null {
|
||||
desc = baseInfo.info;
|
||||
icon = baseInfo.icon;
|
||||
break;
|
||||
case CardType.Hero:
|
||||
case CardType.Partner:
|
||||
baseInfo = HeroInfo[uuid];
|
||||
if (!baseInfo) return null;
|
||||
name = baseInfo.name;
|
||||
@@ -175,7 +166,7 @@ function getDefaultPool(type: CardType, level: number = 1): IPoolItem[] {
|
||||
Object.keys(SkillSet).forEach(key => items.push({ id: Number(key), weight: 80 }));
|
||||
}
|
||||
break;
|
||||
case CardType.Hero:
|
||||
case CardType.Partner:
|
||||
// 优先使用 CanSelectHeros 中的配置
|
||||
if (CanSelectHeros[level]) {
|
||||
CanSelectHeros[level].forEach(id => items.push({ id, weight: 100 }));
|
||||
@@ -199,11 +190,14 @@ function getDefaultPool(type: CardType, level: number = 1): IPoolItem[] {
|
||||
* @param level 当前等级
|
||||
* @param count 选项数量 (默认3个)
|
||||
* @param excludeUuids 排除的卡牌UUID列表 (用于去重或排除已拥有)
|
||||
* @param forcedType 强制指定卡牌类型 (用于特殊获取,如商店、技能书等)
|
||||
*/
|
||||
export function getCardOptions(level: number, count: number = 3, excludeUuids: number[] = []): ICardInfo[] {
|
||||
export function getCardOptions(level: number, count: number = 3, excludeUuids: number[] = [], forcedType?: CardType): ICardInfo[] {
|
||||
// 1. 获取该等级的池配置
|
||||
// 必须复制一份,因为我们可能需要修改它(比如移除空的池子)
|
||||
const initialPoolConfigs = LevelPoolConfigs[level] || [{ type: CardType.Attr, poolWeight: 100 }];
|
||||
// 如果强制指定类型,则构造一个只包含该类型的配置
|
||||
const initialPoolConfigs = forcedType
|
||||
? [{ type: forcedType, poolWeight: 100 }]
|
||||
: (LevelPoolConfigs[level] || [{ type: CardType.Attr, poolWeight: 100 }]);
|
||||
|
||||
const result: ICardInfo[] = [];
|
||||
const excludeSet = new Set(excludeUuids);
|
||||
|
||||
@@ -49,6 +49,7 @@ export enum GameEvent {
|
||||
TalentSelect = "TalentSelect",
|
||||
UseTalentCard = "UseTalentCard",
|
||||
UseItemCard = "UseItemCard",
|
||||
UseAttrCard = "UseAttrCard",
|
||||
NewWave = "NewWave",
|
||||
AD_BACK_TRUE = "AD_BACK_TRUE",
|
||||
AD_BACK_FALSE = "AD_BACK_FALSE",
|
||||
|
||||
@@ -26,7 +26,8 @@ export enum CardType {
|
||||
Talent = 1,
|
||||
Skill = 2,
|
||||
Potion = 3,
|
||||
Partner = 4
|
||||
Partner = 4,
|
||||
Attr = 5
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user