123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- class RoomNode {
- private room : RoomRandom;
- private mainDiv : HTMLElement = document.createElement("div");
- public constructor (room : RoomRandom) {
- this.room = room;
- this.mainDiv.classList.add("mapRoom");
- if (room != undefined) {
- this.mainDiv.classList.add("linked", room.getBackgroundClass());
- Room.DIRECTIONS.forEach((direction) => {
- if (room.connections[direction] != undefined) {
- let directionDiv = document.createElement("div");
- directionDiv.classList.add("mapRoomConnection" + DirectionNames[Direction[direction]]);
- this.mainDiv.appendChild(directionDiv);
- }
- });
- Controls.Links.makeLink(this.mainDiv, new ActionGo(WorldState.player, room));
- // ASSUME THIS IS NOT UPDATED
- //this.update();
- }
- }
- public async createRoomNameFloater () {
- if (this.room != undefined) {
- let roomName = document.createElement("div");
- let sayName = new Say(this.room);
- await sayName.getPureElements().then(value => {
- value.forEach(element => {
- roomName.appendChild(element);
- });
- Elements.HoverInfo.makeHoverable(this.mainDiv, value);
- });
- }
- }
- public async update () {
- if (this.room != undefined) {
- if (WorldState.player.getRoom() == this.room) {
- this.mainDiv.classList.add("current");
- } else {
- this.mainDiv.classList.remove("current");
- }
- let isRemembered = await WorldState.isRoomRemembered(this.room);
- if (!isRemembered) {
- this.mainDiv.classList.add("unknown");
- } else {
- this.mainDiv.classList.remove("unknown");
- }
- }
- }
- public getElement () {
- return this.mainDiv;
- }
- }
|