Commit 6227f5bd authored by nanahira's avatar nanahira

add MSG_RETRY detection

parent ad0bcc57
......@@ -82,6 +82,10 @@
"chat_color": {
"enabled": false
},
"retry_handle": {
"enabled": false,
"max_retry_count": 3
},
"mycard": {
"enabled": false,
"auth_base_url": "https://ygobbs.com",
......
......@@ -372,6 +372,14 @@
"color_not_found_part1": "颜色 ",
"color_not_found_part2": " 不存在,输入 /color help 查看所有可用的颜色。",
"show_color_list": "可用的聊天字体颜色有:",
"retry_not_counted": "你的操作不符合规则。",
"retry_part1": "你的操作第",
"retry_part2": "次不符合规则。若违规操作",
"retry_part3": "次,将被请出房间。",
"retry_too_much_part1": "你由于在决斗中违规操作",
"retry_too_much_part2": "次,已被请出房间。",
"retry_too_much_room_part1": " 由于在决斗中违规操作",
"retry_too_much_room_part2": "次,已被请出房间。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr": {
......
......@@ -1351,11 +1351,32 @@ load_dialogues = () ->
if settings.modules.dialogues.get
load_dialogues()
ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room
msg = buffer.readInt8(0)
if settings.modules.retry_handle.enabled
if ygopro.constants.MSG[msg] == 'RETRY'
if !client.retry_count?
client.retry_count = 0
client.retry_count++
log.warn "MSG_RETRY detected", client.name, client.ip, msg, client.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(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED)
client.destroy()
return true
if client.last_game_msg
if settings.modules.retry_handle.max_retry_count
ygopro.stoc_send_chat(client, "${retry_part1}" + client.retry_count + "${retry_part2}" + settings.modules.retry_handle.max_retry_count + "${retry_part3}", ygopro.constants.COLORS.RED)
else
ygopro.stoc_send_chat(client, "${retry_not_counted}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg)
return true
else
client.last_game_msg = buffer
if (msg >= 10 and msg < 30) or msg == 132 or (msg >= 140 and msg < 144) #SELECT和ANNOUNCE开头的消息
room.waiting_for_player = client
room.last_active_time = moment()
......@@ -1375,6 +1396,9 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
ygopro.stoc_send_chat_to_room(room, "${death_start_final}", ygopro.constants.COLORS.BABYBLUE)
else
ygopro.stoc_send_chat_to_room(room, "${death_start_extra}", ygopro.constants.COLORS.BABYBLUE)
if settings.modules.retry_handle.enabled
client.retry_count = 0
client.last_game_msg = null
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
......@@ -1477,7 +1501,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if dialogues.dialogues[card] and (ygopro.constants.MSG[msg] != 'CHAINING' or (trigger_location & 0x8) and !(trigger_location & 0x200))
for line in _.lines dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK)
return
return false
#房间管理
ygopro.ctos_follow 'HS_TOOBSERVER', true, (buffer, info, client, server)->
......
......@@ -1635,13 +1635,39 @@
load_dialogues();
}
ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) {
ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server) {
var card, count, l, len2, line, loc, msg, playertype, pos, reason, ref2, ref3, ref4, room, trigger_location, val, win_pos;
room = ROOM_all[client.rid];
if (!room) {
return;
}
msg = buffer.readInt8(0);
if (settings.modules.retry_handle.enabled) {
if (ygopro.constants.MSG[msg] === 'RETRY') {
if (client.retry_count == null) {
client.retry_count = 0;
}
client.retry_count++;
log.warn("MSG_RETRY detected", client.name, client.ip, msg, client.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(client, "${retry_too_much_part1}" + settings.modules.retry_handle.max_retry_count + "${retry_too_much_part2}", ygopro.constants.COLORS.RED);
client.destroy();
return true;
}
if (client.last_game_msg) {
if (settings.modules.retry_handle.max_retry_count) {
ygopro.stoc_send_chat(client, "${retry_part1}" + client.retry_count + "${retry_part2}" + settings.modules.retry_handle.max_retry_count + "${retry_part3}", ygopro.constants.COLORS.RED);
} else {
ygopro.stoc_send_chat(client, "${retry_not_counted}", ygopro.constants.COLORS.BABYBLUE);
}
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg);
return true;
}
} else {
client.last_game_msg = buffer;
}
}
if ((msg >= 10 && msg < 30) || msg === 132 || (msg >= 140 && msg < 144)) {
room.waiting_for_player = client;
room.last_active_time = moment();
......@@ -1664,6 +1690,10 @@
}
}
}
if (settings.modules.retry_handle.enabled) {
client.retry_count = 0;
client.last_game_msg = null;
}
}
if (ygopro.constants.MSG[msg] === 'NEW_TURN') {
if (client.pos === 0) {
......@@ -1808,6 +1838,7 @@
}
}
}
return false;
});
ygopro.ctos_follow('HS_TOOBSERVER', true, function(buffer, info, client, server) {
......
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