Commit ff8cf381 authored by nanahira's avatar nanahira

Merge branch 'mc'

parents d9fc3b46 bef24b52
Pipeline #3120 passed with stages
in 5 minutes and 15 seconds
...@@ -1802,6 +1802,48 @@ class Room ...@@ -1802,6 +1802,48 @@ class Room
ygopro.stoc_send_chat_to_room(room, "#{player.name}${using_athletic_deck}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "#{player.name}${using_athletic_deck}", ygopro.constants.COLORS.BABYBLUE)
)) ))
await return await return
join_post_watch: (client) ->
if @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !@hostinfo.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this)
client.is_post_watcher = true
if settings.modules.vip.enabled and await CLIENT_check_vip(client)
playWords = await dataManager.getUserWords(CLIENT_get_authorize_key(client))
if playWords
@playLines(playWords)
else if settings.modules.words.enabled and words.words[client.name]
@playLines words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]
ygopro.stoc_send_chat_to_room(this, "#{client.name} ${watch_join}")
@watchers.push client
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE)
for buffer in @watcher_buffers
client.write buffer
return true
else
ygopro.stoc_die(client, "${watch_denied}")
return false
else
return false
join_player: (client) ->
if @error
ygopro.stoc_die(client, @error)
return false
if @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
return @join_post_watch(client)
if @hostinfo.no_watch and @players.length >= (if @hostinfo.mode == 2 then 4 else 2)
ygopro.stoc_die(client, "${watch_denied_room}")
return true
if @challonge_info
for player in @get_playing_player() when player and player != client and player.challonge_info.id == client.challonge_info.id
ygopro.stoc_die(client, "${challonge_player_already_in}")
return false
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this)
@connect(client)
return true
playLines: (lines) -> playLines: (lines) ->
for line in _.lines lines for line in _.lines lines
...@@ -2243,33 +2285,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)-> ...@@ -2243,33 +2285,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
if !room if !room
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error else
ygopro.stoc_die(client, room.error) room.join_player(client)
else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
if settings.modules.vip.enabled and await CLIENT_check_vip(client)
playWords = await dataManager.getUserWords(CLIENT_get_authorize_key(client))
if playWords
room.playLines(playWords)
else if settings.modules.words.enabled and words.words[client.name]
room.playLines words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]
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)
for buffer in room.watcher_buffers
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.hostinfo.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
ygopro.stoc_die(client, "${watch_denied_room}")
else
#client.room = room
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
room.connect(client)
return return
_async.auto({ _async.auto({
...@@ -2369,15 +2386,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)-> ...@@ -2369,15 +2386,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
buffer = struct.buffer buffer = struct.buffer
pre_room = ROOM_find_by_name(info.pass) pre_room = ROOM_find_by_name(info.pass)
if pre_room and pre_room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.hostinfo.no_watch if pre_room and pre_room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.hostinfo.no_watch
room = pre_room pre_room.join_post_watch(client)
client.setTimeout(300000) #连接后超时5分钟 return
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
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)
for buffer in room.watcher_buffers
client.write buffer
else else
ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE)
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
...@@ -2434,36 +2444,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)-> ...@@ -2434,36 +2444,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
room.welcome = "${challonge_match_created}" room.welcome = "${challonge_match_created}"
if !room if !room
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error
ygopro.stoc_die(client, room.error)
else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
#client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
if settings.modules.vip.enabled and await CLIENT_check_vip(client)
playWords = await dataManager.getUserWords(CLIENT_get_authorize_key(client))
if playWords
room.playLines(playWords)
else if settings.modules.words.enabled and words.words[client.name]
room.playLines words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]
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)
for buffer in room.watcher_buffers
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.hostinfo.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
ygopro.stoc_die(client, "${watch_denied_room}")
else else
for player in room.get_playing_player() when player and player != client and player.challonge_info.id == client.challonge_info.id room.join_player(client)
ygopro.stoc_die(client, "${challonge_player_already_in}")
return
#client.room = room
#client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
room.connect(client)
return return
) )
...@@ -2510,32 +2492,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)-> ...@@ -2510,32 +2492,8 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
room = await ROOM_find_or_create_by_name(info.pass, client.ip) room = await ROOM_find_or_create_by_name(info.pass, client.ip)
if !room if !room
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error
ygopro.stoc_die(client, room.error)
else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
client.is_post_watcher = true
if settings.modules.vip.enabled and await CLIENT_check_vip(client)
playWords = await dataManager.getUserWords(CLIENT_get_authorize_key(client))
if playWords
room.playLines(playWords)
else if settings.modules.words.enabled and words.words[client.name]
room.playLines words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]
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)
for buffer in room.watcher_buffers
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.hostinfo.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
ygopro.stoc_die(client, "${watch_denied_room}")
else else
client.setTimeout(300000) #连接后超时5分钟 room.join_player(client)
client.rid = _.indexOf(ROOM_all, room)
room.connect(client)
await return await return
ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
......
...@@ -2438,6 +2438,69 @@ ...@@ -2438,6 +2438,69 @@
})); }));
} }
async join_post_watch(client) {
var buffer, j, len, playWords, ref;
if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !this.hostinfo.no_watch) {
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, this);
client.is_post_watcher = true;
if (settings.modules.vip.enabled && (await CLIENT_check_vip(client))) {
playWords = (await dataManager.getUserWords(CLIENT_get_authorize_key(client)));
if (playWords) {
this.playLines(playWords);
}
} else if (settings.modules.words.enabled && words.words[client.name]) {
this.playLines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
}
ygopro.stoc_send_chat_to_room(this, `${client.name} \${watch_join}`);
this.watchers.push(client);
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE);
ref = this.watcher_buffers;
for (j = 0, len = ref.length; j < len; j++) {
buffer = ref[j];
client.write(buffer);
}
return true;
} else {
ygopro.stoc_die(client, "${watch_denied}");
return false;
}
} else {
return false;
}
}
join_player(client) {
var j, len, player, ref;
if (this.error) {
ygopro.stoc_die(client, this.error);
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;
}
playLines(lines) { playLines(lines) {
var j, len, line, ref, results; var j, len, line, ref, results;
ref = _.lines(lines); ref = _.lines(lines);
...@@ -2771,7 +2834,7 @@ ...@@ -2771,7 +2834,7 @@
}); });
ygopro.ctos_follow('JOIN_GAME', true, async function(buffer, info, client, server, datas) { ygopro.ctos_follow('JOIN_GAME', true, async function(buffer, info, client, server, datas) {
var available_logs, check_buffer_indentity, create_room_with_action, duelLog, exactBan, index, j, l, len, len1, len2, len3, m, n, name, playWords, pre_room, recover_match, ref, ref1, replay, replay_id, replays, room, struct; var available_logs, check_buffer_indentity, create_room_with_action, duelLog, exactBan, index, j, l, len, len1, name, pre_room, recover_match, replay, replay_id, replays, room, struct;
//log.info info //log.info info
info.pass = info.pass.trim(); info.pass = info.pass.trim();
client.pass = info.pass; client.pass = info.pass;
...@@ -2860,7 +2923,7 @@ ...@@ -2860,7 +2923,7 @@
return (checksum & 0xFF) === 0; return (checksum & 0xFF) === 0;
}; };
create_room_with_action = async function(buffer, decrypted_buffer, match_permit) { create_room_with_action = async function(buffer, decrypted_buffer, match_permit) {
var action, len2, len3, m, n, name, opt1, opt2, opt3, options, playWords, player, ref, ref1, room, room_title, title; var action, len2, m, name, opt1, opt2, opt3, options, player, ref, room, room_title, title;
if (client.closed) { if (client.closed) {
return; return;
} }
...@@ -2980,39 +3043,8 @@ ...@@ -2980,39 +3043,8 @@
} }
if (!room) { if (!room) {
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
if (settings.modules.vip.enabled && (await CLIENT_check_vip(client))) {
playWords = (await dataManager.getUserWords(CLIENT_get_authorize_key(client)));
if (playWords) {
room.playLines(playWords);
}
} else if (settings.modules.words.enabled && words.words[client.name]) {
room.playLines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
}
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 (n = 0, len3 = ref1.length; n < len3; n++) {
buffer = ref1[n];
client.write(buffer);
}
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else { } else {
//client.room = room room.join_player(client);
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room);
room.connect(client);
} }
}; };
_async.auto({ _async.auto({
...@@ -3127,18 +3159,8 @@ ...@@ -3127,18 +3159,8 @@
} }
pre_room = ROOM_find_by_name(info.pass); pre_room = ROOM_find_by_name(info.pass);
if (pre_room && pre_room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.hostinfo.no_watch) { if (pre_room && pre_room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.hostinfo.no_watch) {
room = pre_room; pre_room.join_post_watch(client);
client.setTimeout(300000); //连接后超时5分钟 return;
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
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 (m = 0, len2 = ref.length; m < len2; m++) {
buffer = ref[m];
client.write(buffer);
}
} else { } else {
ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE);
client.setTimeout(300000); //连接后超时5分钟 client.setTimeout(300000); //连接后超时5分钟
...@@ -3158,7 +3180,7 @@ ...@@ -3158,7 +3180,7 @@
}); });
} }
}, async function(err, datas) { }, async function(err, datas) {
var create_room_name, found, k, len3, len4, match, n, o, playWords, player, ref1, ref2, ref3, ref4, user; var create_room_name, found, k, match, ref, ref1, room, user;
if (client.closed) { if (client.closed) {
return; return;
} }
...@@ -3168,9 +3190,9 @@ ...@@ -3168,9 +3190,9 @@
return; return;
} }
found = false; found = false;
ref1 = datas.participant_data; ref = datas.participant_data;
for (k in ref1) { for (k in ref) {
user = ref1[k]; user = ref[k];
if (user.participant && user.participant.name && deck_name_match(user.participant.name, client.name)) { if (user.participant && user.participant.name && deck_name_match(user.participant.name, client.name)) {
found = user.participant; found = user.participant;
break; break;
...@@ -3182,9 +3204,9 @@ ...@@ -3182,9 +3204,9 @@
} }
client.challonge_info = found; client.challonge_info = found;
found = false; found = false;
ref2 = datas.match_data; ref1 = datas.match_data;
for (k in ref2) { for (k in ref1) {
match = ref2[k]; match = ref1[k];
if (match && match.match && !match.match.winnerId && match.match.state !== "complete" && match.match.player1Id && match.match.player2Id && (match.match.player1Id === client.challonge_info.id || match.match.player2Id === client.challonge_info.id)) { if (match && match.match && !match.match.winnerId && match.match.state !== "complete" && match.match.player1Id && match.match.player2Id && (match.match.player1Id === client.challonge_info.id || match.match.player2Id === client.challonge_info.id)) {
found = match.match; found = match.match;
break; break;
...@@ -3209,48 +3231,8 @@ ...@@ -3209,48 +3231,8 @@
} }
if (!room) { if (!room) {
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
//client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
if (settings.modules.vip.enabled && (await CLIENT_check_vip(client))) {
playWords = (await dataManager.getUserWords(CLIENT_get_authorize_key(client)));
if (playWords) {
room.playLines(playWords);
}
} else if (settings.modules.words.enabled && words.words[client.name]) {
room.playLines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
}
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);
ref3 = room.watcher_buffers;
for (n = 0, len3 = ref3.length; n < len3; n++) {
buffer = ref3[n];
client.write(buffer);
}
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else { } else {
ref4 = room.get_playing_player(); room.join_player(client);
for (o = 0, len4 = ref4.length; o < len4; o++) {
player = ref4[o];
if (!(player && player !== client && player.challonge_info.id === client.challonge_info.id)) {
continue;
}
ygopro.stoc_die(client, "${challonge_player_already_in}");
return;
}
//client.room = room
//client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room);
room.connect(client);
} }
}); });
} }
...@@ -3294,38 +3276,8 @@ ...@@ -3294,38 +3276,8 @@
room = (await ROOM_find_or_create_by_name(info.pass, client.ip)); room = (await ROOM_find_or_create_by_name(info.pass, client.ip));
if (!room) { if (!room) {
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000); //连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
if (settings.modules.vip.enabled && (await CLIENT_check_vip(client))) {
playWords = (await dataManager.getUserWords(CLIENT_get_authorize_key(client)));
if (playWords) {
room.playLines(playWords);
}
} else if (settings.modules.words.enabled && words.words[client.name]) {
room.playLines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
}
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 (n = 0, len3 = ref1.length; n < len3; n++) {
buffer = ref1[n];
client.write(buffer);
}
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else { } else {
client.setTimeout(300000); //连接后超时5分钟 room.join_player(client);
client.rid = _.indexOf(ROOM_all, room);
room.connect(client);
} }
} }
}); });
......
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