Instances WIP later
This commit is contained in:
parent
945bb02bb6
commit
4d1e2dc426
|
@ -37,10 +37,11 @@ $(document).ready(() ->
|
||||||
salet.beginGame()
|
salet.beginGame()
|
||||||
)
|
)
|
||||||
|
|
||||||
salet.initGame = () ->
|
salet.init = () ->
|
||||||
names = "names".l()
|
names = "names".l()
|
||||||
salet.character.name = names[salet.rnd.randomInt(names.length)]
|
salet.character.name = names[salet.rnd.randomInt(names.length)]
|
||||||
salet.character.id = salet.rnd.randn()
|
salet.character.id = salet.rnd.randn()
|
||||||
|
salet.character.color = 0
|
||||||
button.color = salet.rnd.randomInt(button.colors.length)
|
button.color = salet.rnd.randomInt(button.colors.length)
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -69,6 +70,7 @@ button = unit "button",
|
||||||
@color = @color + 1
|
@color = @color + 1
|
||||||
if @color >= @colors.length
|
if @color >= @colors.length
|
||||||
@color = 0
|
@color = 0
|
||||||
|
salet.character.color = @color
|
||||||
salet.rooms["entry"].canChoose = true
|
salet.rooms["entry"].canChoose = true
|
||||||
salet.view.clearContent()
|
salet.view.clearContent()
|
||||||
salet.here().entering(salet.currentRoom)
|
salet.here().entering(salet.currentRoom)
|
||||||
|
@ -80,7 +82,7 @@ room "instance",
|
||||||
choices: "#instance"
|
choices: "#instance"
|
||||||
optionText: () -> "begin_game".l()
|
optionText: () -> "begin_game".l()
|
||||||
exit: () ->
|
exit: () ->
|
||||||
client.record.listen('presence.*', (match, isSubscribed, response) =>
|
client.record.listen("presence.#{salet.character.color}.*", (match, isSubscribed, response) =>
|
||||||
if (isSubscribed)
|
if (isSubscribed)
|
||||||
response.accept()
|
response.accept()
|
||||||
else
|
else
|
||||||
|
@ -93,23 +95,18 @@ salet.rooms["instance"].take(button)
|
||||||
croom = (name, options) ->
|
croom = (name, options) ->
|
||||||
options.enter = () ->
|
options.enter = () ->
|
||||||
if (salet.interactive)
|
if (salet.interactive)
|
||||||
status = client.record.getRecord('presence.'+@room)
|
color = salet.character.color.toString()
|
||||||
status.set('presence.'+@room+'.'+salet.character.id, salet.character.name)
|
status = client.record.getRecord('presence.'+color)
|
||||||
players = status.get()
|
status.set("players."+salet.character.id, salet.character.name)
|
||||||
|
players = status.get("players")
|
||||||
if players.length > 1
|
if players.length > 1
|
||||||
salet.view.write("room_present".l())
|
salet.view.write("room_present".l())
|
||||||
names = []
|
names = []
|
||||||
for player in players
|
for id, name of players
|
||||||
if player == 'presence.'+@room+'.'+salet.character.id
|
if name == salet.character.id
|
||||||
continue
|
continue
|
||||||
i = client.record.getRecord(player)
|
names.push(name)
|
||||||
names.push(i)
|
|
||||||
salet.view.write(names.join(', '))
|
salet.view.write(names.join(', '))
|
||||||
options.exit = () ->
|
|
||||||
if (salet.interactive)
|
|
||||||
status = client.record.getRecord('presence')
|
|
||||||
status.delete('presence.'+@name+'.'+salet.character.id)
|
|
||||||
|
|
||||||
options.dsc = () ->
|
options.dsc = () ->
|
||||||
"### #{@title()}\n" + @desc()
|
"### #{@title()}\n" + @desc()
|
||||||
return room(name,options)
|
return room(name,options)
|
||||||
|
|
Loading…
Reference in New Issue