refactor(mission): 调整刷新石消耗逻辑并统一配置

1. 新增刷新石单次消耗常量配置到GameSet
2. 重构刷新消耗计算逻辑,统一从配置读取消耗值
3. 更新UI显示逻辑,正确展示单次刷新所需刷新石数量
4. 修复刷新石扣除逻辑,按实际配置值扣除而非固定1
This commit is contained in:
panFD
2026-07-31 20:22:43 +08:00
parent 7124b88201
commit 34b0443ccb
3 changed files with 27 additions and 15 deletions

View File

@@ -50,6 +50,8 @@ export enum FightSet {
BASE_COST = 5, BASE_COST = 5,
INIT_COIN = 7, // 初始金币数 INIT_COIN = 7, // 初始金币数
INIT_REFRESH_STONE = 3, // 初始刷新石数量 INIT_REFRESH_STONE = 3, // 初始刷新石数量
/** 单次刷新消耗的刷新石数量 */
REFRESH_STONE_COST = 1,
} }
/** /**

View File

@@ -1699,10 +1699,11 @@ export class MissionCardComp extends CCComp {
private updateDrawCostUI() { private updateDrawCostUI() {
const stones = MissionEconomy.getRefreshStone(); const stones = MissionEconomy.getRefreshStone();
this.updateOneRefreshBtnUI(this.cards_chou, stones); const stoneCost = MissionEconomy.getRefreshStoneCost();
this.updateOneRefreshBtnUI(this.equip_refresh, stones); this.updateOneRefreshBtnUI(this.cards_chou, stones, stoneCost);
this.updateOneRefreshBtnUI(this.shop_refresh, stones); this.updateOneRefreshBtnUI(this.equip_refresh, stones, stoneCost);
this.updateOneRefreshBtnUI(this.skill_refresh, stones); this.updateOneRefreshBtnUI(this.shop_refresh, stones, stoneCost);
this.updateOneRefreshBtnUI(this.skill_refresh, stones, stoneCost);
} }
/** /**
@@ -1717,11 +1718,13 @@ export class MissionCardComp extends CCComp {
* *
* @param btnNode 刷新按钮节点 * @param btnNode 刷新按钮节点
* @param stones 当前刷新石数量(外部统一读取,避免 4 次重复访问) * @param stones 当前刷新石数量(外部统一读取,避免 4 次重复访问)
* @param stoneCost 单次刷新消耗的刷新石数量
*/ */
private updateOneRefreshBtnUI(btnNode: Node | null, stones: number) { private updateOneRefreshBtnUI(btnNode: Node | null, stones: number, stoneCost: number) {
if (!btnNode || !btnNode.isValid) return; if (!btnNode || !btnNode.isValid) return;
const useStone = stones > 0; // 刷新石足够一次消耗时走刷新石通道,否则走金币通道
const useStone = stones >= stoneCost;
// 置灰遮罩:有刷新石必定可刷新,否则按金币判断 // 置灰遮罩:有刷新石必定可刷新,否则按金币判断
const nobg = btnNode.getChildByName("nobg"); const nobg = btnNode.getChildByName("nobg");
@@ -1745,14 +1748,14 @@ export class MissionCardComp extends CCComp {
} }
} }
// 刷新石费用节点(显示当前持有数量) // 刷新石费用节点(显示单次刷新消耗数量)
const stoneNode = container.getChildByName("stone"); const stoneNode = container.getChildByName("stone");
if (stoneNode) { if (stoneNode) {
stoneNode.active = useStone; stoneNode.active = useStone;
if (useStone) { if (useStone) {
const numLabel = stoneNode.getChildByName("num")?.getComponent(Label); const numLabel = stoneNode.getChildByName("num")?.getComponent(Label);
if (numLabel) { if (numLabel) {
numLabel.string = `${stones}`; numLabel.string = `${stoneCost}`;
} }
} }
} }

View File

@@ -1,6 +1,7 @@
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { FightSet } from "../common/config/GameSet";
import { FieldSkillType } from "../common/config/SkillSet"; import { FieldSkillType } from "../common/config/SkillSet";
import { FieldSkillHelper } from "../hero/FieldSkillHelper"; import { FieldSkillHelper } from "../hero/FieldSkillHelper";
@@ -70,26 +71,32 @@ export class MissionEconomy {
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: amount }); oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: amount });
} }
/** 单次刷新消耗的刷新石数量 */
static getRefreshStoneCost(): number {
return Math.max(1, Math.floor(FightSet.REFRESH_STONE_COST));
}
/** /**
* 判断当前是否可以执行一次刷新(刷新石或金币足够) * 判断当前是否可以执行一次刷新(刷新石足够或金币足够)
*/ */
static canRefresh(baseCost: number = 1): boolean { static canRefresh(baseCost: number = 1): boolean {
if (this.getRefreshStone() > 0) return true; if (this.getRefreshStone() >= this.getRefreshStoneCost()) return true;
return this.getCoin() >= this.getRefreshCost(baseCost); return this.getCoin() >= this.getRefreshCost(baseCost);
} }
/** /**
* 执行刷新卡牌: * 执行刷新卡牌:
* 1. 刷新石 > 0 时优先扣除 1 颗刷新石(不消耗金币)。 * 1. 刷新石足够时优先扣除 REFRESH_STONE_COST 颗刷新石(不消耗金币)。
* 2. 刷新石不足时扣除金币(含刷新优惠折扣)。 * 2. 刷新石不足时扣除金币(含刷新优惠折扣)。
*/ */
static executeRefresh(baseCost: number = 1): boolean { static executeRefresh(baseCost: number = 1): boolean {
// 优先消耗刷新石 // 优先消耗刷新石
const stoneCost = this.getRefreshStoneCost();
const stones = this.getRefreshStone(); const stones = this.getRefreshStone();
if (stones > 0) { if (stones >= stoneCost) {
smc.vmdata.mission_data.refresh_stone = stones - 1; smc.vmdata.mission_data.refresh_stone = stones - stoneCost;
smc.vmdata.scores.refresh_count++; smc.vmdata.scores.refresh_count++;
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: -1 }); oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: -stoneCost });
return true; return true;
} }