From ef514d89232f59fa5d43292135a8c535717a5bba Mon Sep 17 00:00:00 2001 From: StickiStickman Date: Sat, 3 Aug 2019 23:22:30 +0200 Subject: [PATCH 1/3] Added walls for blocking exits Added walls for blocking exits when using coordinates. --- src/Room.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Room.js b/src/Room.js index c7232295..1d307882 100644 --- a/src/Room.js +++ b/src/Room.js @@ -17,6 +17,7 @@ const Logger = require('./Logger'); * @property {string} script Name of custom script attached to this room * @property {string} title Title shown on look/scan * @property {object} doors Doors restricting access to this room. See documentation for format + * @property {object} walls Walls permanently restricting access from this room. * * @extends GameEntity */ @@ -50,6 +51,7 @@ class Room extends GameEntity { // create by-val copies of the doors config so the lock/unlock don't accidentally modify the original definition this.doors = new Map(Object.entries(JSON.parse(JSON.stringify(def.doors || {})))); this.defaultDoors = def.doors; + this.walls = def.walls || []; this.items = new Set(); this.npcs = new Set(); @@ -175,7 +177,8 @@ class Room extends GameEntity { this.coordinates.z + z ); - if (room && !exits.find(ex => ex.direction === adj.dir)) { + //Generate exits based on coordinates and walls + if (room && !exits.find(ex => ex.direction === adj.dir) && !this.hasWall(adj.dir)) { exits.push({ roomId: room.entityReference, direction: adj.dir, inferred: true }); } } @@ -217,6 +220,18 @@ class Room extends GameEntity { return roomExit || false; } + /** + * Check to see if this room has a wall preventing movement in this direction + * @param {String} direciton + * @return {boolean} + */ + hasWall(direciton) { + if(this.walls.find(ex => ex.direction === direciton) ){ + return true; + } + return false; + } + /** * Check to see if this room has a door preventing movement from `fromRoom` to here * @param {Room} fromRoom From 14eb20bc49f54351163a19c93033d9d7fc336519 Mon Sep 17 00:00:00 2001 From: StickiStickman Date: Sun, 4 Aug 2019 00:06:56 +0200 Subject: [PATCH 2/3] Fixed "direction" spelling --- src/Room.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Room.js b/src/Room.js index 1d307882..9c4d2a36 100644 --- a/src/Room.js +++ b/src/Room.js @@ -222,11 +222,11 @@ class Room extends GameEntity { /** * Check to see if this room has a wall preventing movement in this direction - * @param {String} direciton + * @param {String} direction * @return {boolean} */ - hasWall(direciton) { - if(this.walls.find(ex => ex.direction === direciton) ){ + hasWall(direction) { + if(this.walls.find(ex => ex.direction === direction) ){ return true; } return false; From c717f5c30bc316af8b8dc91abf22e5b2631fbff4 Mon Sep 17 00:00:00 2001 From: StickiStickman Date: Sun, 4 Aug 2019 00:36:20 +0200 Subject: [PATCH 3/3] Fixed walls type --- src/Room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Room.js b/src/Room.js index 9c4d2a36..a4d60638 100644 --- a/src/Room.js +++ b/src/Room.js @@ -17,7 +17,7 @@ const Logger = require('./Logger'); * @property {string} script Name of custom script attached to this room * @property {string} title Title shown on look/scan * @property {object} doors Doors restricting access to this room. See documentation for format - * @property {object} walls Walls permanently restricting access from this room. + * @property {Array} walls Walls permanently restricting access from this room { direction: string } * * @extends GameEntity */