In this video, you followed one room, The Harbourmaster’s Office, through the reference version of the escape room builder from the course downloads, from its room file to its verdict and report lines. You followed it part by part, without reading the code line by line.
Here’s what node check-room.js rooms/the-harbourmasters-office.json printed in the reference version’s folder, the run you traced:
The Harbourmaster's Office: can be finished.
Dead end: the sea chest uses up the brass key, and the lamp-room door still needs it.
Longest chain: the tide board, the lamp-room door, the signal mast (3 puzzles, 25 minutes)
In parallel: the harbourmaster's desk and the tide board
In parallel: the signal mast and the sea chest
Key points:
- The file goes in: The room starts as
rooms/the-harbourmasters-office.json, five puzzles that each list what they need and what they unlock. The sea chest also uses up the brass key. - The command reads it:
check-room.jsreads the file and parses the JSON into a room object. That’s the only check at this step. Nothing checks the room’s shape. If a designer misspells an item in a list, the checker takes it as written, and the verdict can be wrong. - Nothing is written: The command only reads. Nothing in this trip writes a file, and the room file never changes.
- The checker decides the verdict: The command hands the room object to
checkRoom()insrc/check-room.js, which asks one question: does any solving order finish the room? To answer, it tries every order a team could take. Solving a puzzle adds what it unlocks and removes what it uses up. - The order that finishes: The lamp-room door and the sea chest both need the brass key, and the sea chest uses it up, so a team has to solve the lamp-room door first. That order solves every puzzle. One order is enough, because a team chooses its own order. That’s a decision in the project map. The checker hands back “can be finished”, and the command prints it as the first line.
- The report lines: The command asks
missingNeeds()for every room. It names any puzzle whose needs nothing reachable unlocks. It doesn’t count used-up keys. Here nothing is missing, so it adds no lines. - The dead end:
findDeadEnds()asks a different question: can a used-up key strand a puzzle in some order? Solve the sea chest before the lamp-room door, and the lamp-room door is stuck without the brass key. That’s the dead-end line. As the map’s decisions say, it’s printed even for a room that can be finished, because a team can still walk into a dead end. Last, because the room can be finished,chainReport()adds the longest chain and the puzzles that run in parallel.