buy-battery.js 465 B

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