added shop functionality. Shop now pulls from db

This commit is contained in:
masongga
2026-05-23 22:46:58 -06:00
parent 598d7f781b
commit 5f0bbaf3cf
3 changed files with 278 additions and 54 deletions

View File

@@ -72,3 +72,17 @@ export async function adjustCoins(delta: number): Promise<number> {
return nextCoins;
}
export async function spendCoins(amount: number): Promise<number> {
if (amount <= 0) {
throw new Error("Purchase amount must be greater than zero.");
}
const currentCoins = await getCoins();
if (currentCoins < amount) {
throw new Error("Not enough points.");
}
return adjustCoins(-amount);
}