From e3e17eb29546fc0478c949cef672b3e6c5996f13 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Sun, 27 Mar 2016 22:49:38 +0700 Subject: [PATCH] Resolved #2: forbid leaving a room You can use `@exit()` to set `canExit` and print the "YOU SHALL NOT LEAVE" message. --- lib/room.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/room.coffee b/lib/room.coffee index a76d54b..beeee5c 100644 --- a/lib/room.coffee +++ b/lib/room.coffee @@ -24,6 +24,7 @@ class SaletRoom @priority = 1 @displayOrder = 1 @canSave = true + @canExit = true @tags = [] @choices = "" @optionText = "Choice" @@ -63,6 +64,14 @@ class SaletRoom Also if f == this.name (we're in the same location) the `before` and `after` callbacks are ignored. ### @entering = (system, f) => + if ( + f != @name and + f? and + system.rooms[f].canExit? and + system.rooms[f].canExit == false + ) + return system.goTo(f, f) + if @clear and f? system.view.clearContent() else