|
|
|
@ -1,13 +1,6 @@
|
|
|
|
|
salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one"
|
|
|
|
|
salet.game_version = "1.0"
|
|
|
|
|
client = deepstream('localhost:6020').login()
|
|
|
|
|
client.record.listen('presence.*', (match, isSubscribed, response) =>
|
|
|
|
|
if (isSubscribed)
|
|
|
|
|
response.accept()
|
|
|
|
|
else
|
|
|
|
|
# stop publishing data, client disconnected
|
|
|
|
|
client.record.getRecord(match).discard()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$.holdReady( true )
|
|
|
|
|
$.getJSON('game/translations/'+i18n.lang+'.json', (data) ->
|
|
|
|
@ -44,6 +37,12 @@ $(document).ready(() ->
|
|
|
|
|
salet.beginGame()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
salet.initGame = () ->
|
|
|
|
|
names = "names".l()
|
|
|
|
|
salet.character.name = names[salet.rnd.randomInt(names.length)]
|
|
|
|
|
salet.character.id = salet.rnd.randn()
|
|
|
|
|
button.color = salet.rnd.randomInt(button.colors.length)
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
|
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
|
|
|
|
@ -59,44 +58,37 @@ actlink = (content, ref) ->
|
|
|
|
|
# The first room of the game.
|
|
|
|
|
# For accessibility reasons the text is provided in HTML, not here.
|
|
|
|
|
room "start",
|
|
|
|
|
enter: () ->
|
|
|
|
|
if (salet.character.name == undefined)
|
|
|
|
|
names = "names".l()
|
|
|
|
|
salet.character.name = names[salet.rnd.randomInt(names.length)]
|
|
|
|
|
salet.character.id = salet.rnd.randn()
|
|
|
|
|
dsc: () -> "intro".l()
|
|
|
|
|
choices: "#start"
|
|
|
|
|
|
|
|
|
|
button = unit "button",
|
|
|
|
|
colors: ["red", "blue", "green", "yellow", "orange", "violet"]
|
|
|
|
|
color: 0
|
|
|
|
|
dsc: () -> "{"+"color_"+@colors[@color].l()+"}"
|
|
|
|
|
dsc: () -> "<center><b>{{"+("color_"+@colors[@color]).l()+"}}</b></center>"
|
|
|
|
|
act: () ->
|
|
|
|
|
index = @colors.indexOf(@color)
|
|
|
|
|
index = index + 1
|
|
|
|
|
if index > @colors.length
|
|
|
|
|
index = 0
|
|
|
|
|
@color = @colors[index]
|
|
|
|
|
@color = @color + 1
|
|
|
|
|
if @color >= @colors.length
|
|
|
|
|
@color = 0
|
|
|
|
|
salet.rooms["entry"].canChoose = true
|
|
|
|
|
salet.view.clearContent()
|
|
|
|
|
salet.here().entering(salet.currentRoom)
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
room "instance",
|
|
|
|
|
dsc: () -> "instance".l()
|
|
|
|
|
tags: ["start"]
|
|
|
|
|
choices: "#instance"
|
|
|
|
|
optionText: () -> "begin_game".l()
|
|
|
|
|
enter: () ->
|
|
|
|
|
for u in @units
|
|
|
|
|
u.color = salet.rnd.randomInt(u.colors.length)
|
|
|
|
|
units: [
|
|
|
|
|
button "first",
|
|
|
|
|
button "second"
|
|
|
|
|
]
|
|
|
|
|
exit: () ->
|
|
|
|
|
client.record.listen('presence.*', (match, isSubscribed, response) =>
|
|
|
|
|
if (isSubscribed)
|
|
|
|
|
response.accept()
|
|
|
|
|
else
|
|
|
|
|
# stop publishing data, client disconnected
|
|
|
|
|
client.record.getRecord(match).discard()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
croom "entry",
|
|
|
|
|
canChoose: false
|
|
|
|
|
optionText: () -> "entry_option".l()
|
|
|
|
|
title: () -> "entry_title".l()
|
|
|
|
|
ways: ["corridor"]
|
|
|
|
|
desc: () -> "entry_dsc".l()
|
|
|
|
|
salet.rooms["instance"].take(button)
|
|
|
|
|
|
|
|
|
|
croom = (name, options) ->
|
|
|
|
|
options.enter = () ->
|
|
|
|
@ -121,3 +113,11 @@ croom = (name, options) ->
|
|
|
|
|
options.dsc = () ->
|
|
|
|
|
"### #{@title()}\n" + @desc()
|
|
|
|
|
return room(name,options)
|
|
|
|
|
|
|
|
|
|
croom "entry",
|
|
|
|
|
canChoose: false
|
|
|
|
|
tags: ["instance"]
|
|
|
|
|
optionText: () -> "entry_option".l()
|
|
|
|
|
title: () -> "entry_title".l()
|
|
|
|
|
ways: ["corridor"]
|
|
|
|
|
desc: () -> "entry_dsc".l()
|
|
|
|
|