From 8b9441bfe6ae247c9974cc10760da034ef5702c3 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 24 Mar 2021 22:40:07 +0000 Subject: [PATCH 1/2] Fix room directions not being functions --- mandatory/9-choose-your-own-adventure.js | 32 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/mandatory/9-choose-your-own-adventure.js b/mandatory/9-choose-your-own-adventure.js index 8b8470c7..00b3b5f2 100644 --- a/mandatory/9-choose-your-own-adventure.js +++ b/mandatory/9-choose-your-own-adventure.js @@ -65,20 +65,30 @@ DO NOT EDIT BELOW THIS LINE let rooms = { hall: { name: "hall", - north: null, + north: function() { + return null + }, east: function () { return rooms.classroom; }, south: function () { return rooms.library; }, - west: null, + west: function() { + return null + }, }, classroom: { name: "classroom", - north: null, - east: null, - south: null, + north: function() { + return null + }, + east: function() { + return null + }, + south: function() { + return null + }, west: function () { return rooms.hall; }, @@ -88,9 +98,15 @@ let rooms = { north: function () { return rooms.hall; }, - east: null, - south: null, - west: null, + east: function() { + return null + }, + south: function() { + return null + }, + west: function() { + return null + }, }, }; From 328ca7a1804aa637237c5334ffbe813bb79f2af3 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 24 Mar 2021 22:51:19 +0000 Subject: [PATCH 2/2] Improve error checking --- mandatory/9-choose-your-own-adventure.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mandatory/9-choose-your-own-adventure.js b/mandatory/9-choose-your-own-adventure.js index 00b3b5f2..f9a01ba6 100644 --- a/mandatory/9-choose-your-own-adventure.js +++ b/mandatory/9-choose-your-own-adventure.js @@ -134,7 +134,7 @@ function start() { } function play(method) { - if (!game.currentRoom) { + if (!game.currentRoom && !game.currentRoom.name) { throw new Error( `It looks like the game isn't quite right! Make sure your \`${method}\` method is correct` );