Commit 295c1d91 authored by mercury233's avatar mercury233

这是替身攻击!

parent f67de5fb
...@@ -96,6 +96,10 @@ ...@@ -96,6 +96,10 @@
"allow_kick_reconnect": true, "allow_kick_reconnect": true,
"wait_time": 90000 "wait_time": 90000
}, },
"stand_bot": {
"enabled": true,
"name": "悠悠"
},
"heartbeat_detection": { "heartbeat_detection": {
"enabled": false, "enabled": false,
"interval": 20000, "interval": 20000,
...@@ -154,7 +158,8 @@ ...@@ -154,7 +158,8 @@
"test_mode": { "test_mode": {
"watch_public_hand": false, "watch_public_hand": false,
"no_connect_count_limit": false, "no_connect_count_limit": false,
"no_ban_player": false "no_ban_player": false,
"surrender_anytime": false
}, },
"pre_util": { "pre_util": {
"enabled": false, "enabled": false,
......
...@@ -1156,11 +1156,24 @@ class Room ...@@ -1156,11 +1156,24 @@ class Room
index = _.indexOf(@players, client) index = _.indexOf(@players, client)
@players.splice(index, 1) unless index == -1 @players.splice(index, 1) unless index == -1
if @started and @disconnector != 'server' and client.pos < 4 if @started and @disconnector != 'server' and client.pos < 4
@finished = true if settings.modules.stand_bot.enabled and (@random_type == 'S' or @random_type == 'M') and !@stand_bot
if !@finished_by_death client.stand_bot = true
@scores[client.name] = -9 @stand_bot = true
if @random_type and not client.flee_free and (!settings.modules.reconnect.enabled or @get_disconnected_count() == 0) for player in @players when player != client
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}") ygopro.stoc_send player, 'HS_PLAYER_ENTER', {
name: settings.modules.stand_bot.name,
pos: if player.is_first then client.pos else 1 - client.pos
}
ygopro.stoc_send_chat player, "#{client.name} 已离开,但你可以和机器人继续决斗", ygopro.constants.COLORS.GREEN
player.flee_free = true
if client.last_game_msg and client.last_game_msg_title != 'WAITING'
stand_bot_action client.last_game_msg_title, client.last_game_msg, client.server
else
@finished = true
if !@finished_by_death
@scores[client.name] = -9
if @random_type and not client.flee_free and (!settings.modules.reconnect.enabled or @get_disconnected_count() == 0)
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}")
if @players.length and !(@windbot and client.is_host) and !(@arena and !@started and client.pos <= 3) if @players.length and !(@windbot and client.is_host) and !(@arena and !@started and client.pos <= 3)
ygopro.stoc_send_chat_to_room this, "#{client.name} ${left_game}" + if error then ": #{error}" else '' ygopro.stoc_send_chat_to_room this, "#{client.name} ${left_game}" + if error then ": #{error}" else ''
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
...@@ -1169,7 +1182,7 @@ class Room ...@@ -1169,7 +1182,7 @@ class Room
@process.kill() @process.kill()
#client.room = null #client.room = null
this.delete() this.delete()
if !CLIENT_reconnect_unregister(client, false, true) if !CLIENT_reconnect_unregister(client, false, true) && !client.stand_bot
client.server.destroy() client.server.destroy()
return return
...@@ -1958,10 +1971,31 @@ load_dialogues = () -> ...@@ -1958,10 +1971,31 @@ load_dialogues = () ->
if settings.modules.dialogues.get if settings.modules.dialogues.get
load_dialogues() load_dialogues()
stand_bot_action = (msg, buffer, server) ->
switch msg
when "SELECT_CHAIN"
buf = Buffer.allocUnsafe(4)
buf.writeInt32LE(-1)
ygopro.ctos_send server, 'RESPONSE', buf
when "SELECT_BATTLECMD"
buf = Buffer.allocUnsafe(4)
buf.writeInt32LE(3)
ygopro.ctos_send server, 'RESPONSE', buf
when "SELECT_IDLECMD"
buf = Buffer.allocUnsafe(4)
buf.writeInt32LE(7)
ygopro.ctos_send server, 'RESPONSE', buf
else
log.info msg
return
ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)-> ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room and !client.reconnecting return unless room and !client.reconnecting
msg = buffer.readInt8(0) msg = buffer.readInt8(0)
if client.stand_bot
stand_bot_action ygopro.constants.MSG[msg], buffer, server
return
if settings.modules.retry_handle.enabled if settings.modules.retry_handle.enabled
if ygopro.constants.MSG[msg] == 'RETRY' if ygopro.constants.MSG[msg] == 'RETRY'
if !client.retry_count? if !client.retry_count?
...@@ -2447,7 +2481,7 @@ ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server)-> ...@@ -2447,7 +2481,7 @@ ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server)->
return unless room return unless room
if !room.started or room.hostinfo.mode==2 if !room.started or room.hostinfo.mode==2
return true return true
if room.random_type and room.turn < 3 and not client.flee_free if room.random_type and room.turn < 3 and not client.flee_free and not settings.modules.test_mode.surrender_anytime
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE)
return true return true
return false return false
...@@ -2725,6 +2759,9 @@ ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)-> ...@@ -2725,6 +2759,9 @@ ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)->
ygopro.stoc_follow 'TIME_LIMIT', true, (buffer, info, client, server)-> ygopro.stoc_follow 'TIME_LIMIT', true, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
if client.stand_bot
ygopro.ctos_send(server, 'TIME_CONFIRM')
return true
if settings.modules.reconnect.enabled if settings.modules.reconnect.enabled
if client.closed if client.closed
ygopro.ctos_send(server, 'TIME_CONFIRM') ygopro.ctos_send(server, 'TIME_CONFIRM')
......
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 1.12.7
(function() { (function() {
var CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, 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, 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_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, _, addCallback, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_queue_callbacks, chat_color, 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, l, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, 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, wait_room_start, wait_room_start_arena, windbot_looplimit, windbots, ygopro, zlib; var CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, 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, 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_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, _, addCallback, badwords, ban_user, bunyan, challonge, challonge_cache, challonge_queue_callbacks, chat_color, 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, l, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, refresh_challonge_cache, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, spawn_windbot, stand_bot_action, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_looplimit, windbots, ygopro, zlib;
net = require('net'); net = require('net');
...@@ -1450,7 +1450,7 @@ ...@@ -1450,7 +1450,7 @@
}; };
Room.prototype.disconnect = function(client, error) { Room.prototype.disconnect = function(client, error) {
var index, len2, m, player, ref2; var index, len2, len3, m, n, player, ref2, ref3;
if (client.had_new_reconnection) { if (client.had_new_reconnection) {
return; return;
} }
...@@ -1479,11 +1479,32 @@ ...@@ -1479,11 +1479,32 @@
this.players.splice(index, 1); this.players.splice(index, 1);
} }
if (this.started && this.disconnector !== 'server' && client.pos < 4) { if (this.started && this.disconnector !== 'server' && client.pos < 4) {
this.finished = true; if (settings.modules.stand_bot.enabled && (this.random_type === 'S' || this.random_type === 'M') && !this.stand_bot) {
if (!this.finished_by_death) { client.stand_bot = true;
this.scores[client.name] = -9; this.stand_bot = true;
if (this.random_type && !client.flee_free && (!settings.modules.reconnect.enabled || this.get_disconnected_count() === 0)) { ref3 = this.players;
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}"); for (n = 0, len3 = ref3.length; n < len3; n++) {
player = ref3[n];
if (!(player !== client)) {
continue;
}
ygopro.stoc_send(player, 'HS_PLAYER_ENTER', {
name: settings.modules.stand_bot.name,
pos: player.is_first ? client.pos : 1 - client.pos
});
ygopro.stoc_send_chat(player, client.name + " 已离开,但你可以和机器人继续决斗", ygopro.constants.COLORS.GREEN);
player.flee_free = true;
}
if (client.last_game_msg && client.last_game_msg_title !== 'WAITING') {
stand_bot_action(client.last_game_msg_title, client.last_game_msg, client.server);
}
} else {
this.finished = true;
if (!this.finished_by_death) {
this.scores[client.name] = -9;
if (this.random_type && !client.flee_free && (!settings.modules.reconnect.enabled || this.get_disconnected_count() === 0)) {
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}");
}
} }
} }
} }
...@@ -1496,7 +1517,7 @@ ...@@ -1496,7 +1517,7 @@
this.process.kill(); this.process.kill();
this["delete"](); this["delete"]();
} }
if (!CLIENT_reconnect_unregister(client, false, true)) { if (!CLIENT_reconnect_unregister(client, false, true) && !client.stand_bot) {
client.server.destroy(); client.server.destroy();
} }
} }
...@@ -2361,6 +2382,29 @@ ...@@ -2361,6 +2382,29 @@
load_dialogues(); load_dialogues();
} }
stand_bot_action = function(msg, buffer, server) {
var buf;
switch (msg) {
case "SELECT_CHAIN":
buf = Buffer.allocUnsafe(4);
buf.writeInt32LE(-1);
ygopro.ctos_send(server, 'RESPONSE', buf);
break;
case "SELECT_BATTLECMD":
buf = Buffer.allocUnsafe(4);
buf.writeInt32LE(3);
ygopro.ctos_send(server, 'RESPONSE', buf);
break;
case "SELECT_IDLECMD":
buf = Buffer.allocUnsafe(4);
buf.writeInt32LE(7);
ygopro.ctos_send(server, 'RESPONSE', buf);
break;
default:
log.info(msg);
}
};
ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server) { ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server) {
var card, chain, check, count, cpos, deck_found, found, hint_type, i, id, len2, len3, len4, len5, limbo_found, line, loc, m, max_loop, msg, n, o, oppo_pos, p, phase, player, playertype, pos, ppos, q, reason, ref2, ref3, ref4, ref5, ref6, ref7, room, trigger_location, val, win_pos; var card, chain, check, count, cpos, deck_found, found, hint_type, i, id, len2, len3, len4, len5, limbo_found, line, loc, m, max_loop, msg, n, o, oppo_pos, p, phase, player, playertype, pos, ppos, q, reason, ref2, ref3, ref4, ref5, ref6, ref7, room, trigger_location, val, win_pos;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
...@@ -2368,6 +2412,10 @@ ...@@ -2368,6 +2412,10 @@
return; return;
} }
msg = buffer.readInt8(0); msg = buffer.readInt8(0);
if (client.stand_bot) {
stand_bot_action(ygopro.constants.MSG[msg], buffer, server);
return;
}
if (settings.modules.retry_handle.enabled) { if (settings.modules.retry_handle.enabled) {
if (ygopro.constants.MSG[msg] === 'RETRY') { if (ygopro.constants.MSG[msg] === 'RETRY') {
if (client.retry_count == null) { if (client.retry_count == null) {
...@@ -3021,7 +3069,7 @@ ...@@ -3021,7 +3069,7 @@
if (!room.started || room.hostinfo.mode === 2) { if (!room.started || room.hostinfo.mode === 2) {
return true; return true;
} }
if (room.random_type && room.turn < 3 && !client.flee_free) { if (room.random_type && room.turn < 3 && !client.flee_free && !settings.modules.test_mode.surrender_anytime) {
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE);
return true; return true;
} }
...@@ -3397,6 +3445,10 @@ ...@@ -3397,6 +3445,10 @@
if (!room) { if (!room) {
return; return;
} }
if (client.stand_bot) {
ygopro.ctos_send(server, 'TIME_CONFIRM');
return true;
}
if (settings.modules.reconnect.enabled) { if (settings.modules.reconnect.enabled) {
if (client.closed) { if (client.closed) {
ygopro.ctos_send(server, 'TIME_CONFIRM'); ygopro.ctos_send(server, 'TIME_CONFIRM');
......
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