|  |  | @@ -11,7 +11,11 @@ dirs = { | 
		
	
		
			
			|  |  |  | "descend": "Down" | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | function updateRoom(dest) { | 
		
	
		
			
			|  |  |  | function moveToRoom(dest, state) { | 
		
	
		
			
			|  |  |  | updateRoom(dest, state); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | function updateRoom(dest, state) { | 
		
	
		
			
			|  |  |  | const room = world[dest]; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | const areaName = document.querySelector("#area-name"); | 
		
	
	
		
			
				|  |  | @@ -20,18 +24,40 @@ function updateRoom(dest) { | 
		
	
		
			
			|  |  |  | areaName.innerText = room.name; | 
		
	
		
			
			|  |  |  | areaDesc.innerText = room.desc; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | document.querySelectorAll(".move-button").forEach(button => { | 
		
	
		
			
			|  |  |  | const dir = button.id.replace("move-", ""); | 
		
	
		
			
			|  |  |  | const holder = document.querySelector("#move-holder"); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | holder.innerHTML = ""; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | Object.entries(dirs).forEach(([dir, name]) => { | 
		
	
		
			
			|  |  |  | const button = document.createElement("button"); | 
		
	
		
			
			|  |  |  | button.classList.add("move-button") | 
		
	
		
			
			|  |  |  | button.id = "move-" + dir; | 
		
	
		
			
			|  |  |  | button.classList.add("disabled"); | 
		
	
		
			
			|  |  |  | button.setAttribute("disabled", "true"); | 
		
	
		
			
			|  |  |  | button.innerText = dirs[dir]; | 
		
	
		
			
			|  |  |  | holder.appendChild(button); | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | Object.entries(room.exits).forEach(([dir, val]) => { | 
		
	
		
			
			|  |  |  | Object.entries(room.exits).forEach(([dir, exit]) => { | 
		
	
		
			
			|  |  |  | const button = document.querySelector("#move-" + dir); | 
		
	
		
			
			|  |  |  | const dest = world[exit.target]; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // if any condition fails, don't enable/add a listener | 
		
	
		
			
			|  |  |  | if (exit.conditions) { | 
		
	
		
			
			|  |  |  | console.log(exit.conditions); | 
		
	
		
			
			|  |  |  | if (!exit.conditions.every(cond => cond(state))) { | 
		
	
		
			
			|  |  |  | return; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | button.classList.remove("disabled"); | 
		
	
		
			
			|  |  |  | button.removeAttribute("disabled"); | 
		
	
		
			
			|  |  |  | button.innerText = dest.name; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | button.innerText = val.target; | 
		
	
		
			
			|  |  |  | button.addEventListener("click", () => { | 
		
	
		
			
			|  |  |  | // todo: log | 
		
	
		
			
			|  |  |  | moveToRoom(exit.target, state); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
				|  |  | @@ -41,8 +67,25 @@ world = { | 
		
	
		
			
			|  |  |  | "desc": "Where the wifi autoconnects", | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "up": { | 
		
	
		
			
			|  |  |  | "target": "Dennis", | 
		
	
		
			
			|  |  |  | "desc": "The obvious exit, but better." | 
		
	
		
			
			|  |  |  | "target": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "It's locked!", | 
		
	
		
			
			|  |  |  | "move": "You enter the secret locked room", | 
		
	
		
			
			|  |  |  | "conditions": [ | 
		
	
		
			
			|  |  |  | state => { | 
		
	
		
			
			|  |  |  | return state.player.items.keys.includes("Locked Room"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "Locked Room": { | 
		
	
		
			
			|  |  |  | "name": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "Super seecret", | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "down": { | 
		
	
		
			
			|  |  |  | "target": "Home", | 
		
	
		
			
			|  |  |  | "desc": "Back to home", | 
		
	
		
			
			|  |  |  | "move": "You dab" | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
				|  |  | 
 |