nomadro/apps/minigame-cocos/assets/scripts/sim/EnergySystem.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
419 B
TypeScript

import type { PlayerStats } from '../core/types'
export function applyEnergy(
stats: PlayerStats,
energyDelta: number,
): PlayerStats {
const energy = Math.min(
stats.maxEnergy,
Math.max(0, Math.round(stats.energy + energyDelta)),
)
return { ...stats, energy }
}
export function hasEnergy(stats: PlayerStats, cost: number): boolean {
if (cost >= 0) return true
return stats.energy + cost >= 0
}