Commit ce17fe58 authored by mercury233's avatar mercury233

add test mode for local AI test

parent 1c202597
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
}, },
"random_duel": { "random_duel": {
"enabled": false, "enabled": false,
"no_rematch_check": false,
"hang_timeout": 90 "hang_timeout": 90
}, },
"cloud_replay": { "cloud_replay": {
...@@ -89,6 +90,11 @@ ...@@ -89,6 +90,11 @@
"password": "123456", "password": "123456",
"port": 7933 "port": 7933
}, },
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": false,
"no_ban_player": false
},
"pre_util": { "pre_util": {
"enabled": false, "enabled": false,
"port": 7944, "port": 7944,
......
...@@ -163,6 +163,7 @@ ban_user = (name) -> ...@@ -163,6 +163,7 @@ ban_user = (name) ->
# automatically ban user to use random duel # automatically ban user to use random duel
ROOM_ban_player = (name, ip, reason, countadd = 1)-> ROOM_ban_player = (name, ip, reason, countadd = 1)->
return if settings.modules.test_mode.no_ban_player
bannedplayer = _.find ROOM_players_banned, (bannedplayer)-> bannedplayer = _.find ROOM_players_banned, (bannedplayer)->
ip == bannedplayer.ip ip == bannedplayer.ip
if bannedplayer if bannedplayer
...@@ -211,7 +212,8 @@ ROOM_find_or_create_random = (type, player_ip)-> ...@@ -211,7 +212,8 @@ ROOM_find_or_create_random = (type, player_ip)->
return room and room.random_type != '' and !room.started and return room and room.random_type != '' and !room.started and
((type == '' and room.random_type != 'T') or room.random_type == type) and ((type == '' and room.random_type != 'T') or room.random_type == type) and
room.get_playing_player().length < max_player and room.get_playing_player().length < max_player and
(room.get_host() == null or room.get_host().ip != ROOM_players_oppentlist[player_ip]) and (settings.modules.random_duel.no_rematch_check or room.get_host() == null or
room.get_host().ip != ROOM_players_oppentlist[player_ip]) and
(playerbanned == room.deprecated or type == 'T') (playerbanned == room.deprecated or type == 'T')
if result if result
result.welcome = '${random_duel_enter_room_waiting}' result.welcome = '${random_duel_enter_room_waiting}'
...@@ -596,7 +598,7 @@ class Room ...@@ -596,7 +598,7 @@ class Room
net.createServer (client) -> net.createServer (client) ->
client.ip = client.remoteAddress client.ip = client.remoteAddress
connect_count = ROOM_connected_ip[client.ip] or 0 connect_count = ROOM_connected_ip[client.ip] or 0
if client.ip != '::ffff:127.0.0.1' if !settings.modules.test_mode.no_connect_count_limit and client.ip != '::ffff:127.0.0.1'
connect_count++ connect_count++
ROOM_connected_ip[client.ip] = connect_count ROOM_connected_ip[client.ip] = connect_count
#log.info "connect", client.ip, ROOM_connected_ip[client.ip] #log.info "connect", client.ip, ROOM_connected_ip[client.ip]
...@@ -1175,7 +1177,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -1175,7 +1177,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
return return
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher
room.watcher = watcher = net.connect room.port, -> 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', { ygopro.ctos_send watcher, 'PLAYER_INFO', {
name: "the Big Brother" name: "the Big Brother"
} }
......
...@@ -221,6 +221,9 @@ ...@@ -221,6 +221,9 @@
if (countadd == null) { if (countadd == null) {
countadd = 1; countadd = 1;
} }
if (settings.modules.test_mode.no_ban_player) {
return;
}
bannedplayer = _.find(ROOM_players_banned, function(bannedplayer) { bannedplayer = _.find(ROOM_players_banned, function(bannedplayer) {
return ip === bannedplayer.ip; return ip === bannedplayer.ip;
}); });
...@@ -292,7 +295,7 @@ ...@@ -292,7 +295,7 @@
max_player = type === 'T' ? 4 : 2; max_player = type === 'T' ? 4 : 2;
playerbanned = bannedplayer && bannedplayer.count > 3 && moment() < bannedplayer.time; playerbanned = bannedplayer && bannedplayer.count > 3 && moment() < bannedplayer.time;
result = _.find(ROOM_all, function(room) { result = _.find(ROOM_all, function(room) {
return room && room.random_type !== '' && !room.started && ((type === '' && room.random_type !== 'T') || room.random_type === type) && room.get_playing_player().length < max_player && (room.get_host() === null || room.get_host().ip !== ROOM_players_oppentlist[player_ip]) && (playerbanned === room.deprecated || type === 'T'); return room && room.random_type !== '' && !room.started && ((type === '' && room.random_type !== 'T') || room.random_type === type) && room.get_playing_player().length < max_player && (settings.modules.random_duel.no_rematch_check || room.get_host() === null || room.get_host().ip !== ROOM_players_oppentlist[player_ip]) && (playerbanned === room.deprecated || type === 'T');
}); });
if (result) { if (result) {
result.welcome = '${random_duel_enter_room_waiting}'; result.welcome = '${random_duel_enter_room_waiting}';
...@@ -799,7 +802,7 @@ ...@@ -799,7 +802,7 @@
var connect_count, server; var connect_count, server;
client.ip = client.remoteAddress; client.ip = client.remoteAddress;
connect_count = ROOM_connected_ip[client.ip] || 0; connect_count = ROOM_connected_ip[client.ip] || 0;
if (client.ip !== '::ffff:127.0.0.1') { if (!settings.modules.test_mode.no_connect_count_limit && client.ip !== '::ffff:127.0.0.1') {
connect_count++; connect_count++;
} }
ROOM_connected_ip[client.ip] = connect_count; ROOM_connected_ip[client.ip] = connect_count;
...@@ -1418,7 +1421,7 @@ ...@@ -1418,7 +1421,7 @@
recorder.on('error', function(error) {}); recorder.on('error', function(error) {});
} }
if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher) { if (settings.modules.cloud_replay.enable_halfway_watch && !room.watcher) {
room.watcher = watcher = net.connect(room.port, function() { room.watcher = watcher = settings.modules.test_mode.watch_public_hand ? room.recorder : net.connect(room.port, function() {
ygopro.ctos_send(watcher, 'PLAYER_INFO', { ygopro.ctos_send(watcher, 'PLAYER_INFO', {
name: "the Big Brother" name: "the Big Brother"
}); });
......
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