")
pruneVerbs = () ->
for verb in document.querySelectorAll(".verb")
text = $(verb).data("verb")
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 = () ->
if salet.interactive and _paq?
# Piwik analytics: room stats
_paq.push(['trackPageView', name])
$(".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 = () ->
if salet.interactive and _paq?
# Piwik analytics: room stats
_paq.push(['trackPageView', name])
salet.character.update_sidebar()
if @onEnter?
@onEnter()
return room(name, spec)
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 "settings",
text: () ->
nightclass = ""
if window.night
nightclass = "active"
return "credits".l() + """\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 ""