navigationui.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { ROOM_SHOP, ROOM_BREW, ROOM_MARKET, moveToRoom } from "../game.js"
  2. export function navigationUI(game, stageData) {
  3. document.getElementById("prev").addEventListener("click", (event) => {
  4. previousRoom(game, stageData)
  5. })
  6. document.getElementById("next").addEventListener("click", (event) => {
  7. nextRoom(game, stageData)
  8. })
  9. }
  10. export function showNavigationUI(game, stageData) {
  11. document.getElementById("room-navigation").style.display = "block"
  12. }
  13. export function hideNavigationUI(game, stageData) {
  14. document.getElementById("room-navigation").style.display = "none"
  15. document.getElementById("prev").style.display = "block"
  16. document.getElementById("next").style.display = "block"
  17. document.getElementById("prev-text").innerHTML = "Shop"
  18. document.getElementById("next-text").innerHTML = "Market"
  19. }
  20. export function previousRoom(game, stageData) {
  21. switch(stageData.currentRoom) {
  22. case ROOM_BREW:
  23. moveToRoom(ROOM_SHOP)
  24. document.getElementById("prev").style.display = "none"
  25. document.getElementById("next-text").innerHTML = "Brew"
  26. break;
  27. case ROOM_MARKET:
  28. moveToRoom(ROOM_BREW)
  29. document.getElementById("next").style.display = "block"
  30. document.getElementById("prev-text").innerHTML = "Shop"
  31. break;
  32. }
  33. }
  34. export function nextRoom(game, stageData) {
  35. switch(stageData.currentRoom) {
  36. case ROOM_BREW:
  37. moveToRoom(ROOM_MARKET)
  38. document.getElementById("next").style.display = "none"
  39. document.getElementById("prev-text").innerHTML = "Brew"
  40. break;
  41. case ROOM_SHOP:
  42. moveToRoom(ROOM_BREW)
  43. document.getElementById("prev").style.display = "block"
  44. document.getElementById("next-text").innerHTML = "Market"
  45. break;
  46. }
  47. }