Commit c452e487 authored by mercury233's avatar mercury233

allow show private room in started roomlist

parent 0f10dfcb
......@@ -20,23 +20,23 @@ init = (http_server, ROOM_all)->
connection.filter = url.parse(connection.upgradeReq.url, true).query.filter || 'waiting'
connection.send JSON.stringify
event: 'init'
data: room_data(room) for room in ROOM_all when room and room.established and !room.private and (room.started == (connection.filter == 'started'))
data: room_data(room) for room in ROOM_all when room and room.established and (connection.filter == 'started' or !room.private) and (room.started == (connection.filter == 'started'))
create = (room)->
broadcast('create', room_data(room), 'waiting')
broadcast('create', room_data(room), 'waiting') if !room.private
update = (room)->
broadcast('update', room_data(room), 'waiting')
broadcast('update', room_data(room), 'waiting') if !room.private
start = (room)->
broadcast('delete', room_data(room), 'waiting')
broadcast('delete', room_data(room), 'waiting') if !room.private
broadcast('create', room_data(room), 'started')
_delete = (room)->
if(room.started)
broadcast('delete', room.name, 'started')
else
broadcast('delete', room.name, 'waiting')
broadcast('delete', room.name, 'waiting') if !room.private
broadcast = (event, data, filter)->
return if !server
......
......@@ -50,7 +50,7 @@
results = [];
for (i = 0, len = ROOM_all.length; i < len; i++) {
room = ROOM_all[i];
if (room && room.established && !room["private"] && (room.started === (connection.filter === 'started'))) {
if (room && room.established && (connection.filter === 'started' || !room["private"]) && (room.started === (connection.filter === 'started'))) {
results.push(room_data(room));
}
}
......@@ -61,15 +61,21 @@
};
create = function(room) {
return broadcast('create', room_data(room), 'waiting');
if (!room["private"]) {
return broadcast('create', room_data(room), 'waiting');
}
};
update = function(room) {
return broadcast('update', room_data(room), 'waiting');
if (!room["private"]) {
return broadcast('update', room_data(room), 'waiting');
}
};
start = function(room) {
broadcast('delete', room_data(room), 'waiting');
if (!room["private"]) {
broadcast('delete', room_data(room), 'waiting');
}
return broadcast('create', room_data(room), 'started');
};
......@@ -77,7 +83,9 @@
if (room.started) {
return broadcast('delete', room.name, 'started');
} else {
return broadcast('delete', room.name, 'waiting');
if (!room["private"]) {
return broadcast('delete', room.name, 'waiting');
}
}
};
......
......@@ -415,7 +415,7 @@ class Room
@process.stdout.setEncoding('utf8')
@process.stdout.once 'data', (data)=>
@established = true
roomlist.create(this) if !@private and settings.modules.http.websocket_roomlist
roomlist.create(this) if settings.modules.http.websocket_roomlist
@port = parseInt data
_.each @players, (player)=>
player.server.connect @port, '127.0.0.1', ->
......@@ -509,7 +509,7 @@ class Room
index = _.indexOf(ROOM_all, this)
ROOM_all[index] = null unless index == -1
#ROOM_all.splice(index, 1) unless index == -1
roomlist.delete this if !@private and @established and settings.modules.http.websocket_roomlist
roomlist.delete this if @established and settings.modules.http.websocket_roomlist
return
get_playing_player: ->
......@@ -553,7 +553,7 @@ class Room
ROOM_players_oppentlist[client.ip] = null
if @established
roomlist.update(this) if !@private and !@started and settings.modules.http.websocket_roomlist
roomlist.update(this) if !@started and settings.modules.http.websocket_roomlist
client.server.connect @port, '127.0.0.1', ->
client.server.write buffer for buffer in client.pre_establish_buffers
client.established = true
......@@ -578,7 +578,7 @@ class Room
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}")
if @players.length and !(@windbot and client.is_host)
ygopro.stoc_send_chat_to_room this, "#{client.name} ${left_game}" + if error then ": #{error}" else ''
roomlist.update(this) if !@private and !@started and settings.modules.http.websocket_roomlist
roomlist.update(this) if !@started and settings.modules.http.websocket_roomlist
#client.room = null
else
@process.kill()
......@@ -1370,7 +1370,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
unless room.started #first start
room.started = true
room.start_time = moment().format()
roomlist.start room if settings.modules.http.websocket_roomlist and not room.private
roomlist.start room if settings.modules.http.websocket_roomlist
#room.duels = []
room.dueling_players = []
for player in room.players when player.pos != 7
......
......@@ -555,7 +555,7 @@
this.process.stdout.once('data', (function(_this) {
return function(data) {
_this.established = true;
if (!_this["private"] && settings.modules.http.websocket_roomlist) {
if (settings.modules.http.websocket_roomlist) {
roomlist.create(_this);
}
_this.port = parseInt(data);
......@@ -682,7 +682,7 @@
if (index !== -1) {
ROOM_all[index] = null;
}
if (!this["private"] && this.established && settings.modules.http.websocket_roomlist) {
if (this.established && settings.modules.http.websocket_roomlist) {
roomlist["delete"](this);
}
};
......@@ -737,7 +737,7 @@
}
}
if (this.established) {
if (!this["private"] && !this.started && settings.modules.http.websocket_roomlist) {
if (!this.started && settings.modules.http.websocket_roomlist) {
roomlist.update(this);
}
client.server.connect(this.port, '127.0.0.1', function() {
......@@ -775,7 +775,7 @@
}
if (this.players.length && !(this.windbot && client.is_host)) {
ygopro.stoc_send_chat_to_room(this, (client.name + " ${left_game}") + (error ? ": " + error : ''));
if (!this["private"] && !this.started && settings.modules.http.websocket_roomlist) {
if (!this.started && settings.modules.http.websocket_roomlist) {
roomlist.update(this);
}
} else {
......@@ -1674,7 +1674,7 @@
if (!room.started) {
room.started = true;
room.start_time = moment().format();
if (settings.modules.http.websocket_roomlist && !room["private"]) {
if (settings.modules.http.websocket_roomlist) {
roomlist.start(room);
}
room.dueling_players = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment