diff --git a/game/begin.coffee b/game/begin.coffee index fb63958..76d23a3 100644 --- a/game/begin.coffee +++ b/game/begin.coffee @@ -11,7 +11,6 @@ salet = Salet({ }) $(document).ready(() -> salet.beginGame() - salet.character.bought_lamp = false ) ### @@ -31,6 +30,8 @@ textcycle = (content, ref) -> # The first room of the game. # For accessibility reasons the text is provided in HTML, not here. room "start", salet, + enter: (salet) -> + salet.character.bought_lamp = false dsc: """ """, choices: "#start" diff --git a/lib/salet.coffee b/lib/salet.coffee index 45af881..3db518b 100644 --- a/lib/salet.coffee +++ b/lib/salet.coffee @@ -304,10 +304,12 @@ class Salet # Go back N rooms. It's not an UNDO. # Also, steps = 1 is the current room @goBack = (steps = 2) => - if @progress.path.length > steps + if @progress.path.length == 1 + location = @start + else if @progress.path.length > steps location = @progress.path[@progress.path.length - steps] else - location = @start + return @goBack(steps - 1) @processClick(location) # Transition between rooms. diff --git a/lib/view.coffee b/lib/view.coffee index 11d88c0..f5a6905 100644 --- a/lib/view.coffee +++ b/lib/view.coffee @@ -26,7 +26,7 @@ addClass = (element, className) -> class SaletView init: (salet) => - $("#content, #ways, #buttons").on("click", "a", (event) -> + $("#page").on("click", "a", (event) -> event.preventDefault() a = $(this) href = a.attr('href') @@ -86,7 +86,9 @@ class SaletView ### clearContent: (elementSelector = "#content") -> if (elementSelector == "#content") # empty the intro with the content - document.getElementById("intro").innerHTML = "" + intro = document.getElementById("intro") + if intro? + intro.innerHTML = "" document.querySelector(elementSelector).innerHTML = "" prepareContent: (content) ->