20 lines
1.1 KiB
TypeScript
20 lines
1.1 KiB
TypeScript
/** Lightweight local test storage. No bundle assets, network or real wallet writes. */
|
|
export function coinMadnessMockEnabled(): boolean {
|
|
try { return CC_PREVIEW || ['开发版', '体验版'].indexOf(cc.fx.GameTool.getWechatGameVersion()) >= 0; }
|
|
catch { return false; }
|
|
}
|
|
export function coinMadnessMockKey(): string { return 'coinMadnessMock_v1_' + cc.fx.GameConfig.GM_INFO.uid; }
|
|
export function recordCoinMadnessMockWin(level: number): void {
|
|
if (!coinMadnessMockEnabled()) return;
|
|
try {
|
|
const key = coinMadnessMockKey();
|
|
const state = cc.fx.StorageMessage.getStorage(key);
|
|
if (!state || !state.paidAt || state.settled || Date.now() >= state.config.endsAt || level <= state.lastLevel) return;
|
|
// This hook represents one actual victory, not a level delta. Gaps can follow
|
|
// config catchup or older builds; count this win once without backfilling them.
|
|
state.totalWins++;
|
|
state.lastLevel = level;
|
|
cc.fx.StorageMessage.setStorage(key, state);
|
|
} catch (error) { cc.warn('Coin Madness mock progress unavailable', error); }
|
|
}
|