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