From e1b4f82156f395a3a5b27c6fd5bd8b4f7ff8ad03 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Thu, 10 Mar 2016 22:30:28 +0700 Subject: [PATCH] wrapLevel sort of fixed --- lib/room.coffee | 6 ++---- lib/salet.coffee | 2 +- lib/view.coffee | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/room.coffee b/lib/room.coffee index 6a90671..1fc85d3 100644 --- a/lib/room.coffee +++ b/lib/room.coffee @@ -169,11 +169,9 @@ class SaletRoom @entering.fcall(this, system, @name) return system.view.write(thing.take.fcall(thing, system).toString()) if thing.act - text = system.view.wrapLevel( - thing.act.fcall(thing, system).toString(), - thing.level + return system.view.changeLevel(thing.level, () -> + return thing.act.fcall(thing, system).toString() ) - return system.view.changeLevel(thing.level, text) # the loop is done but no return came - match not found console.error("Could not find #{link[2]} in current room.") diff --git a/lib/salet.coffee b/lib/salet.coffee index ea1c210..61de915 100644 --- a/lib/salet.coffee +++ b/lib/salet.coffee @@ -153,7 +153,7 @@ class Salet room = @rooms[roomId] assert(room, "unknown_situation".l({id:roomId})) - if (room.canView.fcall(this, currentRoom)) + if (room.canView.fcall(this, this, currentRoom)) viewableRoomData.push({ priority: room.priority id: roomId diff --git a/lib/view.coffee b/lib/view.coffee index 88c0be8..d29c7a7 100644 --- a/lib/view.coffee +++ b/lib/view.coffee @@ -205,7 +205,7 @@ class SaletView # Remove every section marked as a different level. # For a link level 0, we hide every link of level 1 and above. # It's for the player to focus. - changeLevel: (level, text) => + changeLevel: (level, callback) => maxLevel = 6 if level < maxLevel i = level + 1 @@ -215,7 +215,7 @@ class SaletView i++ directive = hideArray.join(", ") $(directive).hide() - @write text + @write system.view.wrapLevel(callback(), level) wrapLevel: (text, level) => return "
"+markdown(text)+'
'