feat: add money system with income, afford check, spend

This commit is contained in:
2026-05-13 03:36:38 +00:00
parent a063f51b20
commit cbed651937
2 changed files with 92 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
// ==================== 银两系统 ====================
export function applyDailyIncome(state, amount) {
state.money += amount;
if (state.money < 0) {
state.money = 0;
}
}
export function canAfford(state, cost) {
return state.money >= cost;
}
export function spendMoney(state, amount) {
if (!canAfford(state, amount)) {
return false;
}
state.money -= amount;
return true;
}