From 1bc261531b0b6a085c6930f8ee3bc97b0c153456 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 6 Jan 2019 10:55:11 -0600 Subject: [PATCH] Added hooks for rooms --- world.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/world.js b/world.js index 3b35590..f4b1469 100644 --- a/world.js +++ b/world.js @@ -23,6 +23,18 @@ function initRoomState(state) { } function moveToRoom(dest, state) { + const room = world[dest]; + + console.log(room); + + if (room.hooks) { + for (let hook of room.hooks) { + if (!hook(room, state)) { + return; + } + } + } + updateRoom(dest, state); } @@ -169,7 +181,13 @@ world = { } ] } - } + }, + "hooks": [ + (self, state) => { + print(["This is a test of the hooks"]); + return true; + } + ] }, "Locked Room": { "id": "Locked Room",