Commit acd35df1 authored by nanahira's avatar nanahira

Merge branch 'master' into tcg_random

parents 1fe34a6b 2c2db8ed
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
"http": { "http": {
"port": 7211, "port": 7211,
"password": "Nanahira", "password": "Nanahira",
"websocket_roomlist": true, "websocket_roomlist": false,
"public_roomlist": false, "public_roomlist": false,
"show_ip": true, "show_ip": true,
"show_info": true, "show_info": true,
......
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
"http": { "http": {
"port": 1263, "port": 1263,
"password": "Nanahira", "password": "Nanahira",
"websocket_roomlist": true, "websocket_roomlist": false,
"public_roomlist": true, "public_roomlist": true,
"show_ip": true, "show_ip": true,
"show_info": true, "show_info": true,
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"stop": false, "stop": false,
"side_timeout": false, "side_timeout": false,
"tag_duel_surrender": true, "tag_duel_surrender": true,
"replay_delay": false,
"i18n": { "i18n": {
"auto_pick": false, "auto_pick": false,
"default": "zh-cn", "default": "zh-cn",
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"invalid_password_existed": "Password invalid (Already Existed)", "invalid_password_existed": "Password invalid (Already Existed)",
"invalid_password_not_found": "Password invalid (Not Found)", "invalid_password_not_found": "Password invalid (Not Found)",
"invalid_password_action": "Password invalid (Invalid Action)", "invalid_password_action": "Password invalid (Invalid Action)",
"invalid_password_checksum": "Password incorrect (Checksum Failed)", "invalid_password_checksum": "Password incorrect (Checksum Failed) (Please re-login your account.)",
"bad_user_name": "Please enter the correct ID", "bad_user_name": "Please enter the correct ID",
"server_full": "Server is full, please try again later.", "server_full": "Server is full, please try again later.",
"too_much_connection": "Too many clients running at the moment! ", "too_much_connection": "Too many clients running at the moment! ",
...@@ -186,6 +186,8 @@ ...@@ -186,6 +186,8 @@
"vip_set_victory": "Your victory word have been set.", "vip_set_victory": "Your victory word have been set.",
"vip_password_changed": "Password changed.", "vip_password_changed": "Password changed.",
"vip_player_name_too_long": "Your username or password is too long to log in. Please change your username and try again.", "vip_player_name_too_long": "Your username or password is too long to log in. Please change your username and try again.",
"replay_hint_part1": "Sending the replay of the duel number ",
"replay_hint_part2": ".",
"athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender." "athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender."
}, },
"es-es": { "es-es": {
...@@ -371,7 +373,7 @@ ...@@ -371,7 +373,7 @@
"invalid_password_existed": "主机密码不正确 (Already Existed)", "invalid_password_existed": "主机密码不正确 (Already Existed)",
"invalid_password_not_found": "主机密码不正确 (Not Found)", "invalid_password_not_found": "主机密码不正确 (Not Found)",
"invalid_password_action": "主机密码不正确 (Invalid Action)", "invalid_password_action": "主机密码不正确 (Invalid Action)",
"invalid_password_checksum": "主机密码不正确 (Checksum Failed)", "invalid_password_checksum": "主机密码不正确 (Checksum Failed) (请退出并重新登录你的账号)",
"bad_user_name": "请输入正确的用户名", "bad_user_name": "请输入正确的用户名",
"server_full": "服务器已经爆满,请稍候再试", "server_full": "服务器已经爆满,请稍候再试",
"too_much_connection": "同时开启的客户端数量过多 ", "too_much_connection": "同时开启的客户端数量过多 ",
...@@ -519,6 +521,8 @@ ...@@ -519,6 +521,8 @@
"vip_set_victory": "已设置胜利台词。", "vip_set_victory": "已设置胜利台词。",
"vip_password_changed": "密码修改成功。", "vip_password_changed": "密码修改成功。",
"vip_player_name_too_long": "你的用户名或设置的密码太长,使用此用户名可能会无法登陆。请更换用户名重试。", "vip_player_name_too_long": "你的用户名或设置的密码太长,使用此用户名可能会无法登陆。请更换用户名重试。",
"replay_hint_part1": "正在发送第",
"replay_hint_part2": "局决斗的录像。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。" "athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
}, },
"ko-kr": { "ko-kr": {
......
...@@ -378,36 +378,36 @@ if settings.modules.challonge.enabled ...@@ -378,36 +378,36 @@ if settings.modules.challonge.enabled
if settings.modules.challonge.cache_ttl if settings.modules.challonge.cache_ttl
challonge_cache = [] challonge_cache = []
challonge_queue_callbacks = [[], []] challonge_queue_callbacks = [[], []]
is_requesting = [false, false] is_requesting = [null, null]
get_callback = (challonge_type, _callback) -> get_callback = (challonge_type, _callback) ->
return ((err, data) -> return ((err, data) ->
if settings.modules.challonge.cache_ttl and !err and data if settings.modules.challonge.cache_ttl and !err and data
challonge_cache[challonge_type] = data challonge_cache[challonge_type] = data
is_requesting[challonge_type] =null
_callback(err, data) _callback(err, data)
while challonge_queue_callbacks[challonge_type].length while challonge_queue_callbacks[challonge_type].length
cur_callback = challonge_queue_callbacks[challonge_type].splice(0, 1)[0] cur_callback = challonge_queue_callbacks[challonge_type].splice(0, 1)[0]
cur_callback(err, data) cur_callback(err, data)
is_requesting[challonge_type] = false
return return
) )
challonge.participants._index = (_data) -> challonge.participants._index = (_data) ->
if settings.modules.challonge.cache_ttl and challonge_cache[0] if settings.modules.challonge.cache_ttl and challonge_cache[0]
_data.callback(null, challonge_cache[0]) _data.callback(null, challonge_cache[0])
else if is_requesting[0] else if is_requesting[0] and moment() - is_requesting[0] <= 5000
challonge_queue_callbacks[0].push(_data.callback) challonge_queue_callbacks[0].push(_data.callback)
else else
_data.callback = get_callback(0, _data.callback) _data.callback = get_callback(0, _data.callback)
is_requesting[0] = true is_requesting[0] = moment()
challonge.participants.index(_data) challonge.participants.index(_data)
return return
challonge.matches._index = (_data) -> challonge.matches._index = (_data) ->
if settings.modules.challonge.cache_ttl and challonge_cache[1] if settings.modules.challonge.cache_ttl and challonge_cache[1]
_data.callback(null, challonge_cache[1]) _data.callback(null, challonge_cache[1])
else if is_requesting[1] else if is_requesting[1] and moment() - is_requesting[1] <= 5000
challonge_queue_callbacks[1].push(_data.callback) challonge_queue_callbacks[1].push(_data.callback)
else else
_data.callback = get_callback(1, _data.callback) _data.callback = get_callback(1, _data.callback)
is_requesting[1] = true is_requesting[1] = moment()
challonge.matches.index(_data) challonge.matches.index(_data)
return return
refresh_challonge_cache = () -> refresh_challonge_cache = () ->
...@@ -480,6 +480,7 @@ ban_user = (name) -> ...@@ -480,6 +480,7 @@ ban_user = (name) ->
ROOM_bad_ip[bad_ip]=99 ROOM_bad_ip[bad_ip]=99
settings.ban.banned_ip.push(player.ip) settings.ban.banned_ip.push(player.ip)
ygopro.stoc_send_chat_to_room(room, "#{player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
CLIENT_send_replays(player, room)
CLIENT_kick(player) CLIENT_kick(player)
continue continue
return return
...@@ -849,7 +850,7 @@ CLIENT_send_reconnect_info = (client, server, room) -> ...@@ -849,7 +850,7 @@ CLIENT_send_reconnect_info = (client, server, room) ->
client.reconnecting = false client.reconnecting = false
else if room.selecting_tp else if room.selecting_tp
ygopro.stoc_send(client, 'DUEL_START') ygopro.stoc_send(client, 'DUEL_START')
if client == room.selecting_tp and !client.selected_preduel if client == room.selecting_tp # and !client.selected_preduel
ygopro.stoc_send(client, 'SELECT_TP') ygopro.stoc_send(client, 'SELECT_TP')
client.reconnecting = false client.reconnecting = false
else else
...@@ -981,6 +982,15 @@ CLIENT_get_partner = (client) -> ...@@ -981,6 +982,15 @@ CLIENT_get_partner = (client) ->
else else
return room.dueling_players[5 - client.pos] return room.dueling_players[5 - client.pos]
CLIENT_send_replays = (client, room) ->
return false unless settings.modules.replay_delay and room.replays.length and room.hostinfo.mode == 1
i = 0
for buffer in room.replays
++i
ygopro.stoc_send_chat(client, "${replay_hint_part1}" + i + "${replay_hint_part2}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send(client, "REPLAY", buffer)
return true
class Room class Room
constructor: (name, @hostinfo) -> constructor: (name, @hostinfo) ->
@name = name @name = name
...@@ -1001,6 +1011,8 @@ class Room ...@@ -1001,6 +1011,8 @@ class Room
@duel_count = 0 @duel_count = 0
@death = 0 @death = 0
@turn = 0 @turn = 0
if settings.modules.replay_delay
@replays = []
ROOM_all.push this ROOM_all.push this
@hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo)) @hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo))
...@@ -1010,7 +1022,6 @@ class Room ...@@ -1010,7 +1022,6 @@ class Room
@hostinfo.lflist = _.findIndex lflists, (list)-> list.tcg @hostinfo.lflist = _.findIndex lflists, (list)-> list.tcg
else else
@hostinfo.lflist = -1 @hostinfo.lflist = -1
@hostinfo.replay_mode = if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe then 1 else 0
if name[0...2] == 'M#' if name[0...2] == 'M#'
@hostinfo.mode = 1 @hostinfo.mode = 1
...@@ -1136,12 +1147,15 @@ class Room ...@@ -1136,12 +1147,15 @@ class Room
if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/) if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/)
@no_watch = true @no_watch = true
@hostinfo.replay_mode = if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe or @hostinfo.mode == 1 and settings.modules.replay_delay then 1 else 0
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'), param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'),
(if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'), (if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'),
@hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit, @hostinfo.replay_mode] @hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit, @hostinfo.replay_mode]
try try
@process = spawn './ygopro', param, {cwd: 'ygopro'} @process = spawn './ygopro', param, {cwd: 'ygopro'}
@process_pid = @process.pid
@process.on 'error', (err)=> @process.on 'error', (err)=>
_.each @players, (player)-> _.each @players, (player)->
ygopro.stoc_die(player, "${create_room_failed}") ygopro.stoc_die(player, "${create_room_failed}")
...@@ -1176,6 +1190,7 @@ class Room ...@@ -1176,6 +1190,7 @@ class Room
@has_ygopro_error = true @has_ygopro_error = true
@ygopro_error_length = if @ygopro_error_length then @ygopro_error_length + data.length else data.length @ygopro_error_length = if @ygopro_error_length then @ygopro_error_length + data.length else data.length
if @ygopro_error_length > 10000 if @ygopro_error_length > 10000
@send_replays()
@process.kill() @process.kill()
return return
catch catch
...@@ -1344,6 +1359,14 @@ class Room ...@@ -1344,6 +1359,14 @@ class Room
challonge_duel_log.scoresCsv = "0-0" challonge_duel_log.scoresCsv = "0-0"
return challonge_duel_log return challonge_duel_log
send_replays: () ->
return false unless settings.modules.replay_delay and @replays.length and @hostinfo.mode == 1
for player in @players
CLIENT_send_replays(player, this)
for player in @watchers
CLIENT_send_replays(player, this)
return true
add_windbot: (botdata)-> add_windbot: (botdata)->
@windbot = botdata @windbot = botdata
request request
...@@ -1410,6 +1433,7 @@ class Room ...@@ -1410,6 +1433,7 @@ class Room
roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist
#client.room = null #client.room = null
else else
@send_replays()
@process.kill() @process.kill()
#client.room = null #client.room = null
this.delete() this.delete()
...@@ -1488,6 +1512,8 @@ net.createServer (client) -> ...@@ -1488,6 +1512,8 @@ net.createServer (client) ->
return return
unless server.client.closed unless server.client.closed
ygopro.stoc_send_chat(server.client, "${server_closed}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(server.client, "${server_closed}", ygopro.constants.COLORS.RED)
#if room and settings.modules.replay_delay
# room.send_replays()
CLIENT_kick(server.client) CLIENT_kick(server.client)
SERVER_clear_disconnect(server) SERVER_clear_disconnect(server)
return return
...@@ -1502,6 +1528,8 @@ net.createServer (client) -> ...@@ -1502,6 +1528,8 @@ net.createServer (client) ->
return return
unless server.client.closed unless server.client.closed
ygopro.stoc_send_chat(server.client, "${server_error}: #{error}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(server.client, "${server_error}: #{error}", ygopro.constants.COLORS.RED)
#if room and settings.modules.replay_delay
# room.send_replays()
CLIENT_kick(server.client) CLIENT_kick(server.client)
SERVER_clear_disconnect(server) SERVER_clear_disconnect(server)
return return
...@@ -1799,9 +1827,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -1799,9 +1827,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
room_buffer.write(player_string, buffer_pos, 128, "utf8") room_buffer.write(player_string, buffer_pos, 128, "utf8")
buffer_pos += 128 buffer_pos += 128
if room.started if room.started
room_buffer.writeInt8((if room.scores[room_players[0].name_vpass]? then room.scores[room_players[0].name_vpass] else 0), buffer_pos) room_buffer.writeInt8((if room_players[0] and room.scores[room_players[0].name_vpass]? then room.scores[room_players[0].name_vpass] else 0), buffer_pos)
buffer_pos++ buffer_pos++
room_buffer.writeInt32LE((if room_players[0].lp? then room_players[0].lp else room.hostinfo.start_lp), buffer_pos) room_buffer.writeInt32LE((if room_players[0] and room_players[0].lp? then room_players[0].lp else room.hostinfo.start_lp), buffer_pos)
buffer_pos += 4 buffer_pos += 4
else else
room_buffer.writeInt8(0, buffer_pos) room_buffer.writeInt8(0, buffer_pos)
...@@ -1816,9 +1844,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -1816,9 +1844,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
room_buffer.write(player_string, buffer_pos, 128, "utf8") room_buffer.write(player_string, buffer_pos, 128, "utf8")
buffer_pos += 128 buffer_pos += 128
if room.started if room.started
room_buffer.writeInt8((if room.scores[room_players[oppo_pos].name_vpass]? then room.scores[room_players[oppo_pos].name_vpass] else 0), buffer_pos) room_buffer.writeInt8((if room_players[oppo_pos] and room.scores[room_players[oppo_pos].name_vpass]? then room.scores[room_players[oppo_pos].name_vpass] else 0), buffer_pos)
buffer_pos++ buffer_pos++
room_buffer.writeInt32LE((if room_players[oppo_pos].lp? then room_players[oppo_pos].lp else room.hostinfo.start_lp), buffer_pos) room_buffer.writeInt32LE((if room_players[oppo_pos] and room_players[oppo_pos].lp? then room_players[oppo_pos].lp else room.hostinfo.start_lp), buffer_pos)
buffer_pos += 4 buffer_pos += 4
else else
room_buffer.writeInt8(0, buffer_pos) room_buffer.writeInt8(0, buffer_pos)
...@@ -2353,6 +2381,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)-> ...@@ -2353,6 +2381,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
if settings.modules.retry_handle.max_retry_count and client.retry_count >= settings.modules.retry_handle.max_retry_count if settings.modules.retry_handle.max_retry_count and client.retry_count >= settings.modules.retry_handle.max_retry_count
ygopro.stoc_send_chat_to_room(room, client.name + "${retry_too_much_room_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_room_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, client.name + "${retry_too_much_room_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_room_part2}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send_chat(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED)
CLIENT_send_replays(client, room)
CLIENT_kick(client) CLIENT_kick(client)
return true return true
if client.last_game_msg if client.last_game_msg
...@@ -2712,6 +2741,17 @@ ygopro.stoc_follow 'FIELD_FINISH', true, (buffer, info, client, server)-> ...@@ -2712,6 +2741,17 @@ ygopro.stoc_follow 'FIELD_FINISH', true, (buffer, info, client, server)->
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg) ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg)
return true return true
ygopro.stoc_follow 'DUEL_END', false, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room and settings.modules.replay_delay and room.hostinfo.mode == 1
CLIENT_send_replays(client, room)
if !room.replays_sent_to_watchers
room.replays_sent_to_watchers = true
for player in room.players when player and player.pos > 3
CLIENT_send_replays(player, room)
for player in room.watchers when player
CLIENT_send_replays(player, room)
wait_room_start = (room, time)-> wait_room_start = (room, time)->
unless !room or room.started or room.ready_player_count_without_host < room.max_player - 1 unless !room or room.started or room.ready_player_count_without_host < room.max_player - 1
time -= 1 time -= 1
...@@ -2840,7 +2880,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)-> ...@@ -2840,7 +2880,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
deck_arena = deck_arena + 'custom' deck_arena = deck_arena + 'custom'
#log.info "DECK LOG START", client.name, room.arena #log.info "DECK LOG START", client.name, room.arena
if settings.modules.deck_log.local if settings.modules.deck_log.local
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_') deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.process_pid + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_')
fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) -> fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) ->
if err if err
log.warn 'DECK SAVE ERROR', err log.warn 'DECK SAVE ERROR', err
...@@ -2943,7 +2983,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)-> ...@@ -2943,7 +2983,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
ygopro.stoc_send_random_tip(client) if settings.modules.tips.enabled ygopro.stoc_send_random_tip(client) if settings.modules.tips.enabled
when '/ai' when '/ai'
if settings.modules.windbot.enabled and client.is_host and !settings.modules.challonge.enabled if settings.modules.windbot.enabled and client.is_host and !settings.modules.challonge.enabled and !room.arena and room.random_type != 'M'
if name = cmd[1] if name = cmd[1]
windbot = _.sample _.filter windbots, (w)-> windbot = _.sample _.filter windbots, (w)->
w.name == name or w.deck == name w.name == name or w.deck == name
...@@ -3102,6 +3142,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)-> ...@@ -3102,6 +3142,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED)
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}") ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}")
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}", 3) ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}", 3)
CLIENT_send_replays(client, room)
CLIENT_kick(client) CLIENT_kick(client)
return true return true
else else
...@@ -3196,6 +3237,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)-> ...@@ -3196,6 +3237,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos
room.finished_by_death = true room.finished_by_death = true
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
CLIENT_send_replays(room.dueling_players[oppo_pos - win_pos], room) if room.hostinfo.mode == 1
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END') ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END')
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END') if room.hostinfo.mode == 2 ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END') if room.hostinfo.mode == 2
room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1 room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1
...@@ -3320,7 +3362,7 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server)-> ...@@ -3320,7 +3362,7 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
client.selected_preduel = true client.selected_preduel = true
room.selecting_tp = false # room.selecting_tp = false
return unless room.random_type or room.arena return unless room.random_type or room.arena
room.last_active_time = moment() room.last_active_time = moment()
return return
...@@ -3394,6 +3436,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)-> ...@@ -3394,6 +3436,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
ygopro.stoc_send_chat_to_room(room, client.name + "${side_overtime_room}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, client.name + "${side_overtime_room}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send_chat(client, "${side_overtime}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${side_overtime}", ygopro.constants.COLORS.RED)
#room.scores[client.name_vpass] = -9 #room.scores[client.name_vpass] = -9
CLIENT_send_replays(client, room)
CLIENT_kick(client) CLIENT_kick(client)
clearInterval sinterval clearInterval sinterval
else else
...@@ -3425,9 +3468,11 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)-> ...@@ -3425,9 +3468,11 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player unless room return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay and room.hostinfo.mode == 1 unless room
if settings.modules.cloud_replay.enabled and room.random_type if settings.modules.cloud_replay.enabled and room.random_type
Cloud_replay_ids.push room.cloud_replay_id Cloud_replay_ids.push room.cloud_replay_id
if settings.modules.replay_delay and room.hostinfo.mode == 1 and client.pos == 0 and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player)
room.replays.push(buffer)
if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe
if client.pos == 0 if client.pos == 0
dueltime=moment().format('YYYY-MM-DD HH-mm-ss') dueltime=moment().format('YYYY-MM-DD HH-mm-ss')
...@@ -3442,7 +3487,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ...@@ -3442,7 +3487,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
duellog = { duellog = {
time: dueltime, time: dueltime,
name: room.name + (if settings.modules.tournament_mode.show_info then (" (Duel:" + room.duel_count + ")") else ""), name: room.name + (if settings.modules.tournament_mode.show_info then (" (Duel:" + room.duel_count + ")") else ""),
roomid: room.port.toString(), roomid: room.process_pid.toString(),
cloud_replay_id: "R#"+room.cloud_replay_id, cloud_replay_id: "R#"+room.cloud_replay_id,
replay_filename: replay_filename, replay_filename: replay_filename,
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
...@@ -3458,9 +3503,9 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ...@@ -3458,9 +3503,9 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
) )
if settings.modules.cloud_replay.enabled if settings.modules.cloud_replay.enabled
ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R##{room.cloud_replay_id}${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R##{room.cloud_replay_id}${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE)
return settings.modules.tournament_mode.block_replay_to_player return settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay and room.hostinfo.mode == 1
else else
return false return settings.modules.replay_delay and room.hostinfo.mode == 1
if settings.modules.random_duel.enabled if settings.modules.random_duel.enabled
setInterval ()-> setInterval ()->
...@@ -3473,6 +3518,7 @@ if settings.modules.random_duel.enabled ...@@ -3473,6 +3518,7 @@ if settings.modules.random_duel.enabled
room.scores[room.waiting_for_player.name_vpass] = -9 room.scores[room.waiting_for_player.name_vpass] = -9
#log.info room.waiting_for_player.name, room.scores[room.waiting_for_player.name_vpass] #log.info room.waiting_for_player.name, room.scores[room.waiting_for_player.name_vpass]
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)
CLIENT_send_replays(room.waiting_for_player, room)
CLIENT_kick(room.waiting_for_player) CLIENT_kick(room.waiting_for_player)
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10) else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
...@@ -3490,6 +3536,7 @@ if settings.modules.mycard.enabled ...@@ -3490,6 +3536,7 @@ if settings.modules.mycard.enabled
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)
room.scores[room.waiting_for_player.name_vpass] = -9 room.scores[room.waiting_for_player.name_vpass] = -9
#log.info room.waiting_for_player.name, room.scores[room.waiting_for_player.name_vpass] #log.info room.waiting_for_player.name, room.scores[room.waiting_for_player.name_vpass]
CLIENT_send_replays(room.waiting_for_player, room)
CLIENT_kick(room.waiting_for_player) CLIENT_kick(room.waiting_for_player)
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10) else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
...@@ -3561,16 +3608,21 @@ if settings.modules.http ...@@ -3561,16 +3608,21 @@ if settings.modules.http
else else
response.writeHead(200) response.writeHead(200)
roomsjson = JSON.stringify rooms: (for room in ROOM_all when room and room.established roomsjson = JSON.stringify rooms: (for room in ROOM_all when room and room.established
pid: room.process.pid.toString(), roomid: room.process_pid.toString(),
roomid: room.port.toString(),
roomname: if pass_validated then room.name else room.name.split('$', 2)[0], roomname: if pass_validated then room.name else room.name.split('$', 2)[0],
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') != -1).toString(), needpass: (room.name.indexOf('$') != -1).toString(),
users: (for player in room.players when player.pos? users: _.sortBy((for player in room.players when player.pos?
id: (-1).toString(), id: (-1).toString(),
name: player.name + (if settings.modules.http.show_ip and pass_validated and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.http.show_info and room.started and player.pos != 7 and not (room.hostinfo.mode == 2 and player.pos % 2 > 0) then (" (Score:" + room.scores[player.name_vpass] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + (if room.hostinfo.mode != 2 then (" Cards:" + (if player.card_count? then player.card_count else room.hostinfo.start_hand)) else "") + ")") else ""), name: player.name,
ip: if settings.modules.http.show_ip and pass_validated and !player.is_local then player.ip.slice(7) else null,
status: if settings.modules.http.show_info and room.started and player.pos != 7 then (
score: room.scores[player.name_vpass],
lp: if player.lp? then player.lp else room.hostinfo.start_lp,
cards: if room.hostinfo.mode != 2 then (if player.card_count? then player.card_count else room.hostinfo.start_hand) else null
) else null,
pos: player.pos pos: player.pos
), ), "pos"),
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.changing_side then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait' istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.changing_side then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait'
), null, 2 ), null, 2
response.end(addCallback(u.query.callback, roomsjson)) response.end(addCallback(u.query.callback, roomsjson))
...@@ -3732,12 +3784,13 @@ if settings.modules.http ...@@ -3732,12 +3784,13 @@ if settings.modules.http
else if u.query.kick else if u.query.kick
kick_room_found = false kick_room_found = false
for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.port.toString() or u.query.kick == room.name) for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.process_pid.toString() or u.query.kick == room.name)
kick_room_found = true kick_room_found = true
if room.started if room.started
room.scores[room.dueling_players[0].name_vpass] = 0 room.scores[room.dueling_players[0].name_vpass] = 0
room.scores[room.dueling_players[1].name_vpass] = 0 room.scores[room.dueling_players[1].name_vpass] = 0
room.kicked = true room.kicked = true
@send_replays()
room.process.kill() room.process.kill()
room.delete() room.delete()
response.writeHead(200) response.writeHead(200)
...@@ -3748,7 +3801,7 @@ if settings.modules.http ...@@ -3748,7 +3801,7 @@ if settings.modules.http
else if u.query.death else if u.query.death
death_room_found = false death_room_found = false
for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.port.toString() or u.query.death == room.name) for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.process_pid.toString() or u.query.death == room.name)
death_room_found = true death_room_found = true
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1 oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
if !room.changing_side and (!room.duel_count or room.turn) if !room.changing_side and (!room.duel_count or room.turn)
...@@ -3773,6 +3826,7 @@ if settings.modules.http ...@@ -3773,6 +3826,7 @@ if settings.modules.http
win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos
room.finished_by_death = true room.finished_by_death = true
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
CLIENT_send_replays(room.dueling_players[oppo_pos - win_pos], room) if room.hostinfo.mode == 1
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END') ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END')
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END') if room.hostinfo.mode == 2 ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END') if room.hostinfo.mode == 2
room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1 room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1
...@@ -3792,7 +3846,7 @@ if settings.modules.http ...@@ -3792,7 +3846,7 @@ if settings.modules.http
else if u.query.deathcancel else if u.query.deathcancel
death_room_found = false death_room_found = false
for room in ROOM_all when room and room.established and room.started and room.death and (u.query.deathcancel == "all" or u.query.deathcancel == room.port.toString()) for room in ROOM_all when room and room.established and room.started and room.death and (u.query.deathcancel == "all" or u.query.deathcancel == room.process_pid.toString())
death_room_found = true death_room_found = true
room.death = 0 room.death = 0
ygopro.stoc_send_chat_to_room(room, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE)
......
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 1.12.7
(function() { (function() {
var CLIENT_check_vip, CLIENT_get_absolute_pos, CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, CLIENT_get_partner, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_kick_reconnect, CLIENT_is_able_to_reconnect, CLIENT_is_banned_by_mc, CLIENT_is_player, CLIENT_kick, CLIENT_kick_reconnect, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_player_flee, ROOM_player_get_score, ROOM_player_lose, ROOM_player_win, ROOM_players_banned, ROOM_players_oppentlist, ROOM_players_scores, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, VIP_generate_cdkeys, _, addCallback, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_queue_callbacks, chat_color, concat_name, config, cppversion, crypto, date, default_config, default_data, dialogues, disconnect_list, duel_log, e, exec, execFile, fs, geoip, get_callback, get_memory_usage, http, http_server, https, https_server, import_datas, imported, is_requesting, j, k, l, len, len1, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_tips_zh, load_words, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, ref2, refresh_challonge_cache, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, spawn_windbot, tips, url, users_cache, v, vip_info, wait_room_start, wait_room_start_arena, windbot_looplimit, windbots, words, ygopro, zlib; var CLIENT_check_vip, CLIENT_get_absolute_pos, CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, CLIENT_get_partner, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_kick_reconnect, CLIENT_is_able_to_reconnect, CLIENT_is_banned_by_mc, CLIENT_is_player, CLIENT_kick, CLIENT_kick_reconnect, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_replays, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_player_flee, ROOM_player_get_score, ROOM_player_lose, ROOM_player_win, ROOM_players_banned, ROOM_players_oppentlist, ROOM_players_scores, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, VIP_generate_cdkeys, _, addCallback, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_queue_callbacks, chat_color, concat_name, config, cppversion, crypto, date, default_config, default_data, dialogues, disconnect_list, duel_log, e, exec, execFile, fs, geoip, get_callback, get_memory_usage, http, http_server, https, https_server, import_datas, imported, is_requesting, j, k, l, len, len1, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_tips_zh, load_words, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, ref2, refresh_challonge_cache, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, spawn_windbot, tips, url, users_cache, v, vip_info, wait_room_start, wait_room_start_arena, windbot_looplimit, windbots, words, ygopro, zlib;
net = require('net'); net = require('net');
...@@ -470,40 +470,40 @@ ...@@ -470,40 +470,40 @@
challonge_cache = []; challonge_cache = [];
} }
challonge_queue_callbacks = [[], []]; challonge_queue_callbacks = [[], []];
is_requesting = [false, false]; is_requesting = [null, null];
get_callback = function(challonge_type, _callback) { get_callback = function(challonge_type, _callback) {
return (function(err, data) { return (function(err, data) {
var cur_callback; var cur_callback;
if (settings.modules.challonge.cache_ttl && !err && data) { if (settings.modules.challonge.cache_ttl && !err && data) {
challonge_cache[challonge_type] = data; challonge_cache[challonge_type] = data;
} }
is_requesting[challonge_type] = null;
_callback(err, data); _callback(err, data);
while (challonge_queue_callbacks[challonge_type].length) { while (challonge_queue_callbacks[challonge_type].length) {
cur_callback = challonge_queue_callbacks[challonge_type].splice(0, 1)[0]; cur_callback = challonge_queue_callbacks[challonge_type].splice(0, 1)[0];
cur_callback(err, data); cur_callback(err, data);
} }
is_requesting[challonge_type] = false;
}); });
}; };
challonge.participants._index = function(_data) { challonge.participants._index = function(_data) {
if (settings.modules.challonge.cache_ttl && challonge_cache[0]) { if (settings.modules.challonge.cache_ttl && challonge_cache[0]) {
_data.callback(null, challonge_cache[0]); _data.callback(null, challonge_cache[0]);
} else if (is_requesting[0]) { } else if (is_requesting[0] && moment() - is_requesting[0] <= 5000) {
challonge_queue_callbacks[0].push(_data.callback); challonge_queue_callbacks[0].push(_data.callback);
} else { } else {
_data.callback = get_callback(0, _data.callback); _data.callback = get_callback(0, _data.callback);
is_requesting[0] = true; is_requesting[0] = moment();
challonge.participants.index(_data); challonge.participants.index(_data);
} }
}; };
challonge.matches._index = function(_data) { challonge.matches._index = function(_data) {
if (settings.modules.challonge.cache_ttl && challonge_cache[1]) { if (settings.modules.challonge.cache_ttl && challonge_cache[1]) {
_data.callback(null, challonge_cache[1]); _data.callback(null, challonge_cache[1]);
} else if (is_requesting[1]) { } else if (is_requesting[1] && moment() - is_requesting[1] <= 5000) {
challonge_queue_callbacks[1].push(_data.callback); challonge_queue_callbacks[1].push(_data.callback);
} else { } else {
_data.callback = get_callback(1, _data.callback); _data.callback = get_callback(1, _data.callback);
is_requesting[1] = true; is_requesting[1] = moment();
challonge.matches.index(_data); challonge.matches.index(_data);
} }
}; };
...@@ -588,6 +588,7 @@ ...@@ -588,6 +588,7 @@
ROOM_bad_ip[bad_ip] = 99; ROOM_bad_ip[bad_ip] = 99;
settings.ban.banned_ip.push(player.ip); settings.ban.banned_ip.push(player.ip);
ygopro.stoc_send_chat_to_room(room, player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
CLIENT_send_replays(player, room);
CLIENT_kick(player); CLIENT_kick(player);
continue; continue;
} }
...@@ -1121,7 +1122,7 @@ ...@@ -1121,7 +1122,7 @@
client.reconnecting = false; client.reconnecting = false;
} else if (room.selecting_tp) { } else if (room.selecting_tp) {
ygopro.stoc_send(client, 'DUEL_START'); ygopro.stoc_send(client, 'DUEL_START');
if (client === room.selecting_tp && !client.selected_preduel) { if (client === room.selecting_tp) {
ygopro.stoc_send(client, 'SELECT_TP'); ygopro.stoc_send(client, 'SELECT_TP');
} }
client.reconnecting = false; client.reconnecting = false;
...@@ -1275,6 +1276,22 @@ ...@@ -1275,6 +1276,22 @@
} }
}; };
CLIENT_send_replays = function(client, room) {
var buffer, i, len2, m, ref3;
if (!(settings.modules.replay_delay && room.replays.length && room.hostinfo.mode === 1)) {
return false;
}
i = 0;
ref3 = room.replays;
for (m = 0, len2 = ref3.length; m < len2; m++) {
buffer = ref3[m];
++i;
ygopro.stoc_send_chat(client, "${replay_hint_part1}" + i + "${replay_hint_part2}", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send(client, "REPLAY", buffer);
}
return true;
};
Room = (function() { Room = (function() {
function Room(name, hostinfo) { function Room(name, hostinfo) {
var draw_count, lflist, param, rule, start_hand, start_lp, time_limit; var draw_count, lflist, param, rule, start_hand, start_lp, time_limit;
...@@ -1297,6 +1314,9 @@ ...@@ -1297,6 +1314,9 @@
this.duel_count = 0; this.duel_count = 0;
this.death = 0; this.death = 0;
this.turn = 0; this.turn = 0;
if (settings.modules.replay_delay) {
this.replays = [];
}
ROOM_all.push(this); ROOM_all.push(this);
this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo))); this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo)));
delete this.hostinfo.comment; delete this.hostinfo.comment;
...@@ -1309,7 +1329,6 @@ ...@@ -1309,7 +1329,6 @@
} else { } else {
this.hostinfo.lflist = -1; this.hostinfo.lflist = -1;
} }
this.hostinfo.replay_mode = settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe ? 1 : 0;
if (name.slice(0, 2) === 'M#') { if (name.slice(0, 2) === 'M#') {
this.hostinfo.mode = 1; this.hostinfo.mode = 1;
} else if (name.slice(0, 2) === 'T#') { } else if (name.slice(0, 2) === 'T#') {
...@@ -1458,11 +1477,13 @@ ...@@ -1458,11 +1477,13 @@
this.no_watch = true; this.no_watch = true;
} }
} }
this.hostinfo.replay_mode = settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe || this.hostinfo.mode === 1 && settings.modules.replay_delay ? 1 : 0;
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit, this.hostinfo.replay_mode]; param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (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];
try { try {
this.process = spawn('./ygopro', param, { this.process = spawn('./ygopro', param, {
cwd: 'ygopro' cwd: 'ygopro'
}); });
this.process_pid = this.process.pid;
this.process.on('error', (function(_this) { this.process.on('error', (function(_this) {
return function(err) { return function(err) {
_.each(_this.players, function(player) { _.each(_this.players, function(player) {
...@@ -1515,6 +1536,7 @@ ...@@ -1515,6 +1536,7 @@
_this.has_ygopro_error = true; _this.has_ygopro_error = true;
_this.ygopro_error_length = _this.ygopro_error_length ? _this.ygopro_error_length + data.length : data.length; _this.ygopro_error_length = _this.ygopro_error_length ? _this.ygopro_error_length + data.length : data.length;
if (_this.ygopro_error_length > 10000) { if (_this.ygopro_error_length > 10000) {
_this.send_replays();
_this.process.kill(); _this.process.kill();
} }
}; };
...@@ -1750,6 +1772,24 @@ ...@@ -1750,6 +1772,24 @@
return challonge_duel_log; return challonge_duel_log;
}; };
Room.prototype.send_replays = function() {
var len2, len3, m, n, player, ref2, ref3;
if (!(settings.modules.replay_delay && this.replays.length && this.hostinfo.mode === 1)) {
return false;
}
ref2 = this.players;
for (m = 0, len2 = ref2.length; m < len2; m++) {
player = ref2[m];
CLIENT_send_replays(player, this);
}
ref3 = this.watchers;
for (n = 0, len3 = ref3.length; n < len3; n++) {
player = ref3[n];
CLIENT_send_replays(player, this);
}
return true;
};
Room.prototype.add_windbot = function(botdata) { Room.prototype.add_windbot = function(botdata) {
this.windbot = botdata; this.windbot = botdata;
request({ request({
...@@ -1841,6 +1881,7 @@ ...@@ -1841,6 +1881,7 @@
roomlist.update(this); roomlist.update(this);
} }
} else { } else {
this.send_replays();
this.process.kill(); this.process.kill();
this["delete"](); this["delete"]();
} }
...@@ -2279,9 +2320,9 @@ ...@@ -2279,9 +2320,9 @@
room_buffer.write(player_string, buffer_pos, 128, "utf8"); room_buffer.write(player_string, buffer_pos, 128, "utf8");
buffer_pos += 128; buffer_pos += 128;
if (room.started) { if (room.started) {
room_buffer.writeInt8((room.scores[room_players[0].name_vpass] != null ? room.scores[room_players[0].name_vpass] : 0), buffer_pos); room_buffer.writeInt8((room_players[0] && (room.scores[room_players[0].name_vpass] != null) ? room.scores[room_players[0].name_vpass] : 0), buffer_pos);
buffer_pos++; buffer_pos++;
room_buffer.writeInt32LE((room_players[0].lp != null ? room_players[0].lp : room.hostinfo.start_lp), buffer_pos); room_buffer.writeInt32LE((room_players[0] && (room_players[0].lp != null) ? room_players[0].lp : room.hostinfo.start_lp), buffer_pos);
buffer_pos += 4; buffer_pos += 4;
} else { } else {
room_buffer.writeInt8(0, buffer_pos); room_buffer.writeInt8(0, buffer_pos);
...@@ -2299,9 +2340,9 @@ ...@@ -2299,9 +2340,9 @@
room_buffer.write(player_string, buffer_pos, 128, "utf8"); room_buffer.write(player_string, buffer_pos, 128, "utf8");
buffer_pos += 128; buffer_pos += 128;
if (room.started) { if (room.started) {
room_buffer.writeInt8((room.scores[room_players[oppo_pos].name_vpass] != null ? room.scores[room_players[oppo_pos].name_vpass] : 0), buffer_pos); room_buffer.writeInt8((room_players[oppo_pos] && (room.scores[room_players[oppo_pos].name_vpass] != null) ? room.scores[room_players[oppo_pos].name_vpass] : 0), buffer_pos);
buffer_pos++; buffer_pos++;
room_buffer.writeInt32LE((room_players[oppo_pos].lp != null ? room_players[oppo_pos].lp : room.hostinfo.start_lp), buffer_pos); room_buffer.writeInt32LE((room_players[oppo_pos] && (room_players[oppo_pos].lp != null) ? room_players[oppo_pos].lp : room.hostinfo.start_lp), buffer_pos);
buffer_pos += 4; buffer_pos += 4;
} else { } else {
room_buffer.writeInt8(0, buffer_pos); room_buffer.writeInt8(0, buffer_pos);
...@@ -2922,6 +2963,7 @@ ...@@ -2922,6 +2963,7 @@
if (settings.modules.retry_handle.max_retry_count && client.retry_count >= settings.modules.retry_handle.max_retry_count) { if (settings.modules.retry_handle.max_retry_count && client.retry_count >= settings.modules.retry_handle.max_retry_count) {
ygopro.stoc_send_chat_to_room(room, client.name + "${retry_too_much_room_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_room_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, client.name + "${retry_too_much_room_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_room_part2}", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED);
CLIENT_send_replays(client, room);
CLIENT_kick(client); CLIENT_kick(client);
return true; return true;
} }
...@@ -3414,6 +3456,34 @@ ...@@ -3414,6 +3456,34 @@
return true; return true;
}); });
ygopro.stoc_follow('DUEL_END', false, function(buffer, info, client, server) {
var len2, len3, m, n, player, ref3, ref4, results, room;
room = ROOM_all[client.rid];
if (!(room && settings.modules.replay_delay && room.hostinfo.mode === 1)) {
return;
}
CLIENT_send_replays(client, room);
if (!room.replays_sent_to_watchers) {
room.replays_sent_to_watchers = true;
ref3 = room.players;
for (m = 0, len2 = ref3.length; m < len2; m++) {
player = ref3[m];
if (player && player.pos > 3) {
CLIENT_send_replays(player, room);
}
}
ref4 = room.watchers;
results = [];
for (n = 0, len3 = ref4.length; n < len3; n++) {
player = ref4[n];
if (player) {
results.push(CLIENT_send_replays(player, room));
}
}
return results;
}
});
wait_room_start = function(room, time) { wait_room_start = function(room, time) {
var len2, m, player, ref3; var len2, m, player, ref3;
if (!(!room || room.started || room.ready_player_count_without_host < room.max_player - 1)) { if (!(!room || room.started || room.ready_player_count_without_host < room.max_player - 1)) {
...@@ -3601,7 +3671,7 @@ ...@@ -3601,7 +3671,7 @@
deck_arena = deck_arena + 'custom'; deck_arena = deck_arena + 'custom';
} }
if (settings.modules.deck_log.local) { if (settings.modules.deck_log.local) {
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_'); deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.process_pid + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_');
fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) { fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) {
if (err) { if (err) {
return log.warn('DECK SAVE ERROR', err); return log.warn('DECK SAVE ERROR', err);
...@@ -3750,7 +3820,7 @@ ...@@ -3750,7 +3820,7 @@
} }
break; break;
case '/ai': case '/ai':
if (settings.modules.windbot.enabled && client.is_host && !settings.modules.challonge.enabled) { if (settings.modules.windbot.enabled && client.is_host && !settings.modules.challonge.enabled && !room.arena && room.random_type !== 'M') {
if (name = cmd[1]) { if (name = cmd[1]) {
windbot = _.sample(_.filter(windbots, function(w) { windbot = _.sample(_.filter(windbots, function(w) {
return w.name === name || w.deck === name; return w.name === name || w.deck === name;
...@@ -3953,6 +4023,7 @@ ...@@ -3953,6 +4023,7 @@
ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${banned_duel_tip}", ygopro.constants.COLORS.RED);
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}"); ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}");
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}", 3); ROOM_ban_player(client.name, client.ip, "${random_ban_reason_abuse}", 3);
CLIENT_send_replays(client, room);
CLIENT_kick(client); CLIENT_kick(client);
return true; return true;
} else { } else {
...@@ -4073,6 +4144,9 @@ ...@@ -4073,6 +4144,9 @@
win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos; win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos;
room.finished_by_death = true; room.finished_by_death = true;
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
if (room.hostinfo.mode === 1) {
CLIENT_send_replays(room.dueling_players[oppo_pos - win_pos], room);
}
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END'); ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END');
if (room.hostinfo.mode === 2) { if (room.hostinfo.mode === 2) {
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END'); ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END');
...@@ -4250,7 +4324,6 @@ ...@@ -4250,7 +4324,6 @@
return; return;
} }
client.selected_preduel = true; client.selected_preduel = true;
room.selecting_tp = false;
if (!(room.random_type || room.arena)) { if (!(room.random_type || room.arena)) {
return; return;
} }
...@@ -4353,6 +4426,7 @@ ...@@ -4353,6 +4426,7 @@
if (client.side_tcount === 1) { if (client.side_tcount === 1) {
ygopro.stoc_send_chat_to_room(room, client.name + "${side_overtime_room}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, client.name + "${side_overtime_room}", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat(client, "${side_overtime}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${side_overtime}", ygopro.constants.COLORS.RED);
CLIENT_send_replays(client, room);
CLIENT_kick(client); CLIENT_kick(client);
return clearInterval(sinterval); return clearInterval(sinterval);
} else { } else {
...@@ -4392,11 +4466,14 @@ ...@@ -4392,11 +4466,14 @@
var duellog, dueltime, i, len2, len3, m, n, player, ref3, ref4, replay_filename, room; var duellog, dueltime, i, len2, len3, m, n, player, ref3, ref4, replay_filename, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe && settings.modules.tournament_mode.block_replay_to_player; return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe && settings.modules.tournament_mode.block_replay_to_player || settings.modules.replay_delay && room.hostinfo.mode === 1;
} }
if (settings.modules.cloud_replay.enabled && room.random_type) { if (settings.modules.cloud_replay.enabled && room.random_type) {
Cloud_replay_ids.push(room.cloud_replay_id); Cloud_replay_ids.push(room.cloud_replay_id);
} }
if (settings.modules.replay_delay && room.hostinfo.mode === 1 && client.pos === 0 && !(settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe && settings.modules.tournament_mode.block_replay_to_player)) {
room.replays.push(buffer);
}
if (settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) { if (settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) {
if (client.pos === 0) { if (client.pos === 0) {
dueltime = moment().format('YYYY-MM-DD HH-mm-ss'); dueltime = moment().format('YYYY-MM-DD HH-mm-ss');
...@@ -4418,7 +4495,7 @@ ...@@ -4418,7 +4495,7 @@
duellog = { duellog = {
time: dueltime, time: dueltime,
name: room.name + (settings.modules.tournament_mode.show_info ? " (Duel:" + room.duel_count + ")" : ""), name: room.name + (settings.modules.tournament_mode.show_info ? " (Duel:" + room.duel_count + ")" : ""),
roomid: room.port.toString(), roomid: room.process_pid.toString(),
cloud_replay_id: "R#" + room.cloud_replay_id, cloud_replay_id: "R#" + room.cloud_replay_id,
replay_filename: replay_filename, replay_filename: replay_filename,
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
...@@ -4447,9 +4524,9 @@ ...@@ -4447,9 +4524,9 @@
if (settings.modules.cloud_replay.enabled) { if (settings.modules.cloud_replay.enabled) {
ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R#" + room.cloud_replay_id + "${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R#" + room.cloud_replay_id + "${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE);
} }
return settings.modules.tournament_mode.block_replay_to_player; return settings.modules.tournament_mode.block_replay_to_player || settings.modules.replay_delay && room.hostinfo.mode === 1;
} else { } else {
return false; return settings.modules.replay_delay && room.hostinfo.mode === 1;
} }
}); });
...@@ -4467,6 +4544,7 @@ ...@@ -4467,6 +4544,7 @@
ROOM_ban_player(room.waiting_for_player.name, room.waiting_for_player.ip, "${random_ban_reason_AFK}"); ROOM_ban_player(room.waiting_for_player.name, room.waiting_for_player.ip, "${random_ban_reason_AFK}");
room.scores[room.waiting_for_player.name_vpass] = -9; room.scores[room.waiting_for_player.name_vpass] = -9;
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);
CLIENT_send_replays(room.waiting_for_player, room);
CLIENT_kick(room.waiting_for_player); CLIENT_kick(room.waiting_for_player);
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) { } else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) {
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED);
...@@ -4489,6 +4567,7 @@ ...@@ -4489,6 +4567,7 @@
room.last_active_time = moment(); room.last_active_time = moment();
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);
room.scores[room.waiting_for_player.name_vpass] = -9; room.scores[room.waiting_for_player.name_vpass] = -9;
CLIENT_send_replays(room.waiting_for_player, room);
CLIENT_kick(room.waiting_for_player); CLIENT_kick(room.waiting_for_player);
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) { } else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) {
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED);
...@@ -4585,12 +4664,11 @@ ...@@ -4585,12 +4664,11 @@
room = ROOM_all[m]; room = ROOM_all[m];
if (room && room.established) { if (room && room.established) {
results.push({ results.push({
pid: room.process.pid.toString(), roomid: room.process_pid.toString(),
roomid: room.port.toString(),
roomname: pass_validated ? room.name : room.name.split('$', 2)[0], roomname: pass_validated ? room.name : room.name.split('$', 2)[0],
roommode: room.hostinfo.mode, roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') !== -1).toString(), needpass: (room.name.indexOf('$') !== -1).toString(),
users: (function() { users: _.sortBy((function() {
var len3, n, ref3, results1; var len3, n, ref3, results1;
ref3 = room.players; ref3 = room.players;
results1 = []; results1 = [];
...@@ -4599,13 +4677,19 @@ ...@@ -4599,13 +4677,19 @@
if (player.pos != null) { if (player.pos != null) {
results1.push({ results1.push({
id: (-1).toString(), id: (-1).toString(),
name: player.name + (settings.modules.http.show_ip && pass_validated && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.http.show_info && room.started && player.pos !== 7 && !(room.hostinfo.mode === 2 && player.pos % 2 > 0) ? " (Score:" + room.scores[player.name_vpass] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + (room.hostinfo.mode !== 2 ? " Cards:" + (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : "") + ")" : ""), name: player.name,
ip: settings.modules.http.show_ip && pass_validated && !player.is_local ? player.ip.slice(7) : null,
status: settings.modules.http.show_info && room.started && player.pos !== 7 ? {
score: room.scores[player.name_vpass],
lp: player.lp != null ? player.lp : room.hostinfo.start_lp,
cards: room.hostinfo.mode !== 2 ? (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : null
} : null,
pos: player.pos pos: player.pos
}); });
} }
} }
return results1; return results1;
})(), })(), "pos"),
istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " " + (room.changing_side ? "Siding" : "Turn:" + (room.turn != null ? room.turn : 0) + (room.death ? "/" + (room.death > 0 ? room.death - 1 : "Death") : "")) : 'start') : 'wait' istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " " + (room.changing_side ? "Siding" : "Turn:" + (room.turn != null ? room.turn : 0) + (room.death ? "/" + (room.death > 0 ? room.death - 1 : "Death") : "")) : 'start') : 'wait'
}); });
} }
...@@ -4802,7 +4886,7 @@ ...@@ -4802,7 +4886,7 @@
kick_room_found = false; kick_room_found = false;
for (p = 0, len5 = ROOM_all.length; p < len5; p++) { for (p = 0, len5 = ROOM_all.length; p < len5; p++) {
room = ROOM_all[p]; room = ROOM_all[p];
if (!(room && room.established && (u.query.kick === "all" || u.query.kick === room.port.toString() || u.query.kick === room.name))) { if (!(room && room.established && (u.query.kick === "all" || u.query.kick === room.process_pid.toString() || u.query.kick === room.name))) {
continue; continue;
} }
kick_room_found = true; kick_room_found = true;
...@@ -4811,6 +4895,7 @@ ...@@ -4811,6 +4895,7 @@
room.scores[room.dueling_players[1].name_vpass] = 0; room.scores[room.dueling_players[1].name_vpass] = 0;
} }
room.kicked = true; room.kicked = true;
this.send_replays();
room.process.kill(); room.process.kill();
room["delete"](); room["delete"]();
} }
...@@ -4824,7 +4909,7 @@ ...@@ -4824,7 +4909,7 @@
death_room_found = false; death_room_found = false;
for (q = 0, len6 = ROOM_all.length; q < len6; q++) { for (q = 0, len6 = ROOM_all.length; q < len6; q++) {
room = ROOM_all[q]; room = ROOM_all[q];
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.port.toString() || u.query.death === room.name))) { if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.process_pid.toString() || u.query.death === room.name))) {
continue; continue;
} }
death_room_found = true; death_room_found = true;
...@@ -4855,6 +4940,9 @@ ...@@ -4855,6 +4940,9 @@
win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos; win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos;
room.finished_by_death = true; room.finished_by_death = true;
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
if (room.hostinfo.mode === 1) {
CLIENT_send_replays(room.dueling_players[oppo_pos - win_pos], room);
}
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END'); ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END');
if (room.hostinfo.mode === 2) { if (room.hostinfo.mode === 2) {
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END'); ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END');
...@@ -4886,7 +4974,7 @@ ...@@ -4886,7 +4974,7 @@
death_room_found = false; death_room_found = false;
for (r = 0, len7 = ROOM_all.length; r < len7; r++) { for (r = 0, len7 = ROOM_all.length; r < len7; r++) {
room = ROOM_all[r]; room = ROOM_all[r];
if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.port.toString()))) { if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.process_pid.toString()))) {
continue; continue;
} }
death_room_found = true; death_room_found = true;
......
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