1
0
Fork 0
mirror of https://gitlab.com/Oreolek/black_phone.git synced 2024-04-28 15:19:41 +03:00
black_phone/game/begin.coffee

120 lines
4.4 KiB
CoffeeScript

# 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
situation = require('raconteur')
undum = require('undum-commonjs')
oneOf = require('raconteur/lib/oneOf.js')
qualities = require('raconteur/lib/qualities.js')
$ = require("jquery")
Array.prototype.oneOf = () ->
oneOf.apply(null, this)
md = require('markdown-it')
markdown = new md({
typographer: true,
html: true
})
shortid = require('shortid')
# you have to alter linkRe in Undum core to use that.
# Undum doesn't allow using uppercase letters in situation names by default.
undum.game.id = "6a9909a4-586a-4089-bd18-26da684d1c8d"
undum.game.version = "1.0"
a = require('raconteur/lib/elements.js').a
way_to = (content, ref) -> a(content).class('way').ref(ref)
textlink = (content, ref) -> a(content).once().writer(ref)
textcycle = (content, ref) -> a(content).replacer(ref).class("cycle").id(ref).toString()
# usage: writemd( system, "Text to write")
writemd = (system, text) ->
if typeof text is Function
text = text()
system.write(markdown.render(text))
money = (character, system, amount) ->
system.setQuality("money", character.qualities.money + amount)
code_can_input = (character) ->
return character.sandbox.code.length < 8
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 == "31122017" or 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.
""")
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 = ""
situation "start",
content: """
Peter had so much trouble sleeping he had to drown his pills in at least an hour of thoughts.
A violent ringing of the bell awakened him.
He rose from the bed, grumbling:
“Crazy neighbors and their guests. It must be three o'clock!”
The visitor entered the hallway.
It was him ringing the bell, but he was not going to meet Peter.
In fact, he wasn't looking for meeting anybody here.
Fourth floor, apartment 406.
There, he tried two keys.
The second of them fitted the lock.
Burglary is a curious line of employment.
Befittedly, Ronald Chernoff was very curious about a black phone behind the door of apartment 406 in a wooden box on a small table no farther than two meters from the bed.
A gift, a prototype, a valuable treasure left by Anastacia Kozlowa when she fled the country.
Of course, one had to be reasonably au fait with her *Instagram* to notice that.
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 [the living room.](living-room)
"""
is_visited = (situation) ->
situations = undum.game.situations[situation]
if situations
return Boolean situations.visited
return 0