Commit 0ad19f16 authored by nanahira's avatar nanahira

add hide_name and disable_chat

parent bd64c628
Pipeline #29616 passed with stages
in 15 minutes
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
"record_match_scores": false, "record_match_scores": false,
"post_match_scores": false, "post_match_scores": false,
"post_match_accesskey": "123456", "post_match_accesskey": "123456",
"disable_chat": false,
"blank_pass_modes": { "blank_pass_modes": {
"S": true, "S": true,
"M": true, "M": true,
......
...@@ -178,6 +178,7 @@ ...@@ -178,6 +178,7 @@
"refresh_failed": "Refresh field failed.", "refresh_failed": "Refresh field failed.",
"banned_athletic_deck_part1": "Entertainment Mode does not allow top ", "banned_athletic_deck_part1": "Entertainment Mode does not allow top ",
"banned_athletic_deck_part2": " popular meta decks. Please change your deck.", "banned_athletic_deck_part2": " popular meta decks. Please change your deck.",
"chat_disabled": "Chat is disabled in this room.",
"using_athletic_deck": " is using a competitive deck." "using_athletic_deck": " is using a competitive deck."
}, },
"es-es": { "es-es": {
...@@ -505,6 +506,7 @@ ...@@ -505,6 +506,7 @@
"refresh_fail": "刷新场面失败。", "refresh_fail": "刷新场面失败。",
"banned_athletic_deck_part1": "娱乐匹配中禁止使用使用数前", "banned_athletic_deck_part1": "娱乐匹配中禁止使用使用数前",
"banned_athletic_deck_part2": "的竞技卡组。请更换卡组。", "banned_athletic_deck_part2": "的竞技卡组。请更换卡组。",
"chat_disabled": "本房间禁止聊天。",
"using_athletic_deck": " 正在使用竞技卡组。" "using_athletic_deck": " 正在使用竞技卡组。"
}, },
"ko-kr": { "ko-kr": {
......
...@@ -314,6 +314,9 @@ init = () -> ...@@ -314,6 +314,9 @@ init = () ->
settings.modules.random_duel.blank_pass_modes = {"S":true,"M":false,"T":false} settings.modules.random_duel.blank_pass_modes = {"S":true,"M":false,"T":false}
delete settings.modules.random_duel.blank_pass_match delete settings.modules.random_duel.blank_pass_match
imported = true imported = true
if settings.modules.hide_name == true
settings.modules.hide_name = "start"
imported = true
#finish #finish
keysFromEnv = Object.keys(process.env).filter((key) => key.startsWith('SRVPRO_')) keysFromEnv = Object.keys(process.env).filter((key) => key.startsWith('SRVPRO_'))
if keysFromEnv.length > 0 if keysFromEnv.length > 0
...@@ -1660,7 +1663,7 @@ class Room ...@@ -1660,7 +1663,7 @@ class Room
if settings.modules.random_duel.record_match_scores and @random_type == 'M' if settings.modules.random_duel.record_match_scores and @random_type == 'M'
ROOM_player_flee(client.name_vpass) ROOM_player_flee(client.name_vpass)
if @players.length and !(@windbot and client.is_host) and !(@arena and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and client.pos <= 3) if @players.length and !(@windbot and client.is_host) and !(@arena and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and client.pos <= 3)
left_name = (if settings.modules.hide_name and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN then "********" else client.name) left_name = @getMaskedPlayerName(client)
ygopro.stoc_send_chat_to_room this, "#{left_name} ${left_game}" + if error then ": #{error}" else '' ygopro.stoc_send_chat_to_room this, "#{left_name} ${left_game}" + if error then ": #{error}" else ''
roomlist.update(this) if !@windbot and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.http.websocket_roomlist roomlist.update(this) if !@windbot and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.http.websocket_roomlist
#client.room = null #client.room = null
...@@ -1670,7 +1673,7 @@ class Room ...@@ -1670,7 +1673,7 @@ class Room
#client.room = null #client.room = null
this.delete() this.delete()
if !CLIENT_reconnect_unregister(client, false, true) if !CLIENT_reconnect_unregister(client, false, true)
SERVER_kick(client.server) SERVER_kick(client.server)
return return
start_death: () -> start_death: () ->
...@@ -1816,6 +1819,15 @@ class Room ...@@ -1816,6 +1819,15 @@ class Room
@watcher_buffers.push chat_buf @watcher_buffers.push chat_buf
return return
getMaskedPlayerName(player, sight_player) ->
if not settings.modules.hide_name or (sight_player and player == sight_player) or not (@random_type or @arena)
return player.name
if @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.hide_name == "start"
return "********"
if settings.modules.hide_name == "always"
return "********"
return player.name
# 网络连接 # 网络连接
netRequestHandler = (client) -> netRequestHandler = (client) ->
if !client.isWs if !client.isWs
...@@ -2815,13 +2827,13 @@ ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)-> ...@@ -2815,13 +2827,13 @@ ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'HS_PLAYER_ENTER', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'HS_PLAYER_ENTER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return false unless room and settings.modules.hide_name and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN if room and settings.modules.hide_name and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
pos = info.pos pos = info.pos
if pos < 4 and pos != client.pos if pos < 4 and pos != client.pos
struct = ygopro.structs.get("STOC_HS_PlayerEnter") struct = ygopro.structs.get("STOC_HS_PlayerEnter")
struct._setBuff(buffer) struct._setBuff(buffer)
struct.set("name", "********") struct.set("name", "********")
buffer = struct.buffer buffer = struct.buffer
await return false await return false
ygopro.stoc_follow 'HS_PLAYER_CHANGE', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'HS_PLAYER_CHANGE', true, (buffer, info, client, server, datas)->
...@@ -2924,7 +2936,7 @@ wait_room_start_arena = (room)-> ...@@ -2924,7 +2936,7 @@ wait_room_start_arena = (room)->
if room.waiting_for_player_time > 0 if room.waiting_for_player_time > 0
unless room.waiting_for_player_time % 5 unless room.waiting_for_player_time % 5
for player in room.players when player for player in room.players when player
display_name = (if settings.modules.hide_name and player != room.waiting_for_player then "********" else room.waiting_for_player.name) display_name = room.getMaskedPlayerName(player, room.waiting_for_player)
ygopro.stoc_send_chat(player, "#{if room.waiting_for_player_time <= 9 then ' ' else ''}#{room.waiting_for_player_time}${kick_count_down_arena_part1} #{display_name} ${kick_count_down_arena_part2}", if room.waiting_for_player_time <= 9 then ygopro.constants.COLORS.RED else ygopro.constants.COLORS.LIGHTBLUE) ygopro.stoc_send_chat(player, "#{if room.waiting_for_player_time <= 9 then ' ' else ''}#{room.waiting_for_player_time}${kick_count_down_arena_part1} #{display_name} ${kick_count_down_arena_part2}", if room.waiting_for_player_time <= 9 then ygopro.constants.COLORS.RED else ygopro.constants.COLORS.LIGHTBLUE)
else else
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
...@@ -2990,7 +3002,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)-> ...@@ -2990,7 +3002,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
clearInterval client.side_interval clearInterval client.side_interval
client.side_interval = null client.side_interval = null
client.side_tcount = null client.side_tcount = null
if settings.modules.hide_name and room.duel_count == 0 if settings.modules.hide_name == "start" and room.duel_count == 0
for player in room.get_playing_player() when player != client for player in room.get_playing_player() when player != client
ygopro.stoc_send(client, 'HS_PLAYER_ENTER', { ygopro.stoc_send(client, 'HS_PLAYER_ENTER', {
name: player.name, name: player.name,
...@@ -3186,6 +3198,9 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)-> ...@@ -3186,6 +3198,9 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
ygopro.stoc_send_chat_to_room(room, "#{client.name}: #{msg}", 9) ygopro.stoc_send_chat_to_room(room, "#{client.name}: #{msg}", 9)
return true return true
return cancel return cancel
if room.random_type and settings.modules.random_duel.disable_chat
ygopro.stoc_send_chat(client, "${chat_disabled}", ygopro.constants.COLORS.BABYBLUE)
return true
if client.abuse_count>=5 or CLIENT_is_banned_by_mc(client) if client.abuse_count>=5 or CLIENT_is_banned_by_mc(client)
log.warn "BANNED CHAT", client.name, client.ip, msg log.warn "BANNED CHAT", client.name, client.ip, msg
ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (if client.ban_mc and client.ban_mc.message then (": " + client.ban_mc.message) else ""), ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (if client.ban_mc and client.ban_mc.message then (": " + client.ban_mc.message) else ""), ygopro.constants.COLORS.RED)
......
...@@ -415,6 +415,10 @@ ...@@ -415,6 +415,10 @@
delete settings.modules.random_duel.blank_pass_match; delete settings.modules.random_duel.blank_pass_match;
imported = true; imported = true;
} }
if (settings.modules.hide_name === true) {
settings.modules.hide_name = "start";
imported = true;
}
//finish //finish
keysFromEnv = Object.keys(process.env).filter((key) => { keysFromEnv = Object.keys(process.env).filter((key) => {
return key.startsWith('SRVPRO_'); return key.startsWith('SRVPRO_');
...@@ -1582,882 +1586,900 @@ ...@@ -1582,882 +1586,900 @@
}); });
}; };
Room = class Room { Room = (function() {
constructor(name, hostinfo) { class Room {
var death_time, draw_count, duel_rule, extra_mode_func, lflist, param, rule, start_hand, start_lp, time_limit; constructor(name, hostinfo) {
this.hostinfo = hostinfo; var death_time, draw_count, duel_rule, extra_mode_func, lflist, param, rule, start_hand, start_lp, time_limit;
this.name = name; this.hostinfo = hostinfo;
//@alive = true this.name = name;
this.players = []; //@alive = true
this.player_datas = []; this.players = [];
this.status = 'starting'; this.player_datas = [];
//@started = false this.status = 'starting';
this.established = false; //@started = false
this.watcher_buffers = []; this.established = false;
this.recorder_buffers = []; this.watcher_buffers = [];
this.cloud_replay_id = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER); this.recorder_buffers = [];
this.watchers = []; this.cloud_replay_id = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
this.random_type = ''; this.watchers = [];
this.welcome = ''; this.random_type = '';
this.scores = {}; this.welcome = '';
this.decks = {}; this.scores = {};
this.duel_count = 0; this.decks = {};
this.death = 0; this.duel_count = 0;
this.turn = 0; this.death = 0;
this.duel_stage = ygopro.constants.DUEL_STAGE.BEGIN; this.turn = 0;
this.replays = []; this.duel_stage = ygopro.constants.DUEL_STAGE.BEGIN;
this.first_list = []; this.replays = [];
ROOM_all.push(this); this.first_list = [];
this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo))); ROOM_all.push(this);
delete this.hostinfo.comment; this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo)));
if (lflists.length) { delete this.hostinfo.comment;
if (this.hostinfo.rule === 1 && this.hostinfo.lflist === 0) { if (lflists.length) {
this.hostinfo.lflist = _.findIndex(lflists, function(list) { if (this.hostinfo.rule === 1 && this.hostinfo.lflist === 0) {
return list.tcg; this.hostinfo.lflist = _.findIndex(lflists, function(list) {
}); return list.tcg;
});
}
} else {
this.hostinfo.lflist = -1;
} }
} else { if (name.slice(0, 2) === 'M#') {
this.hostinfo.lflist = -1;
}
if (name.slice(0, 2) === 'M#') {
this.hostinfo.mode = 1;
} else if (name.slice(0, 2) === 'T#') {
this.hostinfo.mode = 2;
this.hostinfo.start_lp = 16000;
} else if (name.slice(0, 3) === 'AI#') {
this.hostinfo.rule = 5;
this.hostinfo.lflist = -1;
this.hostinfo.time_limit = 999;
} else if ((param = name.match(/^(\d)(\d)([12345TF])(T|F)(T|F)(\d+),(\d+),(\d+)/i))) {
this.hostinfo.rule = parseInt(param[1]);
this.hostinfo.mode = parseInt(param[2]);
this.hostinfo.duel_rule = (parseInt(param[3]) ? parseInt(param[3]) : (param[3] === 'T' ? 3 : 5));
this.hostinfo.no_check_deck = param[4] === 'T';
this.hostinfo.no_shuffle_deck = param[5] === 'T';
this.hostinfo.start_lp = parseInt(param[6]);
this.hostinfo.start_hand = parseInt(param[7]);
this.hostinfo.draw_count = parseInt(param[8]);
} else if ((param = name.match(/(.+)#/)) !== null) {
rule = param[1].toUpperCase();
if (rule.match(/(^|,|,)(M|MATCH)(,|,|$)/)) {
this.hostinfo.mode = 1; this.hostinfo.mode = 1;
} } else if (name.slice(0, 2) === 'T#') {
if (rule.match(/(^|,|,)(T|TAG)(,|,|$)/)) {
this.hostinfo.mode = 2; this.hostinfo.mode = 2;
this.hostinfo.start_lp = 16000; this.hostinfo.start_lp = 16000;
} } else if (name.slice(0, 3) === 'AI#') {
if (rule.match(/(^|,|,)(TCGONLY|TO)(,|,|$)/)) {
this.hostinfo.rule = 1;
this.hostinfo.lflist = _.findIndex(lflists, function(list) {
return list.tcg;
});
}
if (rule.match(/(^|,|,)(OCGONLY|OO)(,|,|$)/)) {
this.hostinfo.rule = 0;
this.hostinfo.lflist = 0;
}
if (rule.match(/(^|,|,)(OT|TCG)(,|,|$)/)) {
this.hostinfo.rule = 5; this.hostinfo.rule = 5;
}
if (rule.match(/(^|,|,)(SC|CN|CCG|CHINESE)(,|,|$)/)) {
this.hostinfo.rule = 2;
this.hostinfo.lflist = -1; this.hostinfo.lflist = -1;
} this.hostinfo.time_limit = 999;
if ((param = rule.match(/(^|,|,)LP(\d+)(,|,|$)/))) { } else if ((param = name.match(/^(\d)(\d)([12345TF])(T|F)(T|F)(\d+),(\d+),(\d+)/i))) {
start_lp = parseInt(param[2]); this.hostinfo.rule = parseInt(param[1]);
if (start_lp <= 0) { this.hostinfo.mode = parseInt(param[2]);
start_lp = 1; this.hostinfo.duel_rule = (parseInt(param[3]) ? parseInt(param[3]) : (param[3] === 'T' ? 3 : 5));
this.hostinfo.no_check_deck = param[4] === 'T';
this.hostinfo.no_shuffle_deck = param[5] === 'T';
this.hostinfo.start_lp = parseInt(param[6]);
this.hostinfo.start_hand = parseInt(param[7]);
this.hostinfo.draw_count = parseInt(param[8]);
} else if ((param = name.match(/(.+)#/)) !== null) {
rule = param[1].toUpperCase();
if (rule.match(/(^|,|,)(M|MATCH)(,|,|$)/)) {
this.hostinfo.mode = 1;
} }
if (start_lp >= 99999) { if (rule.match(/(^|,|,)(T|TAG)(,|,|$)/)) {
start_lp = 99999; this.hostinfo.mode = 2;
this.hostinfo.start_lp = 16000;
} }
this.hostinfo.start_lp = start_lp; if (rule.match(/(^|,|,)(TCGONLY|TO)(,|,|$)/)) {
} this.hostinfo.rule = 1;
if ((param = rule.match(/(^|,|,)(TIME|TM|TI)(\d+)(,|,|$)/))) { this.hostinfo.lflist = _.findIndex(lflists, function(list) {
time_limit = parseInt(param[3]); return list.tcg;
if (time_limit < 0) { });
time_limit = 180;
} }
if (time_limit >= 1 && time_limit <= 60) { if (rule.match(/(^|,|,)(OCGONLY|OO)(,|,|$)/)) {
time_limit = time_limit * 60; this.hostinfo.rule = 0;
this.hostinfo.lflist = 0;
} }
if (time_limit >= 999) { if (rule.match(/(^|,|,)(OT|TCG)(,|,|$)/)) {
time_limit = 999; this.hostinfo.rule = 5;
} }
this.hostinfo.time_limit = time_limit; if (rule.match(/(^|,|,)(SC|CN|CCG|CHINESE)(,|,|$)/)) {
} this.hostinfo.rule = 2;
if ((param = rule.match(/(^|,|,)(START|ST)(\d+)(,|,|$)/))) { this.hostinfo.lflist = -1;
start_hand = parseInt(param[3]);
if (start_hand <= 0) {
start_hand = 1;
} }
if (start_hand >= 40) { if ((param = rule.match(/(^|,|,)LP(\d+)(,|,|$)/))) {
start_hand = 40; start_lp = parseInt(param[2]);
if (start_lp <= 0) {
start_lp = 1;
}
if (start_lp >= 99999) {
start_lp = 99999;
}
this.hostinfo.start_lp = start_lp;
} }
this.hostinfo.start_hand = start_hand; if ((param = rule.match(/(^|,|,)(TIME|TM|TI)(\d+)(,|,|$)/))) {
} time_limit = parseInt(param[3]);
if ((param = rule.match(/(^|,|,)(DRAW|DR)(\d+)(,|,|$)/))) { if (time_limit < 0) {
draw_count = parseInt(param[3]); time_limit = 180;
if (draw_count >= 35) { }
draw_count = 35; if (time_limit >= 1 && time_limit <= 60) {
time_limit = time_limit * 60;
}
if (time_limit >= 999) {
time_limit = 999;
}
this.hostinfo.time_limit = time_limit;
}
if ((param = rule.match(/(^|,|,)(START|ST)(\d+)(,|,|$)/))) {
start_hand = parseInt(param[3]);
if (start_hand <= 0) {
start_hand = 1;
}
if (start_hand >= 40) {
start_hand = 40;
}
this.hostinfo.start_hand = start_hand;
}
if ((param = rule.match(/(^|,|,)(DRAW|DR)(\d+)(,|,|$)/))) {
draw_count = parseInt(param[3]);
if (draw_count >= 35) {
draw_count = 35;
}
this.hostinfo.draw_count = draw_count;
}
if ((param = rule.match(/(^|,|,)(LFLIST|LF)(\d+)(,|,|$)/))) {
lflist = parseInt(param[3]) - 1;
this.hostinfo.lflist = lflist;
}
for (extra_mode_func of extra_mode_list) {
extra_mode_func.call(this, rule);
}
if (rule.match(/(^|,|,)(NOLFLIST|NF)(,|,|$)/)) {
this.hostinfo.lflist = -1;
}
if (rule.match(/(^|,|,)(NOUNIQUE|NU)(,|,|$)/)) {
this.hostinfo.rule = 4;
}
if (rule.match(/(^|,|,)(CUSTOM|DIY)(,|,|$)/)) {
this.hostinfo.rule = 3;
}
if (rule.match(/(^|,|,)(NOCHECK|NC)(,|,|$)/)) {
this.hostinfo.no_check_deck = true;
}
if (rule.match(/(^|,|,)(NOSHUFFLE|NS)(,|,|$)/)) {
this.hostinfo.no_shuffle_deck = true;
}
if (rule.match(/(^|,|,)(IGPRIORITY|PR)(,|,|$)/)) { // deprecated
this.hostinfo.duel_rule = 4;
}
if ((param = rule.match(/(^|,|,)(DUELRULE|MR)(\d+)(,|,|$)/))) {
duel_rule = parseInt(param[3]);
if (duel_rule && duel_rule > 0 && duel_rule <= 5) {
this.hostinfo.duel_rule = duel_rule;
}
}
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) {
this.hostinfo.no_watch = true;
}
if ((param = rule.match(/(^|,|,)(DEATH|DH)(\d*)(,|,|$)/))) {
death_time = parseInt(param[3]);
if (death_time && death_time > 0) {
this.hostinfo.auto_death = death_time;
} else {
this.hostinfo.auto_death = 40;
}
}
if (settings.modules.tournament_mode.enable_recover && (param = rule.match(/(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/))) {
this.recovered = true;
this.recovering = true;
this.recover_from_turn = parseInt(param[4]);
this.recover_duel_log_id = parseInt(param[3]);
this.recover_buffers = [[], [], [], []];
this.welcome = "${recover_hint}";
} }
this.hostinfo.draw_count = draw_count;
}
if ((param = rule.match(/(^|,|,)(LFLIST|LF)(\d+)(,|,|$)/))) {
lflist = parseInt(param[3]) - 1;
this.hostinfo.lflist = lflist;
}
for (extra_mode_func of extra_mode_list) {
extra_mode_func.call(this, rule);
}
if (rule.match(/(^|,|,)(NOLFLIST|NF)(,|,|$)/)) {
this.hostinfo.lflist = -1;
}
if (rule.match(/(^|,|,)(NOUNIQUE|NU)(,|,|$)/)) {
this.hostinfo.rule = 4;
} }
if (rule.match(/(^|,|,)(CUSTOM|DIY)(,|,|$)/)) { this.hostinfo.replay_mode = 0;
this.hostinfo.rule = 3; if (settings.modules.tournament_mode.enabled) { // 0x1: Save the replays in file
this.hostinfo.replay_mode |= 0x1;
} }
if (rule.match(/(^|,|,)(NOCHECK|NC)(,|,|$)/)) { if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) { // 0x2: Block the replays to observers
this.hostinfo.no_check_deck = true; this.hostinfo.replay_mode |= 0x2;
} }
if (rule.match(/(^|,|,)(NOSHUFFLE|NS)(,|,|$)/)) { if (settings.modules.tournament_mode.enabled || this.arena) { // 0x4: Save chat in cloud replay
this.hostinfo.no_shuffle_deck = true; this.hostinfo.replay_mode |= 0x4;
} }
if (rule.match(/(^|,|,)(IGPRIORITY|PR)(,|,|$)/)) { // deprecated if (!this.recovered) {
this.hostinfo.duel_rule = 4; this.spawn();
} }
if ((param = rule.match(/(^|,|,)(DUELRULE|MR)(\d+)(,|,|$)/))) { }
duel_rule = parseInt(param[3]);
if (duel_rule && duel_rule > 0 && duel_rule <= 5) { spawn(firstSeed) {
this.hostinfo.duel_rule = duel_rule; var e, i, j, l, param, seeds;
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];
if (firstSeed) {
param.push(firstSeed);
seeds = getSeedTimet(2);
for (i = j = 0; j < 2; i = ++j) {
param.push(seeds[i]);
} }
} } else {
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) { seeds = getSeedTimet(3);
this.hostinfo.no_watch = true; for (i = l = 0; l < 3; i = ++l) {
} param.push(seeds[i]);
if ((param = rule.match(/(^|,|,)(DEATH|DH)(\d*)(,|,|$)/))) {
death_time = parseInt(param[3]);
if (death_time && death_time > 0) {
this.hostinfo.auto_death = death_time;
} else {
this.hostinfo.auto_death = 40;
} }
} }
if (settings.modules.tournament_mode.enable_recover && (param = rule.match(/(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/))) { try {
this.recovered = true; this.process = spawn('./ygopro', param, {
this.recovering = true; cwd: 'ygopro'
this.recover_from_turn = parseInt(param[4]); });
this.recover_duel_log_id = parseInt(param[3]); this.process_pid = this.process.pid;
this.recover_buffers = [[], [], [], []]; this.process.on('error', (err) => {
this.welcome = "${recover_hint}"; log.warn('CREATE ROOM ERROR', err);
_.each(this.players, function(player) {
return ygopro.stoc_die(player, "${create_room_failed}");
});
this.delete();
});
this.process.on('exit', (code) => {
if (!this.disconnector) {
this.disconnector = 'server';
}
this.delete();
});
this.process.stdout.setEncoding('utf8');
this.process.stdout.once('data', (data) => {
this.established = true;
if (!this.windbot && settings.modules.http.websocket_roomlist) {
roomlist.create(this);
}
this.port = parseInt(data);
_.each(this.players, (player) => {
player.server.connect(this.port, '127.0.0.1', async function() {
var buffer, len, m, ref;
ref = player.pre_establish_buffers;
for (m = 0, len = ref.length; m < len; m++) {
buffer = ref[m];
await ygopro.helper.send(player.server, buffer);
}
player.established = true;
player.pre_establish_buffers = [];
});
});
if (this.windbot) {
setTimeout(() => {
return this.add_windbot(this.windbot);
}, 200);
}
});
return this.process.stderr.on('data', async(data) => {
data = "Debug: " + data;
data = data.replace(/\n$/, "");
log.info("YGOPRO " + data);
ygopro.stoc_send_chat_to_room(this, data, ygopro.constants.COLORS.RED);
this.has_ygopro_error = true;
this.ygopro_error_length = this.ygopro_error_length ? this.ygopro_error_length + data.length : data.length;
if (this.ygopro_error_length > 10000) {
await this.send_replays();
this.process.kill();
}
});
} catch (error1) {
e = error1;
log.warn('CREATE ROOM FAIL', e);
return this.error = "${create_room_failed}";
} }
} }
this.hostinfo.replay_mode = 0;
if (settings.modules.tournament_mode.enabled) { // 0x1: Save the replays in file
this.hostinfo.replay_mode |= 0x1;
}
if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) { // 0x2: Block the replays to observers
this.hostinfo.replay_mode |= 0x2;
}
if (settings.modules.tournament_mode.enabled || this.arena) { // 0x4: Save chat in cloud replay
this.hostinfo.replay_mode |= 0x4;
}
if (!this.recovered) {
this.spawn();
}
}
spawn(firstSeed) { delete() {
var e, i, j, l, param, seeds; var end_time, formatted_replays, index, j, len, log_rep_id, name, player_datas, recorder_buffer, ref, ref1, repbuf, replay_id, room_name, score, score_array, score_form;
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]; if (this.deleted) {
if (firstSeed) { return;
param.push(firstSeed);
seeds = getSeedTimet(2);
for (i = j = 0; j < 2; i = ++j) {
param.push(seeds[i]);
}
} else {
seeds = getSeedTimet(3);
for (i = l = 0; l < 3; i = ++l) {
param.push(seeds[i]);
} }
} //log.info 'room-delete', this.name, ROOM_all.length
try { score_array = [];
this.process = spawn('./ygopro', param, { ref = this.scores;
cwd: 'ygopro' for (name in ref) {
}); score = ref[name];
this.process_pid = this.process.pid; score_form = {
this.process.on('error', (err) => { name: name.split('$')[0],
log.warn('CREATE ROOM ERROR', err); score: score,
_.each(this.players, function(player) { deck: null,
return ygopro.stoc_die(player, "${create_room_failed}"); name_vpass: name
}); };
this.delete(); if (this.decks[name]) {
}); score_form.deck = this.decks[name];
this.process.on('exit', (code) => {
if (!this.disconnector) {
this.disconnector = 'server';
}
this.delete();
});
this.process.stdout.setEncoding('utf8');
this.process.stdout.once('data', (data) => {
this.established = true;
if (!this.windbot && settings.modules.http.websocket_roomlist) {
roomlist.create(this);
} }
this.port = parseInt(data); score_array.push(score_form);
_.each(this.players, (player) => { }
player.server.connect(this.port, '127.0.0.1', async function() { if (settings.modules.random_duel.record_match_scores && this.random_type === 'M') {
var buffer, len, m, ref; if (score_array.length === 2) {
ref = player.pre_establish_buffers; if (score_array[0].score !== score_array[1].score) {
for (m = 0, len = ref.length; m < len; m++) { if (score_array[0].score > score_array[1].score) {
buffer = ref[m]; ROOM_player_win(score_array[0].name_vpass);
await ygopro.helper.send(player.server, buffer); ROOM_player_lose(score_array[1].name_vpass);
} else {
ROOM_player_win(score_array[1].name_vpass);
ROOM_player_lose(score_array[0].name_vpass);
} }
player.established = true; }
player.pre_establish_buffers = [];
});
});
if (this.windbot) {
setTimeout(() => {
return this.add_windbot(this.windbot);
}, 200);
} }
}); if (score_array.length === 1) { // same name
return this.process.stderr.on('data', async(data) => { //log.info score_array[0].name
data = "Debug: " + data; ROOM_player_win(score_array[0].name_vpass);
data = data.replace(/\n$/, ""); ROOM_player_lose(score_array[0].name_vpass);
log.info("YGOPRO " + data);
ygopro.stoc_send_chat_to_room(this, data, ygopro.constants.COLORS.RED);
this.has_ygopro_error = true;
this.ygopro_error_length = this.ygopro_error_length ? this.ygopro_error_length + data.length : data.length;
if (this.ygopro_error_length > 10000) {
await this.send_replays();
this.process.kill();
} }
});
} catch (error1) {
e = error1;
log.warn('CREATE ROOM FAIL', e);
return this.error = "${create_room_failed}";
}
}
delete() {
var end_time, formatted_replays, index, j, len, log_rep_id, name, player_datas, recorder_buffer, ref, ref1, repbuf, replay_id, room_name, score, score_array, score_form;
if (this.deleted) {
return;
}
//log.info 'room-delete', this.name, ROOM_all.length
score_array = [];
ref = this.scores;
for (name in ref) {
score = ref[name];
score_form = {
name: name.split('$')[0],
score: score,
deck: null,
name_vpass: name
};
if (this.decks[name]) {
score_form.deck = this.decks[name];
} }
score_array.push(score_form); if (settings.modules.arena_mode.enabled && this.arena) {
} //log.info 'SCORE', score_array, @start_time
if (settings.modules.random_duel.record_match_scores && this.random_type === 'M') { end_time = moment_now_string;
if (score_array.length === 2) { if (!this.start_time) {
if (score_array[0].score !== score_array[1].score) { this.start_time = end_time;
if (score_array[0].score > score_array[1].score) { }
ROOM_player_win(score_array[0].name_vpass); if (score_array.length !== 2) {
ROOM_player_lose(score_array[1].name_vpass); if (!score_array[0]) {
score_array[0] = {
name: null,
score: -5,
deck: null
};
}
if (!score_array[1]) {
score_array[1] = {
name: null,
score: -5,
deck: null
};
}
score_array[0].score = -5;
score_array[1].score = -5;
}
formatted_replays = [];
ref1 = this.replays;
for (j = 0, len = ref1.length; j < len; j++) {
repbuf = ref1[j];
if (repbuf) {
formatted_replays.push(repbuf.toString("base64"));
}
}
request.post({
url: settings.modules.arena_mode.post_score,
form: {
accesskey: settings.modules.arena_mode.accesskey,
usernameA: score_array[0].name,
usernameB: score_array[1].name,
userscoreA: score_array[0].score,
userscoreB: score_array[1].score,
userdeckA: score_array[0].deck,
userdeckB: score_array[1].deck,
first: JSON.stringify(this.first_list),
replays: JSON.stringify(formatted_replays),
start: this.start_time,
end: end_time,
arena: this.arena
}
}, (error, response, body) => {
if (error) {
log.warn('SCORE POST ERROR', error);
} else { } else {
ROOM_player_win(score_array[1].name_vpass); if (response.statusCode >= 300) {
ROOM_player_lose(score_array[0].name_vpass); log.warn('SCORE POST FAIL', response.statusCode, response.statusMessage, this.name, body);
}
} }
});
}
//else
// log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
if (settings.modules.challonge.enabled && this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.hostinfo.mode !== 2 && !this.kicked) {
room_name = this.name;
this.post_challonge_score();
}
if (this.player_datas.length && settings.modules.cloud_replay.enabled) {
replay_id = this.cloud_replay_id;
if (this.has_ygopro_error) {
log_rep_id = true;
} }
recorder_buffer = Buffer.concat(this.recorder_buffers);
player_datas = this.player_datas;
zlib.deflate(recorder_buffer, function(err, replay_buffer) {
dataManager.saveCloudReplay(replay_id, replay_buffer, player_datas).catch(function(err) {
return log.warn(`Replay save error: R#${replay_id} ${err.toString()}`);
});
if (log_rep_id) {
log.info("error replay: R#" + replay_id);
}
});
}
this.watcher_buffers = [];
this.recorder_buffers = [];
this.players = [];
if (this.watcher) {
this.watcher.destroy();
}
if (this.recorder) {
this.recorder.destroy();
} }
if (score_array.length === 1) { // same name this.deleted = true;
//log.info score_array[0].name index = _.indexOf(ROOM_all, this);
ROOM_player_win(score_array[0].name_vpass); if (settings.modules.reconnect.enabled) {
ROOM_player_lose(score_array[0].name_vpass); ROOM_clear_disconnect(index);
}
if (index !== -1) {
ROOM_all[index] = null;
}
if (!this.windbot && this.established && settings.modules.http.websocket_roomlist) {
//ROOM_all.splice(index, 1) unless index == -1
roomlist.delete(this);
} }
} }
if (settings.modules.arena_mode.enabled && this.arena) {
//log.info 'SCORE', score_array, @start_time async initialize_recover() {
end_time = moment_now_string; var e;
if (!this.start_time) { this.recover_duel_log = (await dataManager.getDuelLogFromId(this.recover_duel_log_id));
this.start_time = end_time; if (!this.recover_duel_log || !fs.existsSync(settings.modules.tournament_mode.replay_path + this.recover_duel_log.replayFileName)) {
this.terminate();
return false;
} }
if (score_array.length !== 2) { try {
if (!score_array[0]) { this.recover_replay = (await ReplayParser.fromFile(settings.modules.tournament_mode.replay_path + this.recover_duel_log.replayFileName));
score_array[0] = { this.spawn(this.recover_replay.header.seed);
name: null, return true;
score: -5, } catch (error1) {
deck: null e = error1;
}; log.warn("LOAD RECOVER REPLAY FAIL", e.toString());
} this.terminate();
if (!score_array[1]) { return false;
score_array[1] = {
name: null,
score: -5,
deck: null
};
}
score_array[0].score = -5;
score_array[1].score = -5;
}
formatted_replays = [];
ref1 = this.replays;
for (j = 0, len = ref1.length; j < len; j++) {
repbuf = ref1[j];
if (repbuf) {
formatted_replays.push(repbuf.toString("base64"));
}
} }
request.post({
url: settings.modules.arena_mode.post_score,
form: {
accesskey: settings.modules.arena_mode.accesskey,
usernameA: score_array[0].name,
usernameB: score_array[1].name,
userscoreA: score_array[0].score,
userscoreB: score_array[1].score,
userdeckA: score_array[0].deck,
userdeckB: score_array[1].deck,
first: JSON.stringify(this.first_list),
replays: JSON.stringify(formatted_replays),
start: this.start_time,
end: end_time,
arena: this.arena
}
}, (error, response, body) => {
if (error) {
log.warn('SCORE POST ERROR', error);
} else {
if (response.statusCode >= 300) {
log.warn('SCORE POST FAIL', response.statusCode, response.statusMessage, this.name, body);
}
}
});
} }
//else
// log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body get_playing_player() {
if (settings.modules.challonge.enabled && this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.hostinfo.mode !== 2 && !this.kicked) { var playing_player;
room_name = this.name; playing_player = [];
this.post_challonge_score(); _.each(this.players, function(player) {
} if (player.pos < 4) {
if (this.player_datas.length && settings.modules.cloud_replay.enabled) { playing_player.push(player);
replay_id = this.cloud_replay_id;
if (this.has_ygopro_error) {
log_rep_id = true;
}
recorder_buffer = Buffer.concat(this.recorder_buffers);
player_datas = this.player_datas;
zlib.deflate(recorder_buffer, function(err, replay_buffer) {
dataManager.saveCloudReplay(replay_id, replay_buffer, player_datas).catch(function(err) {
return log.warn(`Replay save error: R#${replay_id} ${err.toString()}`);
});
if (log_rep_id) {
log.info("error replay: R#" + replay_id);
} }
}); });
return playing_player;
} }
this.watcher_buffers = [];
this.recorder_buffers = [];
this.players = [];
if (this.watcher) {
this.watcher.destroy();
}
if (this.recorder) {
this.recorder.destroy();
}
this.deleted = true;
index = _.indexOf(ROOM_all, this);
if (settings.modules.reconnect.enabled) {
ROOM_clear_disconnect(index);
}
if (index !== -1) {
ROOM_all[index] = null;
}
if (!this.windbot && this.established && settings.modules.http.websocket_roomlist) {
//ROOM_all.splice(index, 1) unless index == -1
roomlist.delete(this);
}
}
async initialize_recover() { get_host() {
var e; var host_player;
this.recover_duel_log = (await dataManager.getDuelLogFromId(this.recover_duel_log_id)); host_player = null;
if (!this.recover_duel_log || !fs.existsSync(settings.modules.tournament_mode.replay_path + this.recover_duel_log.replayFileName)) { _.each(this.players, function(player) {
this.terminate(); if (player.is_host) {
return false; host_player = player;
} }
try { });
this.recover_replay = (await ReplayParser.fromFile(settings.modules.tournament_mode.replay_path + this.recover_duel_log.replayFileName)); return host_player;
this.spawn(this.recover_replay.header.seed);
return true;
} catch (error1) {
e = error1;
log.warn("LOAD RECOVER REPLAY FAIL", e.toString());
this.terminate();
return false;
} }
}
get_playing_player() { get_disconnected_count() {
var playing_player; var found, j, len, player, ref;
playing_player = []; if (!settings.modules.reconnect.enabled) {
_.each(this.players, function(player) { return 0;
if (player.pos < 4) {
playing_player.push(player);
} }
}); found = 0;
return playing_player; ref = this.get_playing_player();
} for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
get_host() { if (player.isClosed) {
var host_player; found++;
host_player = null; }
_.each(this.players, function(player) {
if (player.is_host) {
host_player = player;
}
});
return host_player;
}
get_disconnected_count() {
var found, j, len, player, ref;
if (!settings.modules.reconnect.enabled) {
return 0;
}
found = 0;
ref = this.get_playing_player();
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.isClosed) {
found++;
} }
return found;
} }
return found;
}
get_challonge_score() { get_challonge_score() {
var challonge_duel_log; var challonge_duel_log;
if (!settings.modules.challonge.enabled || this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.hostinfo.mode === 2) { if (!settings.modules.challonge.enabled || this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.hostinfo.mode === 2) {
return null; return null;
} }
challonge_duel_log = {}; challonge_duel_log = {};
if (this.scores[this.dueling_players[0].name_vpass] > this.scores[this.dueling_players[1].name_vpass]) { if (this.scores[this.dueling_players[0].name_vpass] > this.scores[this.dueling_players[1].name_vpass]) {
challonge_duel_log.winner_id = this.dueling_players[0].challonge_info.id; challonge_duel_log.winner_id = this.dueling_players[0].challonge_info.id;
} else if (this.scores[this.dueling_players[0].name_vpass] < this.scores[this.dueling_players[1].name_vpass]) { } else if (this.scores[this.dueling_players[0].name_vpass] < this.scores[this.dueling_players[1].name_vpass]) {
challonge_duel_log.winner_id = this.dueling_players[1].challonge_info.id; challonge_duel_log.winner_id = this.dueling_players[1].challonge_info.id;
} else {
challonge_duel_log.winner_id = "tie";
}
if (settings.modules.challonge.post_detailed_score) {
if (this.dueling_players[0].challonge_info.id === this.challonge_info.player1_id && this.dueling_players[1].challonge_info.id === this.challonge_info.player2_id) {
challonge_duel_log.scores_csv = this.scores[this.dueling_players[0].name_vpass] + "-" + this.scores[this.dueling_players[1].name_vpass];
} else if (this.dueling_players[1].challonge_info.id === this.challonge_info.player1_id && this.dueling_players[0].challonge_info.id === this.challonge_info.player2_id) {
challonge_duel_log.scores_csv = this.scores[this.dueling_players[1].name_vpass] + "-" + this.scores[this.dueling_players[0].name_vpass];
} else { } else {
challonge_duel_log.scores_csv = "0-0"; challonge_duel_log.winner_id = "tie";
log.warn("Score mismatch.", this.name);
} }
} else { if (settings.modules.challonge.post_detailed_score) {
if (challonge_duel_log.winner_id === this.challonge_info.player1_id) { if (this.dueling_players[0].challonge_info.id === this.challonge_info.player1_id && this.dueling_players[1].challonge_info.id === this.challonge_info.player2_id) {
challonge_duel_log.scores_csv = "1-0"; challonge_duel_log.scores_csv = this.scores[this.dueling_players[0].name_vpass] + "-" + this.scores[this.dueling_players[1].name_vpass];
} else if (challonge_duel_log.winner_id === this.challonge_info.player2_id) { } else if (this.dueling_players[1].challonge_info.id === this.challonge_info.player1_id && this.dueling_players[0].challonge_info.id === this.challonge_info.player2_id) {
challonge_duel_log.scores_csv = "0-1"; challonge_duel_log.scores_csv = this.scores[this.dueling_players[1].name_vpass] + "-" + this.scores[this.dueling_players[0].name_vpass];
} else {
challonge_duel_log.scores_csv = "0-0";
log.warn("Score mismatch.", this.name);
}
} else { } else {
challonge_duel_log.scores_csv = "0-0"; if (challonge_duel_log.winner_id === this.challonge_info.player1_id) {
challonge_duel_log.scores_csv = "1-0";
} else if (challonge_duel_log.winner_id === this.challonge_info.player2_id) {
challonge_duel_log.scores_csv = "0-1";
} else {
challonge_duel_log.scores_csv = "0-0";
}
} }
return challonge_duel_log;
} }
return challonge_duel_log;
}
post_challonge_score(noWinner) { post_challonge_score(noWinner) {
var matchResult; var matchResult;
matchResult = this.get_challonge_score(); matchResult = this.get_challonge_score();
if (noWinner) { if (noWinner) {
delete matchResult.winner_id; delete matchResult.winner_id;
}
return challonge.putScore(this.challonge_info.id, matchResult);
}
get_roomlist_hostinfo() { // Just for supporting websocket roomlist in old MyCard client....
//ret = _.clone(@hostinfo)
//ret.enable_priority = (@hostinfo.duel_rule != 5)
//return ret
return this.hostinfo;
}
async send_replays() {
var j, l, len, len1, player, ref, ref1, send_tasks;
if (!(settings.modules.replay_delay && this.replays.length && this.hostinfo.mode === 1)) {
return false;
}
send_tasks = [];
ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player) {
send_tasks.push(CLIENT_send_replays(player, this));
} }
return challonge.putScore(this.challonge_info.id, matchResult);
} }
ref1 = this.watchers;
for (l = 0, len1 = ref1.length; l < len1; l++) { get_roomlist_hostinfo() { // Just for supporting websocket roomlist in old MyCard client....
player = ref1[l]; //ret = _.clone(@hostinfo)
if (player) { //ret.enable_priority = (@hostinfo.duel_rule != 5)
send_tasks.push(CLIENT_send_replays(player, this)); //return ret
} return this.hostinfo;
} }
await Promise.all(send_tasks);
return true;
}
add_windbot(botdata) { async send_replays() {
this.windbot = botdata; var j, l, len, len1, player, ref, ref1, send_tasks;
request({ if (!(settings.modules.replay_delay && this.replays.length && this.hostinfo.mode === 1)) {
url: `http://${settings.modules.windbot.server_ip}:${settings.modules.windbot.port}/?name=${encodeURIComponent(botdata.name)}&deck=${encodeURIComponent(botdata.deck)}&host=${settings.modules.windbot.my_ip}&port=${settings.port}&dialog=${encodeURIComponent(botdata.dialog)}&version=${settings.version}&password=${encodeURIComponent(this.name)}` return false;
}, (error, response, body) => {
if (error) {
log.warn('windbot add error', error, this.name);
ygopro.stoc_send_chat_to_room(this, "${add_windbot_failed}", ygopro.constants.COLORS.RED);
} }
}); send_tasks = [];
} ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
//else player = ref[j];
//log.info "windbot added" if (player) {
connect(client) { send_tasks.push(CLIENT_send_replays(player, this));
var host_player; }
this.players.push(client);
client.join_time = moment_now_string;
if (this.random_type) {
client.abuse_count = 0;
host_player = this.get_host();
if (host_player && (host_player !== client)) {
// 进来时已经有人在等待了,互相记录为匹配过
ROOM_players_oppentlist[host_player.ip] = client.ip;
ROOM_players_oppentlist[client.ip] = host_player.ip;
} else {
// 第一个玩家刚进来,还没就位
ROOM_players_oppentlist[client.ip] = null;
} }
} ref1 = this.watchers;
if (this.established) { for (l = 0, len1 = ref1.length; l < len1; l++) {
if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) { player = ref1[l];
roomlist.update(this); if (player) {
send_tasks.push(CLIENT_send_replays(player, this));
}
} }
client.server.connect(this.port, '127.0.0.1', async function() { await Promise.all(send_tasks);
var buffer, j, len, ref; return true;
ref = client.pre_establish_buffers; }
for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j]; add_windbot(botdata) {
await ygopro.helper.send(client.server, buffer); this.windbot = botdata;
request({
url: `http://${settings.modules.windbot.server_ip}:${settings.modules.windbot.port}/?name=${encodeURIComponent(botdata.name)}&deck=${encodeURIComponent(botdata.deck)}&host=${settings.modules.windbot.my_ip}&port=${settings.port}&dialog=${encodeURIComponent(botdata.dialog)}&version=${settings.version}&password=${encodeURIComponent(this.name)}`
}, (error, response, body) => {
if (error) {
log.warn('windbot add error', error, this.name);
ygopro.stoc_send_chat_to_room(this, "${add_windbot_failed}", ygopro.constants.COLORS.RED);
} }
client.established = true;
client.pre_establish_buffers = [];
}); });
} }
}
async disconnect(client, error) { //else
var index, j, l, left_name, len, len1, player, ref, ref1; //log.info "windbot added"
if (client.had_new_reconnection) { connect(client) {
return; var host_player;
} this.players.push(client);
if (client.is_post_watcher) { client.join_time = moment_now_string;
ygopro.stoc_send_chat_to_room(this, `${client.name} \${quit_watch}` + (error ? `: ${error}` : '')); if (this.random_type) {
index = _.indexOf(this.watchers, client); client.abuse_count = 0;
if (index !== -1) { host_player = this.get_host();
this.watchers.splice(index, 1); if (host_player && (host_player !== client)) {
} // 进来时已经有人在等待了,互相记录为匹配过
//client.room = null ROOM_players_oppentlist[host_player.ip] = client.ip;
SERVER_kick(client.server); ROOM_players_oppentlist[client.ip] = host_player.ip;
} else {
//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 (settings.modules.arena_mode.punish_quit_before_match && this.players.length === 2 && !client.arena_quit_free) {
ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.pos !== 7) {
this.scores[player.name_vpass] = 0;
}
}
this.scores[client.name_vpass] = -9;
} else { } else {
ref1 = this.players; // 第一个玩家刚进来,还没就位
for (l = 0, len1 = ref1.length; l < len1; l++) { ROOM_players_oppentlist[client.ip] = null;
player = ref1[l];
if (player.pos !== 7) {
this.scores[player.name_vpass] = -5;
}
}
if (this.players.length === 2 && this.arena === 'athletic' && !client.arena_quit_free) {
this.scores[client.name_vpass] = -9;
}
}
this.arena_score_handled = true;
}
index = _.indexOf(this.players, client);
if (index !== -1) {
this.players.splice(index, 1);
}
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && client.pos < 4) {
this.finished = true;
if (!this.finished_by_death) {
this.scores[client.name_vpass] = -9;
if (this.random_type && !client.flee_free && (!settings.modules.reconnect.enabled || this.get_disconnected_count() === 0) && !client.kicked_by_system && !client.kicked_by_player) {
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}");
if (settings.modules.random_duel.record_match_scores && this.random_type === 'M') {
ROOM_player_flee(client.name_vpass);
}
}
} }
} }
if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && client.pos <= 3)) { if (this.established) {
left_name = (settings.modules.hide_name && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN ? "********" : client.name);
ygopro.stoc_send_chat_to_room(this, `${left_name} \${left_game}` + (error ? `: ${error}` : ''));
if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) { if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
} }
} else { client.server.connect(this.port, '127.0.0.1', async function() {
//client.room = null var buffer, j, len, ref;
await this.send_replays(); ref = client.pre_establish_buffers;
this.process.kill(); for (j = 0, len = ref.length; j < len; j++) {
//client.room = null buffer = ref[j];
this.delete(); await ygopro.helper.send(client.server, buffer);
} }
if (!CLIENT_reconnect_unregister(client, false, true)) { client.established = true;
SERVER_kick(client.server); client.pre_establish_buffers = [];
});
} }
} }
}
async start_death() { async disconnect(client, error) {
var oppo_pos, win_pos; var index, j, l, left_name, len, len1, player, ref, ref1;
if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.death) { if (client.had_new_reconnection) {
return false; return;
}
oppo_pos = this.hostinfo.mode === 2 ? 2 : 1;
if (this.duel_stage === ygopro.constants.DUEL_STAGE.DUELING) {
switch (settings.modules.http.quick_death_rule) {
case 3:
this.death = -2;
ygopro.stoc_send_chat_to_room(this, "${death_start_phase}", ygopro.constants.COLORS.BABYBLUE);
break;
default:
this.death = (this.turn ? this.turn + 4 : 5);
ygopro.stoc_send_chat_to_room(this, "${death_start}", ygopro.constants.COLORS.BABYBLUE); // Extra duel started in siding
} }
} else { if (client.is_post_watcher) {
switch (settings.modules.http.quick_death_rule) { ygopro.stoc_send_chat_to_room(this, `${client.name} \${quit_watch}` + (error ? `: ${error}` : ''));
case 2: index = _.indexOf(this.watchers, client);
case 3: if (index !== -1) {
if (this.scores[this.dueling_players[0].name_vpass] === this.scores[this.dueling_players[oppo_pos].name_vpass]) { this.watchers.splice(index, 1);
if (settings.modules.http.quick_death_rule === 3) { }
this.death = -1; //client.room = null
ygopro.stoc_send_chat_to_room(this, "${death_start_quick}", ygopro.constants.COLORS.BABYBLUE); SERVER_kick(client.server);
} else { } else {
this.death = 5; //log.info(client.name, @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN, @disconnector, @random_type, @players.length)
ygopro.stoc_send_chat_to_room(this, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE); 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) {
ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.pos !== 7) {
this.scores[player.name_vpass] = 0;
}
} }
this.scores[client.name_vpass] = -9;
} else { } else {
win_pos = this.scores[this.dueling_players[0].name_vpass] > this.scores[this.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos; ref1 = this.players;
this.finished_by_death = true; for (l = 0, len1 = ref1.length; l < len1; l++) {
ygopro.stoc_send_chat_to_room(this, "${death2_finish_part1}" + this.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE); player = ref1[l];
if (this.hostinfo.mode === 1) { if (player.pos !== 7) {
await CLIENT_send_replays(this.dueling_players[oppo_pos - win_pos], this); this.scores[player.name_vpass] = -5;
}
} }
await ygopro.stoc_send(this.dueling_players[oppo_pos - win_pos], 'DUEL_END'); if (this.players.length === 2 && this.arena === 'athletic' && !client.arena_quit_free) {
if (this.hostinfo.mode === 2) { this.scores[client.name_vpass] = -9;
await ygopro.stoc_send(this.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END');
} }
this.scores[this.dueling_players[oppo_pos - win_pos].name_vpass] = -1; }
CLIENT_kick(this.dueling_players[oppo_pos - win_pos]); this.arena_score_handled = true;
if (this.hostinfo.mode === 2) { }
CLIENT_kick(this.dueling_players[oppo_pos - win_pos + 1]); index = _.indexOf(this.players, client);
if (index !== -1) {
this.players.splice(index, 1);
}
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && client.pos < 4) {
this.finished = true;
if (!this.finished_by_death) {
this.scores[client.name_vpass] = -9;
if (this.random_type && !client.flee_free && (!settings.modules.reconnect.enabled || this.get_disconnected_count() === 0) && !client.kicked_by_system && !client.kicked_by_player) {
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}");
if (settings.modules.random_duel.record_match_scores && this.random_type === 'M') {
ROOM_player_flee(client.name_vpass);
}
} }
} }
break; }
case 1: if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && client.pos <= 3)) {
this.death = -1; left_name = this.getMaskedPlayerName(client);
ygopro.stoc_send_chat_to_room(this, "${death_start_quick}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(this, `${left_name} \${left_game}` + (error ? `: ${error}` : ''));
break; if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) {
default: roomlist.update(this);
this.death = 5; }
ygopro.stoc_send_chat_to_room(this, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE); } else {
//client.room = null
await this.send_replays();
this.process.kill();
//client.room = null
this.delete();
}
if (!CLIENT_reconnect_unregister(client, false, true)) {
SERVER_kick(client.server);
}
} }
} }
return true;
}
cancel_death() { async start_death() {
if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || !this.death) { var oppo_pos, win_pos;
return false; if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.death) {
return false;
}
oppo_pos = this.hostinfo.mode === 2 ? 2 : 1;
if (this.duel_stage === ygopro.constants.DUEL_STAGE.DUELING) {
switch (settings.modules.http.quick_death_rule) {
case 3:
this.death = -2;
ygopro.stoc_send_chat_to_room(this, "${death_start_phase}", ygopro.constants.COLORS.BABYBLUE);
break;
default:
this.death = (this.turn ? this.turn + 4 : 5);
ygopro.stoc_send_chat_to_room(this, "${death_start}", ygopro.constants.COLORS.BABYBLUE); // Extra duel started in siding
}
} else {
switch (settings.modules.http.quick_death_rule) {
case 2:
case 3:
if (this.scores[this.dueling_players[0].name_vpass] === this.scores[this.dueling_players[oppo_pos].name_vpass]) {
if (settings.modules.http.quick_death_rule === 3) {
this.death = -1;
ygopro.stoc_send_chat_to_room(this, "${death_start_quick}", ygopro.constants.COLORS.BABYBLUE);
} else {
this.death = 5;
ygopro.stoc_send_chat_to_room(this, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE);
}
} else {
win_pos = this.scores[this.dueling_players[0].name_vpass] > this.scores[this.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos;
this.finished_by_death = true;
ygopro.stoc_send_chat_to_room(this, "${death2_finish_part1}" + this.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
if (this.hostinfo.mode === 1) {
await CLIENT_send_replays(this.dueling_players[oppo_pos - win_pos], this);
}
await ygopro.stoc_send(this.dueling_players[oppo_pos - win_pos], 'DUEL_END');
if (this.hostinfo.mode === 2) {
await ygopro.stoc_send(this.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END');
}
this.scores[this.dueling_players[oppo_pos - win_pos].name_vpass] = -1;
CLIENT_kick(this.dueling_players[oppo_pos - win_pos]);
if (this.hostinfo.mode === 2) {
CLIENT_kick(this.dueling_players[oppo_pos - win_pos + 1]);
}
}
break;
case 1:
this.death = -1;
ygopro.stoc_send_chat_to_room(this, "${death_start_quick}", ygopro.constants.COLORS.BABYBLUE);
break;
default:
this.death = 5;
ygopro.stoc_send_chat_to_room(this, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE);
}
}
return true;
} }
this.death = 0;
ygopro.stoc_send_chat_to_room(this, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE);
return true;
}
async terminate() { cancel_death() {
var e; if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || !this.death) {
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) { return false;
this.scores[this.dueling_players[0].name_vpass] = 0; }
this.scores[this.dueling_players[1].name_vpass] = 0; this.death = 0;
ygopro.stoc_send_chat_to_room(this, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE);
return true;
} }
this.kicked = true;
await this.send_replays(); async terminate() {
if (this.process) { var e;
try { if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
this.process.kill(); this.scores[this.dueling_players[0].name_vpass] = 0;
} catch (error1) { this.scores[this.dueling_players[1].name_vpass] = 0;
e = error1; }
this.kicked = true;
await this.send_replays();
if (this.process) {
try {
this.process.kill();
} catch (error1) {
e = error1;
}
} }
return this.delete();
} }
return this.delete();
}
finish_recover(fail) { finish_recover(fail) {
var buffer, j, len, player, ref, results; var buffer, j, len, player, ref, 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.terminate(); return this.terminate();
} 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;
ref = this.get_playing_player(); ref = this.get_playing_player();
results = []; results = [];
for (j = 0, len = ref.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
player = ref[j]; player = ref[j];
results.push((function() { results.push((function() {
var l, len1, ref1, results1; var l, len1, ref1, results1;
ref1 = this.recover_buffers[player.pos]; ref1 = this.recover_buffers[player.pos];
results1 = []; results1 = [];
for (l = 0, len1 = ref1.length; l < len1; l++) { for (l = 0, len1 = ref1.length; l < len1; l++) {
buffer = ref1[l]; buffer = ref1[l];
results1.push(ygopro.stoc_send(player, "GAME_MSG", buffer)); results1.push(ygopro.stoc_send(player, "GAME_MSG", buffer));
} }
return results1; return results1;
}).call(this)); }).call(this));
}
return results;
} }
return results;
} }
}
async check_athletic() { async check_athletic() {
var players, room; var players, room;
players = this.get_playing_player(); players = this.get_playing_player();
room = this; room = this;
await Promise.all(players.map(async function(player) { await Promise.all(players.map(async function(player) {
var main, side, using_athletic; var main, side, using_athletic;
main = _.clone(player.main); main = _.clone(player.main);
side = _.clone(player.side); side = _.clone(player.side);
using_athletic = (await athleticChecker.checkAthletic({ using_athletic = (await athleticChecker.checkAthletic({
main: main, main: main,
side: side side: side
}));
if (!using_athletic.success) {
log.warn("GET ATHLETIC FAIL", player.name, using_athletic.message);
} else if (using_athletic.athletic) {
ygopro.stoc_send_chat_to_room(room, `${player.name}\${using_athletic_deck}`, ygopro.constants.COLORS.BABYBLUE);
}
})); }));
if (!using_athletic.success) { }
log.warn("GET ATHLETIC FAIL", player.name, using_athletic.message);
} else if (using_athletic.athletic) {
ygopro.stoc_send_chat_to_room(room, `${player.name}\${using_athletic_deck}`, ygopro.constants.COLORS.BABYBLUE);
}
}));
}
async join_post_watch(client) { async join_post_watch(client) {
var buffer, j, len, ref; var buffer, j, len, ref;
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) { if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !this.hostinfo.no_watch) { if (settings.modules.cloud_replay.enable_halfway_watch && !this.hostinfo.no_watch) {
client.setTimeout(300000); //连接后超时5分钟 client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this); client.rid = _.indexOf(ROOM_all, this);
client.is_post_watcher = true; client.is_post_watcher = true;
ygopro.stoc_send_chat_to_room(this, `${client.name} \${watch_join}`); ygopro.stoc_send_chat_to_room(this, `${client.name} \${watch_join}`);
this.watchers.push(client); this.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);
ref = this.watcher_buffers; ref = this.watcher_buffers;
for (j = 0, len = ref.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j]; buffer = ref[j];
await ygopro.helper.send(client, buffer); await ygopro.helper.send(client, buffer);
}
return true;
} else {
ygopro.stoc_die(client, "${watch_denied}");
return false;
} }
return true;
} else { } else {
ygopro.stoc_die(client, "${watch_denied}");
return false; return false;
} }
} else {
return false;
} }
}
join_player(client) { join_player(client) {
var j, len, player, ref; var j, len, player, ref;
if (this.error) { if (this.error) {
ygopro.stoc_die(client, this.error); ygopro.stoc_die(client, this.error);
return false; return false;
}
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
return this.join_post_watch(client);
}
if (this.hostinfo.no_watch && this.players.length >= (this.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
return true;
}
if (this.challonge_info) {
ref = this.get_playing_player();
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (!(player && player !== client && player.challonge_info.id === client.challonge_info.id)) {
continue;
}
ygopro.stoc_die(client, "${challonge_player_already_in}");
return false;
}
}
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this);
this.connect(client);
return true;
} }
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
return this.join_post_watch(client); refreshLastActiveTime(longAgo) {
if (longAgo) {
return this.last_active_time = moment_long_ago_string;
} else {
return this.last_active_time = moment_now_string;
}
} }
if (this.hostinfo.no_watch && this.players.length >= (this.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}"); addRecorderBuffer(buffer) {
return true; if (settings.modules.cloud_replay.enabled) {
this.recorder_buffers.push(buffer);
}
} }
if (this.challonge_info) {
ref = this.get_playing_player(); recordChatMessage(msg, player) {
var chat_buf, j, len, line, ref;
ref = ygopro.split_chat_lines(msg, player, settings.modules.i18n.default);
for (j = 0, len = ref.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
player = ref[j]; line = ref[j];
if (!(player && player !== client && player.challonge_info.id === client.challonge_info.id)) { chat_buf = ygopro.helper.prepareMessage("STOC_CHAT", {
continue; player: player,
msg: line
});
if (settings.modules.cloud_replay.enabled && (this.arena || settings.modules.tournament_mode.enabled)) {
this.addRecorderBuffer(chat_buf);
} }
ygopro.stoc_die(client, "${challonge_player_already_in}"); this.watcher_buffers.push(chat_buf);
return false;
} }
} }
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this);
this.connect(client);
return true;
}
refreshLastActiveTime(longAgo) { };
if (longAgo) {
return this.last_active_time = moment_long_ago_string;
} else {
return this.last_active_time = moment_now_string;
}
}
addRecorderBuffer(buffer) { getMaskedPlayerName(player, sight_player)(function() {
if (settings.modules.cloud_replay.enabled) { if (!settings.modules.hide_name || (sight_player && player === sight_player) || !(this.random_type || this.arena)) {
this.recorder_buffers.push(buffer); return player.name;
} }
} if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.hide_name === "start") {
return "********";
recordChatMessage(msg, player) {
var chat_buf, j, len, line, ref;
ref = ygopro.split_chat_lines(msg, player, settings.modules.i18n.default);
for (j = 0, len = ref.length; j < len; j++) {
line = ref[j];
chat_buf = ygopro.helper.prepareMessage("STOC_CHAT", {
player: player,
msg: line
});
if (settings.modules.cloud_replay.enabled && (this.arena || settings.modules.tournament_mode.enabled)) {
this.addRecorderBuffer(chat_buf);
}
this.watcher_buffers.push(chat_buf);
} }
} if (settings.modules.hide_name === "always") {
return "********";
}
return player.name;
});
}; return Room;
}).call(this);
// 网络连接 // 网络连接
netRequestHandler = function(client) { netRequestHandler = function(client) {
...@@ -3718,15 +3740,14 @@ ...@@ -3718,15 +3740,14 @@
ygopro.stoc_follow('HS_PLAYER_ENTER', true, async function(buffer, info, client, server, datas) { ygopro.stoc_follow('HS_PLAYER_ENTER', true, async function(buffer, info, client, server, datas) {
var pos, room, struct; var pos, room, struct;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && settings.modules.hide_name && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN)) { if (room && settings.modules.hide_name && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
return false; pos = info.pos;
} if (pos < 4 && pos !== client.pos) {
pos = info.pos; struct = ygopro.structs.get("STOC_HS_PlayerEnter");
if (pos < 4 && pos !== client.pos) { struct._setBuff(buffer);
struct = ygopro.structs.get("STOC_HS_PlayerEnter"); struct.set("name", "********");
struct._setBuff(buffer); buffer = struct.buffer;
struct.set("name", "********"); }
buffer = struct.buffer;
} }
return false; return false;
}); });
...@@ -3894,7 +3915,7 @@ ...@@ -3894,7 +3915,7 @@
if (!(player)) { if (!(player)) {
continue; continue;
} }
display_name = (settings.modules.hide_name && player !== room.waiting_for_player ? "********" : room.waiting_for_player.name); display_name = room.getMaskedPlayerName(player, room.waiting_for_player);
ygopro.stoc_send_chat(player, `${room.waiting_for_player_time <= 9 ? ' ' : ''}${room.waiting_for_player_time}\${kick_count_down_arena_part1} ${display_name} \${kick_count_down_arena_part2}`, room.waiting_for_player_time <= 9 ? ygopro.constants.COLORS.RED : ygopro.constants.COLORS.LIGHTBLUE); ygopro.stoc_send_chat(player, `${room.waiting_for_player_time <= 9 ? ' ' : ''}${room.waiting_for_player_time}\${kick_count_down_arena_part1} ${display_name} \${kick_count_down_arena_part2}`, room.waiting_for_player_time <= 9 ? ygopro.constants.COLORS.RED : ygopro.constants.COLORS.LIGHTBLUE);
} }
} }
...@@ -3991,7 +4012,7 @@ ...@@ -3991,7 +4012,7 @@
client.side_tcount = null; client.side_tcount = null;
} }
} }
if (settings.modules.hide_name && room.duel_count === 0) { if (settings.modules.hide_name === "start" && room.duel_count === 0) {
ref1 = room.get_playing_player(); ref1 = room.get_playing_player();
for (l = 0, len1 = ref1.length; l < len1; l++) { for (l = 0, len1 = ref1.length; l < len1; l++) {
player = ref1[l]; player = ref1[l];
...@@ -4275,6 +4296,10 @@ ...@@ -4275,6 +4296,10 @@
} }
return cancel; return cancel;
} }
if (room.random_type && settings.modules.random_duel.disable_chat) {
ygopro.stoc_send_chat(client, "${chat_disabled}", ygopro.constants.COLORS.BABYBLUE);
return true;
}
if (client.abuse_count >= 5 || CLIENT_is_banned_by_mc(client)) { if (client.abuse_count >= 5 || CLIENT_is_banned_by_mc(client)) {
log.warn("BANNED CHAT", client.name, client.ip, msg); log.warn("BANNED CHAT", client.name, client.ip, msg);
ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (client.ban_mc && client.ban_mc.message ? ": " + client.ban_mc.message : ""), ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (client.ban_mc && client.ban_mc.message ? ": " + client.ban_mc.message : ""), ygopro.constants.COLORS.RED);
......
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