Commit c7b080c0 authored by nanahira's avatar nanahira

Merge branch 'mc'

parents 2cb5b0b9 24183ed8
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
"replay_path": "./replays/", "replay_path": "./replays/",
"replay_archive_tool": "7z", "replay_archive_tool": "7z",
"block_replay_to_player": false, "block_replay_to_player": false,
"enable_recover": true, "enable_recover": false,
"show_ip": false, "show_ip": false,
"show_info": true, "show_info": true,
"log_save_path": "./config/", "log_save_path": "./config/",
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
"cloud_replay_error": "Replay opening failed.", "cloud_replay_error": "Replay opening failed.",
"cloud_replay_playing": "Accessing cloud replay", "cloud_replay_playing": "Accessing cloud replay",
"cloud_replay_hint": "These are the recent saved replay codes, please enter the replay code at the password column to access it.", "cloud_replay_hint": "These are the recent saved replay codes, please enter the replay code at the password column to access it.",
"recover_replay_hint": "These are the recent duels, please enter the code RC[ID]%[TURN]#[ROOMNAME] at the password column to recover the duel.", "recover_replay_hint": "These are the recent duels, please enter the code RC[ID]T[TURN]#[ROOMNAME] at the password column to recover the duel.",
"recover_hint": "You entered a recover room. Please be ready with your deck on that duel.", "recover_hint": "You entered a recover room. Please be ready with your deck on that duel.",
"recover_start_hint": "Started recovering...", "recover_start_hint": "Started recovering...",
"recover_success": "Recover success. Please wait until current turn.", "recover_success": "Recover success. Please wait until current turn.",
...@@ -379,7 +379,7 @@ ...@@ -379,7 +379,7 @@
"cloud_replay_error": "播放录像出错", "cloud_replay_error": "播放录像出错",
"cloud_replay_playing": "正在观看云录像", "cloud_replay_playing": "正在观看云录像",
"cloud_replay_hint": "以下是您近期的云录像,密码处输入 R#录像编号 即可观看", "cloud_replay_hint": "以下是您近期的云录像,密码处输入 R#录像编号 即可观看",
"recover_replay_hint": "以下是您近期进行的决斗,密码处输入 RC决斗编号%回合数#房间号 即可创建复盘房间", "recover_replay_hint": "以下是您近期进行的决斗,密码处输入 RC决斗编号T回合数#房间号 即可创建复盘房间",
"recover_hint": "你进入了一个复盘房间,请使用复盘局的卡组准备。", "recover_hint": "你进入了一个复盘房间,请使用复盘局的卡组准备。",
"recover_start_hint": "开始复盘...", "recover_start_hint": "开始复盘...",
"recover_success": "复盘成功。请耐心等待跳到当前回合。", "recover_success": "复盘成功。请耐心等待跳到当前回合。",
......
...@@ -481,47 +481,42 @@ if settings.modules.challonge.enabled ...@@ -481,47 +481,42 @@ if settings.modules.challonge.enabled
challonge = global.challonge = require(challonge_module_name).createClient(settings.modules.challonge.options) challonge = global.challonge = require(challonge_module_name).createClient(settings.modules.challonge.options)
if settings.modules.challonge.cache_ttl if settings.modules.challonge.cache_ttl
challonge_cache = [] challonge_cache = []
challonge_queue_callbacks = [[], []] challonge_queue_callbacks = {
is_requesting = [null, null] participants: []
matches: []
}
is_challonge_requesting = {
participants: null
matches: null
}
get_callback = (challonge_type, resolve_data) -> get_callback = (challonge_type, resolve_data) ->
return ((err, data) -> return ((err, data) ->
if settings.modules.challonge.cache_ttl and !err and data if settings.modules.challonge.cache_ttl and !err and data
challonge_cache[challonge_type] = data challonge_cache[challonge_type] = data
is_requesting[challonge_type] =null is_challonge_requesting[challonge_type] = null
resolve_data.resolve(err, data) resolve_data.resolve(err, data)
while challonge_queue_callbacks[challonge_type].length while challonge_queue_callbacks[challonge_type].length
cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0] cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0]
cur_resolve_data.resolve(err, data) cur_resolve_data.resolve(err, data)
return return
) )
challonge.participants._index = (_data) -> replaced_index = (challonge_type) ->
resolve_data = new ResolveData(_data.callback) return (_data) ->
if settings.modules.challonge.cache_ttl and challonge_cache[0] resolve_data = new ResolveData(_data.callback)
resolve_data.resolve(null, challonge_cache[0]) if settings.modules.challonge.cache_ttl and !_data.no_cache and challonge_cache[0]
else if is_requesting[0] and moment() - is_requesting[0] <= 5000 resolve_data.resolve(null, challonge_cache[challonge_type])
challonge_queue_callbacks[0].push(resolve_data) else if is_challonge_requesting[challonge_type] and moment() - is_challonge_requesting[challonge_type] <= 5000
else challonge_queue_callbacks[challonge_type].push(resolve_data)
_data.callback = get_callback(0, resolve_data) else
is_requesting[0] = moment() _data.callback = get_callback(challonge_type, resolve_data)
try is_challonge_requesting[challonge_type] = moment()
challonge.participants.index(_data) try
catch err challonge[challonge_type].index(_data)
_data.callback(err, null) catch err
return _data.callback(err, null)
challonge.matches._index = (_data) -> return
resolve_data = new ResolveData(_data.callback) for challonge_type in ["participants", "matches"]
if settings.modules.challonge.cache_ttl and challonge_cache[1] challonge[challonge_type]._index = replaced_index(challonge_type)
resolve_data.resolve(null, challonge_cache[1])
else if is_requesting[1] and moment() - is_requesting[1] <= 5000
challonge_queue_callbacks[1].push(resolve_data)
else
_data.callback = get_callback(1, resolve_data)
is_requesting[1] = moment()
try
challonge.matches.index(_data)
catch err
_data.callback(err, null)
return
challonge.matches._update = (_data) -> challonge.matches._update = (_data) ->
try try
challonge.matches.update(_data) challonge.matches.update(_data)
...@@ -1152,7 +1147,7 @@ CLIENT_get_partner = global.CLIENT_get_partner = (client) -> ...@@ -1152,7 +1147,7 @@ CLIENT_get_partner = global.CLIENT_get_partner = (client) ->
return room.dueling_players[5 - client.pos] return room.dueling_players[5 - client.pos]
CLIENT_send_replays = global.CLIENT_send_replays = (client, room) -> CLIENT_send_replays = global.CLIENT_send_replays = (client, room) ->
return false unless settings.modules.replay_delay and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player) and room.replays.length and room.hostinfo.mode == 1 and !client.replays_sent and !client.closed return false unless settings.modules.replay_delay and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) and room.replays.length and room.hostinfo.mode == 1 and !client.replays_sent and !client.closed
client.replays_sent = true client.replays_sent = true
i = 0 i = 0
for buffer in room.replays for buffer in room.replays
...@@ -1303,7 +1298,7 @@ class Room ...@@ -1303,7 +1298,7 @@ class Room
else else
@hostinfo.auto_death = 40 @hostinfo.auto_death = 40
if settings.modules.tournament_mode.enable_recover and (param = rule.match /(^|,|,)(RC|RECOVER)(\d*)%(\d*)(,|,|$)/) if settings.modules.tournament_mode.enable_recover and (param = rule.match /(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/)
@recovered = true @recovered = true
@recovering = true @recovering = true
@recover_from_turn = parseInt(param[4]) @recover_from_turn = parseInt(param[4])
...@@ -1322,7 +1317,7 @@ class Room ...@@ -1322,7 +1317,7 @@ class Room
if settings.modules.tournament_mode.enabled if settings.modules.tournament_mode.enabled
@hostinfo.replay_mode |= 0x1 @hostinfo.replay_mode |= 0x1
if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe) or (@hostinfo.mode == 1 and settings.modules.replay_delay) if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) or (@hostinfo.mode == 1 and settings.modules.replay_delay)
@hostinfo.replay_mode |= 0x2 @hostinfo.replay_mode |= 0x2
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, @hostinfo.duel_rule, param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, @hostinfo.duel_rule,
...@@ -2403,6 +2398,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2403,6 +2398,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else else
ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE)
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
recover_match = info.pass.match(/^(RC|RECOVER)(\d*)T(\d*)$/)
_async.auto({ _async.auto({
participant_data: (done) -> participant_data: (done) ->
challonge.participants._index({ challonge.participants._index({
...@@ -2414,7 +2410,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2414,7 +2410,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
match_data: (done) -> match_data: (done) ->
challonge.matches._index({ challonge.matches._index({
id: settings.modules.challonge.tournament_id, id: settings.modules.challonge.tournament_id,
callback: done callback: done,
no_cache: !!recover_match
}) })
return return
}, (err, datas) -> }, (err, datas) ->
...@@ -2444,7 +2441,10 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2444,7 +2441,10 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
#if found.winnerId #if found.winnerId
# ygopro.stoc_die(client, '${challonge_match_already_finished}') # ygopro.stoc_die(client, '${challonge_match_already_finished}')
# return # return
room = ROOM_find_or_create_by_name('M#' + found.id) create_room_name = 'M#' + found.id
if recover_match
create_room_name = recover_match[0] + ',' + create_room_name
room = ROOM_find_or_create_by_name(create_room_name)
if room if room
room.challonge_info = found room.challonge_info = found
# room.max_player = 2 # room.max_player = 2
...@@ -3903,13 +3903,13 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)-> ...@@ -3903,13 +3903,13 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay unless room return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay unless room
if settings.modules.cloud_replay.enabled and room.random_type if settings.modules.cloud_replay.enabled and room.random_type
Cloud_replay_ids.push room.cloud_replay_id Cloud_replay_ids.push room.cloud_replay_id
if !room.replays[room.duel_count - 1] if !room.replays[room.duel_count - 1]
# console.log("Replay saved: ", room.duel_count - 1, client.pos) # console.log("Replay saved: ", room.duel_count - 1, client.pos)
room.replays[room.duel_count - 1] = buffer room.replays[room.duel_count - 1] = buffer
if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe or settings.modules.tournament_mode.enable_recover
if client.pos == 0 if client.pos == 0
dueltime=moment().format('YYYY-MM-DD HH-mm-ss') dueltime=moment().format('YYYY-MM-DD HH-mm-ss')
replay_filename=dueltime replay_filename=dueltime
......
// Generated by CoffeeScript 2.5.1 // Generated by CoffeeScript 2.5.1
(function() { (function() {
// 标准库 // 标准库
var CLIENT_check_vip, CLIENT_get_absolute_pos, CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, CLIENT_get_partner, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_kick_reconnect, CLIENT_is_able_to_reconnect, CLIENT_is_banned_by_mc, CLIENT_is_player, CLIENT_kick, CLIENT_kick_reconnect, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_replays, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_pid, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_kick, ROOM_player_flee, ROOM_player_get_score, ROOM_player_lose, ROOM_player_win, ROOM_players_banned, ROOM_players_oppentlist, ROOM_players_scores, ROOM_unwelcome, ROOM_validate, ReplayParser, ResolveData, Room, SERVER_clear_disconnect, SERVER_kick, SOCKET_flush_data, VIP_generate_cdkeys, _, _async, addCallback, auth, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_module_name, challonge_queue_callbacks, chat_color, concat_name, config, cppversion, crypto, date, deck_name_match, default_config, default_data, dialogues, disconnect_list, dns, duel_log, e, exec, execFile, fs, geoip, get_callback, get_memory_usage, http, http_server, https, https_server, import_datas, imported, is_requesting, j, k, l, len, len1, len2, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_tips_zh, load_words, log, long_resolve_cards, m, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, plugin_filename, plugin_list, plugin_path, real_windbot_server_ip, redis, redisdb, ref, ref1, ref2, refresh_challonge_cache, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, spawn_windbot, tips, url, users_cache, util, v, vip_info, wait_room_start, wait_room_start_arena, windbot_looplimit, windbot_process, windbots, words, ygopro, zlib; var CLIENT_check_vip, CLIENT_get_absolute_pos, CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, CLIENT_get_partner, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_kick_reconnect, CLIENT_is_able_to_reconnect, CLIENT_is_banned_by_mc, CLIENT_is_player, CLIENT_kick, CLIENT_kick_reconnect, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_replays, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_pid, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_kick, ROOM_player_flee, ROOM_player_get_score, ROOM_player_lose, ROOM_player_win, ROOM_players_banned, ROOM_players_oppentlist, ROOM_players_scores, ROOM_unwelcome, ROOM_validate, ReplayParser, ResolveData, Room, SERVER_clear_disconnect, SERVER_kick, SOCKET_flush_data, VIP_generate_cdkeys, _, _async, addCallback, auth, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_module_name, challonge_queue_callbacks, challonge_type, chat_color, concat_name, config, cppversion, crypto, date, deck_name_match, default_config, default_data, dialogues, disconnect_list, dns, duel_log, e, exec, execFile, fs, geoip, get_callback, get_memory_usage, http, http_server, https, https_server, import_datas, imported, is_challonge_requesting, j, k, l, len, len1, len2, len3, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_tips_zh, load_words, log, long_resolve_cards, m, memory_usage, merge, moment, n, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, plugin_filename, plugin_list, plugin_path, real_windbot_server_ip, redis, redisdb, ref, ref1, ref2, ref3, refresh_challonge_cache, release_disconnect, replaced_index, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, spawn_windbot, tips, url, users_cache, util, v, vip_info, wait_room_start, wait_room_start_arena, windbot_looplimit, windbot_process, windbots, words, ygopro, zlib;
net = require('net'); net = require('net');
...@@ -642,15 +642,21 @@ ...@@ -642,15 +642,21 @@
if (settings.modules.challonge.cache_ttl) { if (settings.modules.challonge.cache_ttl) {
challonge_cache = []; challonge_cache = [];
} }
challonge_queue_callbacks = [[], []]; challonge_queue_callbacks = {
is_requesting = [null, null]; participants: [],
matches: []
};
is_challonge_requesting = {
participants: null,
matches: null
};
get_callback = function(challonge_type, resolve_data) { get_callback = function(challonge_type, resolve_data) {
return (function(err, data) { return (function(err, data) {
var cur_resolve_data; var cur_resolve_data;
if (settings.modules.challonge.cache_ttl && !err && data) { if (settings.modules.challonge.cache_ttl && !err && data) {
challonge_cache[challonge_type] = data; challonge_cache[challonge_type] = data;
} }
is_requesting[challonge_type] = null; is_challonge_requesting[challonge_type] = null;
resolve_data.resolve(err, data); resolve_data.resolve(err, data);
while (challonge_queue_callbacks[challonge_type].length) { while (challonge_queue_callbacks[challonge_type].length) {
cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0]; cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0];
...@@ -658,42 +664,31 @@ ...@@ -658,42 +664,31 @@
} }
}); });
}; };
challonge.participants._index = function(_data) { replaced_index = function(challonge_type) {
var err, resolve_data; return function(_data) {
resolve_data = new ResolveData(_data.callback); var err, resolve_data;
if (settings.modules.challonge.cache_ttl && challonge_cache[0]) { resolve_data = new ResolveData(_data.callback);
resolve_data.resolve(null, challonge_cache[0]); if (settings.modules.challonge.cache_ttl && !_data.no_cache && challonge_cache[0]) {
} else if (is_requesting[0] && moment() - is_requesting[0] <= 5000) { resolve_data.resolve(null, challonge_cache[challonge_type]);
challonge_queue_callbacks[0].push(resolve_data); } else if (is_challonge_requesting[challonge_type] && moment() - is_challonge_requesting[challonge_type] <= 5000) {
} else { challonge_queue_callbacks[challonge_type].push(resolve_data);
_data.callback = get_callback(0, resolve_data); } else {
is_requesting[0] = moment(); _data.callback = get_callback(challonge_type, resolve_data);
try { is_challonge_requesting[challonge_type] = moment();
challonge.participants.index(_data); try {
} catch (error1) { challonge[challonge_type].index(_data);
err = error1; } catch (error1) {
_data.callback(err, null); err = error1;
} _data.callback(err, null);
} }
};
challonge.matches._index = function(_data) {
var err, resolve_data;
resolve_data = new ResolveData(_data.callback);
if (settings.modules.challonge.cache_ttl && challonge_cache[1]) {
resolve_data.resolve(null, challonge_cache[1]);
} else if (is_requesting[1] && moment() - is_requesting[1] <= 5000) {
challonge_queue_callbacks[1].push(resolve_data);
} else {
_data.callback = get_callback(1, resolve_data);
is_requesting[1] = moment();
try {
challonge.matches.index(_data);
} catch (error1) {
err = error1;
_data.callback(err, null);
} }
} };
}; };
ref2 = ["participants", "matches"];
for (m = 0, len2 = ref2.length; m < len2; m++) {
challonge_type = ref2[m];
challonge[challonge_type]._index = replaced_index(challonge_type);
}
challonge.matches._update = function(_data) { challonge.matches._update = function(_data) {
var err; var err;
try { try {
...@@ -728,9 +723,9 @@ ...@@ -728,9 +723,9 @@
} }
if (settings.modules.vip.enabled) { if (settings.modules.vip.enabled) {
ref2 = vip_info.cdkeys; ref3 = vip_info.cdkeys;
for (k in ref2) { for (k in ref3) {
v = ref2[k]; v = ref3[k];
if (v.length === 0) { if (v.length === 0) {
VIP_generate_cdkeys(k, settings.modules.vip.generate_count); VIP_generate_cdkeys(k, settings.modules.vip.generate_count);
} }
...@@ -1113,13 +1108,13 @@ ...@@ -1113,13 +1108,13 @@
}; };
ROOM_unwelcome = global.ROOM_unwelcome = function(room, bad_player, reason) { ROOM_unwelcome = global.ROOM_unwelcome = function(room, bad_player, reason) {
var len2, m, player, ref3; var len3, n, player, ref4;
if (!room) { if (!room) {
return; return;
} }
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && player === bad_player) { if (player && player === bad_player) {
ygopro.stoc_send_chat(player, `\${unwelcome_warn_part1}${reason}\${unwelcome_warn_part2}`, ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(player, `\${unwelcome_warn_part1}${reason}\${unwelcome_warn_part2}`, ygopro.constants.COLORS.RED);
} else if (player && player.pos !== 7 && player !== bad_player) { } else if (player && player.pos !== 7 && player !== bad_player) {
...@@ -1231,10 +1226,10 @@ ...@@ -1231,10 +1226,10 @@
}; };
CLIENT_import_data = global.CLIENT_import_data = function(client, old_client, room) { CLIENT_import_data = global.CLIENT_import_data = function(client, old_client, room) {
var index, key, len2, len3, m, n, player, ref3; var index, key, len3, len4, n, o, player, ref4;
ref3 = room.players; ref4 = room.players;
for (index = m = 0, len2 = ref3.length; m < len2; index = ++m) { for (index = n = 0, len3 = ref4.length; n < len3; index = ++n) {
player = ref3[index]; player = ref4[index];
if (player === old_client) { if (player === old_client) {
room.players[index] = client; room.players[index] = client;
break; break;
...@@ -1253,8 +1248,8 @@ ...@@ -1253,8 +1248,8 @@
if (room.determine_firstgo === old_client) { if (room.determine_firstgo === old_client) {
room.determine_firstgo = client; room.determine_firstgo = client;
} }
for (n = 0, len3 = import_datas.length; n < len3; n++) { for (o = 0, len4 = import_datas.length; o < len4; o++) {
key = import_datas[n]; key = import_datas[o];
client[key] = old_client[key]; client[key] = old_client[key];
} }
old_client.had_new_reconnection = true; old_client.had_new_reconnection = true;
...@@ -1291,11 +1286,11 @@ ...@@ -1291,11 +1286,11 @@
}; };
CLIENT_is_player = global.CLIENT_is_player = function(client, room) { CLIENT_is_player = global.CLIENT_is_player = function(client, room) {
var is_player, len2, m, player, ref3; var is_player, len3, n, player, ref4;
is_player = false; is_player = false;
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (client === player) { if (client === player) {
is_player = true; is_player = true;
break; break;
...@@ -1328,13 +1323,13 @@ ...@@ -1328,13 +1323,13 @@
}; };
CLIENT_get_kick_reconnect_target = global.CLIENT_get_kick_reconnect_target = function(client, deckbuf) { CLIENT_get_kick_reconnect_target = global.CLIENT_get_kick_reconnect_target = function(client, deckbuf) {
var len2, len3, m, n, player, ref3, room; var len3, len4, n, o, player, ref4, room;
for (m = 0, len2 = ROOM_all.length; m < len2; m++) { for (n = 0, len3 = ROOM_all.length; n < len3; n++) {
room = ROOM_all[m]; room = ROOM_all[n];
if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot) { if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot) {
ref3 = room.get_playing_player(); ref4 = room.get_playing_player();
for (n = 0, len3 = ref3.length; n < len3; n++) { for (o = 0, len4 = ref4.length; o < len4; o++) {
player = ref3[n]; player = ref4[o];
if (!player.closed && player.name === client.name && (settings.modules.challonge.enabled || player.pass === client.pass) && (settings.modules.mycard.enabled || settings.modules.tournament_mode.enabled || player.ip === client.ip || (client.vpass && client.vpass === player.vpass)) && (!deckbuf || _.isEqual(player.start_deckbuf, deckbuf))) { if (!player.closed && player.name === client.name && (settings.modules.challonge.enabled || player.pass === client.pass) && (settings.modules.mycard.enabled || settings.modules.tournament_mode.enabled || player.ip === client.ip || (client.vpass && client.vpass === player.vpass)) && (!deckbuf || _.isEqual(player.start_deckbuf, deckbuf))) {
return player; return player;
} }
...@@ -1355,7 +1350,7 @@ ...@@ -1355,7 +1350,7 @@
}; };
CLIENT_send_pre_reconnect_info = global.CLIENT_send_pre_reconnect_info = function(client, room, old_client) { CLIENT_send_pre_reconnect_info = global.CLIENT_send_pre_reconnect_info = function(client, room, old_client) {
var len2, m, player, ref3, req_pos; var len3, n, player, ref4, req_pos;
ygopro.stoc_send_chat(client, "${pre_reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${pre_reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send(client, 'JOIN_GAME', room.join_game_buffer); ygopro.stoc_send(client, 'JOIN_GAME', room.join_game_buffer);
req_pos = old_client.pos; req_pos = old_client.pos;
...@@ -1365,9 +1360,9 @@ ...@@ -1365,9 +1360,9 @@
ygopro.stoc_send(client, 'TYPE_CHANGE', { ygopro.stoc_send(client, 'TYPE_CHANGE', {
type: req_pos type: req_pos
}); });
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
ygopro.stoc_send(client, 'HS_PLAYER_ENTER', { ygopro.stoc_send(client, 'HS_PLAYER_ENTER', {
name: player.name, name: player.name,
pos: player.pos pos: player.pos
...@@ -1556,15 +1551,15 @@ ...@@ -1556,15 +1551,15 @@
}; };
CLIENT_send_replays = global.CLIENT_send_replays = function(client, room) { CLIENT_send_replays = global.CLIENT_send_replays = function(client, room) {
var buffer, i, len2, m, ref3; var buffer, i, len3, n, ref4;
if (!(settings.modules.replay_delay && !(settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe && settings.modules.tournament_mode.block_replay_to_player) && room.replays.length && room.hostinfo.mode === 1 && !client.replays_sent && !client.closed)) { if (!(settings.modules.replay_delay && !(settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) && room.replays.length && room.hostinfo.mode === 1 && !client.replays_sent && !client.closed)) {
return false; return false;
} }
client.replays_sent = true; client.replays_sent = true;
i = 0; i = 0;
ref3 = room.replays; ref4 = room.replays;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
buffer = ref3[m]; buffer = ref4[n];
++i; ++i;
if (buffer) { if (buffer) {
ygopro.stoc_send_chat(client, "${replay_hint_part1}" + i + "${replay_hint_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${replay_hint_part1}" + i + "${replay_hint_part2}", ygopro.constants.COLORS.BABYBLUE);
...@@ -1575,12 +1570,12 @@ ...@@ -1575,12 +1570,12 @@
}; };
SOCKET_flush_data = global.SOCKET_flush_data = function(sk, datas) { SOCKET_flush_data = global.SOCKET_flush_data = function(sk, datas) {
var buffer, len2, m; var buffer, len3, n;
if (!sk || sk.closed) { if (!sk || sk.closed) {
return false; return false;
} }
for (m = 0, len2 = datas.length; m < len2; m++) { for (n = 0, len3 = datas.length; n < len3; n++) {
buffer = datas[m]; buffer = datas[n];
sk.write(buffer); sk.write(buffer);
} }
datas.splice(0, datas.length); datas.splice(0, datas.length);
...@@ -1741,7 +1736,7 @@ ...@@ -1741,7 +1736,7 @@
this.hostinfo.auto_death = 40; this.hostinfo.auto_death = 40;
} }
} }
if (settings.modules.tournament_mode.enable_recover && (param = rule.match(/(^|,|,)(RC|RECOVER)(\d*)%(\d*)(,|,|$)/))) { if (settings.modules.tournament_mode.enable_recover && (param = rule.match(/(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/))) {
this.recovered = true; this.recovered = true;
this.recovering = true; this.recovering = true;
this.recover_from_turn = parseInt(param[4]); this.recover_from_turn = parseInt(param[4]);
...@@ -1762,7 +1757,7 @@ ...@@ -1762,7 +1757,7 @@
if (settings.modules.tournament_mode.enabled) { if (settings.modules.tournament_mode.enabled) {
this.hostinfo.replay_mode |= 0x1; this.hostinfo.replay_mode |= 0x1;
} }
if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) { if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) {
this.hostinfo.replay_mode |= 0x2; this.hostinfo.replay_mode |= 0x2;
} }
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, this.hostinfo.duel_rule, (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit, this.hostinfo.replay_mode]; param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, this.hostinfo.duel_rule, (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit, this.hostinfo.replay_mode];
...@@ -1795,10 +1790,10 @@ ...@@ -1795,10 +1790,10 @@
this.port = parseInt(data); this.port = parseInt(data);
_.each(this.players, (player) => { _.each(this.players, (player) => {
player.server.connect(this.port, '127.0.0.1', function() { player.server.connect(this.port, '127.0.0.1', function() {
var buffer, len2, m, ref3; var buffer, len3, n, ref4;
ref3 = player.pre_establish_buffers; ref4 = player.pre_establish_buffers;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
buffer = ref3[m]; buffer = ref4[n];
player.server.write(buffer); player.server.write(buffer);
} }
player.established = true; player.established = true;
...@@ -1829,15 +1824,15 @@ ...@@ -1829,15 +1824,15 @@
} }
delete() { delete() {
var end_time, formatted_replays, index, len2, log_rep_id, m, name, player_ips, player_names, recorder_buffer, ref3, ref4, repbuf, replay_id, room_name, score, score_array, score_form; var end_time, formatted_replays, index, len3, log_rep_id, n, name, player_ips, player_names, recorder_buffer, ref4, ref5, repbuf, replay_id, room_name, score, score_array, score_form;
if (this.deleted) { if (this.deleted) {
return; return;
} }
//log.info 'room-delete', this.name, ROOM_all.length //log.info 'room-delete', this.name, ROOM_all.length
score_array = []; score_array = [];
ref3 = this.scores; ref4 = this.scores;
for (name in ref3) { for (name in ref4) {
score = ref3[name]; score = ref4[name];
score_form = { score_form = {
name: name.split('$')[0], name: name.split('$')[0],
score: score, score: score,
...@@ -1892,9 +1887,9 @@ ...@@ -1892,9 +1887,9 @@
score_array[1].score = -5; score_array[1].score = -5;
} }
formatted_replays = []; formatted_replays = [];
ref4 = this.replays; ref5 = this.replays;
for (m = 0, len2 = ref4.length; m < len2; m++) { for (n = 0, len3 = ref5.length; n < len3; n++) {
repbuf = ref4[m]; repbuf = ref5[n];
if (repbuf) { if (repbuf) {
formatted_replays.push(repbuf.toString("base64")); formatted_replays.push(repbuf.toString("base64"));
} }
...@@ -2022,14 +2017,14 @@ ...@@ -2022,14 +2017,14 @@
} }
get_disconnected_count() { get_disconnected_count() {
var found, len2, m, player, ref3; var found, len3, n, player, ref4;
if (!settings.modules.reconnect.enabled) { if (!settings.modules.reconnect.enabled) {
return 0; return 0;
} }
found = 0; found = 0;
ref3 = this.get_playing_player(); ref4 = this.get_playing_player();
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player.closed) { if (player.closed) {
found++; found++;
} }
...@@ -2079,20 +2074,20 @@ ...@@ -2079,20 +2074,20 @@
} }
send_replays() { send_replays() {
var len2, len3, m, n, player, ref3, ref4; var len3, len4, n, o, player, ref4, ref5;
if (!(settings.modules.replay_delay && this.replays.length && this.hostinfo.mode === 1)) { if (!(settings.modules.replay_delay && this.replays.length && this.hostinfo.mode === 1)) {
return false; return false;
} }
ref3 = this.players; ref4 = this.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player) { if (player) {
CLIENT_send_replays(player, this); CLIENT_send_replays(player, this);
} }
} }
ref4 = this.watchers; ref5 = this.watchers;
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player) { if (player) {
CLIENT_send_replays(player, this); CLIENT_send_replays(player, this);
} }
...@@ -2135,10 +2130,10 @@ ...@@ -2135,10 +2130,10 @@
roomlist.update(this); roomlist.update(this);
} }
client.server.connect(this.port, '127.0.0.1', function() { client.server.connect(this.port, '127.0.0.1', function() {
var buffer, len2, m, ref3; var buffer, len3, n, ref4;
ref3 = client.pre_establish_buffers; ref4 = client.pre_establish_buffers;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
buffer = ref3[m]; buffer = ref4[n];
client.server.write(buffer); client.server.write(buffer);
} }
client.established = true; client.established = true;
...@@ -2148,7 +2143,7 @@ ...@@ -2148,7 +2143,7 @@
} }
disconnect(client, error) { disconnect(client, error) {
var index, left_name, len2, len3, m, n, player, ref3, ref4; var index, left_name, len3, len4, n, o, player, ref4, ref5;
if (client.had_new_reconnection) { if (client.had_new_reconnection) {
return; return;
} }
...@@ -2164,18 +2159,18 @@ ...@@ -2164,18 +2159,18 @@
//log.info(client.name, @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN, @disconnector, @random_type, @players.length) //log.info(client.name, @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN, @disconnector, @random_type, @players.length)
if (this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && !this.arena_score_handled) { if (this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && !this.arena_score_handled) {
if (settings.modules.arena_mode.punish_quit_before_match && this.players.length === 2 && !client.arena_quit_free) { if (settings.modules.arena_mode.punish_quit_before_match && this.players.length === 2 && !client.arena_quit_free) {
ref3 = this.players; ref4 = this.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player.pos !== 7) { if (player.pos !== 7) {
this.scores[player.name_vpass] = 0; this.scores[player.name_vpass] = 0;
} }
} }
this.scores[client.name_vpass] = -9; this.scores[client.name_vpass] = -9;
} else { } else {
ref4 = this.players; ref5 = this.players;
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player.pos !== 7) { if (player.pos !== 7) {
this.scores[player.name_vpass] = -5; this.scores[player.name_vpass] = -5;
} }
...@@ -2300,23 +2295,23 @@ ...@@ -2300,23 +2295,23 @@
} }
finish_recover(fail) { finish_recover(fail) {
var buffer, len2, m, player, ref3, results; var buffer, len3, n, player, ref4, results;
if (fail) { if (fail) {
ygopro.stoc_send_chat_to_room(this, "${recover_fail}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(this, "${recover_fail}", ygopro.constants.COLORS.RED);
return this.termiate(); return this.termiate();
} else { } else {
ygopro.stoc_send_chat_to_room(this, "${recover_success}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(this, "${recover_success}", ygopro.constants.COLORS.BABYBLUE);
this.recovering = false; this.recovering = false;
ref3 = this.get_playing_player(); ref4 = this.get_playing_player();
results = []; results = [];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
results.push((function() { results.push((function() {
var len3, n, ref4, results1; var len4, o, ref5, results1;
ref4 = this.recover_buffers[player.pos]; ref5 = this.recover_buffers[player.pos];
results1 = []; results1 = [];
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
buffer = ref4[n]; buffer = ref5[o];
results1.push(ygopro.stoc_send(player, "GAME_MSG", buffer)); results1.push(ygopro.stoc_send(player, "GAME_MSG", buffer));
} }
return results1; return results1;
...@@ -2471,7 +2466,7 @@ ...@@ -2471,7 +2466,7 @@
// 客户端到服务端(ctos)协议分析 // 客户端到服务端(ctos)协议分析
client.pre_establish_buffers = new Array(); client.pre_establish_buffers = new Array();
client.on('data', function(ctos_buffer) { client.on('data', function(ctos_buffer) {
var b, bad_ip_count, buffer, cancel, ctos_event, ctos_message_length, ctos_proto, datas, info, len2, len3, len4, len5, looplimit, m, n, o, p, ref3, ref4, result, room, struct; var b, bad_ip_count, buffer, cancel, ctos_event, ctos_message_length, ctos_proto, datas, info, len3, len4, len5, len6, looplimit, n, o, p, q, ref4, ref5, result, room, struct;
if (client.is_post_watcher) { if (client.is_post_watcher) {
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (room && !CLIENT_is_banned_by_mc(client)) { if (room && !CLIENT_is_banned_by_mc(client)) {
...@@ -2516,9 +2511,9 @@ ...@@ -2516,9 +2511,9 @@
info = _.clone(struct.fields); info = _.clone(struct.fields);
} }
if (ygopro.ctos_follows_before[ctos_proto] && !cancel) { if (ygopro.ctos_follows_before[ctos_proto] && !cancel) {
ref3 = ygopro.ctos_follows_before[ctos_proto]; ref4 = ygopro.ctos_follows_before[ctos_proto];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
ctos_event = ref3[m]; ctos_event = ref4[n];
result = ctos_event.callback(b, info, client, client.server, datas); result = ctos_event.callback(b, info, client, client.server, datas);
if (result && ctos_event.synchronous) { if (result && ctos_event.synchronous) {
cancel = true; cancel = true;
...@@ -2540,9 +2535,9 @@ ...@@ -2540,9 +2535,9 @@
info = _.clone(struct.fields); info = _.clone(struct.fields);
} }
if (ygopro.ctos_follows_after[ctos_proto] && !cancel) { if (ygopro.ctos_follows_after[ctos_proto] && !cancel) {
ref4 = ygopro.ctos_follows_after[ctos_proto]; ref5 = ygopro.ctos_follows_after[ctos_proto];
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
ctos_event = ref4[n]; ctos_event = ref5[o];
result = ctos_event.callback(b, info, client, client.server, datas); result = ctos_event.callback(b, info, client, client.server, datas);
if (result && ctos_event.synchronous) { if (result && ctos_event.synchronous) {
cancel = true; cancel = true;
...@@ -2580,13 +2575,13 @@ ...@@ -2580,13 +2575,13 @@
return; return;
} }
if (client.established) { if (client.established) {
for (o = 0, len4 = datas.length; o < len4; o++) { for (p = 0, len5 = datas.length; p < len5; p++) {
buffer = datas[o]; buffer = datas[p];
client.server.write(buffer); client.server.write(buffer);
} }
} else { } else {
for (p = 0, len5 = datas.length; p < len5; p++) { for (q = 0, len6 = datas.length; q < len6; q++) {
buffer = datas[p]; buffer = datas[q];
client.pre_establish_buffers.push(buffer); client.pre_establish_buffers.push(buffer);
} }
} }
...@@ -2594,7 +2589,7 @@ ...@@ -2594,7 +2589,7 @@
}); });
// 服务端到客户端(stoc) // 服务端到客户端(stoc)
server.on('data', function(stoc_buffer) { server.on('data', function(stoc_buffer) {
var b, buffer, cancel, datas, info, len2, len3, len4, looplimit, m, n, o, ref3, ref4, result, stoc_event, stoc_message_length, stoc_proto, struct; var b, buffer, cancel, datas, info, len3, len4, len5, looplimit, n, o, p, ref4, ref5, result, stoc_event, stoc_message_length, stoc_proto, struct;
//stoc_buffer = Buffer.alloc(0) //stoc_buffer = Buffer.alloc(0)
stoc_message_length = 0; stoc_message_length = 0;
stoc_proto = 0; stoc_proto = 0;
...@@ -2633,9 +2628,9 @@ ...@@ -2633,9 +2628,9 @@
info = _.clone(struct.fields); info = _.clone(struct.fields);
} }
if (ygopro.stoc_follows_before[stoc_proto] && !cancel) { if (ygopro.stoc_follows_before[stoc_proto] && !cancel) {
ref3 = ygopro.stoc_follows_before[stoc_proto]; ref4 = ygopro.stoc_follows_before[stoc_proto];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
stoc_event = ref3[m]; stoc_event = ref4[n];
result = stoc_event.callback(b, info, server.client, server, datas); result = stoc_event.callback(b, info, server.client, server, datas);
if (result && stoc_event.synchronous) { if (result && stoc_event.synchronous) {
cancel = true; cancel = true;
...@@ -2657,9 +2652,9 @@ ...@@ -2657,9 +2652,9 @@
info = _.clone(struct.fields); info = _.clone(struct.fields);
} }
if (ygopro.stoc_follows_after[stoc_proto] && !cancel) { if (ygopro.stoc_follows_after[stoc_proto] && !cancel) {
ref4 = ygopro.stoc_follows_after[stoc_proto]; ref5 = ygopro.stoc_follows_after[stoc_proto];
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
stoc_event = ref4[n]; stoc_event = ref5[o];
result = stoc_event.callback(b, info, server.client, server, datas); result = stoc_event.callback(b, info, server.client, server, datas);
if (result && stoc_event.synchronous) { if (result && stoc_event.synchronous) {
cancel = true; cancel = true;
...@@ -2686,8 +2681,8 @@ ...@@ -2686,8 +2681,8 @@
} }
} }
if (server.client && !server.client.closed) { if (server.client && !server.client.closed) {
for (o = 0, len4 = datas.length; o < len4; o++) { for (p = 0, len5 = datas.length; p < len5; p++) {
buffer = datas[o]; buffer = datas[p];
server.client.write(buffer); server.client.write(buffer);
} }
} }
...@@ -2783,7 +2778,7 @@ ...@@ -2783,7 +2778,7 @@
}); });
ygopro.ctos_follow('JOIN_GAME', false, function(buffer, info, client, server, datas) { ygopro.ctos_follow('JOIN_GAME', false, function(buffer, info, client, server, datas) {
var available_logs, check_buffer_indentity, create_room_with_action, len2, len3, len4, len5, line, m, n, name, o, p, pre_room, ref3, ref4, ref5, ref6, replay_id, room; var available_logs, check_buffer_indentity, create_room_with_action, len3, len4, len5, len6, line, n, name, o, p, pre_room, q, recover_match, ref4, ref5, ref6, ref7, replay_id, room;
//log.info info //log.info info
info.pass = info.pass.trim(); info.pass = info.pass.trim();
client.pass = info.pass; client.pass = info.pass;
...@@ -2885,15 +2880,15 @@ ...@@ -2885,15 +2880,15 @@
return; return;
} }
check_buffer_indentity = function(buf) { check_buffer_indentity = function(buf) {
var checksum, i, m, ref3; var checksum, i, n, ref4;
checksum = 0; checksum = 0;
for (i = m = 0, ref3 = buf.length; (0 <= ref3 ? m < ref3 : m > ref3); i = 0 <= ref3 ? ++m : --m) { for (i = n = 0, ref4 = buf.length; (0 <= ref4 ? n < ref4 : n > ref4); i = 0 <= ref4 ? ++n : --n) {
checksum += buf.readUInt8(i); checksum += buf.readUInt8(i);
} }
return (checksum & 0xFF) === 0; return (checksum & 0xFF) === 0;
}; };
create_room_with_action = function(buffer, decrypted_buffer, match_permit) { create_room_with_action = function(buffer, decrypted_buffer, match_permit) {
var action, len2, len3, len4, len5, line, m, n, name, o, opt1, opt2, opt3, options, p, player, ref3, ref4, ref5, ref6, room, room_title, title; var action, len3, len4, len5, len6, line, n, name, o, opt1, opt2, opt3, options, p, player, q, ref4, ref5, ref6, ref7, room, room_title, title;
if (client.closed) { if (client.closed) {
return; return;
} }
...@@ -2982,9 +2977,9 @@ ...@@ -2982,9 +2977,9 @@
} }
room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8)); room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8));
if (room) { if (room) {
ref3 = room.get_playing_player(); ref4 = room.get_playing_player();
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (!(player && player.name === client.name)) { if (!(player && player.name === client.name)) {
continue; continue;
} }
...@@ -3021,24 +3016,24 @@ ...@@ -3021,24 +3016,24 @@
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true; client.is_post_watcher = true;
if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) { if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) {
ref4 = _.lines(vip_info.players[client.name].words); ref5 = _.lines(vip_info.players[client.name].words);
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
line = ref4[n]; line = ref5[o];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.words.enabled && words.words[client.name]) { } else if (settings.modules.words.enabled && words.words[client.name]) {
ref5 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]); ref6 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
for (o = 0, len4 = ref5.length; o < len4; o++) { for (p = 0, len5 = ref6.length; p < len5; p++) {
line = ref5[o]; line = ref6[p];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`); ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`);
room.watchers.push(client); room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref6 = room.watcher_buffers; ref7 = room.watcher_buffers;
for (p = 0, len5 = ref6.length; p < len5; p++) { for (q = 0, len6 = ref7.length; q < len6; q++) {
buffer = ref6[p]; buffer = ref7[q];
client.write(buffer); client.write(buffer);
} }
} else { } else {
...@@ -3085,7 +3080,7 @@ ...@@ -3085,7 +3080,7 @@
}); });
}, },
get_user: function(done) { get_user: function(done) {
var decrypted_buffer, i, id, len2, m, ref3, secret; var decrypted_buffer, i, id, len3, n, ref4, secret;
if (client.closed) { if (client.closed) {
done(); done();
return; return;
...@@ -3093,9 +3088,9 @@ ...@@ -3093,9 +3088,9 @@
if (id = users_cache[client.name]) { if (id = users_cache[client.name]) {
secret = id % 65535 + 1; secret = id % 65535 + 1;
decrypted_buffer = Buffer.allocUnsafe(6); decrypted_buffer = Buffer.allocUnsafe(6);
ref3 = [0, 2, 4]; ref4 = [0, 2, 4];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
i = ref3[m]; i = ref4[n];
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i); decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i);
} }
if (check_buffer_indentity(decrypted_buffer)) { if (check_buffer_indentity(decrypted_buffer)) {
...@@ -3117,14 +3112,14 @@ ...@@ -3117,14 +3112,14 @@
}, },
json: true json: true
}, function(error, response, body) { }, function(error, response, body) {
var len3, n, ref4; var len4, o, ref5;
if (!error && body && body.user) { if (!error && body && body.user) {
users_cache[client.name] = body.user.id; users_cache[client.name] = body.user.id;
secret = body.user.id % 65535 + 1; secret = body.user.id % 65535 + 1;
decrypted_buffer = Buffer.allocUnsafe(6); decrypted_buffer = Buffer.allocUnsafe(6);
ref4 = [0, 2, 4]; ref5 = [0, 2, 4];
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
i = ref4[n]; i = ref5[o];
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i); decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i);
} }
if (check_buffer_indentity(decrypted_buffer)) { if (check_buffer_indentity(decrypted_buffer)) {
...@@ -3165,14 +3160,15 @@ ...@@ -3165,14 +3160,15 @@
ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`); ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`);
room.watchers.push(client); room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref3 = room.watcher_buffers; ref4 = room.watcher_buffers;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
buffer = ref3[m]; buffer = ref4[n];
client.write(buffer); client.write(buffer);
} }
} else { } else {
ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE);
client.setTimeout(300000); //连接后超时5分钟 client.setTimeout(300000); //连接后超时5分钟
recover_match = info.pass.match(/^(RC|RECOVER)(\d*)T(\d*)$/);
_async.auto({ _async.auto({
participant_data: function(done) { participant_data: function(done) {
challonge.participants._index({ challonge.participants._index({
...@@ -3183,11 +3179,12 @@ ...@@ -3183,11 +3179,12 @@
match_data: function(done) { match_data: function(done) {
challonge.matches._index({ challonge.matches._index({
id: settings.modules.challonge.tournament_id, id: settings.modules.challonge.tournament_id,
callback: done callback: done,
no_cache: !!recover_match
}); });
} }
}, function(err, datas) { }, function(err, datas) {
var found, len3, len4, len5, len6, line, match, n, o, p, player, q, ref4, ref5, ref6, ref7, ref8, ref9, user; var create_room_name, found, len4, len5, len6, len7, line, match, o, p, player, q, r, ref10, ref5, ref6, ref7, ref8, ref9, user;
if (client.closed) { if (client.closed) {
return; return;
} }
...@@ -3197,9 +3194,9 @@ ...@@ -3197,9 +3194,9 @@
return; return;
} }
found = false; found = false;
ref4 = datas.participant_data; ref5 = datas.participant_data;
for (k in ref4) { for (k in ref5) {
user = ref4[k]; user = ref5[k];
if (user.participant && user.participant.name && deck_name_match(user.participant.name, client.name)) { if (user.participant && user.participant.name && deck_name_match(user.participant.name, client.name)) {
found = user.participant; found = user.participant;
break; break;
...@@ -3211,9 +3208,9 @@ ...@@ -3211,9 +3208,9 @@
} }
client.challonge_info = found; client.challonge_info = found;
found = false; found = false;
ref5 = datas.match_data; ref6 = datas.match_data;
for (k in ref5) { for (k in ref6) {
match = ref5[k]; match = ref6[k];
if (match && match.match && !match.match.winnerId && match.match.state !== "complete" && match.match.player1Id && match.match.player2Id && (match.match.player1Id === client.challonge_info.id || match.match.player2Id === client.challonge_info.id)) { if (match && match.match && !match.match.winnerId && match.match.state !== "complete" && match.match.player1Id && match.match.player2Id && (match.match.player1Id === client.challonge_info.id || match.match.player2Id === client.challonge_info.id)) {
found = match.match; found = match.match;
break; break;
...@@ -3226,7 +3223,11 @@ ...@@ -3226,7 +3223,11 @@
//if found.winnerId //if found.winnerId
// ygopro.stoc_die(client, '${challonge_match_already_finished}') // ygopro.stoc_die(client, '${challonge_match_already_finished}')
// return // return
room = ROOM_find_or_create_by_name('M#' + found.id); create_room_name = 'M#' + found.id;
if (recover_match) {
create_room_name = recover_match[0] + ',' + create_room_name;
}
room = ROOM_find_or_create_by_name(create_room_name);
if (room) { if (room) {
room.challonge_info = found; room.challonge_info = found;
// room.max_player = 2 // room.max_player = 2
...@@ -3242,24 +3243,24 @@ ...@@ -3242,24 +3243,24 @@
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true; client.is_post_watcher = true;
if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) { if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) {
ref6 = _.lines(vip_info.players[client.name].words); ref7 = _.lines(vip_info.players[client.name].words);
for (n = 0, len3 = ref6.length; n < len3; n++) { for (o = 0, len4 = ref7.length; o < len4; o++) {
line = ref6[n]; line = ref7[o];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.words.enabled && words.words[client.name]) { } else if (settings.modules.words.enabled && words.words[client.name]) {
ref7 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]); ref8 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
for (o = 0, len4 = ref7.length; o < len4; o++) { for (p = 0, len5 = ref8.length; p < len5; p++) {
line = ref7[o]; line = ref8[p];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`); ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`);
room.watchers.push(client); room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref8 = room.watcher_buffers; ref9 = room.watcher_buffers;
for (p = 0, len5 = ref8.length; p < len5; p++) { for (q = 0, len6 = ref9.length; q < len6; q++) {
buffer = ref8[p]; buffer = ref9[q];
client.write(buffer); client.write(buffer);
} }
} else { } else {
...@@ -3268,9 +3269,9 @@ ...@@ -3268,9 +3269,9 @@
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) { } else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}"); ygopro.stoc_die(client, "${watch_denied_room}");
} else { } else {
ref9 = room.get_playing_player(); ref10 = room.get_playing_player();
for (q = 0, len6 = ref9.length; q < len6; q++) { for (r = 0, len7 = ref10.length; r < len7; r++) {
player = ref9[q]; player = ref10[r];
if (!(player && player !== client && player.challonge_info.id === client.challonge_info.id)) { if (!(player && player !== client && player.challonge_info.id === client.challonge_info.id)) {
continue; continue;
} }
...@@ -3341,24 +3342,24 @@ ...@@ -3341,24 +3342,24 @@
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true; client.is_post_watcher = true;
if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) { if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) {
ref4 = _.lines(vip_info.players[client.name].words); ref5 = _.lines(vip_info.players[client.name].words);
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
line = ref4[n]; line = ref5[o];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.words.enabled && words.words[client.name]) { } else if (settings.modules.words.enabled && words.words[client.name]) {
ref5 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]); ref6 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
for (o = 0, len4 = ref5.length; o < len4; o++) { for (p = 0, len5 = ref6.length; p < len5; p++) {
line = ref5[o]; line = ref6[p];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`); ygopro.stoc_send_chat_to_room(room, `${client.name} \${watch_join}`);
room.watchers.push(client); room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref6 = room.watcher_buffers; ref7 = room.watcher_buffers;
for (p = 0, len5 = ref6.length; p < len5; p++) { for (q = 0, len6 = ref7.length; q < len6; q++) {
buffer = ref6[p]; buffer = ref7[q];
client.write(buffer); client.write(buffer);
} }
} else { } else {
...@@ -3375,7 +3376,7 @@ ...@@ -3375,7 +3376,7 @@
}); });
ygopro.stoc_follow('JOIN_GAME', false, function(buffer, info, client, server, datas) { ygopro.stoc_follow('JOIN_GAME', false, function(buffer, info, client, server, datas) {
var len2, len3, len4, line, m, n, o, player, recorder, ref3, ref4, ref5, room, watcher; var len3, len4, len5, line, n, o, p, player, recorder, ref4, ref5, ref6, room, watcher;
//欢迎信息 //欢迎信息
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && !client.reconnecting)) { if (!(room && !client.reconnecting)) {
...@@ -3385,15 +3386,15 @@ ...@@ -3385,15 +3386,15 @@
room.join_game_buffer = buffer; room.join_game_buffer = buffer;
} }
if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) { if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) {
ref3 = _.lines(vip_info.players[client.name].words); ref4 = _.lines(vip_info.players[client.name].words);
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
line = ref3[m]; line = ref4[n];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.words.enabled && words.words[client.name]) { } else if (settings.modules.words.enabled && words.words[client.name]) {
ref4 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]); ref5 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
line = ref4[n]; line = ref5[o];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
...@@ -3426,9 +3427,9 @@ ...@@ -3426,9 +3427,9 @@
//client.score_shown = true //client.score_shown = true
if (settings.modules.random_duel.record_match_scores && room.random_type === 'M') { if (settings.modules.random_duel.record_match_scores && room.random_type === 'M') {
ygopro.stoc_send_chat_to_room(room, ROOM_player_get_score(client), ygopro.constants.COLORS.GREEN); ygopro.stoc_send_chat_to_room(room, ROOM_player_get_score(client), ygopro.constants.COLORS.GREEN);
ref5 = room.players; ref6 = room.players;
for (o = 0, len4 = ref5.length; o < len4; o++) { for (p = 0, len5 = ref6.length; p < len5; p++) {
player = ref5[o]; player = ref6[p];
if (player.pos !== 7 && player !== client) { if (player.pos !== 7 && player !== client) {
ygopro.stoc_send_chat(client, ROOM_player_get_score(player), ygopro.constants.COLORS.GREEN); ygopro.stoc_send_chat(client, ROOM_player_get_score(player), ygopro.constants.COLORS.GREEN);
} }
...@@ -3466,15 +3467,15 @@ ...@@ -3466,15 +3467,15 @@
ygopro.ctos_send(watcher, 'HS_TOOBSERVER'); ygopro.ctos_send(watcher, 'HS_TOOBSERVER');
}); });
watcher.on('data', function(data) { watcher.on('data', function(data) {
var len5, p, ref6, w; var len6, q, ref7, w;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
} }
room.watcher_buffers.push(data); room.watcher_buffers.push(data);
ref6 = room.watchers; ref7 = room.watchers;
for (p = 0, len5 = ref6.length; p < len5; p++) { for (q = 0, len6 = ref7.length; q < len6; q++) {
w = ref6[p]; w = ref7[q];
if (w) { //a WTF fix if (w) { //a WTF fix
w.write(data); w.write(data);
} }
...@@ -3557,7 +3558,7 @@ ...@@ -3557,7 +3558,7 @@
} }
ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server, datas) { ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server, datas) {
var act_pos, card, chain, check, count, cpos, deck_found, found, hint_type, i, id, len10, len2, len3, len4, len5, len6, len7, len8, len9, limbo_found, line, loc, m, max_loop, msg, n, o, oppo_pos, p, phase, player, playertype, pos, ppos, q, r, r_player, reason, ref10, ref11, ref12, ref13, ref3, ref4, ref5, ref6, ref7, ref8, ref9, room, s, t, trigger_location, val, win_pos, x, y; var act_pos, card, chain, check, count, cpos, deck_found, found, hint_type, i, id, len10, len11, len3, len4, len5, len6, len7, len8, len9, limbo_found, line, loc, max_loop, msg, n, o, oppo_pos, p, phase, player, playertype, pos, ppos, q, r, r_player, reason, ref10, ref11, ref12, ref13, ref14, ref4, ref5, ref6, ref7, ref8, ref9, room, s, t, trigger_location, val, win_pos, x, y, z;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && !client.reconnecting)) { if (!(room && !client.reconnecting)) {
return; return;
...@@ -3717,9 +3718,9 @@ ...@@ -3717,9 +3718,9 @@
room.turn = 0; room.turn = 0;
room.duel_stage = ygopro.constants.DUEL_STAGE.END; room.duel_stage = ygopro.constants.DUEL_STAGE.END;
if (settings.modules.heartbeat_detection.enabled) { if (settings.modules.heartbeat_detection.enabled) {
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
player.heartbeat_protected = false; player.heartbeat_protected = false;
} }
delete room.long_resolve_card; delete room.long_resolve_card;
...@@ -3734,15 +3735,15 @@ ...@@ -3734,15 +3735,15 @@
room.scores[room.winner_name] = 99; room.scores[room.winner_name] = 99;
} }
if (settings.modules.vip.enabled && room.dueling_players[pos].vip && vip_info.players[room.dueling_players[pos].name].victory) { if (settings.modules.vip.enabled && room.dueling_players[pos].vip && vip_info.players[room.dueling_players[pos].name].victory) {
ref4 = _.lines(vip_info.players[room.dueling_players[pos].name].victory); ref5 = _.lines(vip_info.players[room.dueling_players[pos].name].victory);
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
line = ref4[n]; line = ref5[o];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} else if (room.hostinfo.mode === 2 && settings.modules.vip.enabled && room.dueling_players[pos + 1].vip && vip_info.players[room.dueling_players[pos + 1].name].victory) { } else if (room.hostinfo.mode === 2 && settings.modules.vip.enabled && room.dueling_players[pos + 1].vip && vip_info.players[room.dueling_players[pos + 1].name].victory) {
ref5 = _.lines(vip_info.players[room.dueling_players[pos + 1].name].victory); ref6 = _.lines(vip_info.players[room.dueling_players[pos + 1].name].victory);
for (o = 0, len4 = ref5.length; o < len4; o++) { for (p = 0, len5 = ref6.length; p < len5; p++) {
line = ref5[o]; line = ref6[p];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
} }
} }
...@@ -3772,7 +3773,7 @@ ...@@ -3772,7 +3773,7 @@
if (room.dueling_players[pos].lp < 0) { if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0; room.dueling_players[pos].lp = 0;
} }
if ((0 < (ref6 = room.dueling_players[pos].lp) && ref6 <= 100)) { if ((0 < (ref7 = room.dueling_players[pos].lp) && ref7 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK);
} }
} }
...@@ -3811,7 +3812,7 @@ ...@@ -3811,7 +3812,7 @@
if (room.dueling_players[pos].lp < 0) { if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0; room.dueling_players[pos].lp = 0;
} }
if ((0 < (ref7 = room.dueling_players[pos].lp) && ref7 <= 100)) { if ((0 < (ref8 = room.dueling_players[pos].lp) && ref8 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK);
} }
} }
...@@ -3852,7 +3853,7 @@ ...@@ -3852,7 +3853,7 @@
max_loop = 3 + (count - 1) * 7; max_loop = 3 + (count - 1) * 7;
deck_found = 0; deck_found = 0;
limbo_found = 0; // support custom cards which may be in location 0 in KoishiPro or EdoPro limbo_found = 0; // support custom cards which may be in location 0 in KoishiPro or EdoPro
for (i = p = 3, ref8 = max_loop; p <= ref8; i = p += 7) { for (i = q = 3, ref9 = max_loop; q <= ref9; i = q += 7) {
loc = buffer.readInt8(i + 5); loc = buffer.readInt8(i + 5);
if ((loc & 0x41) > 0) { if ((loc & 0x41) > 0) {
deck_found++; deck_found++;
...@@ -3874,8 +3875,8 @@ ...@@ -3874,8 +3875,8 @@
if (ygopro.constants.MSG[msg] === 'CHAINING') { if (ygopro.constants.MSG[msg] === 'CHAINING') {
card = buffer.readUInt32LE(1); card = buffer.readUInt32LE(1);
found = false; found = false;
for (q = 0, len5 = long_resolve_cards.length; q < len5; q++) { for (r = 0, len6 = long_resolve_cards.length; r < len6; r++) {
id = long_resolve_cards[q]; id = long_resolve_cards[r];
if (!(id === card)) { if (!(id === card)) {
continue; continue;
} }
...@@ -3900,9 +3901,9 @@ ...@@ -3900,9 +3901,9 @@
chain = buffer.readInt8(1); chain = buffer.readInt8(1);
// console.log(2,chain) // console.log(2,chain)
if (room.long_resolve_chain[chain]) { if (room.long_resolve_chain[chain]) {
ref9 = room.get_playing_player(); ref10 = room.get_playing_player();
for (r = 0, len6 = ref9.length; r < len6; r++) { for (s = 0, len7 = ref10.length; s < len7; s++) {
player = ref9[r]; player = ref10[s];
player.heartbeat_protected = true; player.heartbeat_protected = true;
} }
} }
...@@ -3930,29 +3931,29 @@ ...@@ -3930,29 +3931,29 @@
} }
if (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && client.ready_trap) { if (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && client.ready_trap) {
if (settings.modules.vip.enabled && room.dueling_players[act_pos].vip && vip_info.players[room.dueling_players[act_pos].name].dialogues[card]) { if (settings.modules.vip.enabled && room.dueling_players[act_pos].vip && vip_info.players[room.dueling_players[act_pos].name].dialogues[card]) {
ref10 = _.lines(vip_info.players[room.dueling_players[act_pos].name].dialogues[card]); ref11 = _.lines(vip_info.players[room.dueling_players[act_pos].name].dialogues[card]);
for (s = 0, len7 = ref10.length; s < len7; s++) {
line = ref10[s];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
}
} else if (settings.modules.vip.enabled && room.hostinfo.mode === 2 && room.dueling_players[act_pos + 1].vip && vip_info.players[room.dueling_players[act_pos + 1].name].dialogues[card]) {
ref11 = _.lines(vip_info.players[room.dueling_players[act_pos + 1].name].dialogues[card]);
for (t = 0, len8 = ref11.length; t < len8; t++) { for (t = 0, len8 = ref11.length; t < len8; t++) {
line = ref11[t]; line = ref11[t];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.dialogues.enabled && dialogues.dialogues[card]) { } else if (settings.modules.vip.enabled && room.hostinfo.mode === 2 && room.dueling_players[act_pos + 1].vip && vip_info.players[room.dueling_players[act_pos + 1].name].dialogues[card]) {
ref12 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]); ref12 = _.lines(vip_info.players[room.dueling_players[act_pos + 1].name].dialogues[card]);
for (x = 0, len9 = ref12.length; x < len9; x++) { for (x = 0, len9 = ref12.length; x < len9; x++) {
line = ref12[x]; line = ref12[x];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.dialogues.enabled && dialogues.dialogues_custom[card]) { } else if (settings.modules.dialogues.enabled && dialogues.dialogues[card]) {
ref13 = _.lines(dialogues.dialogues_custom[card][Math.floor(Math.random() * dialogues.dialogues_custom[card].length)]); ref13 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]);
for (y = 0, len10 = ref13.length; y < len10; y++) { for (y = 0, len10 = ref13.length; y < len10; y++) {
line = ref13[y]; line = ref13[y];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
} }
} else if (settings.modules.dialogues.enabled && dialogues.dialogues_custom[card]) {
ref14 = _.lines(dialogues.dialogues_custom[card][Math.floor(Math.random() * dialogues.dialogues_custom[card].length)]);
for (z = 0, len11 = ref14.length; z < len11; z++) {
line = ref14[z];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
}
} }
} }
} }
...@@ -3976,7 +3977,7 @@ ...@@ -3976,7 +3977,7 @@
//房间管理 //房间管理
ygopro.ctos_follow('HS_TOOBSERVER', true, function(buffer, info, client, server, datas) { ygopro.ctos_follow('HS_TOOBSERVER', true, function(buffer, info, client, server, datas) {
var len2, m, player, ref3, room; var len3, n, player, ref4, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
...@@ -3988,9 +3989,9 @@ ...@@ -3988,9 +3989,9 @@
if ((!room.arena && !settings.modules.challonge.enabled) || client.is_local) { if ((!room.arena && !settings.modules.challonge.enabled) || client.is_local) {
return false; return false;
} }
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player === client) { if (player === client) {
ygopro.stoc_send_chat(client, "${cannot_to_observer}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${cannot_to_observer}", ygopro.constants.COLORS.BABYBLUE);
return true; return true;
...@@ -4000,14 +4001,14 @@ ...@@ -4000,14 +4001,14 @@
}); });
ygopro.ctos_follow('HS_KICK', true, function(buffer, info, client, server, datas) { ygopro.ctos_follow('HS_KICK', true, function(buffer, info, client, server, datas) {
var len2, m, player, ref3, room; var len3, n, player, ref4, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
} }
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && player.pos === info.pos && player !== client) { if (player && player.pos === info.pos && player !== client) {
if (room.arena === "athletic" || settings.modules.challonge.enabled) { if (room.arena === "athletic" || settings.modules.challonge.enabled) {
ygopro.stoc_send_chat_to_room(room, `${client.name} \${kicked_by_system}`, ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, `${client.name} \${kicked_by_system}`, ygopro.constants.COLORS.RED);
...@@ -4057,7 +4058,7 @@ ...@@ -4057,7 +4058,7 @@
}); });
ygopro.stoc_follow('HS_PLAYER_CHANGE', false, function(buffer, info, client, server, datas) { ygopro.stoc_follow('HS_PLAYER_CHANGE', false, function(buffer, info, client, server, datas) {
var is_ready, len2, len3, m, n, p1, p2, player, pos, ref3, ref4, room; var is_ready, len3, len4, n, o, p1, p2, player, pos, ref4, ref5, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && room.max_player && client.is_host)) { if (!(room && room.max_player && client.is_host)) {
return; return;
...@@ -4067,9 +4068,9 @@ ...@@ -4067,9 +4068,9 @@
if (pos < room.max_player) { if (pos < room.max_player) {
if (room.arena) { if (room.arena) {
room.ready_player_count = 0; room.ready_player_count = 0;
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player.pos === pos) { if (player.pos === pos) {
player.is_ready = is_ready; player.is_ready = is_ready;
} }
...@@ -4107,9 +4108,9 @@ ...@@ -4107,9 +4108,9 @@
} }
} else { } else {
room.ready_player_count_without_host = 0; room.ready_player_count_without_host = 0;
ref4 = room.players; ref5 = room.players;
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player.pos === pos) { if (player.pos === pos) {
player.is_ready = is_ready; player.is_ready = is_ready;
} }
...@@ -4150,7 +4151,7 @@ ...@@ -4150,7 +4151,7 @@
}); });
ygopro.stoc_follow('DUEL_END', false, function(buffer, info, client, server, datas) { ygopro.stoc_follow('DUEL_END', false, function(buffer, info, client, server, datas) {
var len2, len3, m, n, player, ref3, ref4, results, room; var len3, len4, n, o, player, ref4, ref5, results, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && settings.modules.replay_delay && room.hostinfo.mode === 1)) { if (!(room && settings.modules.replay_delay && room.hostinfo.mode === 1)) {
return; return;
...@@ -4159,17 +4160,17 @@ ...@@ -4159,17 +4160,17 @@
CLIENT_send_replays(client, room); CLIENT_send_replays(client, room);
if (!room.replays_sent_to_watchers) { if (!room.replays_sent_to_watchers) {
room.replays_sent_to_watchers = true; room.replays_sent_to_watchers = true;
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && player.pos > 3) { if (player && player.pos > 3) {
CLIENT_send_replays(player, room); CLIENT_send_replays(player, room);
} }
} }
ref4 = room.watchers; ref5 = room.watchers;
results = []; results = [];
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player) { if (player) {
results.push(CLIENT_send_replays(player, room)); results.push(CLIENT_send_replays(player, room));
} }
...@@ -4179,7 +4180,7 @@ ...@@ -4179,7 +4180,7 @@
}); });
wait_room_start = function(room, time) { wait_room_start = function(room, time) {
var len2, m, player, ref3; var len3, n, player, ref4;
if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.ready_player_count_without_host >= room.max_player - 1) { if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.ready_player_count_without_host >= room.max_player - 1) {
time -= 1; time -= 1;
if (time) { if (time) {
...@@ -4190,9 +4191,9 @@ ...@@ -4190,9 +4191,9 @@
wait_room_start(room, time); wait_room_start(room, time);
}), 1000); }), 1000);
} else { } else {
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && player.is_host) { if (player && player.is_host) {
ROOM_ban_player(player.name, player.ip, "${random_ban_reason_zombie}"); ROOM_ban_player(player.name, player.ip, "${random_ban_reason_zombie}");
ygopro.stoc_send_chat_to_room(room, `${player.name} \${kicked_by_system}`, ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, `${player.name} \${kicked_by_system}`, ygopro.constants.COLORS.RED);
...@@ -4204,14 +4205,14 @@ ...@@ -4204,14 +4205,14 @@
}; };
wait_room_start_arena = function(room) { wait_room_start_arena = function(room) {
var display_name, len2, m, player, ref3; var display_name, len3, n, player, ref4;
if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.waiting_for_player) { if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.waiting_for_player) {
room.waiting_for_player_time = room.waiting_for_player_time - 1; room.waiting_for_player_time = room.waiting_for_player_time - 1;
if (room.waiting_for_player_time > 0) { if (room.waiting_for_player_time > 0) {
if (!(room.waiting_for_player_time % 5)) { if (!(room.waiting_for_player_time % 5)) {
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (!(player)) { if (!(player)) {
continue; continue;
} }
...@@ -4243,18 +4244,18 @@ ...@@ -4243,18 +4244,18 @@
}; };
ygopro.stoc_send_random_tip_to_room = function(room) { ygopro.stoc_send_random_tip_to_room = function(room) {
var len2, len3, m, n, player, ref3, ref4; var len3, len4, n, o, player, ref4, ref5;
if (settings.modules.tips.enabled && tips.tips.length) { if (settings.modules.tips.enabled && tips.tips.length) {
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && !player.is_local && !player.closed) { if (player && !player.is_local && !player.closed) {
ygopro.stoc_send_random_tip(player); ygopro.stoc_send_random_tip(player);
} }
} }
ref4 = room.watchers; ref5 = room.watchers;
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player && !player.is_local && !player.closed) { if (player && !player.is_local && !player.closed) {
ygopro.stoc_send_random_tip(player); ygopro.stoc_send_random_tip(player);
} }
...@@ -4310,9 +4311,9 @@ ...@@ -4310,9 +4311,9 @@
if (settings.modules.tips.enabled) { if (settings.modules.tips.enabled) {
setInterval(function() { setInterval(function() {
var len2, m, room; var len3, n, room;
for (m = 0, len2 = ROOM_all.length; m < len2; m++) { for (n = 0, len3 = ROOM_all.length; n < len3; n++) {
room = ROOM_all[m]; room = ROOM_all[n];
if (room && room.established) { if (room && room.established) {
if (room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING || room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING || room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
ygopro.stoc_send_random_tip_to_room(room); ygopro.stoc_send_random_tip_to_room(room);
...@@ -4323,7 +4324,7 @@ ...@@ -4323,7 +4324,7 @@
} }
ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server, datas) { ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server, datas) {
var deck_arena, deck_name, deck_text, len2, len3, m, n, player, ref3, ref4, room; var deck_arena, deck_name, deck_text, len3, len4, n, o, player, ref4, ref5, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && !client.reconnecting)) { if (!(room && !client.reconnecting)) {
return; return;
...@@ -4337,9 +4338,9 @@ ...@@ -4337,9 +4338,9 @@
} }
//room.duels = [] //room.duels = []
room.dueling_players = []; room.dueling_players = [];
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (!(player.pos !== 7)) { if (!(player.pos !== 7)) {
continue; continue;
} }
...@@ -4366,9 +4367,9 @@ ...@@ -4366,9 +4367,9 @@
} }
} }
if (settings.modules.hide_name && room.duel_count === 0) { if (settings.modules.hide_name && room.duel_count === 0) {
ref4 = room.get_playing_player(); ref5 = room.get_playing_player();
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
player = ref4[n]; player = ref5[o];
if (player !== client) { if (player !== client) {
ygopro.stoc_send(client, 'HS_PLAYER_ENTER', { ygopro.stoc_send(client, 'HS_PLAYER_ENTER', {
name: player.name, name: player.name,
...@@ -4488,7 +4489,7 @@ ...@@ -4488,7 +4489,7 @@
//else //else
//log.info 'BIG BROTHER OK', response.statusCode, roomname, body //log.info 'BIG BROTHER OK', response.statusCode, roomname, body
ygopro.ctos_follow('CHAT', true, function(buffer, info, client, server, datas) { ygopro.ctos_follow('CHAT', true, function(buffer, info, client, server, datas) {
var buy_result, cancel, ccolor, cip, cmd, cmsg, cname, code, color, cvalue, key, msg, name, oldmsg, ref3, room, struct, sur_player, uname, windbot, word; var buy_result, cancel, ccolor, cip, cmd, cmsg, cname, code, color, cvalue, key, msg, name, oldmsg, ref4, room, struct, sur_player, uname, windbot, word;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
...@@ -4587,9 +4588,9 @@ ...@@ -4587,9 +4588,9 @@
} else if (cmsg = cmd[1]) { } else if (cmsg = cmd[1]) {
if (cmsg.toLowerCase() === "help") { if (cmsg.toLowerCase() === "help") {
ygopro.stoc_send_chat(client, "${show_color_list}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${show_color_list}", ygopro.constants.COLORS.BABYBLUE);
ref3 = ygopro.constants.COLORS; ref4 = ygopro.constants.COLORS;
for (cname in ref3) { for (cname in ref4) {
cvalue = ref3[cname]; cvalue = ref4[cname];
if (cvalue > 10) { if (cvalue > 10) {
ygopro.stoc_send_chat(client, cname, cvalue); ygopro.stoc_send_chat(client, cname, cvalue);
} }
...@@ -4830,7 +4831,7 @@ ...@@ -4830,7 +4831,7 @@
}); });
ygopro.ctos_follow('UPDATE_DECK', true, function(buffer, info, client, server, datas) { ygopro.ctos_follow('UPDATE_DECK', true, function(buffer, info, client, server, datas) {
var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, len2, len3, line, m, n, oppo_pos, recover_player_data, room, struct, win_pos; var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, len3, len4, line, n, o, oppo_pos, recover_player_data, room, struct, win_pos;
if (settings.modules.reconnect.enabled && client.pre_reconnecting) { if (settings.modules.reconnect.enabled && client.pre_reconnecting) {
if (!CLIENT_is_able_to_reconnect(client) && !CLIENT_is_able_to_kick_reconnect(client)) { if (!CLIENT_is_able_to_reconnect(client) && !CLIENT_is_able_to_kick_reconnect(client)) {
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED);
...@@ -4861,17 +4862,17 @@ ...@@ -4861,17 +4862,17 @@
return true; return true;
} }
buff_main = (function() { buff_main = (function() {
var m, ref3, results; var n, ref4, results;
results = []; results = [];
for (i = m = 0, ref3 = info.mainc; (0 <= ref3 ? m < ref3 : m > ref3); i = 0 <= ref3 ? ++m : --m) { for (i = n = 0, ref4 = info.mainc; (0 <= ref4 ? n < ref4 : n > ref4); i = 0 <= ref4 ? ++n : --n) {
results.push(info.deckbuf[i]); results.push(info.deckbuf[i]);
} }
return results; return results;
})(); })();
buff_side = (function() { buff_side = (function() {
var m, ref3, ref4, results; var n, ref4, ref5, results;
results = []; results = [];
for (i = m = ref3 = info.mainc, ref4 = info.mainc + info.sidec; (ref3 <= ref4 ? m < ref4 : m > ref4); i = ref3 <= ref4 ? ++m : --m) { for (i = n = ref4 = info.mainc, ref5 = info.mainc + info.sidec; (ref4 <= ref5 ? n < ref5 : n > ref5); i = ref4 <= ref5 ? ++n : --n) {
results.push(info.deckbuf[i]); results.push(info.deckbuf[i]);
} }
return results; return results;
...@@ -4929,8 +4930,8 @@ ...@@ -4929,8 +4930,8 @@
buffer = struct.buffer; buffer = struct.buffer;
found_deck = false; found_deck = false;
decks = fs.readdirSync(settings.modules.tournament_mode.deck_path); decks = fs.readdirSync(settings.modules.tournament_mode.deck_path);
for (m = 0, len2 = decks.length; m < len2; m++) { for (n = 0, len3 = decks.length; n < len3; n++) {
deck = decks[m]; deck = decks[n];
if (deck_name_match(deck, client.name)) { if (deck_name_match(deck, client.name)) {
found_deck = deck; found_deck = deck;
} }
...@@ -4943,8 +4944,8 @@ ...@@ -4943,8 +4944,8 @@
deck_main = []; deck_main = [];
deck_side = []; deck_side = [];
current_deck = deck_main; current_deck = deck_main;
for (n = 0, len3 = deck_array.length; n < len3; n++) { for (o = 0, len4 = deck_array.length; o < len4; o++) {
line = deck_array[n]; line = deck_array[o];
if (line.indexOf("!side") >= 0) { if (line.indexOf("!side") >= 0) {
current_deck = deck_side; current_deck = deck_side;
} }
...@@ -5097,7 +5098,7 @@ ...@@ -5097,7 +5098,7 @@
}); });
ygopro.stoc_follow('CHAT', true, function(buffer, info, client, server, datas) { ygopro.stoc_follow('CHAT', true, function(buffer, info, client, server, datas) {
var len2, m, pid, player, ref3, room, tcolor, tplayer; var len3, n, pid, player, ref4, room, tcolor, tplayer;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
pid = info.player; pid = info.player;
if (!(room && pid < 4 && settings.modules.chat_color.enabled && (!settings.modules.hide_name || room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN))) { if (!(room && pid < 4 && settings.modules.chat_color.enabled && (!settings.modules.hide_name || room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN))) {
...@@ -5115,9 +5116,9 @@ ...@@ -5115,9 +5116,9 @@
pid = 1 - pid; pid = 1 - pid;
} }
} }
ref3 = room.players; ref4 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player && player.pos === pid) { if (player && player.pos === pid) {
tplayer = player; tplayer = player;
} }
...@@ -5255,10 +5256,10 @@ ...@@ -5255,10 +5256,10 @@
}); });
ygopro.stoc_follow('REPLAY', true, function(buffer, info, client, server, datas) { ygopro.stoc_follow('REPLAY', true, function(buffer, info, client, server, datas) {
var duellog, dueltime, i, len2, len3, m, n, player, ref3, ref4, replay_filename, room; var duellog, dueltime, i, len3, len4, n, o, player, ref4, ref5, replay_filename, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe && settings.modules.tournament_mode.block_replay_to_player || settings.modules.replay_delay; return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player || settings.modules.replay_delay;
} }
if (settings.modules.cloud_replay.enabled && room.random_type) { if (settings.modules.cloud_replay.enabled && room.random_type) {
Cloud_replay_ids.push(room.cloud_replay_id); Cloud_replay_ids.push(room.cloud_replay_id);
...@@ -5267,20 +5268,20 @@ ...@@ -5267,20 +5268,20 @@
// console.log("Replay saved: ", room.duel_count - 1, client.pos) // console.log("Replay saved: ", room.duel_count - 1, client.pos)
room.replays[room.duel_count - 1] = buffer; room.replays[room.duel_count - 1] = buffer;
} }
if (settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) { if (settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe || settings.modules.tournament_mode.enable_recover) {
if (client.pos === 0) { if (client.pos === 0) {
dueltime = moment().format('YYYY-MM-DD HH-mm-ss'); dueltime = moment().format('YYYY-MM-DD HH-mm-ss');
replay_filename = dueltime; replay_filename = dueltime;
if (room.hostinfo.mode !== 2) { if (room.hostinfo.mode !== 2) {
ref3 = room.dueling_players;
for (i = m = 0, len2 = ref3.length; m < len2; i = ++m) {
player = ref3[i];
replay_filename = replay_filename + (i > 0 ? " VS " : " ") + player.name;
}
} else {
ref4 = room.dueling_players; ref4 = room.dueling_players;
for (i = n = 0, len3 = ref4.length; n < len3; i = ++n) { for (i = n = 0, len3 = ref4.length; n < len3; i = ++n) {
player = ref4[i]; player = ref4[i];
replay_filename = replay_filename + (i > 0 ? " VS " : " ") + player.name;
}
} else {
ref5 = room.dueling_players;
for (i = o = 0, len4 = ref5.length; o < len4; i = ++o) {
player = ref5[i];
replay_filename = replay_filename + (i > 0 ? (i === 2 ? " VS " : " & ") : " ") + player.name; replay_filename = replay_filename + (i > 0 ? (i === 2 ? " VS " : " & ") : " ") + player.name;
} }
} }
...@@ -5294,11 +5295,11 @@ ...@@ -5294,11 +5295,11 @@
replay_filename: replay_filename, replay_filename: replay_filename,
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
players: (function() { players: (function() {
var len4, o, ref5, results; var len5, p, ref6, results;
ref5 = room.dueling_players; ref6 = room.dueling_players;
results = []; results = [];
for (o = 0, len4 = ref5.length; o < len4; o++) { for (p = 0, len5 = ref6.length; p < len5; p++) {
player = ref5[o]; player = ref6[p];
results.push({ results.push({
real_name: player.name_vpass, real_name: player.name_vpass,
deckbuf: player.start_deckbuf.toString("base64"), deckbuf: player.start_deckbuf.toString("base64"),
...@@ -5487,7 +5488,7 @@ ...@@ -5487,7 +5488,7 @@
return callback + "( " + text + " );"; return callback + "( " + text + " );";
}; };
requestListener = async function(request, response) { requestListener = async function(request, response) {
var archive_args, archive_name, archive_process, check, death_room_found, duellog, err, error, filename, getpath, key, len2, len3, m, n, parseQueryString, pass_validated, ref3, ref4, replay, ret_keys, roomsjson, tasks, u; var archive_args, archive_name, archive_process, check, death_room_found, duellog, err, error, filename, getpath, key, len3, len4, n, o, parseQueryString, pass_validated, ref4, ref5, replay, ret_keys, roomsjson, tasks, u;
parseQueryString = true; parseQueryString = true;
u = url.parse(request.url, parseQueryString); u = url.parse(request.url, parseQueryString);
//pass_validated = u.query.pass == settings.modules.http.password //pass_validated = u.query.pass == settings.modules.http.password
...@@ -5512,11 +5513,11 @@ ...@@ -5512,11 +5513,11 @@
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') !== -1).toString(), needpass: (room.name.indexOf('$') !== -1).toString(),
users: _.sortBy((function() { users: _.sortBy((function() {
var len2, m, ref3, results; var len3, n, ref4, results;
ref3 = room.players; ref4 = room.players;
results = []; results = [];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref3[m]; player = ref4[n];
if (player.pos != null) { if (player.pos != null) {
results.push({ results.push({
id: (-1).toString(), id: (-1).toString(),
...@@ -5565,9 +5566,9 @@ ...@@ -5565,9 +5566,9 @@
} else { } else {
response.writeHead(200); response.writeHead(200);
ret_keys = ""; ret_keys = "";
ref3 = vip_info.cdkeys[u.query.keytype]; ref4 = vip_info.cdkeys[u.query.keytype];
for (m = 0, len2 = ref3.length; m < len2; m++) { for (n = 0, len3 = ref4.length; n < len3; n++) {
key = ref3[m]; key = ref4[n];
ret_keys = ret_keys + u.query.keytype + "D" + settings.port + ":" + key + "\n"; ret_keys = ret_keys + u.query.keytype + "D" + settings.port + ":" + key + "\n";
} }
response.end(addCallback(u.query.callback, ret_keys)); response.end(addCallback(u.query.callback, ret_keys));
...@@ -5582,9 +5583,9 @@ ...@@ -5582,9 +5583,9 @@
archive_name = moment().format('YYYY-MM-DD HH-mm-ss') + ".zip"; archive_name = moment().format('YYYY-MM-DD HH-mm-ss') + ".zip";
archive_args = ["a", "-mx0", "-y", archive_name]; archive_args = ["a", "-mx0", "-y", archive_name];
check = false; check = false;
ref4 = duel_log.duel_log; ref5 = duel_log.duel_log;
for (n = 0, len3 = ref4.length; n < len3; n++) { for (o = 0, len4 = ref5.length; o < len4; o++) {
replay = ref4[n]; replay = ref5[o];
check = true; check = true;
archive_args.push(replay.replay_filename); archive_args.push(replay.replay_filename);
} }
...@@ -5904,8 +5905,8 @@ ...@@ -5904,8 +5905,8 @@
plugin_list = fs.readdirSync("./plugins"); plugin_list = fs.readdirSync("./plugins");
for (m = 0, len2 = plugin_list.length; m < len2; m++) { for (n = 0, len3 = plugin_list.length; n < len3; n++) {
plugin_filename = plugin_list[m]; plugin_filename = plugin_list[n];
plugin_path = process.cwd() + "/plugins/" + plugin_filename; plugin_path = process.cwd() + "/plugins/" + plugin_filename;
require(plugin_path); require(plugin_path);
log.info("Plugin loaded:", plugin_filename); log.info("Plugin loaded:", plugin_filename);
......
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