### # This is the file with all logic code *inside* Salet. # This is not story code but something around the story and inside the game. ### ### 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}" choice = (text, url) -> retval = ' options.canSave = false options.exit = () -> if document.querySelector('#current-room') salet.view.clearContent('#current-room') $(".action").show() options.dsc ?= () -> return @text.fcall()+"\n\n"+"""
""" options.text ?= () -> name.l() options.actions = { exit: () -> return salet.goBack() } return croom(name, options) croom = (name, spec) -> spec.clear ?= true spec.optionColor ?= "" spec.optionText ?= () -> retval = """
#{spec.title.fcall()}
""" if (spec.subtitle?) retval += """
#{spec.subtitle.fcall()}
""" retval += '
' spec.dsc ?= () -> name.l() return room(name, spec) $(document).on("room_enter", (event, data) -> # Piwik analytics: room stats if salet.interactive and _paq? _paq.push(['trackPageView', data.to]) ) sysroom "inventory", text: () -> if salet.character.inventory.length == 0 text = "inventory_empty".l() else text = "inventory_contains".l()+"\n\n" for thing in salet.character.inventory text += "* #{salet.character.listinv(thing.name)}\n" sysroom "map", text: () -> return "
" after: () -> data = { edges: [] nodes: [] } edges = [] rooms = [] globx = 1 globy = 1 deltas = [ # [1, 0], # looks bad on our map [0, 1], [-1, 0], [0, -1], ] for name, room of salet.rooms if room.canSave == false or name == "start" continue if rooms.indexOf(name) == -1 data.nodes.push({ "id": name "label": room.title() "size": 5 "color": "#000" "x": globx "y": globy }) rooms.push(name) if room.ways? and room.ways.length > 0 delta = 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" }) if rooms.indexOf(way) == -1 data.nodes.push({ "id": way "label": salet.rooms[way].title() "size": 5 "color": "#000" "x": globx + deltas[delta][0] "y": globy + deltas[delta][1] }) rooms.push(way) delta++ globy = globy - 2 s = new sigma({ graph: data, container: 'map' }) s.bind('clickNode', (e) -> switchTab("storytab") salet.goTo(e.data.node.id) ) return "" $(document).on("room_language_after_choices", () -> $(".options").addClass("narrowchoice") ) sysroom "language", dsc: "" choices: "#language" sysroom "ru", title: "Русский", tags: ["language"] dsc: "" enter: () -> i18n.lang = "ru" salet.goTo('maze') sysroom "en", title: "English", tags: ["language"] canChoose: false dsc: "" enter: () -> i18n.lang = "en" salet.goTo('maze') sysroom "menu", dsc: "" choices: "#menu" sysroom "settings", tags: ["menu"] title: () -> "settings_title".l() text: () -> nightclass = "" if window.night nightclass = "active" return "credits".l() + """\n """ sysroom "inventory", text: () -> if salet.character.inventory.length == 0 text = "inventory_empty".l() else text = "inventory_contains".l()+"\n\n" for thing in salet.character.inventory text += "* #{salet.character.listinv(thing.name)}\n" sysroom "map", text: () -> """ Здесь будет карта """