buy-fuel.js 454 B

12345678910111213141516171819
  1. states.push({
  2. id: "buy-fuel",
  3. button: "Buy Fuel (100 for ₩300)",
  4. action: "Purchasing",
  5. duration: 300,
  6. requires: () => {
  7. let enoughMoney = userData.money >= 300;
  8. if (!enoughMoney) {
  9. errorMessage = "Not enough money to buy fuel";
  10. return false;
  11. }
  12. let confirmPurchase = confirm(`Are you sure you want to purchase 100 fuel for ₩300?`);
  13. return confirmPurchase;
  14. },
  15. run: () => {
  16. userData.money -= 300;
  17. userData.fuel += 100;
  18. },
  19. });