refactor: 将刷新石替换为银币作为卡牌刷新消耗

1. 重构全局配置,移除刷新石相关定义,新增银币刷新消耗常量
2. 新增局外持久货币银币的数据结构与管理逻辑
3. 重构卡牌刷新经济系统,统一使用银币进行刷新消耗
4. 更新UI显示与事件通知,适配银币系统变更
5. 调整清屏奖励逻辑,将刷新石奖励改为金币奖励
This commit is contained in:
panFD
2026-09-10 14:12:51 +08:00
parent a02bf54ede
commit 317a500439
9 changed files with 1763 additions and 343 deletions

View File

@@ -39,68 +39,45 @@ export class MissionEconomy {
return true;
}
/**
* 计算卡牌刷新费用
* @param baseCost 基础费用,默认为1
*/
static getRefreshCost(baseCost: number = 1): number {
return Math.floor(Math.max(0, baseCost));
}
/** 获取当前刷新石数量 */
static getRefreshStone(): number {
return Math.max(0, Math.floor(smc.vmdata.mission_data.refresh_stone ?? 0));
/** 获取当前银币数量(局外持久货币,刷新卡牌消耗) */
static getSilver(): number {
return Math.max(0, Math.floor(smc.vmdata.silver ?? 0));
}
/**
* 增加刷新石
* 增加银币
* @param amount 增加数量,<=0 时忽略
*/
static addRefreshStone(amount: number) {
static addSilver(amount: number) {
if (amount <= 0) return;
amount = Math.floor(amount);
smc.vmdata.mission_data.refresh_stone = this.getRefreshStone() + amount;
// 发送 UI 更新事件(复用 RefreshStone 事件通知刷新按钮状态刷新)
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: amount });
smc.updateSilver(Math.floor(amount));
}
/** 单次刷新消耗的刷新石数量 */
static getRefreshStoneCost(): number {
return Math.max(1, Math.floor(FightSet.REFRESH_STONE_COST));
/** 单次刷新消耗的银币数量 */
static getSilverRefreshCost(): number {
return Math.max(1, Math.floor(FightSet.SILVER_REFRESH_COST));
}
/**
* 判断当前是否可以执行一次刷新(刷新石足够或金币足够)
* 判断当前是否可以执行一次刷新(银币足够)
*/
static canRefresh(baseCost: number = 1): boolean {
if (this.getRefreshStone() >= this.getRefreshStoneCost()) return true;
return this.getCoin() >= this.getRefreshCost(baseCost);
static canRefresh(): boolean {
return this.getSilver() >= this.getSilverRefreshCost();
}
/**
* 执行刷新卡牌:
* 1. 刷新石足够时优先扣除 REFRESH_STONE_COST 颗刷新石(不消耗金币)。
* 2. 刷新石不足时扣除金币(含刷新优惠折扣)。
* 银币足够时扣除 SILVER_REFRESH_COST 枚银币,否则刷新失败。
* Why: 英雄卡牌只能银币刷新,不能金币刷新,银币为局外持久货币,靠日常积攒。
*/
static executeRefresh(baseCost: number = 1): boolean {
// 优先消耗刷新石
const stoneCost = this.getRefreshStoneCost();
const stones = this.getRefreshStone();
if (stones >= stoneCost) {
smc.vmdata.mission_data.refresh_stone = stones - stoneCost;
smc.vmdata.scores.refresh_count++;
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: -stoneCost });
return true;
}
static executeRefresh(): boolean {
const cost = this.getSilverRefreshCost();
const silver = this.getSilver();
if (silver < cost) return false;
// 刷新石不足 → 扣除金币
const cost = this.getRefreshCost(baseCost);
const success = this.spendCoin(cost);
if (success) {
smc.vmdata.scores.refresh_count++;
}
return success;
smc.updateSilver(-cost);
smc.vmdata.scores.refresh_count++;
return true;
}
/**