2016-01-15 03:06:03 +02:00
|
|
|
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')
|
2016-01-15 03:31:04 +02:00
|
|
|
undum = require('../../lib/undum.js')
|
2016-01-07 13:27:57 +02:00
|
|
|
|
2016-01-15 03:06:03 +02:00
|
|
|
undum.game.id = "your-game-id-here"
|
2016-01-07 13:27:57 +02:00
|
|
|
undum.game.version = "1.0"
|
|
|
|
|
2016-01-15 03:06:03 +02:00
|
|
|
###
|
|
|
|
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 "<a href='#{ref}' class='way'>#{content}</a>"
|
|
|
|
textlink = (content, ref) ->
|
|
|
|
return "<a href='./_writer_#{ref}' class='once'>#{content}</a>"
|
|
|
|
actlink = (content, ref) ->
|
|
|
|
return "<a href='./#{ref}' class='once'>#{content}</a>"
|
|
|
|
textcycle = (content, ref) ->
|
|
|
|
return "<a href='./_replacer_#{ref}' class='cycle' id='#{ref}'>#{content}</a>"
|
2016-01-16 08:26:25 +02:00
|
|
|
cyclelink = (content) ->
|
|
|
|
return "<a href='./_replacer_cyclewriter' class='cycle' id='cyclewriter'>#{content}</a>"
|
2016-01-15 03:06:03 +02:00
|
|
|
|
2016-01-15 17:29:15 +02:00
|
|
|
# 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')
|
2016-01-15 10:10:12 +02:00
|
|
|
|
2016-01-07 13:27:57 +02:00
|
|
|
# usage: writemd( system, "Text to write")
|
|
|
|
writemd = (system, text) ->
|
2016-01-15 03:06:03 +02:00
|
|
|
text = markdown(text)
|
2016-01-07 13:27:57 +02:00
|
|
|
system.write(text)
|
|
|
|
|
2016-01-16 18:24:23 +02:00
|
|
|
get_room = (name) ->
|
|
|
|
return undum.game.situations[name]
|
|
|
|
|
2016-01-16 18:43:20 +02:00
|
|
|
# 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")]
|
|
|
|
|
2016-01-15 03:06:03 +02:00
|
|
|
# The first room of the game.
|
|
|
|
# For accessibility reasons the text is provided in HTML, not here.
|
|
|
|
room "start",
|
2016-01-07 13:27:57 +02:00
|
|
|
content: """
|
2016-01-15 03:06:03 +02:00
|
|
|
""",
|
|
|
|
choices: "#start"
|
2016-01-07 13:27:57 +02:00
|
|
|
|
2016-01-15 03:06:03 +02:00
|
|
|
# This function needs to go after the start room.
|
2016-01-07 13:27:57 +02:00
|
|
|
is_visited = (situation) ->
|
2016-01-15 03:06:03 +02:00
|
|
|
place = undum.game.situations[situation]
|
|
|
|
if place
|
|
|
|
return Boolean place.visited
|
2016-01-07 13:27:57 +02:00
|
|
|
return 0
|