fix(missionCard): 修复卡牌升级提示逻辑并优化显示

1.  新增全局配置常量CARD_POOL_UPGRADE_WAVES,优先使用任务运行时配置
2.  重构升级波次计算逻辑,新增多种状态的提示文本:本回合升级、即将升级
3.  修复prefab布局,更新升级提示UI的样式和引用
4.  补充边界情况处理,避免配置耗尽后显示异常
This commit is contained in:
panFD
2026-06-19 08:58:56 +08:00
parent 40c27e04f2
commit 18c873999b
2 changed files with 229 additions and 220 deletions

View File

@@ -45,7 +45,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroInfo, HType } from "../common/config/heroSet";
import { HeroViewComp } from "../hero/HeroViewComp";
import { FacSet, FightSet } from "../common/config/GameSet";
import { FacSet, FightSet, CARD_POOL_UPGRADE_WAVES } from "../common/config/GameSet";
import { MoveComp } from "../hero/MoveComp";
import { MissionHeroComp } from "./MissionHeroComp";
import { MissionEconomy } from "./MissionEconomy";
@@ -1050,26 +1050,35 @@ export class MissionCardComp extends CCComp {
if (this.poolLv >= CARD_POOL_MAX_LEVEL) {
nextLabel.string = `已满级`;
} else {
let upgradeWaves: number[] = [5, 10];
// 优先取 MissionComp 运行时配置,缺失时回退到全局常量
let upgradeWaves: number[] = CARD_POOL_UPGRADE_WAVES;
ecs.query(ecs.allOf(MissionComp)).forEach((entity) => {
const mission = entity.get(MissionComp);
if (mission && mission.cardPoolUpgradeWaves) {
if (mission && mission.cardPoolUpgradeWaves && mission.cardPoolUpgradeWaves.length > 0) {
upgradeWaves = mission.cardPoolUpgradeWaves;
}
});
// 已完成的升级次数 = 当前等级 - 初始等级
// 例poolLv=2INIT=1→ 已升 1 次 → 下一升级对应 upgradeWaves[1]
const upgradedCount = Math.max(0, Math.floor(this.poolLv) - CARD_POOL_INIT_LEVEL);
const currentWave = this.getCurrentWave();
let nextWave = -1;
for (let i = 0; i < upgradeWaves.length; i++) {
if (upgradeWaves[i] > currentWave) {
nextWave = upgradeWaves[i];
break;
}
}
if (nextWave !== -1) {
const remain = nextWave - currentWave;
nextLabel.string = `${remain} 回合后升级`;
} else {
if (upgradedCount >= upgradeWaves.length) {
// 配置已耗尽但等级未到上限(配置缺陷)
nextLabel.string = `已满级`;
} else {
const nextWave = upgradeWaves[upgradedCount];
if (nextWave > currentWave) {
const remain = nextWave - currentWave;
nextLabel.string = `${remain} 回合后升级`;
} else if (nextWave === currentWave) {
// 当前波次正好是升级波次(事件可能即将触发或刚刚触发)
nextLabel.string = `本回合升级`;
} else {
// nextWave < currentWave异常状态升级事件未按时触发
nextLabel.string = `即将升级`;
}
}
}
}