From 75e7f79c0bde2c1bd1a863a634b9e6a6cf00382a Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 21 Feb 2021 16:49:19 +0000 Subject: [PATCH 1/3] Add spacing between task and hints --- mandatory/9-choose-your-own-adventure.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mandatory/9-choose-your-own-adventure.js b/mandatory/9-choose-your-own-adventure.js index 4a7fa069..1fd4da30 100644 --- a/mandatory/9-choose-your-own-adventure.js +++ b/mandatory/9-choose-your-own-adventure.js @@ -44,6 +44,7 @@ let game = { // to start in. // Finish the function so that the currentRoom property is set to the room // object for the correct room. + // // Hint: the only valid rooms are "hall", "classroom" and "library". }, @@ -51,6 +52,7 @@ let game = { // This function is called with the direction that the player wants to move. // Finish the function so that the currentRoom property is updated with new // room in the direction that the player wants to move in. + // // Hint: the room objects have north/east/south/west methods which return // a new room object that is in the relevant direction. }, From 85b427d22dd291c6a1209bec9120b40a3b4da616 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 21 Feb 2021 16:49:30 +0000 Subject: [PATCH 2/3] Lower-case the room names The comments and prompts all use lower-case, and I feel like there's enough for the trainees to be thinking about without having to think about case-normalisation... --- mandatory/9-choose-your-own-adventure.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mandatory/9-choose-your-own-adventure.js b/mandatory/9-choose-your-own-adventure.js index 1fd4da30..fbee7104 100644 --- a/mandatory/9-choose-your-own-adventure.js +++ b/mandatory/9-choose-your-own-adventure.js @@ -64,7 +64,7 @@ DO NOT EDIT BELOW THIS LINE let rooms = { hall: { - name: "Hall", + name: "hall", north: null, east: function () { return rooms.classroom; @@ -75,7 +75,7 @@ let rooms = { west: null, }, classroom: { - name: "Classroom", + name: "classroom", north: null, east: null, south: null, @@ -84,7 +84,7 @@ let rooms = { }, }, library: { - name: "Library", + name: "library", north: function () { return rooms.hall; }, From 19b1dbdd5f1915067bb16d781a23ce890b0c98db Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 21 Feb 2021 16:50:28 +0000 Subject: [PATCH 3/3] Make !game.currentRoom error message more accurate When I didn't guard setting `this.currentRoom` in `move`, the error message told me to make sure my `start` method was correct. While "Sometimes the error message is misleading" is a good thing for our trainees to learn, I'm not sure this is the place, as there's already a lot of new things to grasp in this exercise. --- mandatory/9-choose-your-own-adventure.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mandatory/9-choose-your-own-adventure.js b/mandatory/9-choose-your-own-adventure.js index fbee7104..ae75a01a 100644 --- a/mandatory/9-choose-your-own-adventure.js +++ b/mandatory/9-choose-your-own-adventure.js @@ -112,15 +112,15 @@ function start() { function (room) { game.start(room); console.log("\n---------------------\n"); - play(); + play("start"); } ); } -function play() { +function play(method) { if (!game.currentRoom) { throw new Error( - `It looks like the game hasn't been correctly started yet! Make sure your start method is correct` + `It looks like the game isn't quite right! Make sure your \`${method}\` method is correct` ); } console.log(`You are in the ${game.currentRoom.name}.\n`); @@ -129,7 +129,7 @@ function play() { function (direction) { game.move(direction); console.log("\n---------------------\n"); - play(); + play("move"); } ); }