1
0
Fork 0
Browse Source

Instances WIP later

master
Alexander Yakovlev 5 years ago
parent
commit
4d1e2dc426
  1. 25
      game/begin.coffee

25
game/begin.coffee

@ -37,10 +37,11 @@ $(document).ready(() ->
salet.beginGame()
)
salet.initGame = () ->
salet.init = () ->
names = "names".l()
salet.character.name = names[salet.rnd.randomInt(names.length)]
salet.character.id = salet.rnd.randn()
salet.character.color = 0
button.color = salet.rnd.randomInt(button.colors.length)
###
@ -69,6 +70,7 @@ button = unit "button",
@color = @color + 1
if @color >= @colors.length
@color = 0
salet.character.color = @color
salet.rooms["entry"].canChoose = true
salet.view.clearContent()
salet.here().entering(salet.currentRoom)
@ -80,7 +82,7 @@ room "instance",
choices: "#instance"
optionText: () -> "begin_game".l()
exit: () ->
client.record.listen('presence.*', (match, isSubscribed, response) =>
client.record.listen("presence.#{salet.character.color}.*", (match, isSubscribed, response) =>
if (isSubscribed)
response.accept()
else
@ -93,23 +95,18 @@ salet.rooms["instance"].take(button)
croom = (name, options) ->
options.enter = () ->
if (salet.interactive)
status = client.record.getRecord('presence.'+@room)
status.set('presence.'+@room+'.'+salet.character.id, salet.character.name)
players = status.get()
color = salet.character.color.toString()
status = client.record.getRecord('presence.'+color)
status.set("players."+salet.character.id, salet.character.name)
players = status.get("players")
if players.length > 1
salet.view.write("room_present".l())
names = []
for player in players
if player == 'presence.'+@room+'.'+salet.character.id
for id, name of players
if name == salet.character.id
continue
i = client.record.getRecord(player)
names.push(i)
names.push(name)
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)

Loading…
Cancel
Save