fix(mission): 修复刷新石初始化和抽卡UI更新逻辑

1.  初始化任务时手动派发刷新石数量变更事件,解决MissionStart早于data_init导致的UI未刷新问题
2.  抽卡按钮置灰和费用显示逻辑抽离为统一的updateDrawCostUI方法,简化重复代码
This commit is contained in:
panFD
2026-07-30 17:18:53 +08:00
parent 68c5d991d5
commit 8fa54e894a
2 changed files with 6 additions and 14 deletions

View File

@@ -1481,12 +1481,8 @@ export class MissionCardComp extends CCComp {
if (this.showHeros && this.showHeros.isValid) {
this.showHeros.active = true;
}
if (this.cards_chou && this.cards_chou.isValid) {
const nobg = this.cards_chou.getChildByName("nobg");
if (nobg) {
nobg.active = !this.canDrawCards();
}
}
// 刷新所有刷新按钮的费用显示(含刷新石/金币切换与置灰状态)
this.updateDrawCostUI();
// 显示卡牌面板(默认进入准备阶段时展开)
if (this.cardPanNode && this.cardPanNode.isValid) {
this.cardPanNode.active = true;
@@ -1518,13 +1514,8 @@ export class MissionCardComp extends CCComp {
private enterBattlePhase() {
if (!this.cards_node || !this.cards_node.isValid) return;
this.initCardsPanelPos();
// 战斗阶段允许抽卡:nobg 按"金币是否足够"判断
if (this.cards_chou && this.cards_chou.isValid) {
const nobg = this.cards_chou.getChildByName("nobg");
if (nobg) {
nobg.active = !this.canDrawCards();
}
}
// 战斗阶段允许抽卡:刷新所有刷新按钮的费用显示(含刷新石/金币切换与置灰状态)
this.updateDrawCostUI();
}
/**

View File

@@ -801,8 +801,9 @@ export class MissionComp extends CCComp {
smc.resetScores();
smc.vmdata.mission_data.coin = Math.max(0, Math.floor(FightSet.INIT_COIN));
// 初始化刷新石数量
// 初始化刷新石数量,并派发事件通知 UI 刷新MissionStart 早于 data_init需手动通知
smc.vmdata.mission_data.refresh_stone = Math.max(0, Math.floor(FightSet.INIT_REFRESH_STONE));
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: FightSet.INIT_REFRESH_STONE });
// 【评分系统 - 效率分】记录初始获得的金币收入
smc.vmdata.scores.gold_earned += smc.vmdata.mission_data.coin;
}