Commit b35e9dd0 authored by mercury233's avatar mercury233

add switches

parent 21ca68db
{
"windbots": [
{
"name": "琪露诺",
"deck": "Burn",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "Frog",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "Horus",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "OldSchool",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Dragunity",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Rank V",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Zexal Weapons",
"dialog": "zh-CN"
}
]
}
\ No newline at end of file
...@@ -5,58 +5,26 @@ ...@@ -5,58 +5,26 @@
"welcome": "YGOPRO Server", "welcome": "YGOPRO Server",
"update": "请更新游戏版本", "update": "请更新游戏版本",
"stop": false, "stop": false,
"tips": "http://mercury233.me/ygosrv233tips.json", "tips": "http://mercury233.me/ygosrv233/tips.json",
"dialogues": "http://mercury233.me/ygosrv233/dialogues.json", "dialogues": "http://mercury233.me/ygosrv233/dialogues.json",
"enable_websocket_roomlist": false,
"enable_random_duel": false, "enable_random_duel": false,
"enable_halfway_watch": true, "enable_halfway_watch": true,
"enable_TCG_as_default": false, "enable_TCG_as_default": false,
"enable_cloud_replay": false, "enable_cloud_replay": false,
"enable_windbot": false,
"enable_websocket_roomlist": false,
"redis_port": 6379, "redis_port": 6379,
"mycard_auth": false, "mycard_auth": false,
"hang_timeout": 90,
"http": { "http": {
"port": 7922, "port": 7922,
"password": "123456", "password": "123456",
"ssl": { "ssl": {
"enabled": false "enabled": false,
"port": 7923,
"cert": "ssl/ygopro-server.crt",
"key": "ssl/ygopro-server.key"
} }
},
"windbot": [
{
"name": "琪露诺",
"deck": "Burn",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "Frog",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "Horus",
"dialog": "zh-CN"
},
{
"name": "琪露诺",
"deck": "OldSchool",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Dragunity",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Rank V",
"dialog": "zh-CN"
},
{
"name": "谜之剑士LV4",
"deck": "Zexal Weapons",
"dialog": "zh-CN"
} }
]
} }
} }
...@@ -25,7 +25,6 @@ moment = require 'moment' ...@@ -25,7 +25,6 @@ moment = require 'moment'
settings = require './config.json' settings = require './config.json'
settings.BANNED_user = [] settings.BANNED_user = []
settings.BANNED_IP = [] settings.BANNED_IP = []
settings.modules.hang_timeout = 90
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16') settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16')
settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g) settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/) date=list.match(/!([\d\.]+)/)
...@@ -37,6 +36,9 @@ if settings.modules.enable_cloud_replay ...@@ -37,6 +36,9 @@ if settings.modules.enable_cloud_replay
zlib = require 'zlib' zlib = require 'zlib'
redisdb = redis.createClient host: "127.0.0.1", port: settings.modules.redis_port redisdb = redis.createClient host: "127.0.0.1", port: settings.modules.redis_port
if settings.modules.enable_windbot
settings.modules.windbots = require('./config.bot.json').windbots
#组件 #组件
ygopro = require './ygopro.js' ygopro = require './ygopro.js'
Room = require './room.js' Room = require './room.js'
...@@ -330,11 +332,11 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -330,11 +332,11 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
} }
client.end() client.end()
else if settings.modules.windbot and info.pass[0...2] == 'AI' else if settings.modules.enable_windbot and info.pass[0...2] == 'AI'
if info.pass.length > 3 and info.pass[0...3] == 'AI#' or info.pass[0...3] == 'AI_' if info.pass.length > 3 and info.pass[0...3] == 'AI#' or info.pass[0...3] == 'AI_'
name = info.pass.slice(3) name = info.pass.slice(3)
windbot = _.sample _.filter settings.modules.windbot, (w)-> windbot = _.sample _.filter settings.modules.windbots, (w)->
w.name == name or w.deck == name w.name == name or w.deck == name
if !windbot if !windbot
ygopro.stoc_send_chat(client, '主机密码不正确 (Invalid Windbot Name)', 11) ygopro.stoc_send_chat(client, '主机密码不正确 (Invalid Windbot Name)', 11)
...@@ -345,7 +347,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -345,7 +347,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client.end() client.end()
return return
else else
windbot = _.sample settings.modules.windbot windbot = _.sample settings.modules.windbots
room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)) # 这个 AI# 没有特殊作用, 仅作为标记 room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)) # 这个 AI# 没有特殊作用, 仅作为标记
room.windbot = windbot room.windbot = windbot
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
settings.BANNED_IP = []; settings.BANNED_IP = [];
settings.modules.hang_timeout = 90;
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16'); settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\d]+)/)[1], '16');
settings.lflist = (function() { settings.lflist = (function() {
...@@ -67,6 +65,10 @@ ...@@ -67,6 +65,10 @@
}); });
} }
if (settings.modules.enable_windbot) {
settings.modules.windbots = require('./config.bot.json').windbots;
}
ygopro = require('./ygopro.js'); ygopro = require('./ygopro.js');
Room = require('./room.js'); Room = require('./room.js');
...@@ -386,10 +388,10 @@ ...@@ -386,10 +388,10 @@
code: 2 code: 2
}); });
client.end(); client.end();
} else if (settings.modules.windbot && info.pass.slice(0, 2) === 'AI') { } else if (settings.modules.enable_windbot && info.pass.slice(0, 2) === 'AI') {
if (info.pass.length > 3 && info.pass.slice(0, 3) === 'AI#' || info.pass.slice(0, 3) === 'AI_') { if (info.pass.length > 3 && info.pass.slice(0, 3) === 'AI#' || info.pass.slice(0, 3) === 'AI_') {
name = info.pass.slice(3); name = info.pass.slice(3);
windbot = _.sample(_.filter(settings.modules.windbot, function(w) { windbot = _.sample(_.filter(settings.modules.windbots, function(w) {
return w.name === name || w.deck === name; return w.name === name || w.deck === name;
})); }));
if (!windbot) { if (!windbot) {
...@@ -402,7 +404,7 @@ ...@@ -402,7 +404,7 @@
return; return;
} }
} else { } else {
windbot = _.sample(settings.modules.windbot); windbot = _.sample(settings.modules.windbots);
} }
room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)); room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000));
room.windbot = windbot; room.windbot = windbot;
......
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