Commit a89f8033 authored by nanahira's avatar nanahira

Merge branch 'master' of https://github.com/moecube/srvpro into mc

parents fd8a5f21 bb5d4ce7
......@@ -163,10 +163,21 @@ catch
#settings.version = settings.version_default
log.info "ygopro version 0x"+settings.version.toString(16), "(from config)"
# load the lflist of current date
lflists = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
continue unless date
{date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), tcg: list.indexOf('TCG') != -1})
lflists = []
# expansions/lflist
try
for list in fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
continue unless date
lflists.push({date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), tcg: list.indexOf('TCG') != -1})
catch
# lflist
try
for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
continue unless date
lflists.push({date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), tcg: list.indexOf('TCG') != -1})
catch
if settings.modules.cloud_replay.enabled
redis = require 'redis'
......@@ -1758,7 +1769,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
client.abuse_count=client.abuse_count+2 if client.abuse_count
ygopro.stoc_send_chat(client, "${chat_warn_level0}", ygopro.constants.COLORS.RED)
cancel = true
if !(room and room.random_type)
if !(room and (room.random_type or room.arena))
return cancel
if client.abuse_count>=5
log.warn "BANNED CHAT", client.name, client.ip, msg
......
// Generated by CoffeeScript 1.12.7
(function() {
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, 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_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, badwords, ban_user, bunyan, chat_color, config, cppversion, crypto, date, default_config, default_data, dialogues, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, lflists, list, loadJSON, load_dialogues, load_tips, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, ygopro, zlib;
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, 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_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, badwords, ban_user, bunyan, chat_color, config, cppversion, crypto, date, default_config, default_data, dialogues, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, j, k, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, ygopro, zlib;
net = require('net');
......@@ -210,23 +210,41 @@
log.info("ygopro version 0x" + settings.version.toString(16), "(from config)");
}
lflists = (function() {
var j, len, ref, results;
ref = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g);
results = [];
lflists = [];
try {
ref = fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g);
for (j = 0, len = ref.length; j < len; j++) {
list = ref[j];
date = list.match(/!([\d\.]+)/);
if (!date) {
continue;
}
results.push({
lflists.push({
date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"),
tcg: list.indexOf('TCG') !== -1
});
}
return results;
})();
} catch (error1) {
}
try {
ref1 = fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g);
for (k = 0, len1 = ref1.length; k < len1; k++) {
list = ref1[k];
date = list.match(/!([\d\.]+)/);
if (!date) {
continue;
}
lflists.push({
date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"),
tcg: list.indexOf('TCG') !== -1
});
}
} catch (error1) {
}
if (settings.modules.cloud_replay.enabled) {
redis = require('redis');
......@@ -319,16 +337,16 @@
ROOM_bad_ip = {};
ban_user = function(name) {
var bad_ip, j, k, len, len1, player, ref, room;
var bad_ip, l, len2, len3, m, player, ref2, room;
settings.ban.banned_user.push(name);
setting_save(settings);
bad_ip = 0;
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (room && room.established) {
ref = room.players;
for (k = 0, len1 = ref.length; k < len1; k++) {
player = ref[k];
ref2 = room.players;
for (m = 0, len3 = ref2.length; m < len3; m++) {
player = ref2[m];
if (player && (player.name === name || player.ip === bad_ip)) {
bad_ip = player.ip;
ROOM_bad_ip[bad_ip] = 99;
......@@ -524,13 +542,13 @@
};
ROOM_unwelcome = function(room, bad_player, reason) {
var j, len, player, ref;
var l, len2, player, ref2;
if (!room) {
return;
}
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player && player === bad_player) {
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) {
......@@ -701,10 +719,10 @@
_this.port = parseInt(data);
_.each(_this.players, function(player) {
player.server.connect(_this.port, '127.0.0.1', function() {
var buffer, j, len, ref;
ref = player.pre_establish_buffers;
for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j];
var buffer, l, len2, ref2;
ref2 = player.pre_establish_buffers;
for (l = 0, len2 = ref2.length; l < len2; l++) {
buffer = ref2[l];
player.server.write(buffer);
}
player.established = true;
......@@ -737,14 +755,14 @@
}
Room.prototype["delete"] = function() {
var end_time, index, log_rep_id, name, player_ips, player_names, recorder_buffer, ref, replay_id, score, score_array;
var end_time, index, log_rep_id, name, player_ips, player_names, recorder_buffer, ref2, replay_id, score, score_array;
if (this.deleted) {
return;
}
score_array = [];
ref = this.scores;
for (name in ref) {
score = ref[name];
ref2 = this.scores;
for (name in ref2) {
score = ref2[name];
score_array.push({
name: name,
score: score
......@@ -886,10 +904,10 @@
roomlist.update(this);
}
client.server.connect(this.port, '127.0.0.1', function() {
var buffer, j, len, ref;
ref = client.pre_establish_buffers;
for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j];
var buffer, l, len2, ref2;
ref2 = client.pre_establish_buffers;
for (l = 0, len2 = ref2.length; l < len2; l++) {
buffer = ref2[l];
client.server.write(buffer);
}
client.established = true;
......@@ -899,7 +917,7 @@
};
Room.prototype.disconnect = function(client, error) {
var index, j, len, player, ref;
var index, l, len2, player, ref2;
if (client.is_post_watcher) {
ygopro.stoc_send_chat_to_room(this, (client.name + " ${quit_watch}") + (error ? ": " + error : ''));
index = _.indexOf(this.watchers, client);
......@@ -908,9 +926,9 @@
}
} else {
if (this.arena === "athletic" && !this.started && this.players.length === 2) {
ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = this.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player.pos !== 7) {
this.scores[player.name] = 0;
}
......@@ -1047,7 +1065,7 @@
}
client.pre_establish_buffers = new Array();
client.on('data', function(ctos_buffer) {
var b, bad_ip_count, buffer, cancel, ctos_message_length, ctos_proto, datas, info, j, k, len, len1, looplimit, room, struct;
var b, bad_ip_count, buffer, cancel, ctos_message_length, ctos_proto, datas, info, l, len2, len3, looplimit, m, room, struct;
if (client.is_post_watcher) {
room = ROOM_all[client.rid];
if (room) {
......@@ -1118,20 +1136,20 @@
}
}
if (client.established) {
for (j = 0, len = datas.length; j < len; j++) {
buffer = datas[j];
for (l = 0, len2 = datas.length; l < len2; l++) {
buffer = datas[l];
server.write(buffer);
}
} else {
for (k = 0, len1 = datas.length; k < len1; k++) {
buffer = datas[k];
for (m = 0, len3 = datas.length; m < len3; m++) {
buffer = datas[m];
client.pre_establish_buffers.push(buffer);
}
}
}
});
server.on('data', function(stoc_buffer) {
var b, buffer, cancel, datas, info, j, len, looplimit, stanzas, stoc_message_length, stoc_proto, struct;
var b, buffer, cancel, datas, info, l, len2, looplimit, stanzas, stoc_message_length, stoc_proto, struct;
stoc_message_length = 0;
stoc_proto = 0;
datas = [];
......@@ -1188,8 +1206,8 @@
break;
}
}
for (j = 0, len = datas.length; j < len; j++) {
buffer = datas[j];
for (l = 0, len2 = datas.length; l < len2; l++) {
buffer = datas[l];
client.write(buffer);
}
});
......@@ -1240,7 +1258,7 @@
});
ygopro.ctos_follow('JOIN_GAME', false, function(buffer, info, client, server) {
var check, decrypted_buffer, finish, i, id, j, k, len, len1, name, ref, ref1, replay_id, room, secret;
var check, decrypted_buffer, finish, i, id, l, len2, len3, m, name, ref2, ref3, replay_id, room, secret;
info.pass = info.pass.trim();
if (settings.modules.stop) {
ygopro.stoc_die(client, settings.modules.stop);
......@@ -1308,15 +1326,15 @@
return;
}
check = function(buf) {
var checksum, i, j, ref;
var checksum, i, l, ref2;
checksum = 0;
for (i = j = 0, ref = buf.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
for (i = l = 0, ref2 = buf.length; 0 <= ref2 ? l < ref2 : l > ref2; i = 0 <= ref2 ? ++l : --l) {
checksum += buf.readUInt8(i);
}
return (checksum & 0xFF) === 0;
};
finish = function(buffer) {
var action, j, len, name, opt1, opt2, opt3, options, ref, room, title;
var action, l, len2, name, opt1, opt2, opt3, options, ref2, room, title;
action = buffer.readUInt8(1) >> 4;
if (buffer !== decrypted_buffer && (action === 1 || action === 2 || action === 4)) {
ygopro.stoc_die(client, '${invalid_password_unauthorized}');
......@@ -1393,9 +1411,9 @@
ygopro.stoc_send_chat_to_room(room, client.name + " ${watch_join}");
room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref = room.watcher_buffers;
for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j];
ref2 = room.watcher_buffers;
for (l = 0, len2 = ref2.length; l < len2; l++) {
buffer = ref2[l];
client.write(buffer);
}
} else {
......@@ -1410,9 +1428,9 @@
if (id = users_cache[client.name]) {
secret = id % 65535 + 1;
decrypted_buffer = new Buffer(6);
ref = [0, 2, 4];
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
ref2 = [0, 2, 4];
for (l = 0, len2 = ref2.length; l < len2; l++) {
i = ref2[l];
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i);
}
if (check(decrypted_buffer)) {
......@@ -1429,14 +1447,14 @@
},
json: true
}, function(error, response, body) {
var k, len1, ref1;
var len3, m, ref3;
if (body && body.user) {
users_cache[client.name] = body.user.id;
secret = body.user.id % 65535 + 1;
decrypted_buffer = new Buffer(6);
ref1 = [0, 2, 4];
for (k = 0, len1 = ref1.length; k < len1; k++) {
i = ref1[k];
ref3 = [0, 2, 4];
for (m = 0, len3 = ref3.length; m < len3; m++) {
i = ref3[m];
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i);
}
if (check(decrypted_buffer)) {
......@@ -1499,9 +1517,9 @@
ygopro.stoc_send_chat_to_room(room, client.name + " ${watch_join}");
room.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref1 = room.watcher_buffers;
for (k = 0, len1 = ref1.length; k < len1; k++) {
buffer = ref1[k];
ref3 = room.watcher_buffers;
for (m = 0, len3 = ref3.length; m < len3; m++) {
buffer = ref3[m];
client.write(buffer);
}
} else {
......@@ -1575,15 +1593,15 @@
ygopro.ctos_send(watcher, 'HS_TOOBSERVER');
});
watcher.on('data', function(data) {
var j, len, ref, w;
var l, len2, ref2, w;
room = ROOM_all[client.rid];
if (!room) {
return;
}
room.watcher_buffers.push(data);
ref = room.watchers;
for (j = 0, len = ref.length; j < len; j++) {
w = ref[j];
ref2 = room.watchers;
for (l = 0, len2 = ref2.length; l < len2; l++) {
w = ref2[l];
if (w) {
w.write(data);
}
......@@ -1614,7 +1632,7 @@
}
ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) {
var card, j, len, line, msg, playertype, pos, reason, ref, ref1, ref2, room, trigger_location, val, win_pos;
var card, l, len2, line, msg, playertype, pos, reason, ref2, ref3, ref4, room, trigger_location, val, win_pos;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -1699,7 +1717,7 @@
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref = room.dueling_players[pos].lp) && ref <= 100)) {
if ((0 < (ref2 = room.dueling_players[pos].lp) && ref2 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK);
}
}
......@@ -1738,7 +1756,7 @@
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref1 = room.dueling_players[pos].lp) && ref1 <= 100)) {
if ((0 < (ref3 = room.dueling_players[pos].lp) && ref3 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK);
}
}
......@@ -1747,9 +1765,9 @@
card = buffer.readUInt32LE(1);
trigger_location = buffer.readUInt8(6);
if (dialogues.dialogues[card] && (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && !(trigger_location & 0x200))) {
ref2 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]);
for (j = 0, len = ref2.length; j < len; j++) {
line = ref2[j];
ref4 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]);
for (l = 0, len2 = ref4.length; l < len2; l++) {
line = ref4[l];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
}
}
......@@ -1758,7 +1776,7 @@
});
ygopro.ctos_follow('HS_TOOBSERVER', true, function(buffer, info, client, server) {
var j, len, player, ref, room;
var l, len2, player, ref2, room;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -1766,9 +1784,9 @@
if (!room.arena || client.is_local) {
return false;
}
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player === client) {
ygopro.stoc_send_chat(client, "${cannot_to_observer}", ygopro.constants.COLORS.BABYBLUE);
return true;
......@@ -1778,14 +1796,14 @@
});
ygopro.ctos_follow('HS_KICK', true, function(buffer, info, client, server) {
var j, len, player, ref, room;
var l, len2, player, ref2, room;
room = ROOM_all[client.rid];
if (!room) {
return;
}
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player && player.pos === info.pos && player !== client) {
if (room.arena === "athletic") {
ygopro.stoc_send_chat_to_room(room, client.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
......@@ -1814,7 +1832,7 @@
});
ygopro.stoc_follow('HS_PLAYER_CHANGE', false, function(buffer, info, client, server) {
var is_ready, j, k, len, len1, p1, p2, player, pos, ref, ref1, room;
var is_ready, l, len2, len3, m, p1, p2, player, pos, ref2, ref3, room;
room = ROOM_all[client.rid];
if (!(room && room.max_player && client.is_host)) {
return;
......@@ -1824,9 +1842,9 @@
if (pos < room.max_player) {
if (room.arena) {
room.ready_player_count = 0;
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player.pos === pos) {
player.is_ready = is_ready;
}
......@@ -1864,9 +1882,9 @@
}
} else {
room.ready_player_count_without_host = 0;
ref1 = room.players;
for (k = 0, len1 = ref1.length; k < len1; k++) {
player = ref1[k];
ref3 = room.players;
for (m = 0, len3 = ref3.length; m < len3; m++) {
player = ref3[m];
if (player.pos === pos) {
player.is_ready = is_ready;
}
......@@ -1884,7 +1902,7 @@
});
wait_room_start = function(room, time) {
var j, len, player, ref;
var l, len2, player, ref2;
if (!(!room || room.started || room.ready_player_count_without_host < room.max_player - 1)) {
time -= 1;
if (time) {
......@@ -1895,9 +1913,9 @@
wait_room_start(room, time);
}), 1000);
} else {
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player && player.is_host) {
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);
......@@ -1957,9 +1975,9 @@
if (settings.modules.tips.get) {
load_tips();
setInterval(function() {
var j, len, room;
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
var l, len2, room;
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (room && room.established) {
if (!room.started || room.changing_side) {
ygopro.stoc_send_random_tip_to_room(room);
......@@ -1970,7 +1988,7 @@
}
ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) {
var deck_arena, deck_name, deck_text, j, len, player, ref, room;
var deck_arena, deck_name, deck_text, l, len2, player, ref2, room;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -1982,9 +2000,9 @@
roomlist.start(room);
}
room.dueling_players = [];
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (!(player.pos !== 7)) {
continue;
}
......@@ -2090,7 +2108,7 @@
};
ygopro.ctos_follow('CHAT', true, function(buffer, info, client, server) {
var cancel, ccolor, cip, cmd, cmsg, cname, color, cvalue, msg, name, oldmsg, ref, room, struct, windbot;
var cancel, ccolor, cip, cmd, cmsg, cname, color, cvalue, msg, name, oldmsg, ref2, room, struct, windbot;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -2169,9 +2187,9 @@
if (cmsg = cmd[1]) {
if (cmsg.toLowerCase() === "help") {
ygopro.stoc_send_chat(client, "${show_color_list}", ygopro.constants.COLORS.BABYBLUE);
ref = ygopro.constants.COLORS;
for (cname in ref) {
cvalue = ref[cname];
ref2 = ygopro.constants.COLORS;
for (cname in ref2) {
cvalue = ref2[cname];
if (cvalue > 10) {
ygopro.stoc_send_chat(client, cname, cvalue);
}
......@@ -2207,7 +2225,7 @@
ygopro.stoc_send_chat(client, "${chat_warn_level0}", ygopro.constants.COLORS.RED);
cancel = true;
}
if (!(room && room.random_type)) {
if (!(room && (room.random_type || room.arena))) {
return cancel;
}
if (client.abuse_count >= 5) {
......@@ -2290,23 +2308,23 @@
});
ygopro.ctos_follow('UPDATE_DECK', true, function(buffer, info, client, server) {
var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, j, k, len, len1, line, 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, l, len2, len3, line, m, room, struct, win_pos;
room = ROOM_all[client.rid];
if (!room) {
return false;
}
buff_main = (function() {
var j, ref, results;
var l, ref2, results;
results = [];
for (i = j = 0, ref = info.mainc; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
for (i = l = 0, ref2 = info.mainc; 0 <= ref2 ? l < ref2 : l > ref2; i = 0 <= ref2 ? ++l : --l) {
results.push(info.deckbuf[i]);
}
return results;
})();
buff_side = (function() {
var j, ref, ref1, results;
var l, ref2, ref3, results;
results = [];
for (i = j = ref = info.mainc, ref1 = info.mainc + info.sidec; ref <= ref1 ? j < ref1 : j > ref1; i = ref <= ref1 ? ++j : --j) {
for (i = l = ref2 = info.mainc, ref3 = info.mainc + info.sidec; ref2 <= ref3 ? l < ref3 : l > ref3; i = ref2 <= ref3 ? ++l : --l) {
results.push(info.deckbuf[i]);
}
return results;
......@@ -2338,8 +2356,8 @@
buffer = struct.buffer;
found_deck = false;
decks = fs.readdirSync(settings.modules.tournament_mode.deck_path);
for (j = 0, len = decks.length; j < len; j++) {
deck = decks[j];
for (l = 0, len2 = decks.length; l < len2; l++) {
deck = decks[l];
if (_.endsWith(deck, client.name + ".ydk")) {
found_deck = deck;
}
......@@ -2355,8 +2373,8 @@
deck_main = [];
deck_side = [];
current_deck = deck_main;
for (k = 0, len1 = deck_array.length; k < len1; k++) {
line = deck_array[k];
for (m = 0, len3 = deck_array.length; m < len3; m++) {
line = deck_array[m];
if (line.indexOf("!side") >= 0) {
current_deck = deck_side;
}
......@@ -2413,7 +2431,7 @@
});
ygopro.stoc_follow('CHAT', true, function(buffer, info, client, server) {
var j, len, pid, player, ref, room, tcolor, tplayer;
var l, len2, pid, player, ref2, room, tcolor, tplayer;
room = ROOM_all[client.rid];
pid = info.player;
if (!(room && pid < 4 && settings.modules.chat_color.enabled)) {
......@@ -2431,9 +2449,9 @@
pid = 1 - pid;
}
}
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
ref2 = room.players;
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
if (player && player.pos === pid) {
tplayer = player;
}
......@@ -2516,7 +2534,7 @@
});
ygopro.stoc_follow('REPLAY', true, function(buffer, info, client, server) {
var duellog, dueltime, i, j, k, len, len1, player, ref, ref1, replay_filename, room;
var duellog, dueltime, i, l, len2, len3, m, player, ref2, ref3, replay_filename, room;
room = ROOM_all[client.rid];
if (!room) {
return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe;
......@@ -2529,15 +2547,15 @@
dueltime = moment().format('YYYY-MM-DD HH:mm:ss');
replay_filename = dueltime;
if (room.hostinfo.mode !== 2) {
ref = room.dueling_players;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
player = ref[i];
ref2 = room.dueling_players;
for (i = l = 0, len2 = ref2.length; l < len2; i = ++l) {
player = ref2[i];
replay_filename = replay_filename + (i > 0 ? " VS " : " ") + player.name;
}
} else {
ref1 = room.dueling_players;
for (i = k = 0, len1 = ref1.length; k < len1; i = ++k) {
player = ref1[i];
ref3 = room.dueling_players;
for (i = m = 0, len3 = ref3.length; m < len3; i = ++m) {
player = ref3[i];
replay_filename = replay_filename + (i > 0 ? (i === 2 ? " VS " : " & ") : " ") + player.name;
}
}
......@@ -2550,11 +2568,11 @@
replay_filename: replay_filename,
roommode: room.hostinfo.mode,
players: (function() {
var l, len2, ref2, results;
ref2 = room.dueling_players;
var len4, n, ref4, results;
ref4 = room.dueling_players;
results = [];
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
for (n = 0, len4 = ref4.length; n < len4; n++) {
player = ref4[n];
results.push({
name: player.name + (settings.modules.tournament_mode.show_ip && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.tournament_mode.show_info && !(room.hostinfo.mode === 2 && player.pos % 2 > 0) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
winner: player.pos === room.winner
......@@ -2582,9 +2600,9 @@
if (settings.modules.random_duel.enabled) {
setInterval(function() {
var j, len, room, time_passed;
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
var l, len2, room, time_passed;
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (!(room && room.started && room.random_type && room.last_active_time && room.waiting_for_player)) {
continue;
}
......@@ -2604,9 +2622,9 @@
if (settings.modules.mycard.enabled) {
setInterval(function() {
var j, len, room, time_passed;
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
var l, len2, room, time_passed;
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (!(room && room.started && room.arena && room.last_active_time && room.waiting_for_player)) {
continue;
}
......@@ -2660,7 +2678,7 @@
return callback + "( " + text + " );";
};
requestListener = function(request, response) {
var archive_args, archive_name, archive_process, check, death_room_found, duellog, error, filename, getpath, j, k, l, len, len1, len2, len3, m, parseQueryString, pass_validated, player, ref, replay, room, roomsjson, u, win_pos;
var archive_args, archive_name, archive_process, check, death_room_found, duellog, error, filename, getpath, l, len2, len3, len4, len5, m, n, o, parseQueryString, pass_validated, player, ref2, replay, room, roomsjson, u, win_pos;
parseQueryString = true;
u = url.parse(request.url, parseQueryString);
pass_validated = u.query.pass === settings.modules.http.password;
......@@ -2672,10 +2690,10 @@
response.writeHead(200);
roomsjson = JSON.stringify({
rooms: (function() {
var j, len, results;
var l, len2, results;
results = [];
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (room && room.established) {
results.push({
pid: room.process.pid.toString(),
......@@ -2684,11 +2702,11 @@
roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') !== -1).toString(),
users: (function() {
var k, len1, ref, results1;
ref = room.players;
var len3, m, ref2, results1;
ref2 = room.players;
results1 = [];
for (k = 0, len1 = ref.length; k < len1; k++) {
player = ref[k];
for (m = 0, len3 = ref2.length; m < len3; m++) {
player = ref2[m];
if (player.pos != null) {
results1.push({
id: (-1).toString(),
......@@ -2728,9 +2746,9 @@
archive_name = moment().format('YYYY-MM-DD HH:mm:ss') + ".zip";
archive_args = ["a", "-mx0", "-y", archive_name];
check = false;
ref = duel_log.duel_log;
for (j = 0, len = ref.length; j < len; j++) {
replay = ref[j];
ref2 = duel_log.duel_log;
for (l = 0, len2 = ref2.length; l < len2; l++) {
replay = ref2[l];
check = true;
archive_args.push(replay.replay_filename);
}
......@@ -2828,8 +2846,8 @@
return;
}
if (u.query.shout) {
for (k = 0, len1 = ROOM_all.length; k < len1; k++) {
room = ROOM_all[k];
for (m = 0, len3 = ROOM_all.length; m < len3; m++) {
room = ROOM_all[m];
if (room && room.established) {
ygopro.stoc_send_chat_to_room(room, u.query.shout, ygopro.constants.COLORS.YELLOW);
}
......@@ -2864,8 +2882,8 @@
response.end(addCallback(u.query.callback, "['ban ok', '" + u.query.ban + "']"));
} else if (u.query.death) {
death_room_found = false;
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
for (n = 0, len4 = ROOM_all.length; n < len4; n++) {
room = ROOM_all[n];
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.port.toString()) && room.hostinfo.mode !== 2)) {
continue;
}
......@@ -2903,8 +2921,8 @@
}
} else if (u.query.deathcancel) {
death_room_found = false;
for (m = 0, len3 = ROOM_all.length; m < len3; m++) {
room = ROOM_all[m];
for (o = 0, len5 = ROOM_all.length; o < len5; o++) {
room = ROOM_all[o];
if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.port.toString()))) {
continue;
}
......
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