|
|
|
@ -1,7 +1,13 @@
|
|
|
|
|
salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one"
|
|
|
|
|
salet.game_version = "1.0"
|
|
|
|
|
ably = new Ably.Realtime('v6yAiA.PKvuDg:iJhwQu-DkAWpDOUB')
|
|
|
|
|
channel = ably.channels.get('astrid-'+i18n.lang)
|
|
|
|
|
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) ->
|
|
|
|
@ -35,14 +41,6 @@ $(document).ready(() ->
|
|
|
|
|
window.night = true
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
channel.subscribe('enter', (message) ->
|
|
|
|
|
if (
|
|
|
|
|
message.data.room == salet.current and
|
|
|
|
|
message.data.name != salet.character.name
|
|
|
|
|
)
|
|
|
|
|
salet.view.write("room_enter".l()+message.data.name+".")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
salet.beginGame()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -62,18 +60,33 @@ actlink = (content, ref) ->
|
|
|
|
|
# For accessibility reasons the text is provided in HTML, not here.
|
|
|
|
|
room "start",
|
|
|
|
|
enter: () ->
|
|
|
|
|
names = "names".l()
|
|
|
|
|
salet.character.name = names[salet.rnd.randomInt(names.length)]
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
croom = (name, options) ->
|
|
|
|
|
options.enter = () ->
|
|
|
|
|
if (salet.interactive)
|
|
|
|
|
channel.publish('enter', {
|
|
|
|
|
room: @name,
|
|
|
|
|
name: salet.character.name
|
|
|
|
|
})
|
|
|
|
|
status = client.record.getRecord('presence.'+@room)
|
|
|
|
|
status.set('presence.'+@room+'.'+salet.character.id, salet.character.name)
|
|
|
|
|
players = status.get()
|
|
|
|
|
if players.length > 1
|
|
|
|
|
salet.view.write("room_present".l())
|
|
|
|
|
names = []
|
|
|
|
|
for player in players
|
|
|
|
|
if player == 'presence.'+@room+'.'+salet.character.id
|
|
|
|
|
continue
|
|
|
|
|
i = client.record.getRecord(player)
|
|
|
|
|
names.push(i)
|
|
|
|
|
salet.view.write(names.join(', '))
|
|
|
|
|
options.exit = () ->
|
|
|
|
|
if (salet.interactive)
|
|
|
|
|
status = client.record.getRecord('presence')
|
|
|
|
|
status.delete('presence.'+@name+'.'+salet.character.id)
|
|
|
|
|
|
|
|
|
|
options.dsc = () ->
|
|
|
|
|
"### #{@title()}\n" + @desc()
|
|
|
|
|
return room(name,options)
|
|
|
|
|