feat: 新增刷新石机制并优化抽卡消耗逻辑
1. 新增refresh_stone玩家数据字段与对应变更事件 2. 实现刷新石的获取、消耗和刷新可用性校验逻辑 3. 抽卡优先消耗刷新石,不足时再扣除金币 4. 为购买按钮添加可配置的消耗标签,优化UI查找逻辑 5. 更新对应预制件绑定新的消耗标签组件
This commit is contained in:
@@ -52,10 +52,48 @@ export class MissionEconomy {
|
||||
return Math.floor(cost);
|
||||
}
|
||||
|
||||
/** 获取当前刷新石数量 */
|
||||
static getRefreshStone(): number {
|
||||
return Math.max(0, Math.floor(smc.vmdata.mission_data.refresh_stone ?? 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加刷新石
|
||||
* @param amount 增加数量,<=0 时忽略
|
||||
*/
|
||||
static addRefreshStone(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 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前是否可以执行一次刷新(有刷新石或金币足够)
|
||||
*/
|
||||
static canRefresh(baseCost: number = 1): boolean {
|
||||
if (this.getRefreshStone() > 0) return true;
|
||||
return this.getCoin() >= this.getRefreshCost(baseCost);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行刷新卡牌并扣除金币
|
||||
* 执行刷新卡牌:
|
||||
* 1. 刷新石 > 0 时优先扣除 1 颗刷新石(不消耗金币)。
|
||||
* 2. 刷新石不足时扣除金币(含刷新优惠折扣)。
|
||||
*/
|
||||
static executeRefresh(baseCost: number = 1): boolean {
|
||||
// 优先消耗刷新石
|
||||
const stones = this.getRefreshStone();
|
||||
if (stones > 0) {
|
||||
smc.vmdata.mission_data.refresh_stone = stones - 1;
|
||||
smc.vmdata.scores.refresh_count++;
|
||||
oops.message.dispatchEvent(GameEvent.RefreshStone, { delta: -1 });
|
||||
return true;
|
||||
}
|
||||
|
||||
// 刷新石不足 → 扣除金币
|
||||
const cost = this.getRefreshCost(baseCost);
|
||||
const success = this.spendCoin(cost);
|
||||
if (success) {
|
||||
|
||||
Reference in New Issue
Block a user