salet.game_id = "8b0c371c-57f4-49b3-ae3c-cba07d1a9733" salet.game_version = "1.0" salet.beforeAction = (room, actionId) -> verbRe = /^verb\_(\w+)\_(\w+)$/ match = verbRe.exec(actionId) if match? and match[1] and match[2] verb = match[1] unit = match[2] if room.has(unit) salet.view.write(room.unitdo(unit, verb)) if salet.character.has(unit) for i in salet.character.inventory if i.name == unit salet.view.write(i[verb].fcall(salet.rooms[room.name])) return true # consume the action return false salet.afterAction = () -> salet.character.update_sidebar() $.holdReady( true ) $.getJSON('game/translations/'+i18n.lang+'.json', (data) -> i18n.push(i18n.lang, data) $.holdReady( false ) ) switchTab = (tabid) -> $(".tab").removeClass("active") $("#"+tabid).addClass("active") $(document).ready(() -> window.addEventListener('popstate', (event) -> salet.goBack() ) $("body").on("click", '#night', () -> if (window.night) $("body").removeClass("night") $("#night").removeClass("active") window.night = false else $("body").addClass("night") $("#night").addClass("active") window.night = true ) $("body").on("click", "#storytab", (event) -> event.preventDefault() if not salet.here().canSave salet.goBack() return false ) $("body").on("click", ".tab", (event) -> if (event.target.id == "storytab") return true switchTab(event.target.id) return true ) salet.beginGame() ) updateverb = (unit, verb) -> if unit[verb]? or salet.character.displayAll if verb == "take" and unit.takeable == false return "" if verb == "drop" and not salet.character.has(unit.name) return "" if verb == "wear" and salet.character.has(unit.name) return "" $("##{verb}list").append("
  • #{unit.display()}
  • ") pruneVerbs = () -> for verb in document.querySelectorAll(".verb") text = verb.innerHTML.toLowerCase() if $("##{text}list").html() == "" verb.style.cssText = "visibility: hidden" else verb.style.cssText = "visibility: visible" ### 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}" sysroom = (name, options) -> options.canSave = false options.enter = () -> $(".action").hide() options.exit = () -> if document.querySelector('#current-room') salet.view.clearContent('#current-room') $(".action").show() options.dsc = () -> return @text.fcall() ### +"\n\n" +"""
    """ options.actions = { exit: () -> return salet.goBack() } ### return room(name, options) croom = (name, spec) -> spec.clear ?= true spec.optionColor ?= "" spec.has = (thing) -> for item in this.units if item.name == thing return true return false spec.unitdo = (thing, verb) -> for item in this.units if item.name == thing and item[verb] != undefined return item[verb].fcall(this) spec.optionText ?= () -> retval = """
    #{spec.title.fcall()}
    """ if (spec.subtitle?) retval += """
    #{spec.subtitle.fcall()}
    """ retval += '
    ' spec.enter = () -> salet.character.update_sidebar() if @onEnter? @onEnter() return room(name, spec) sysroom "inventory", text: () -> if salet.character.inventory.length == 0 text = "You are carrying nothing." else text = "You are carrying:\n\n" for thing in salet.character.inventory text += "* #{salet.character.listinv(thing.name)}\n" sysroom "settings", text: () -> nightclass = "" if window.night nightclass = "active" return "credits".l() + """ """ sysroom "map", text: () -> return "
    " after: () -> data = { edges: [] nodes: [] } edges = [] for name, room of salet.rooms if room.canSave == false or name == "start" continue data.nodes.push({ "id": name "label": room.title() "size": 5 "color": "#000" "x": Math.random()*10 "y": Math.random()*10 }) if room.ways? and room.ways.length > 0 for way in room.ways id = "edge_"+name+"_"+way # we don't want to display a two-way link twice if edges.indexOf("edge_"+way+"_"+name) == -1 edges.push(id) data.edges.push({ "id": id "source": room.name "target": way "size": 1 "color": "#ccc" }) console.log data s = new sigma({ graph: data, container: 'map' }) console.log(s) return ""