nomadro/apps/minigame-cocos/assets/scripts/sim/EconomySystem.ts
Eric 58a845db32 Add WeChat minigame triple-engine scaffold with Godot Chiang Mai plaza SoT.
Unity and Cocos stay as parallel schemes; apps/minigame ships the Godot 4.7 WeChat pack for DevTools.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-06 20:17:14 +08:00

18 lines
475 B
TypeScript

import type { PlayerStats } from '../core/types'
export type ActionEconomy = {
energyDelta: number
cashDelta: number
minutesDelta: number
message: string
}
export function canAfford(stats: PlayerStats, cashDelta: number): boolean {
if (cashDelta >= 0) return true
return stats.cash + cashDelta >= 0
}
export function applyCash(stats: PlayerStats, cashDelta: number): PlayerStats {
return { ...stats, cash: Math.max(0, Math.round(stats.cash + cashDelta)) }
}