1
1

RoomNode.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. class RoomNode {
  2. private room : RoomRandom;
  3. private mainDiv : HTMLElement = document.createElement("div");
  4. public constructor (room : RoomRandom) {
  5. this.room = room;
  6. this.mainDiv.classList.add("mapRoom");
  7. if (room != undefined) {
  8. this.mainDiv.classList.add("linked", room.getBackgroundClass());
  9. Room.DIRECTIONS.forEach((direction) => {
  10. if (room.connections[direction] != undefined) {
  11. let directionDiv = document.createElement("div");
  12. directionDiv.classList.add("mapRoomConnection" + DirectionNames[Direction[direction]]);
  13. this.mainDiv.appendChild(directionDiv);
  14. }
  15. });
  16. Controls.Links.makeLink(this.mainDiv, new ActionGo(WorldState.player, room));
  17. // ASSUME THIS IS NOT UPDATED
  18. //this.update();
  19. }
  20. }
  21. public async createRoomNameFloater () {
  22. if (this.room != undefined) {
  23. let roomName = document.createElement("div");
  24. let sayName = new Say(this.room);
  25. await sayName.getPureElements().then(value => {
  26. value.forEach(element => {
  27. roomName.appendChild(element);
  28. });
  29. Elements.HoverInfo.makeHoverable(this.mainDiv, value);
  30. });
  31. }
  32. }
  33. public async update () {
  34. if (this.room != undefined) {
  35. if (WorldState.player.getRoom() == this.room) {
  36. this.mainDiv.classList.add("current");
  37. } else {
  38. this.mainDiv.classList.remove("current");
  39. }
  40. let isRemembered = await WorldState.isRoomRemembered(this.room);
  41. if (!isRemembered) {
  42. this.mainDiv.classList.add("unknown");
  43. } else {
  44. this.mainDiv.classList.remove("unknown");
  45. }
  46. }
  47. }
  48. public getElement () {
  49. return this.mainDiv;
  50. }
  51. }