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
419 B
TypeScript
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
|
|
}
|