refactor(卡牌系统): 清理废弃的卡池等级相关代码并优化抽卡接口

1. 移除了CardSkillType枚举、废弃的CardLV枚举和相关常量定义
2. 删除了已废弃的getCardPoolByLv、getCardsByLv等兼容旧接口
3. 简化drawCardsByRule接口,移除不再生效的历史参数
4. 调整MissionCardComp中调用drawCardsByRule的传参方式
5. 格式化VictoryComp中的代码格式,统一代码风格
This commit is contained in:
pan
2026-07-27 16:11:52 +08:00
parent 9f2599e9ec
commit a94381b19f
3 changed files with 52 additions and 133 deletions

View File

@@ -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 { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
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 { 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";
@@ -33,7 +33,7 @@ const { ccclass, property } = _decorator;
export class VictoryComp extends CCComp {
@property(Node)
mvp_node=null!
mvp_node = null!
// ======================== 结算 UI 绑定 ========================
@property({ type: Label, tooltip: "总分文本" })
@@ -63,18 +63,18 @@ export class VictoryComp extends CCComp {
/** 调试日志开关 */
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={
exp:0,
gold:0,
diamond:0
game_data: any = {
exp: 0,
gold: 0,
diamond: 0
}
// ======================== 复活相关 ========================
/** 是否可以复活(由 MissionComp 传入,取决于剩余复活次数) */
@@ -82,7 +82,7 @@ export class VictoryComp extends CCComp {
/** 加载时隐藏 loading 遮罩 */
protected onLoad(): void {
this.node.getChildByName("loading").active=false
this.node.getChildByName("loading").active = false
}
/**
@@ -94,18 +94,18 @@ export class VictoryComp extends CCComp {
* @param args.can_revive 是否可复活
*/
onAdded(args: any) {
this.node.getChildByName("loading").active=false
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] onAdded",args)
if(args.game_data){
this.game_data=args.game_data
this.node.getChildByName("loading").active = false
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] onAdded", args)
if (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();
// 渲染分数UI和亮点标签
this.renderScores();
@@ -212,7 +212,7 @@ export class VictoryComp extends CCComp {
private getHighestHighlightLevel(type: HighlightType, value: number): HighlightLevel | null {
const config = HighlightSet[type];
if (!config || !config.levels) return null;
let highest: HighlightLevel | null = null;
for (const levelConfig of config.levels) {
if (value >= levelConfig.threshold) {
@@ -227,7 +227,7 @@ export class VictoryComp extends CCComp {
*/
private getAchievedHighlights(s: any): { type: HighlightType, config: HighlightLevel, value: number }[] {
const achieved: { type: HighlightType, config: HighlightLevel, value: number }[] = [];
// 计算辅助比例
const refreshRatio = s.refresh_count > 0 ? (s.refresh_hit_count / s.refresh_count) : 0;
const goldRatio = s.gold_earned > 0 ? (s.gold_spent / s.gold_earned) : 0;
@@ -251,7 +251,7 @@ export class VictoryComp extends CCComp {
achieved.push({ type: item.type, config: levelConfig, value: item.value });
}
}
return achieved;
}
@@ -260,7 +260,7 @@ export class VictoryComp extends CCComp {
*/
private calculateTotalScore() {
const s = smc.vmdata.scores;
// 1. 战绩分:衡量生存能力——活几回合、赢几场。
s.score_combat = (s.wave_win_count * 100)
- (s.wave_remain_monsters * 15)
@@ -289,7 +289,7 @@ export class VictoryComp extends CCComp {
// 6. 亮点成就额外加分 (按等级叠加)
const achieved = this.getAchievedHighlights(s);
s.achieved_highlights = achieved; // 记录已达成的亮点信息
let highlightBonus = 0;
for (const item of achieved) {
highlightBonus += item.config.scoreBonus;
@@ -297,7 +297,7 @@ export class VictoryComp extends CCComp {
// 取整并存储当前局分数
s.score = Math.floor(s.score_combat + s.score_output + s.score_defense + s.score_build + s.score_efficiency + highlightBonus);
// 判定是否打破历史最高分记录
let isNewRecord = false;
if (s.score > smc.data.score) {
@@ -308,7 +308,7 @@ export class VictoryComp extends CCComp {
smc.updateCloudData();
}
}
// 借用 scores 对象传递新记录标记,供 UI 渲染使用
(s as any).isNewRecord = isNewRecord;
@@ -330,11 +330,11 @@ export class VictoryComp extends CCComp {
*/
private renderScores() {
const s = smc.vmdata.scores;
// 渲染总分
if (this.total_score_label) {
this.total_score_label.string = `${s.score}`;
// 判定是否是新记录,如果是则激活 new 节点
const isNewRecord = (s as any).isNewRecord === true;
const newNode = this.total_score_label.node.getChildByName("new");
@@ -348,13 +348,13 @@ export class VictoryComp extends CCComp {
if (!node) return;
const lab = node.getChildByName("score_label")?.getComponent(Label);
if (lab) lab.string = `${score}`;
const bar = node.getChildByName("progress_bar")?.getComponent(ProgressBar);
const bar = node.getChildByName("progress_bar")?.getComponent(ProgressBar);
if (bar) {
// 根据该维度得分占“预期满分”的比例设置进度条fillRange
bar.progress = Math.min(1, Math.max(0, score / maxScore));
}
};
};
// TODO: 进度条的最大值可按设计期望自行调整,目前为占位预估值
// renderDim(this.combat_node, s.score_combat, 3000);
@@ -372,21 +372,21 @@ export class VictoryComp extends CCComp {
*/
private renderHighlights() {
if (!this.highlights_container || !this.highlight_prefab) return;
// 先清空原有的标签
this.highlights_container.removeAllChildren();
const s = smc.vmdata.scores;
// 获取所有已达成的亮点(包含对应等级的信息)
const achievedList = s.achieved_highlights || [];
// 最多显示前3个亮点如有优先级需求可在截取前对 achievedList 进行排序)
const displayTags = achievedList.slice(0, 3);
displayTags.forEach(item => {
const tagNode = instantiate(this.highlight_prefab);
const lab = tagNode.getComponent(Label) || tagNode.getChildByName("label")?.getComponent(Label);
if (lab) {
const typeConfig = HighlightSet[item.type];
const levelConfig = item.config;
@@ -404,25 +404,25 @@ export class VictoryComp extends CCComp {
// ======================== 操作入口 ========================
/** 退出战斗:清理数据 → 触发任务结束 → 关闭弹窗 */
victory_end(){
victory_end() {
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionEnd)
oops.gui.removeByNode(this.node)
}
/** 清理运行时数据:解除暂停标志 */
clear_data(){
smc.mission.pause=false
clear_data() {
smc.mission.pause = false
}
/** 看广告双倍奖励(预留) */
watch_ad(){
watch_ad() {
return true
}
/** 双倍奖励发放(预留) */
double_reward(){
double_reward() {
}
/**
@@ -432,20 +432,20 @@ export class VictoryComp extends CCComp {
* 3. 显示 loading 遮罩,延迟 0.5 秒后触发 MissionStart。
* 4. 关闭弹窗。
*/
restart(){
restart() {
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionEnd)
this.node.getChildByName("loading").active=true
this.scheduleOnce(()=>{
this.node.getChildByName("loading").active = true
this.scheduleOnce(() => {
oops.gui.open(UIID.Mission)
this.node.getChildByName("loading").active=false
this.node.getChildByName("loading").active = false
oops.gui.removeByNode(this.node)
},0.5)
}, 0.5)
}
/** 物品展示回调(预留) */
item_show(e:any,val:any){
mLogger.log(this.debugMode, 'VictoryComp', "item_show",val)
item_show(e: any, val: any) {
mLogger.log(this.debugMode, 'VictoryComp', "item_show", val)
}
protected onDestroy(): void {