markdown = require('../../lib/markdown.coffee') room = require("../../lib/room.coffee") obj = require('../../lib/obj.coffee') dialogue = require('../../lib/dialogue.coffee') oneOf = require('../../lib/oneOf.coffee') require('../../lib/interface.coffee') undum = require('../../lib/undum.js') undum.game.id = "your-game-id-here" undum.game.version = "1.0" ### Element helpers. There is no real need to build monsters like a().id("hello") because you won't use them as is. It does not make sense in context, the author has Markdown and all utilities to *forget* about the markup. ### way_to = (content, ref) -> return "#{content}" textlink = (content, ref) -> return "#{content}" actlink = (content, ref) -> return "#{content}" textcycle = (content, ref) -> return "#{content}" cyclelink = (content) -> return "#{content}" # Cycling link. It's implied there can be only one per situation. # You are welcome to improve this code. cycle = (obj, character) -> responses = obj.cycle_gallery() character.sandbox.cycle_index ?= [] # initialize with empty array character.sandbox.cycle_index[obj.name] ?= 0 # initialize with 0 response = responses[character.sandbox.cycle_index[obj.name]] character.sandbox.cycle_index[obj.name]++ if character.sandbox.cycle_index[obj.name] == responses.length character.sandbox.cycle_index[obj.name] = 0 return textcycle(response, 'cyclewriter') # usage: writemd( system, "Text to write") writemd = (system, text) -> text = markdown(text) system.write(text) get_room = (name) -> return undum.game.situations[name] # Function to return the current room. # Works because our `enter()` function sets the `data-situation` attribute. here = () -> return undum.game.situations[document.getElementById("current-situation").getAttribute("data-situation")] # The first room of the game. # For accessibility reasons the text is provided in HTML, not here. room "start", content: """ """, choices: "#start" # This function needs to go after the start room. is_visited = (situation) -> place = undum.game.situations[situation] if place return Boolean place.visited return 0