Commit 30fc8506 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:moecube/srvpro into mc

parents 36e170ab d7f1b8c2
...@@ -67,11 +67,16 @@ ...@@ -67,11 +67,16 @@
}, },
"random_duel": { "random_duel": {
"enabled": true, "enabled": true,
"default_type": "S",
"no_rematch_check": false, "no_rematch_check": false,
"record_match_scores": false, "record_match_scores": false,
"post_match_scores": false, "post_match_scores": false,
"post_match_accesskey": "123456", "post_match_accesskey": "123456",
"blank_pass_match": true, "blank_pass_modes": {
"S": true,
"M": true,
"T": false
},
"ready_time": 20, "ready_time": 20,
"hang_timeout": 90 "hang_timeout": 90
}, },
......
...@@ -312,7 +312,9 @@ ...@@ -312,7 +312,9 @@
"zh-cn": { "zh-cn": {
"random_duel_enter_room_waiting": "对手已经在等你了,开始决斗吧!", "random_duel_enter_room_waiting": "对手已经在等你了,开始决斗吧!",
"random_duel_enter_room_new": "已建立随机对战房间,正在等待对手!", "random_duel_enter_room_new": "已建立随机对战房间,正在等待对手!",
"random_duel_enter_room_match": "您进入了比赛模式的房间,我们推荐使用竞技卡组!", "random_duel_enter_room_single": "您进入了单局模式的房间,我们不推荐使用竞技卡组!密码输入M进入比赛模式,输入T进入双打模式!",
"random_duel_enter_room_match": "您进入了比赛模式的房间,我们推荐使用竞技卡组!密码输入S进入单局模式,输入T进入双打模式!",
"random_duel_enter_room_tag": "您进入了双打模式的房间,我们不推荐使用竞技卡组!密码输入S进入单局模式,输入M进入比赛模式!",
"random_banned_part1": "因为您近期在游戏中多次", "random_banned_part1": "因为您近期在游戏中多次",
"random_banned_part2": ",您已被禁止使用随机对战功能,将在", "random_banned_part2": ",您已被禁止使用随机对战功能,将在",
"random_banned_part3": "后解封", "random_banned_part3": "后解封",
......
...@@ -227,6 +227,15 @@ if settings.modules.challonge.api_key ...@@ -227,6 +227,15 @@ if settings.modules.challonge.api_key
settings.modules.challonge.options.apiKey = settings.modules.challonge.api_key settings.modules.challonge.options.apiKey = settings.modules.challonge.api_key
delete settings.modules.challonge.api_key delete settings.modules.challonge.api_key
imported = true imported = true
#import the old random_duel.blank_pass_match option
if settings.modules.random_duel.blank_pass_match == true
settings.modules.random_duel.blank_pass_modes = {"S":true,"M":true,"T":false}
delete settings.modules.random_duel.blank_pass_match
imported = true
if settings.modules.random_duel.blank_pass_match == false
settings.modules.random_duel.blank_pass_modes = {"S":true,"M":false,"T":false}
delete settings.modules.random_duel.blank_pass_match
imported = true
#finish #finish
if imported if imported
setting_save(settings) setting_save(settings)
...@@ -619,7 +628,10 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i ...@@ -619,7 +628,10 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i
playerbanned = (bannedplayer and bannedplayer.count > 3 and moment() < bannedplayer.time) playerbanned = (bannedplayer and bannedplayer.count > 3 and moment() < bannedplayer.time)
result = _.find ROOM_all, (room)-> result = _.find ROOM_all, (room)->
return room and room.random_type != '' and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and !room.windbot and return room and room.random_type != '' and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and !room.windbot and
((type == '' and (room.random_type == 'S' or (settings.modules.random_duel.blank_pass_match and room.random_type != 'T'))) or room.random_type == type) and ((type == '' and
(room.random_type == settings.modules.random_duel.default_type or
settings.modules.random_duel.blank_pass_modes[room.random_type])) or
room.random_type == type) and
room.get_playing_player().length < max_player and room.get_playing_player().length < max_player and
(settings.modules.random_duel.no_rematch_check or room.get_host() == null or (settings.modules.random_duel.no_rematch_check or room.get_host() == null or
room.get_host().ip != ROOM_players_oppentlist[player_ip]) and room.get_host().ip != ROOM_players_oppentlist[player_ip]) and
...@@ -628,7 +640,7 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i ...@@ -628,7 +640,7 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i
result.welcome = '${random_duel_enter_room_waiting}' result.welcome = '${random_duel_enter_room_waiting}'
#log.info 'found room', player_name #log.info 'found room', player_name
else if memory_usage < 90 else if memory_usage < 90
type = if type then type else 'S' type = if type then type else settings.modules.random_duel.default_type
name = type + ',RANDOM#' + Math.floor(Math.random() * 100000) name = type + ',RANDOM#' + Math.floor(Math.random() * 100000)
result = new Room(name) result = new Room(name)
result.random_type = type result.random_type = type
...@@ -638,7 +650,9 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i ...@@ -638,7 +650,9 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i
#log.info 'create room', player_name, name #log.info 'create room', player_name, name
else else
return null return null
if result.random_type=='M' then result.welcome = result.welcome + '\n${random_duel_enter_room_match}' if result.random_type=='S' then result.welcome2 = '${random_duel_enter_room_single}'
if result.random_type=='M' then result.welcome2 = '${random_duel_enter_room_match}'
if result.random_type=='T' then result.welcome2 = '${random_duel_enter_room_tag}'
return result return result
ROOM_find_or_create_ai = global.ROOM_find_or_create_ai = (name)-> ROOM_find_or_create_ai = global.ROOM_find_or_create_ai = (name)->
...@@ -2355,6 +2369,8 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2355,6 +2369,8 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN) ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN)
if room.welcome if room.welcome
ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE)
if room.welcome2
ygopro.stoc_send_chat(client, room.welcome2, ygopro.constants.COLORS.PINK)
if settings.modules.arena_mode.enabled and !client.is_local #and not client.score_shown if settings.modules.arena_mode.enabled and !client.is_local #and not client.score_shown
request request
url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name), url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name),
...@@ -2416,7 +2432,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2416,7 +2432,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
return return
watcher.on 'error', (error)-> watcher.on 'error', (error)->
#log.error "watcher error", error log.error "watcher error", error
return return
return return
......
...@@ -265,6 +265,27 @@ ...@@ -265,6 +265,27 @@
imported = true; imported = true;
} }
//import the old random_duel.blank_pass_match option
if (settings.modules.random_duel.blank_pass_match === true) {
settings.modules.random_duel.blank_pass_modes = {
"S": true,
"M": true,
"T": false
};
delete settings.modules.random_duel.blank_pass_match;
imported = true;
}
if (settings.modules.random_duel.blank_pass_match === false) {
settings.modules.random_duel.blank_pass_modes = {
"S": true,
"M": false,
"T": false
};
delete settings.modules.random_duel.blank_pass_match;
imported = true;
}
//finish //finish
if (imported) { if (imported) {
setting_save(settings); setting_save(settings);
...@@ -815,13 +836,13 @@ ...@@ -815,13 +836,13 @@
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.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot && ((type === '' && (room.random_type === 'S' || (settings.modules.random_duel.blank_pass_match && 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'); return room && room.random_type !== '' && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot && ((type === '' && (room.random_type === settings.modules.random_duel.default_type || settings.modules.random_duel.blank_pass_modes[room.random_type])) || 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}';
//log.info 'found room', player_name //log.info 'found room', player_name
} else if (memory_usage < 90) { } else if (memory_usage < 90) {
type = type ? type : 'S'; type = type ? type : settings.modules.random_duel.default_type;
name = type + ',RANDOM#' + Math.floor(Math.random() * 100000); name = type + ',RANDOM#' + Math.floor(Math.random() * 100000);
result = new Room(name); result = new Room(name);
result.random_type = type; result.random_type = type;
...@@ -832,8 +853,14 @@ ...@@ -832,8 +853,14 @@
//log.info 'create room', player_name, name //log.info 'create room', player_name, name
return null; return null;
} }
if (result.random_type === 'S') {
result.welcome2 = '${random_duel_enter_room_single}';
}
if (result.random_type === 'M') { if (result.random_type === 'M') {
result.welcome = result.welcome + '\n${random_duel_enter_room_match}'; result.welcome2 = '${random_duel_enter_room_match}';
}
if (result.random_type === 'T') {
result.welcome2 = '${random_duel_enter_room_tag}';
} }
return result; return result;
}; };
...@@ -3060,6 +3087,9 @@ ...@@ -3060,6 +3087,9 @@
if (room.welcome) { if (room.welcome) {
ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE);
} }
if (room.welcome2) {
ygopro.stoc_send_chat(client, room.welcome2, ygopro.constants.COLORS.PINK);
}
if (settings.modules.arena_mode.enabled && !client.is_local) { //and not client.score_shown if (settings.modules.arena_mode.enabled && !client.is_local) { //and not client.score_shown
request({ request({
url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name), url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name),
...@@ -3134,12 +3164,13 @@ ...@@ -3134,12 +3164,13 @@
} }
} }
}); });
watcher.on('error', function(error) {}); watcher.on('error', function(error) {
log.error("watcher error", error);
});
} }
}); });
// 登场台词 // 登场台词
//log.error "watcher error", error
load_dialogues = global.load_dialogues = function(callback) { load_dialogues = global.load_dialogues = function(callback) {
request({ request({
url: settings.modules.dialogues.get, url: settings.modules.dialogues.get,
......
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