Commit c7b080c0 authored by nanahira's avatar nanahira

Merge branch 'mc'

parents 2cb5b0b9 24183ed8
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
"replay_path": "./replays/", "replay_path": "./replays/",
"replay_archive_tool": "7z", "replay_archive_tool": "7z",
"block_replay_to_player": false, "block_replay_to_player": false,
"enable_recover": true, "enable_recover": false,
"show_ip": false, "show_ip": false,
"show_info": true, "show_info": true,
"log_save_path": "./config/", "log_save_path": "./config/",
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
"cloud_replay_error": "Replay opening failed.", "cloud_replay_error": "Replay opening failed.",
"cloud_replay_playing": "Accessing cloud replay", "cloud_replay_playing": "Accessing cloud replay",
"cloud_replay_hint": "These are the recent saved replay codes, please enter the replay code at the password column to access it.", "cloud_replay_hint": "These are the recent saved replay codes, please enter the replay code at the password column to access it.",
"recover_replay_hint": "These are the recent duels, please enter the code RC[ID]%[TURN]#[ROOMNAME] at the password column to recover the duel.", "recover_replay_hint": "These are the recent duels, please enter the code RC[ID]T[TURN]#[ROOMNAME] at the password column to recover the duel.",
"recover_hint": "You entered a recover room. Please be ready with your deck on that duel.", "recover_hint": "You entered a recover room. Please be ready with your deck on that duel.",
"recover_start_hint": "Started recovering...", "recover_start_hint": "Started recovering...",
"recover_success": "Recover success. Please wait until current turn.", "recover_success": "Recover success. Please wait until current turn.",
...@@ -379,7 +379,7 @@ ...@@ -379,7 +379,7 @@
"cloud_replay_error": "播放录像出错", "cloud_replay_error": "播放录像出错",
"cloud_replay_playing": "正在观看云录像", "cloud_replay_playing": "正在观看云录像",
"cloud_replay_hint": "以下是您近期的云录像,密码处输入 R#录像编号 即可观看", "cloud_replay_hint": "以下是您近期的云录像,密码处输入 R#录像编号 即可观看",
"recover_replay_hint": "以下是您近期进行的决斗,密码处输入 RC决斗编号%回合数#房间号 即可创建复盘房间", "recover_replay_hint": "以下是您近期进行的决斗,密码处输入 RC决斗编号T回合数#房间号 即可创建复盘房间",
"recover_hint": "你进入了一个复盘房间,请使用复盘局的卡组准备。", "recover_hint": "你进入了一个复盘房间,请使用复盘局的卡组准备。",
"recover_start_hint": "开始复盘...", "recover_start_hint": "开始复盘...",
"recover_success": "复盘成功。请耐心等待跳到当前回合。", "recover_success": "复盘成功。请耐心等待跳到当前回合。",
......
...@@ -481,47 +481,42 @@ if settings.modules.challonge.enabled ...@@ -481,47 +481,42 @@ if settings.modules.challonge.enabled
challonge = global.challonge = require(challonge_module_name).createClient(settings.modules.challonge.options) challonge = global.challonge = require(challonge_module_name).createClient(settings.modules.challonge.options)
if settings.modules.challonge.cache_ttl if settings.modules.challonge.cache_ttl
challonge_cache = [] challonge_cache = []
challonge_queue_callbacks = [[], []] challonge_queue_callbacks = {
is_requesting = [null, null] participants: []
matches: []
}
is_challonge_requesting = {
participants: null
matches: null
}
get_callback = (challonge_type, resolve_data) -> get_callback = (challonge_type, resolve_data) ->
return ((err, data) -> return ((err, data) ->
if settings.modules.challonge.cache_ttl and !err and data if settings.modules.challonge.cache_ttl and !err and data
challonge_cache[challonge_type] = data challonge_cache[challonge_type] = data
is_requesting[challonge_type] =null is_challonge_requesting[challonge_type] = null
resolve_data.resolve(err, data) resolve_data.resolve(err, data)
while challonge_queue_callbacks[challonge_type].length while challonge_queue_callbacks[challonge_type].length
cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0] cur_resolve_data = challonge_queue_callbacks[challonge_type].splice(0, 1)[0]
cur_resolve_data.resolve(err, data) cur_resolve_data.resolve(err, data)
return return
) )
challonge.participants._index = (_data) -> replaced_index = (challonge_type) ->
resolve_data = new ResolveData(_data.callback) return (_data) ->
if settings.modules.challonge.cache_ttl and challonge_cache[0] resolve_data = new ResolveData(_data.callback)
resolve_data.resolve(null, challonge_cache[0]) if settings.modules.challonge.cache_ttl and !_data.no_cache and challonge_cache[0]
else if is_requesting[0] and moment() - is_requesting[0] <= 5000 resolve_data.resolve(null, challonge_cache[challonge_type])
challonge_queue_callbacks[0].push(resolve_data) else if is_challonge_requesting[challonge_type] and moment() - is_challonge_requesting[challonge_type] <= 5000
else challonge_queue_callbacks[challonge_type].push(resolve_data)
_data.callback = get_callback(0, resolve_data) else
is_requesting[0] = moment() _data.callback = get_callback(challonge_type, resolve_data)
try is_challonge_requesting[challonge_type] = moment()
challonge.participants.index(_data) try
catch err challonge[challonge_type].index(_data)
_data.callback(err, null) catch err
return _data.callback(err, null)
challonge.matches._index = (_data) -> return
resolve_data = new ResolveData(_data.callback) for challonge_type in ["participants", "matches"]
if settings.modules.challonge.cache_ttl and challonge_cache[1] challonge[challonge_type]._index = replaced_index(challonge_type)
resolve_data.resolve(null, challonge_cache[1])
else if is_requesting[1] and moment() - is_requesting[1] <= 5000
challonge_queue_callbacks[1].push(resolve_data)
else
_data.callback = get_callback(1, resolve_data)
is_requesting[1] = moment()
try
challonge.matches.index(_data)
catch err
_data.callback(err, null)
return
challonge.matches._update = (_data) -> challonge.matches._update = (_data) ->
try try
challonge.matches.update(_data) challonge.matches.update(_data)
...@@ -1152,7 +1147,7 @@ CLIENT_get_partner = global.CLIENT_get_partner = (client) -> ...@@ -1152,7 +1147,7 @@ CLIENT_get_partner = global.CLIENT_get_partner = (client) ->
return room.dueling_players[5 - client.pos] return room.dueling_players[5 - client.pos]
CLIENT_send_replays = global.CLIENT_send_replays = (client, room) -> CLIENT_send_replays = global.CLIENT_send_replays = (client, room) ->
return false unless settings.modules.replay_delay and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player) and room.replays.length and room.hostinfo.mode == 1 and !client.replays_sent and !client.closed return false unless settings.modules.replay_delay and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) and room.replays.length and room.hostinfo.mode == 1 and !client.replays_sent and !client.closed
client.replays_sent = true client.replays_sent = true
i = 0 i = 0
for buffer in room.replays for buffer in room.replays
...@@ -1303,7 +1298,7 @@ class Room ...@@ -1303,7 +1298,7 @@ class Room
else else
@hostinfo.auto_death = 40 @hostinfo.auto_death = 40
if settings.modules.tournament_mode.enable_recover and (param = rule.match /(^|,|,)(RC|RECOVER)(\d*)%(\d*)(,|,|$)/) if settings.modules.tournament_mode.enable_recover and (param = rule.match /(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/)
@recovered = true @recovered = true
@recovering = true @recovering = true
@recover_from_turn = parseInt(param[4]) @recover_from_turn = parseInt(param[4])
...@@ -1322,7 +1317,7 @@ class Room ...@@ -1322,7 +1317,7 @@ class Room
if settings.modules.tournament_mode.enabled if settings.modules.tournament_mode.enabled
@hostinfo.replay_mode |= 0x1 @hostinfo.replay_mode |= 0x1
if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe) or (@hostinfo.mode == 1 and settings.modules.replay_delay) if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) or (@hostinfo.mode == 1 and settings.modules.replay_delay)
@hostinfo.replay_mode |= 0x2 @hostinfo.replay_mode |= 0x2
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, @hostinfo.duel_rule, param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, @hostinfo.duel_rule,
...@@ -2403,6 +2398,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2403,6 +2398,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else else
ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, '${loading_user_info}', ygopro.constants.COLORS.BABYBLUE)
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
recover_match = info.pass.match(/^(RC|RECOVER)(\d*)T(\d*)$/)
_async.auto({ _async.auto({
participant_data: (done) -> participant_data: (done) ->
challonge.participants._index({ challonge.participants._index({
...@@ -2414,7 +2410,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2414,7 +2410,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
match_data: (done) -> match_data: (done) ->
challonge.matches._index({ challonge.matches._index({
id: settings.modules.challonge.tournament_id, id: settings.modules.challonge.tournament_id,
callback: done callback: done,
no_cache: !!recover_match
}) })
return return
}, (err, datas) -> }, (err, datas) ->
...@@ -2444,7 +2441,10 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2444,7 +2441,10 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
#if found.winnerId #if found.winnerId
# ygopro.stoc_die(client, '${challonge_match_already_finished}') # ygopro.stoc_die(client, '${challonge_match_already_finished}')
# return # return
room = ROOM_find_or_create_by_name('M#' + found.id) create_room_name = 'M#' + found.id
if recover_match
create_room_name = recover_match[0] + ',' + create_room_name
room = ROOM_find_or_create_by_name(create_room_name)
if room if room
room.challonge_info = found room.challonge_info = found
# room.max_player = 2 # room.max_player = 2
...@@ -3903,13 +3903,13 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)-> ...@@ -3903,13 +3903,13 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay unless room return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay unless room
if settings.modules.cloud_replay.enabled and room.random_type if settings.modules.cloud_replay.enabled and room.random_type
Cloud_replay_ids.push room.cloud_replay_id Cloud_replay_ids.push room.cloud_replay_id
if !room.replays[room.duel_count - 1] if !room.replays[room.duel_count - 1]
# console.log("Replay saved: ", room.duel_count - 1, client.pos) # console.log("Replay saved: ", room.duel_count - 1, client.pos)
room.replays[room.duel_count - 1] = buffer room.replays[room.duel_count - 1] = buffer
if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe or settings.modules.tournament_mode.enable_recover
if client.pos == 0 if client.pos == 0
dueltime=moment().format('YYYY-MM-DD HH-mm-ss') dueltime=moment().format('YYYY-MM-DD HH-mm-ss')
replay_filename=dueltime replay_filename=dueltime
......
This diff is collapsed.
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