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>
18 lines
475 B
TypeScript
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)) }
|
|
}
|