|  |  | @@ -12,12 +12,11 @@ dirs = { | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | function initWorld(worldChoice, state) { | 
		
	
		
			
			|  |  |  | state.world = worlds[worldChoice]; | 
		
	
		
			
			|  |  |  | state.world = games[worldChoice]["world"]; | 
		
	
		
			
			|  |  |  | initRoomState(state); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | function initRoomState(state) { | 
		
	
		
			
			|  |  |  | console.log(state.world); | 
		
	
		
			
			|  |  |  | state.player.rooms = {}; | 
		
	
		
			
			|  |  |  | Object.entries(state.world).forEach(([key, val]) => { | 
		
	
		
			
			|  |  |  | state.player.rooms[key] = {}; | 
		
	
	
		
			
				|  |  | @@ -37,7 +36,6 @@ function removeActionDescription() { | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | function moveToRoom(src, exit, dest, state) { | 
		
	
		
			
			|  |  |  | console.log(state) | 
		
	
		
			
			|  |  |  | const room = state.world[dest]; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if (exit.hooks) { | 
		
	
	
		
			
				|  |  | @@ -181,85 +179,97 @@ function updateRoom(dest, state) { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | worlds = { | 
		
	
		
			
			|  |  |  | games = { | 
		
	
		
			
			|  |  |  | "demo": { | 
		
	
		
			
			|  |  |  | "Home": { | 
		
	
		
			
			|  |  |  | "id": "Home", | 
		
	
		
			
			|  |  |  | "name": "Home", | 
		
	
		
			
			|  |  |  | "desc": "Where the wifi autoconnects", | 
		
	
		
			
			|  |  |  | "move": (room, state) => { | 
		
	
		
			
			|  |  |  | print(["You go back to your living room"]); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "actions": [ | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | "name": "Squint", | 
		
	
		
			
			|  |  |  | "desc": "Squint in a very aggressive manner", | 
		
	
		
			
			|  |  |  | "execute": (room, state) => { | 
		
	
		
			
			|  |  |  | state.player.rooms[room.id].squinted = true; | 
		
	
		
			
			|  |  |  | print(["You stare at the wall and notice a secret door. But where is the key?"]); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | "id": "demo", | 
		
	
		
			
			|  |  |  | "sounds": [ | 
		
	
		
			
			|  |  |  | "sfx/oof.ogg" | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "world": { | 
		
	
		
			
			|  |  |  | "Home": { | 
		
	
		
			
			|  |  |  | "id": "Home", | 
		
	
		
			
			|  |  |  | "name": "Home", | 
		
	
		
			
			|  |  |  | "desc": "Where the wifi autoconnects", | 
		
	
		
			
			|  |  |  | "move": (room, state) => { | 
		
	
		
			
			|  |  |  | print(["You go back to your living room"]); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | "name": "Find Keys", | 
		
	
		
			
			|  |  |  | "desc": "Find your keys", | 
		
	
		
			
			|  |  |  | "execute": (room, state) => { | 
		
	
		
			
			|  |  |  | state.player.items.keys.push("Locked Room"); | 
		
	
		
			
			|  |  |  | print(["You found your keys under the couch cushions"]); | 
		
	
		
			
			|  |  |  | "actions": [ | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | "name": "Squint", | 
		
	
		
			
			|  |  |  | "desc": "Squint in a very aggressive manner", | 
		
	
		
			
			|  |  |  | "execute": (room, state) => { | 
		
	
		
			
			|  |  |  | state.player.rooms[room.id].squinted = true; | 
		
	
		
			
			|  |  |  | print(["You stare at the wall and notice a secret door. But where is the key?"]); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "show": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return state.player.rooms[room.id].squinted; | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | "name": "Find Keys", | 
		
	
		
			
			|  |  |  | "desc": "Find your keys", | 
		
	
		
			
			|  |  |  | "execute": (room, state) => { | 
		
	
		
			
			|  |  |  | state.player.items.keys.push("Locked Room"); | 
		
	
		
			
			|  |  |  | print(["You found your keys under the couch cushions"]); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return !state.player.items.keys.includes("Locked Room"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "up": { | 
		
	
		
			
			|  |  |  | "target": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "It's locked!", | 
		
	
		
			
			|  |  |  | "conditions": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return state.player.items.keys.includes("Locked Room"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "show": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | console.log(room); | 
		
	
		
			
			|  |  |  | return state.player.rooms[room.id].squinted; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "hooks": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | print(["This is a test of the hooks"]); | 
		
	
		
			
			|  |  |  | return true; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "Locked Room": { | 
		
	
		
			
			|  |  |  | "id": "Locked Room", | 
		
	
		
			
			|  |  |  | "name": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "Super seecret", | 
		
	
		
			
			|  |  |  | "move": (room, state) => { | 
		
	
		
			
			|  |  |  | print(["You enter the locked room. wowie!"]); | 
		
	
		
			
			|  |  |  | "show": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return state.player.rooms[room.id].squinted; | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return !state.player.items.keys.includes("Locked Room"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "up": { | 
		
	
		
			
			|  |  |  | "target": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "It's locked!", | 
		
	
		
			
			|  |  |  | "conditions": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return state.player.items.keys.includes("Locked Room"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "show": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | return state.player.rooms[room.id].squinted; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "hooks": [ | 
		
	
		
			
			|  |  |  | (room, state) => { | 
		
	
		
			
			|  |  |  | print(["This is a test of the hooks"]); | 
		
	
		
			
			|  |  |  | return true; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "down": { | 
		
	
		
			
			|  |  |  | "target": "Home", | 
		
	
		
			
			|  |  |  | "desc": "Back to home", | 
		
	
		
			
			|  |  |  | "hooks": [ | 
		
	
		
			
			|  |  |  | (room, exit, state) => { | 
		
	
		
			
			|  |  |  | print(["Potato"]); | 
		
	
		
			
			|  |  |  | console.log(room); | 
		
	
		
			
			|  |  |  | console.log(exit); | 
		
	
		
			
			|  |  |  | console.log(state); | 
		
	
		
			
			|  |  |  | return true; | 
		
	
		
			
			|  |  |  | "Locked Room": { | 
		
	
		
			
			|  |  |  | "id": "Locked Room", | 
		
	
		
			
			|  |  |  | "name": "Locked Room", | 
		
	
		
			
			|  |  |  | "desc": "Super seecret", | 
		
	
		
			
			|  |  |  | "move": (room, state) => { | 
		
	
		
			
			|  |  |  | print(["You enter the locked room. wowie!"]); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | "actions": [ | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | name: "Oof", | 
		
	
		
			
			|  |  |  | desc: "Oof", | 
		
	
		
			
			|  |  |  | execute: (room, state) => { | 
		
	
		
			
			|  |  |  | print(["Oof"]); | 
		
	
		
			
			|  |  |  | playSfx("sfx/oof.ogg"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ], | 
		
	
		
			
			|  |  |  | "exits": { | 
		
	
		
			
			|  |  |  | "down": { | 
		
	
		
			
			|  |  |  | "target": "Home", | 
		
	
		
			
			|  |  |  | "desc": "Back to home", | 
		
	
		
			
			|  |  |  | "hooks": [ | 
		
	
		
			
			|  |  |  | (room, exit, state) => { | 
		
	
		
			
			|  |  |  | print(["Potato"]); | 
		
	
		
			
			|  |  |  | return true; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ] | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
	
		
			
				|  |  | 
 |