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, //药水
|
Potion = 4, //药水
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 技能卡触发类型 */
|
|
||||||
export enum CardSkillType {
|
|
||||||
Interval = 1, // 间隔定时触发 (战斗中每隔N秒执行)
|
|
||||||
Field = 2, // 驻场技能 (被动光环)
|
|
||||||
BattleStart = 3, // 战斗开始时触发一次
|
|
||||||
BattleEnd = 4, // 战斗结束时触发一次
|
|
||||||
HeroDead = 5, // 场上己方英雄死亡时触发
|
|
||||||
HeroCall = 6, // 场上己方英雄召唤上场时触发
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡牌技能触发类型
|
* 卡牌技能触发类型
|
||||||
* - 命名对齐英雄侧 SkillTriggerType,便于跨模块认知统一
|
* - 命名对齐英雄侧 SkillTriggerType,便于跨模块认知统一
|
||||||
@@ -62,19 +52,6 @@ export enum CardTriggerType {
|
|||||||
HeroCall = 7, // 英雄上场时触发(主角召唤 + 技能召唤 + 复活)
|
HeroCall = 7, // 英雄上场时触发(主角召唤 + 技能召唤 + 复活)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡池等级占位枚举(已废弃分层语义)。
|
|
||||||
* 新机制下所有英雄卡均属 LV1,不再使用卡池升级。
|
|
||||||
* 保留枚举仅为兼容历史代码引用。
|
|
||||||
*/
|
|
||||||
export enum CardLV {
|
|
||||||
LV1 = 1,
|
|
||||||
LV2 = 2,
|
|
||||||
LV3 = 3,
|
|
||||||
LV4 = 4,
|
|
||||||
LV5 = 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 通用卡牌配置 */
|
/** 通用卡牌配置 */
|
||||||
export interface CardConfig {
|
export interface CardConfig {
|
||||||
uuid: number
|
uuid: number
|
||||||
@@ -116,24 +93,6 @@ export interface CardConfig {
|
|||||||
target_hero_eid?: number;
|
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[] = [];
|
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 ============
|
// ============ 装备相关语义已迁移至 EquipSet.ts ============
|
||||||
// 装备卡池(EquipPoolList)独立管理,不再混入 CardPoolList
|
// 装备卡池(EquipPoolList)独立管理,不再混入 CardPoolList
|
||||||
|
|
||||||
@@ -248,62 +202,27 @@ const pickCards = (cards: CardConfig[], count: number, unique: boolean = false):
|
|||||||
return selected
|
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 normalizeTypeFilter = (type: CardType | CardType[]): Set<CardType> => {
|
||||||
const list = Array.isArray(type) ? type : [type]
|
const list = Array.isArray(type) ? type : [type]
|
||||||
return new Set<CardType>(list)
|
return new Set<CardType>(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常规发牌:前 3 英雄 + 后 1 其他;支持按类型过滤。
|
* 通用按规则抽卡。
|
||||||
* @param lv 历史遗留参数,不再生效
|
* @param options 抽卡选项
|
||||||
* @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 参数,仅为兼容保留)。
|
|
||||||
*/
|
*/
|
||||||
export const drawCardsByRule = (
|
export const drawCardsByRule = (
|
||||||
lv: number,
|
|
||||||
options: {
|
options: {
|
||||||
count?: number
|
count?: number
|
||||||
onlyCurrentLv?: boolean
|
|
||||||
type?: CardType | CardType[]
|
type?: CardType | CardType[]
|
||||||
heroType?: HType
|
heroType?: HType
|
||||||
heroLv?: number
|
heroLv?: number
|
||||||
targetPoolLv?: number
|
|
||||||
wave?: number
|
wave?: number
|
||||||
unique?: boolean
|
unique?: boolean
|
||||||
} = {}
|
} = {}
|
||||||
): CardConfig[] => {
|
): CardConfig[] => {
|
||||||
const count = Math.max(0, Math.floor(options.count ?? 4))
|
const count = Math.max(0, Math.floor(options.count ?? 4))
|
||||||
let pool = getCardPoolByLv(lv, options.onlyCurrentLv ?? false)
|
let pool = CardPoolList
|
||||||
if (options.type !== undefined) {
|
if (options.type !== undefined) {
|
||||||
const typeSet = normalizeTypeFilter(options.type)
|
const typeSet = normalizeTypeFilter(options.type)
|
||||||
pool = pool.filter(card => typeSet.has(card.type))
|
pool = pool.filter(card => typeSet.has(card.type))
|
||||||
|
|||||||
@@ -1473,7 +1473,7 @@ export class MissionCardComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private tryRefreshHeroCards(heroType?: HType): boolean {
|
private tryRefreshHeroCards(heroType?: HType): boolean {
|
||||||
const cards = drawCardsByRule(1, {
|
const cards = drawCardsByRule({
|
||||||
count: 3,
|
count: 3,
|
||||||
type: CardType.Hero,
|
type: CardType.Hero,
|
||||||
heroType,
|
heroType,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
import { _decorator, instantiate, Label ,Prefab,Node, Sprite, Animation, AnimationClip, resources, UITransform, Widget, ProgressBar, Tween, NodeEventType } from "cc";
|
import { _decorator, instantiate, Label, Prefab, Node, Sprite, Animation, AnimationClip, resources, UITransform, Widget, ProgressBar, Tween, NodeEventType } from "cc";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
@@ -13,7 +13,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
|||||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
import { FacSet } from "../common/config/GameSet";
|
import { FacSet } from "../common/config/GameSet";
|
||||||
import { HeroInfo } from "../common/config/heroSet";
|
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 { CardComp } from "./CardComp";
|
||||||
import { HighlightSet, HighlightType, HighlightLevel } from "../common/config/HighlightSet";
|
import { HighlightSet, HighlightType, HighlightLevel } from "../common/config/HighlightSet";
|
||||||
import { LangPrefix, lang, langf } from "../common/LangUtil";
|
import { LangPrefix, lang, langf } from "../common/LangUtil";
|
||||||
@@ -33,7 +33,7 @@ const { ccclass, property } = _decorator;
|
|||||||
export class VictoryComp extends CCComp {
|
export class VictoryComp extends CCComp {
|
||||||
|
|
||||||
@property(Node)
|
@property(Node)
|
||||||
mvp_node=null!
|
mvp_node = null!
|
||||||
|
|
||||||
// ======================== 结算 UI 绑定 ========================
|
// ======================== 结算 UI 绑定 ========================
|
||||||
@property({ type: Label, tooltip: "总分文本" })
|
@property({ type: Label, tooltip: "总分文本" })
|
||||||
@@ -63,16 +63,16 @@ export class VictoryComp extends CCComp {
|
|||||||
/** 调试日志开关 */
|
/** 调试日志开关 */
|
||||||
debugMode: boolean = false;
|
debugMode: boolean = false;
|
||||||
/** 奖励等级(预留) */
|
/** 奖励等级(预留) */
|
||||||
reward_lv:number=1
|
reward_lv: number = 1
|
||||||
/** 奖励数量(预留) */
|
/** 奖励数量(预留) */
|
||||||
reward_num:number=2
|
reward_num: number = 2
|
||||||
/** 掉落奖励列表 */
|
/** 掉落奖励列表 */
|
||||||
rewards:any[]=[]
|
rewards: any[] = []
|
||||||
/** 累计游戏数据(经验 / 金币 / 钻石) */
|
/** 累计游戏数据(经验 / 金币 / 钻石) */
|
||||||
game_data:any={
|
game_data: any = {
|
||||||
exp:0,
|
exp: 0,
|
||||||
gold:0,
|
gold: 0,
|
||||||
diamond:0
|
diamond: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================== 复活相关 ========================
|
// ======================== 复活相关 ========================
|
||||||
@@ -82,7 +82,7 @@ export class VictoryComp extends CCComp {
|
|||||||
|
|
||||||
/** 加载时隐藏 loading 遮罩 */
|
/** 加载时隐藏 loading 遮罩 */
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
this.node.getChildByName("loading").active=false
|
this.node.getChildByName("loading").active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,14 +94,14 @@ export class VictoryComp extends CCComp {
|
|||||||
* @param args.can_revive 是否可复活
|
* @param args.can_revive 是否可复活
|
||||||
*/
|
*/
|
||||||
onAdded(args: any) {
|
onAdded(args: any) {
|
||||||
this.node.getChildByName("loading").active=false
|
this.node.getChildByName("loading").active = false
|
||||||
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] onAdded",args)
|
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] onAdded", args)
|
||||||
if(args.game_data){
|
if (args.game_data) {
|
||||||
this.game_data=args.game_data
|
this.game_data = args.game_data
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据是否可复活决定按钮显示
|
// 根据是否可复活决定按钮显示
|
||||||
this.node.getChildByName("btns").getChildByName("next").active=!args.can_revive
|
this.node.getChildByName("btns").getChildByName("next").active = !args.can_revive
|
||||||
|
|
||||||
// 计算总分
|
// 计算总分
|
||||||
this.calculateTotalScore();
|
this.calculateTotalScore();
|
||||||
@@ -404,24 +404,24 @@ export class VictoryComp extends CCComp {
|
|||||||
// ======================== 操作入口 ========================
|
// ======================== 操作入口 ========================
|
||||||
|
|
||||||
/** 退出战斗:清理数据 → 触发任务结束 → 关闭弹窗 */
|
/** 退出战斗:清理数据 → 触发任务结束 → 关闭弹窗 */
|
||||||
victory_end(){
|
victory_end() {
|
||||||
this.clear_data()
|
this.clear_data()
|
||||||
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
||||||
oops.gui.removeByNode(this.node)
|
oops.gui.removeByNode(this.node)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 清理运行时数据:解除暂停标志 */
|
/** 清理运行时数据:解除暂停标志 */
|
||||||
clear_data(){
|
clear_data() {
|
||||||
smc.mission.pause=false
|
smc.mission.pause = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 看广告双倍奖励(预留) */
|
/** 看广告双倍奖励(预留) */
|
||||||
watch_ad(){
|
watch_ad() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 双倍奖励发放(预留) */
|
/** 双倍奖励发放(预留) */
|
||||||
double_reward(){
|
double_reward() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,20 +432,20 @@ export class VictoryComp extends CCComp {
|
|||||||
* 3. 显示 loading 遮罩,延迟 0.5 秒后触发 MissionStart。
|
* 3. 显示 loading 遮罩,延迟 0.5 秒后触发 MissionStart。
|
||||||
* 4. 关闭弹窗。
|
* 4. 关闭弹窗。
|
||||||
*/
|
*/
|
||||||
restart(){
|
restart() {
|
||||||
this.clear_data()
|
this.clear_data()
|
||||||
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
||||||
this.node.getChildByName("loading").active=true
|
this.node.getChildByName("loading").active = true
|
||||||
this.scheduleOnce(()=>{
|
this.scheduleOnce(() => {
|
||||||
oops.gui.open(UIID.Mission)
|
oops.gui.open(UIID.Mission)
|
||||||
this.node.getChildByName("loading").active=false
|
this.node.getChildByName("loading").active = false
|
||||||
oops.gui.removeByNode(this.node)
|
oops.gui.removeByNode(this.node)
|
||||||
},0.5)
|
}, 0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 物品展示回调(预留) */
|
/** 物品展示回调(预留) */
|
||||||
item_show(e:any,val:any){
|
item_show(e: any, val: any) {
|
||||||
mLogger.log(this.debugMode, 'VictoryComp', "item_show",val)
|
mLogger.log(this.debugMode, 'VictoryComp', "item_show", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onDestroy(): void {
|
protected onDestroy(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user