From 47bc425a949197490fd8a00058d5ce947bc405f6 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 25 May 2020 18:14:26 -0400 Subject: [PATCH] Fix actions not being available again once their conditions are met --- stories/demo.js | 7 ++++++- world.js | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stories/demo.js b/stories/demo.js index dae799e..478e69a 100644 --- a/stories/demo.js +++ b/stories/demo.js @@ -63,7 +63,12 @@ stories.push({ "execute": (room) => { state.player.rooms[room.id].squinted = true; print(["You stare at the wall and notice a secret door. But where is the key?"]); - } + }, + "conditions": [ + (room) => { + return !state.player.rooms[room.id].squinted; + } + ] }, { "name": "Find Keys", diff --git a/world.js b/world.js index aa24d72..fcd6a3e 100644 --- a/world.js +++ b/world.js @@ -259,7 +259,10 @@ function updateRoom() { if (action.conditions) { if (!action.conditions.every(cond => cond(room))) { button.classList.add("disabled"); - button.setAttribute("disabled", "true"); + button.setAttribute("disabled", true); + } else { + button.classList.remove("disabled"); + button.removeAttribute("disabled"); } }