Commit 254b36bd authored by nanahira's avatar nanahira

Merge branch 'mc'

parents 530973f4 4939926b
......@@ -13,7 +13,9 @@
"start_lp": 8000,
"start_hand": 5,
"draw_count": 1,
"time_limit": 180
"time_limit": 180,
"no_watch": false,
"auto_death": false
},
"modules": {
"welcome": "MyCard YGOPro Server",
......
......@@ -192,6 +192,8 @@
"invalid_side_rule": "Illegal cards are contained in your side deck.",
"arena_wait_hint": "If you opponent does not appear within 25 seconds, you may quit without any penalty.",
"arena_wait_timeout": "Your opponent did not appear, you may quit without any penalty.",
"auto_death_part1": "This room is an auto-extra-duel room. The Extra Duel will begin after ",
"auto_death_part2": " minutes.",
"athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender."
},
"es-es": {
......@@ -531,6 +533,8 @@
"invalid_side_rule": "副卡组中包含不允许换入副卡组的卡。",
"arena_wait_hint": "若对手在25秒内不进入游戏,您退房时不会进行扣分。",
"arena_wait_timeout": "由于对手未能在30秒内进入游戏,此时您退出游戏不会扣分。",
"auto_death_part1": "本房间为自动加时赛房间。比赛开始",
"auto_death_part2": "分钟后,将自动进入加时赛。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr": {
......
......@@ -1248,7 +1248,14 @@ class Room
@hostinfo.enable_priority = true
if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/)
@no_watch = true
@hostinfo.no_watch = true
if (param = rule.match /(^|,|,)(DEATH|DH)(\d*)(,|,|$)/)
death_time = parseInt(param[3])
if death_time and death_time > 0
@hostinfo.auto_death = death_time
else
@hostinfo.auto_death = 40
@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
......@@ -2109,6 +2116,8 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
start_lp: opt2
start_hand: opt3 >> 4
draw_count: opt3 & 0xF
no_watch: false
auto_death: false
}
options.lflist = _.findIndex lflists, (list)-> ((options.rule == 1) == list.tcg) and list.date.isBefore()
room = new Room(name, options)
......@@ -2150,7 +2159,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
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
......@@ -2167,7 +2176,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
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
......@@ -2237,7 +2246,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else if settings.modules.challonge.enabled
pre_room = ROOM_find_by_name(info.pass)
if pre_room and pre_room.started and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.no_watch
if pre_room and pre_room.started and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.hostinfo.no_watch
room = pre_room
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
......@@ -2300,7 +2309,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
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
......@@ -2317,7 +2326,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
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
for player in room.get_playing_player() when player and player != client and player.challonge_info.id == client.challonge_info.id
......@@ -2389,7 +2398,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else if room.error
ygopro.stoc_die(client, room.error)
else if room.started
if settings.modules.cloud_replay.enable_halfway_watch and !room.no_watch
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
......@@ -2406,7 +2415,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
client.write buffer
else
ygopro.stoc_die(client, "${watch_denied}")
else if room.no_watch and room.players.length >= (if room.hostinfo.mode == 2 then 4 else 2)
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.setTimeout(300000) #连接后超时5分钟
......@@ -2470,7 +2479,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
recorder.on 'error', (error)->
return
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher and !room.no_watch
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher and !room.hostinfo.no_watch
room.watcher = watcher = if settings.modules.test_mode.watch_public_hand then room.recorder else net.connect room.port, ->
ygopro.ctos_send watcher, 'PLAYER_INFO', {
name: "the Big Brother"
......@@ -2601,7 +2610,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
room.selecting_tp = false
if client.pos == 0
room.turn = 0
room.duel_count = room.duel_count + 1
room.duel_count++
if room.death and room.duel_count > 1
if room.death == -1
ygopro.stoc_send_chat_to_room(room, "${death_start_final}", ygopro.constants.COLORS.BABYBLUE)
......@@ -2825,7 +2834,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
ygopro.ctos_follow 'HS_TOOBSERVER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return unless room
if room.no_watch
if room.hostinfo.no_watch
ygopro.stoc_send_chat(client, "${watch_denied_room}", ygopro.constants.COLORS.RED)
return true
if (!room.arena and !settings.modules.challonge.enabled) or client.is_local
......@@ -2857,7 +2866,7 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)->
selftype = info.type & 0xf
is_host = ((info.type >> 4) & 0xf) != 0
# if room and room.no_watch and selftype == 7
# if room and room.hostinfo.no_watch and selftype == 7
# ygopro.stoc_die(client, "${watch_denied_room}")
# return true
client.is_host = is_host
......@@ -3054,6 +3063,8 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
if room.random_type == 'T'
# 双打房不记录匹配过
ROOM_players_oppentlist[player.ip] = null
if room.hostinfo.auto_death
ygopro.stoc_send_chat_to_room(room, "${auto_death_part1}#{room.hostinfo.auto_death}${auto_death_part2}", ygopro.constants.COLORS.BABYBLUE)
if settings.modules.hide_name and room.duel_count == 0
for player in room.get_playing_player() when player != client
ygopro.stoc_send(client, 'HS_PLAYER_ENTER', {
......@@ -3809,6 +3820,14 @@ if settings.modules.heartbeat_detection.enabled
return
, settings.modules.heartbeat_detection.interval
setInterval ()->
current_time = moment()
for room in ROOM_all when room and room.started and room.hostinfo.auto_death and !room.auto_death_triggered and current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death
room.auto_death_triggered = true
room.start_death()
, 1000
# spawn windbot
windbot_looplimit = 0
......
......@@ -1428,7 +1428,7 @@
Room = (function() {
function Room(name, hostinfo) {
var draw_count, error, lflist, list_official_to_pre, list_pre_to_official, official_database, param, pre_release_database, rule, start_hand, start_lp, temp_list, time_limit;
var death_time, draw_count, error, lflist, list_official_to_pre, list_pre_to_official, official_database, param, pre_release_database, rule, start_hand, start_lp, temp_list, time_limit;
this.hostinfo = hostinfo;
this.name = name;
this.alive = true;
......@@ -1605,7 +1605,15 @@
this.hostinfo.enable_priority = true;
}
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) {
this.no_watch = true;
this.hostinfo.no_watch = true;
}
if ((param = rule.match(/(^|,|,)(DEATH|DH)(\d*)(,|,|$)/))) {
death_time = parseInt(param[3]);
if (death_time && death_time > 0) {
this.hostinfo.auto_death = death_time;
} else {
this.hostinfo.auto_death = 40;
}
}
}
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;
......@@ -2644,7 +2652,9 @@
no_shuffle_deck: !!(opt1 & 1),
start_lp: opt2,
start_hand: opt3 >> 4,
draw_count: opt3 & 0xF
draw_count: opt3 & 0xF,
no_watch: false,
auto_death: false
};
options.lflist = _.findIndex(lflists, function(list) {
return ((options.rule === 1) === list.tcg) && list.date.isBefore();
......@@ -2704,7 +2714,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
......@@ -2732,7 +2742,7 @@
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else {
client.setTimeout(300000);
......@@ -2813,7 +2823,7 @@
}
} else if (settings.modules.challonge.enabled) {
pre_room = ROOM_find_by_name(info.pass);
if (pre_room && pre_room.started && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.no_watch) {
if (pre_room && pre_room.started && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.hostinfo.no_watch) {
room = pre_room;
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
......@@ -2892,7 +2902,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
if (settings.modules.vip.enabled && client.vip && vip_info.players[client.name].words) {
......@@ -2919,7 +2929,7 @@
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else {
ref8 = room.get_playing_player();
......@@ -2982,7 +2992,7 @@
} else if (room.error) {
ygopro.stoc_die(client, room.error);
} else if (room.started) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.no_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true;
......@@ -3010,7 +3020,7 @@
} else {
ygopro.stoc_die(client, "${watch_denied}");
}
} else if (room.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
} else if (room.hostinfo.no_watch && room.players.length >= (room.hostinfo.mode === 2 ? 4 : 2)) {
ygopro.stoc_die(client, "${watch_denied_room}");
} else {
client.setTimeout(300000);
......@@ -3094,7 +3104,7 @@
});
recorder.on('error', function(error) {});
}
if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher && !room.no_watch) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher && !room.hostinfo.no_watch) {
room.watcher = watcher = settings.modules.test_mode.watch_public_hand ? room.recorder : net.connect(room.port, function() {
ygopro.ctos_send(watcher, 'PLAYER_INFO', {
name: "the Big Brother"
......@@ -3245,7 +3255,7 @@
room.selecting_tp = false;
if (client.pos === 0) {
room.turn = 0;
room.duel_count = room.duel_count + 1;
room.duel_count++;
if (room.death && room.duel_count > 1) {
if (room.death === -1) {
ygopro.stoc_send_chat_to_room(room, "${death_start_final}", ygopro.constants.COLORS.BABYBLUE);
......@@ -3553,7 +3563,7 @@
if (!room) {
return;
}
if (room.no_watch) {
if (room.hostinfo.no_watch) {
ygopro.stoc_send_chat(client, "${watch_denied_room}", ygopro.constants.COLORS.RED);
return true;
}
......@@ -3912,6 +3922,9 @@
ROOM_players_oppentlist[player.ip] = null;
}
}
if (room.hostinfo.auto_death) {
ygopro.stoc_send_chat_to_room(room, "${auto_death_part1}" + room.hostinfo.auto_death + "${auto_death_part2}", ygopro.constants.COLORS.BABYBLUE);
}
}
if (settings.modules.hide_name && room.duel_count === 0) {
ref4 = room.get_playing_player();
......@@ -4951,6 +4964,21 @@
}, settings.modules.heartbeat_detection.interval);
}
setInterval(function() {
var current_time, len3, m, results, room;
current_time = moment();
results = [];
for (m = 0, len3 = ROOM_all.length; m < len3; m++) {
room = ROOM_all[m];
if (!(room && room.started && room.hostinfo.auto_death && !room.auto_death_triggered && current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death)) {
continue;
}
room.auto_death_triggered = true;
results.push(room.start_death());
}
return results;
}, 1000);
windbot_looplimit = 0;
spawn_windbot = function() {
......
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