Commit 340b7149 authored by nanahira's avatar nanahira

show ip & duel info in dashboard & replay dashboard

parent 6f635e0b
...@@ -86,6 +86,8 @@ ...@@ -86,6 +86,8 @@
"deck_path": "./decks/", "deck_path": "./decks/",
"replay_safe": true, "replay_safe": true,
"replay_path": "./replays/", "replay_path": "./replays/",
"show_ip": false,
"show_info": true,
"duel_log": [], "duel_log": [],
"password": "123456", "password": "123456",
"port": 7933 "port": 7933
...@@ -136,6 +138,8 @@ ...@@ -136,6 +138,8 @@
"password": "123456", "password": "123456",
"websocket_roomlist": false, "websocket_roomlist": false,
"public_roomlist": false, "public_roomlist": false,
"show_ip": false,
"show_info": true,
"ssl": { "ssl": {
"enabled": false, "enabled": false,
"port": 7923, "port": 7923,
......
...@@ -312,6 +312,7 @@ class Room ...@@ -312,6 +312,7 @@ class Room
@random_type = '' @random_type = ''
@welcome = '' @welcome = ''
@scores = {} @scores = {}
@duel_count = 0
ROOM_all.push this ROOM_all.push this
@hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo)) @hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo))
...@@ -1247,6 +1248,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)-> ...@@ -1247,6 +1248,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
client.lp = room.hostinfo.start_lp client.lp = room.hostinfo.start_lp
if client.pos == 0 if client.pos == 0
room.turn = 0 room.turn = 0
room.duel_count = room.duel_count + 1
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}") #ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
...@@ -1486,7 +1488,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)-> ...@@ -1486,7 +1488,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
deck_arena = deck_arena + 'custom' deck_arena = deck_arena + 'custom'
#log.info "DECK LOG START", client.name, room.arena #log.info "DECK LOG START", client.name, room.arena
if settings.modules.deck_log.local if settings.modules.deck_log.local
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_') deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_')
fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) -> fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) ->
if err if err
log.warn 'DECK SAVE ERROR', err log.warn 'DECK SAVE ERROR', err
...@@ -1783,12 +1785,12 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ...@@ -1783,12 +1785,12 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
replay_filename=replay_filename.replace(/[\/\\\?\*]/g, '_')+".yrp" replay_filename=replay_filename.replace(/[\/\\\?\*]/g, '_')+".yrp"
duellog = { duellog = {
time: dueltime, time: dueltime,
name: room.name, name: room.name + (if settings.modules.tournament_mode.show_info then (" (Duel:" + room.duel_count + ")") else ""),
roomid: room.port.toString(), roomid: room.port.toString(),
cloud_replay_id: "R#"+room.cloud_replay_id, cloud_replay_id: "R#"+room.cloud_replay_id,
replay_filename: replay_filename, replay_filename: replay_filename,
players: (for player in room.dueling_players players: (for player in room.dueling_players
name: player.name, name: player.name + (if settings.modules.tournament_mode.show_ip and player.ip != '::ffff:127.0.0.1' then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.tournament_mode.show_info and not (room.hostinfo.mode == 2 and player.pos > 1) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
winner: player.pos == room.winner winner: player.pos == room.winner
) )
} }
...@@ -1886,10 +1888,10 @@ if settings.modules.http ...@@ -1886,10 +1888,10 @@ if settings.modules.http
needpass: (room.name.indexOf('$') != -1).toString(), needpass: (room.name.indexOf('$') != -1).toString(),
users: (for player in room.players when player.pos? users: (for player in room.players when player.pos?
id: (-1).toString(), id: (-1).toString(),
name: player.name, name: player.name + (if settings.modules.http.show_ip and pass_validated and player.ip != '::ffff:127.0.0.1' then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.http.show_info and room.started and not (room.hostinfo.mode == 2 and player.pos > 1) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
pos: player.pos pos: player.pos
), ),
istart: if room.started then 'start' else 'wait' istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " Turn:" + (if room.turn? then room.turn else 0)) else 'start') else 'wait'
), null, 2 ), null, 2
response.end(addCallback(u.query.callback, roomsjson)) response.end(addCallback(u.query.callback, roomsjson))
......
...@@ -432,6 +432,7 @@ ...@@ -432,6 +432,7 @@
this.random_type = ''; this.random_type = '';
this.welcome = ''; this.welcome = '';
this.scores = {}; this.scores = {};
this.duel_count = 0;
ROOM_all.push(this); ROOM_all.push(this);
this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo))); this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo)));
if (settings.lflist.length) { if (settings.lflist.length) {
...@@ -1492,6 +1493,7 @@ ...@@ -1492,6 +1493,7 @@
client.lp = room.hostinfo.start_lp; client.lp = room.hostinfo.start_lp;
if (client.pos === 0) { if (client.pos === 0) {
room.turn = 0; room.turn = 0;
room.duel_count = room.duel_count + 1;
} }
} }
if (ygopro.constants.MSG[msg] === 'NEW_TURN') { if (ygopro.constants.MSG[msg] === 'NEW_TURN') {
...@@ -1827,7 +1829,7 @@ ...@@ -1827,7 +1829,7 @@
deck_arena = deck_arena + 'custom'; deck_arena = deck_arena + 'custom';
} }
if (settings.modules.deck_log.local) { if (settings.modules.deck_log.local) {
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.name.replace(/[\/\\\?\*]/g, '_'); deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_');
fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) { fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) {
if (err) { if (err) {
return log.warn('DECK SAVE ERROR', err); return log.warn('DECK SAVE ERROR', err);
...@@ -2234,7 +2236,7 @@ ...@@ -2234,7 +2236,7 @@
replay_filename = replay_filename.replace(/[\/\\\?\*]/g, '_') + ".yrp"; replay_filename = replay_filename.replace(/[\/\\\?\*]/g, '_') + ".yrp";
duellog = { duellog = {
time: dueltime, time: dueltime,
name: room.name, name: room.name + (settings.modules.tournament_mode.show_info ? " (Duel:" + room.duel_count + ")" : ""),
roomid: room.port.toString(), roomid: room.port.toString(),
cloud_replay_id: "R#" + room.cloud_replay_id, cloud_replay_id: "R#" + room.cloud_replay_id,
replay_filename: replay_filename, replay_filename: replay_filename,
...@@ -2245,7 +2247,7 @@ ...@@ -2245,7 +2247,7 @@
for (k = 0, len1 = ref1.length; k < len1; k++) { for (k = 0, len1 = ref1.length; k < len1; k++) {
player = ref1[k]; player = ref1[k];
results.push({ results.push({
name: player.name, name: player.name + (settings.modules.tournament_mode.show_ip && player.ip !== '::ffff:127.0.0.1' ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.tournament_mode.show_info && !(room.hostinfo.mode === 2 && player.pos > 1) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
winner: player.pos === room.winner winner: player.pos === room.winner
}); });
} }
...@@ -2380,14 +2382,14 @@ ...@@ -2380,14 +2382,14 @@
if (player.pos != null) { if (player.pos != null) {
results1.push({ results1.push({
id: (-1).toString(), id: (-1).toString(),
name: player.name, name: player.name + (settings.modules.http.show_ip && pass_validated && player.ip !== '::ffff:127.0.0.1' ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.http.show_info && room.started && !(room.hostinfo.mode === 2 && player.pos > 1) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
pos: player.pos pos: player.pos
}); });
} }
} }
return results1; return results1;
})(), })(),
istart: room.started ? 'start' : 'wait' istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " Turn:" + (room.turn != null ? room.turn : 0) : 'start') : 'wait'
}); });
} }
} }
......
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