Commit 295c1d91 authored by mercury233's avatar mercury233

这是替身攻击!

parent f67de5fb
......@@ -96,6 +96,10 @@
"allow_kick_reconnect": true,
"wait_time": 90000
},
"stand_bot": {
"enabled": true,
"name": "悠悠"
},
"heartbeat_detection": {
"enabled": false,
"interval": 20000,
......@@ -154,7 +158,8 @@
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": false,
"no_ban_player": false
"no_ban_player": false,
"surrender_anytime": false
},
"pre_util": {
"enabled": false,
......
......@@ -1156,6 +1156,19 @@ class Room
index = _.indexOf(@players, client)
@players.splice(index, 1) unless index == -1
if @started and @disconnector != 'server' and client.pos < 4
if settings.modules.stand_bot.enabled and (@random_type == 'S' or @random_type == 'M') and !@stand_bot
client.stand_bot = true
@stand_bot = true
for player in @players when player != client
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
......@@ -1169,7 +1182,7 @@ class Room
@process.kill()
#client.room = null
this.delete()
if !CLIENT_reconnect_unregister(client, false, true)
if !CLIENT_reconnect_unregister(client, false, true) && !client.stand_bot
client.server.destroy()
return
......@@ -1958,10 +1971,31 @@ load_dialogues = () ->
if settings.modules.dialogues.get
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)->
room=ROOM_all[client.rid]
return unless room and !client.reconnecting
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 ygopro.constants.MSG[msg] == 'RETRY'
if !client.retry_count?
......@@ -2447,7 +2481,7 @@ ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server)->
return unless room
if !room.started or room.hostinfo.mode==2
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)
return true
return false
......@@ -2725,6 +2759,9 @@ ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)->
ygopro.stoc_follow 'TIME_LIMIT', true, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return unless room
if client.stand_bot
ygopro.ctos_send(server, 'TIME_CONFIRM')
return true
if settings.modules.reconnect.enabled
if client.closed
ygopro.ctos_send(server, 'TIME_CONFIRM')
......
// Generated by CoffeeScript 1.12.7
(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');
......@@ -1450,7 +1450,7 @@
};
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) {
return;
}
......@@ -1479,6 +1479,26 @@
this.players.splice(index, 1);
}
if (this.started && this.disconnector !== 'server' && client.pos < 4) {
if (settings.modules.stand_bot.enabled && (this.random_type === 'S' || this.random_type === 'M') && !this.stand_bot) {
client.stand_bot = true;
this.stand_bot = true;
ref3 = this.players;
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;
......@@ -1487,6 +1507,7 @@
}
}
}
}
if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && !this.started && client.pos <= 3)) {
ygopro.stoc_send_chat_to_room(this, (client.name + " ${left_game}") + (error ? ": " + error : ''));
if (!this.windbot && !this.started && settings.modules.http.websocket_roomlist) {
......@@ -1496,7 +1517,7 @@
this.process.kill();
this["delete"]();
}
if (!CLIENT_reconnect_unregister(client, false, true)) {
if (!CLIENT_reconnect_unregister(client, false, true) && !client.stand_bot) {
client.server.destroy();
}
}
......@@ -2361,6 +2382,29 @@
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) {
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];
......@@ -2368,6 +2412,10 @@
return;
}
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 (ygopro.constants.MSG[msg] === 'RETRY') {
if (client.retry_count == null) {
......@@ -3021,7 +3069,7 @@
if (!room.started || room.hostinfo.mode === 2) {
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);
return true;
}
......@@ -3397,6 +3445,10 @@
if (!room) {
return;
}
if (client.stand_bot) {
ygopro.ctos_send(server, 'TIME_CONFIRM');
return true;
}
if (settings.modules.reconnect.enabled) {
if (client.closed) {
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