12345678910111213141516171819 |
- states.push({
- id: "buy-battery",
- button: "Buy Battery (₩500)",
- action: "Purchasing",
- duration: 300,
- requires: () => {
- let enoughMoney = userData.money > 500;
- if (!enoughMoney) {
- errorMessage = "Not enough money to buy battery";
- return false;
- }
- let confirmPurchase = confirm(`Are you sure you want to purchase another battery for ₩500?`);
- return confirmPurchase;
- },
- run: () => {
- userData.money -= 500;
- userData.maxBattery += 50;
- }
- });
|