a munch adventure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 line
902 B

  1. stories = [];
  2. function initGame(story, state) {
  3. state.info = {};
  4. state.info.time = 60 * 60 * 9;
  5. state.player.stats = {};
  6. state.player.stats.health = 100;
  7. }
  8. // TODO: format string this lol
  9. function renderTime(time) {
  10. let hours = Math.floor(time / 3600) % 12;
  11. const ampm = Math.floor(time / 3600) % 24 < 12 ? "AM" : "PM";
  12. let minutes = Math.floor(time / 60) % 60;
  13. let seconds = time % 60;
  14. if (minutes <= 9)
  15. minutes = "0" + minutes;
  16. if (seconds <= 9)
  17. seconds = "0" + seconds;
  18. return hours + ":" + minutes + ":" + seconds + " " + ampm;
  19. }
  20. function updateWorldInfo(state) {
  21. const timeInfo = document.querySelector("#world-info-time");
  22. timeInfo.textContent = "Time: " + renderTime(state.info.time);
  23. }
  24. function updatePlayerInfo(state) {
  25. const health = document.querySelector("#player-info-health");
  26. health.textContent = "Health: " + state.player.stats.health;
  27. }