Commit 4939926b authored by nanahira's avatar nanahira

add auto extra duel

parent 6dde909e
......@@ -14,7 +14,8 @@
"start_hand": 5,
"draw_count": 1,
"time_limit": 180,
"no_watch": false
"no_watch": false,
"auto_death": false
},
"modules": {
"welcome": "MyCard YGOPro Server",
......
......@@ -158,6 +158,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": {
......@@ -463,6 +465,8 @@
"invalid_side_rule": "副卡组中包含不允许换入副卡组的卡。",
"arena_wait_hint": "若对手在25秒内不进入游戏,您退房时不会进行扣分。",
"arena_wait_timeout": "由于对手未能在30秒内进入游戏,此时您退出游戏不会扣分。",
"auto_death_part1": "本房间为自动加时赛房间。比赛开始",
"auto_death_part2": "分钟后,将自动进入加时赛。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr": {
......
......@@ -1065,6 +1065,13 @@ class Room
if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/)
@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
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'),
......@@ -1852,6 +1859,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
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)
......@@ -2281,7 +2289,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)
......@@ -2704,6 +2712,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', {
......@@ -3313,6 +3323,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
......
......@@ -1221,7 +1221,7 @@
Room = (function() {
function Room(name, hostinfo) {
var draw_count, lflist, param, rule, start_hand, start_lp, time_limit;
var death_time, draw_count, lflist, param, rule, start_hand, start_lp, time_limit;
this.hostinfo = hostinfo;
this.name = name;
this.alive = true;
......@@ -1358,6 +1358,14 @@
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) {
this.hostinfo.no_watch = true;
}
if ((param = rule.match(/(^|,|,)(DEATH|DH)(\d*)(,|,|$)/))) {
death_time = parseInt(param[3]);
if (death_time && death_time > 0) {
this.hostinfo.auto_death = death_time;
} else {
this.hostinfo.auto_death = 40;
}
}
}
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];
......@@ -2308,7 +2316,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();
......@@ -2811,7 +2821,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);
......@@ -2819,6 +2829,9 @@
ygopro.stoc_send_chat_to_room(room, "${death_start_extra}", ygopro.constants.COLORS.BABYBLUE);
}
}
if (room.duel_count === 1 && 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.retry_handle.enabled) {
client.retry_count = 0;
......@@ -4265,6 +4278,21 @@
}, settings.modules.heartbeat_detection.interval);
}
setInterval(function() {
var current_time, len2, m, results, room;
current_time = moment();
results = [];
for (m = 0, len2 = ROOM_all.length; m < len2; 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