# copyright (c) Alexander Yakovlev 2015.
# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0
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 = "6a9909a4-586a-4089-bd18-26da684d1c8d"
undum.game.version = "2.0"
way_to = (content, ref) ->
return "#{content}"
textlink = (content, ref) ->
return "#{content}"
actlink = (content, ref) ->
return "#{content}"
textcycle = (content, ref) ->
return "#{content}"# usage: writemd( system, "Text to write")
writemd = (system, text) ->
text = markdown(text)
system.write(text)
money = (character, amount) ->
character.sandbox.money = character.sandbox.money + amount
code_can_input = (character) ->
return character.sandbox.code.length < 8
code_print = (character) ->
mask = 8 - character.sandbox.code.length
retval = character.sandbox.code
if mask > 0
for i in [1..mask]
retval += "_"
return retval
code_input = (character, digit) ->
if code_can_input(character)
character.sandbox.code = character.sandbox.code + digit
code_reset = (character) ->
character.sandbox.code = ""
code_check = (character, system) ->
if character.sandbox.code.length >= 8
# There is an Undum.. let's call it a feature
# that prevents the player from entering "3112".
# You see, you can't select the situation 1 when you are
# already in this situation, so you can't input 1 twice.
if character.sandbox.code == "01012017"
character.sandbox.box_opened = 1
if character.sandbox.knows_the_code == 0
writemd(system, """
Is he an extraordinary puzzle cracker or was it a sheer luck, but Ronald manages to *guess* the code.
""")
else
writemd(system, """
New Year 2017.
L. Y. must be Leonard Yakovlev, a famous painter.
Some tabloids tried to connect him with Ana but it seemed like a weak link.
By that logic, his sketch is worth more than all the cash here.
Ronald thinks about it, but decides to "let the woman have her memories".
""")
writemd(system, """
Something clicks and box opens.
The phone is slick, black and light in Ronald's hand.
It springs to life, humming with purpose.
The screen plays an animation: "LOADING..."
Ronald has no other business here.
It's time to go.
""")
system.doLink("bedroom")
else
writemd(system, "Something clicks and the display resets, but the box stays locked.")
if character.sandbox.code == "000000"
writemd(system, "Of course, Ronald didn't hope it would be that easy.")
character.sandbox.code = ""
room "start",
dsc: """
Peter opened his door to find an empty silent corridor.
He went to the neighbor's door and met a closed door.
Ronald was working inside, quietly walking around the apartment.
He began the inspection from #{way_to('the living room.', 'living-room')}
"""
is_visited = (situation) ->
situations = undum.game.situations[situation]
if situations
return Boolean situations.visited
return 0
# N-th level examine function
level = (text, mark) ->
$("#content .#{mark}").fadeOut()
return markdown(text, mark)
lvl1 = (text) ->
$("#content .lvl2").fadeOut()
$("#content .lvl3").fadeOut()
$("#content .lvl4").fadeOut()
level(text, "lvl1")
lvl2 = (text) ->
$("#content .lvl3").fadeOut()
$("#content .lvl4").fadeOut()
level(text, "lvl2")
lvl3 = (text) ->
$("#content .lvl4").fadeOut()
level(text, "lvl3")
lvl4 = (text) ->
level(text, "lvl4")