Commit 236cf33b authored by mercury233's avatar mercury233

fix

parent 372c160d
......@@ -43,7 +43,8 @@
"post": "https://mycard.moe/ygopro/analytics/deck/text"
},
"arena_mode": {
"mode": "233",
"enabled": false,
"mode": "entertain",
"comment": "mode: athletic / entertain",
"accesskey": "233",
"post_score": false,
......
......@@ -22,6 +22,7 @@
"post": "https://mycard.moe/ygopro/analytics/deck/text"
},
"arena_mode": {
"enabled": true,
"mode": "entertain",
"accesskey": "233",
"post_score": "https://mycard.moe/ygopro/arena/index.php?c=update",
......@@ -31,7 +32,7 @@
"port": 7922,
"password": "123456",
"ssl": {
"enabled": false,
"enabled": true,
"port": 7923,
"cert": "ssl/fullchain.pem",
"key": "ssl/privkey.pem"
......
......@@ -84,9 +84,10 @@ ban_user = (name) ->
try
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16')
log.info "ygopro version 0x"+settings.version.toString(16), "(from source code)"
catch
settings.version = settings.modules.default_version
log.info "fail to read version from ygopro source code, using 0x"+settings.version.toString(16), "from config"
log.info "ygopro version 0x"+settings.version.toString(16), "(from config)"
# load the lflist of current date
settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
......@@ -241,8 +242,6 @@ ROOM_find_or_create_random = (type, player_ip)->
ROOM_find_or_create_ai = (name)->
if name == ''
name = 'AI'
if name[0...3] == 'AI_'
name = 'AI#' + name.slice(3)
namea = name.split('#')
if room = ROOM_find_by_name(name)
return room
......@@ -433,7 +432,7 @@ class Room
delete: ->
return if @deleted
#log.info 'room-delete', this.name, ROOM_all.length
if @started and settings.modules.arena_mode.post_score
if @started and settings.modules.arena_mode.enabled
#log.info @scores
score_array=[]
for name, score of @scores
......@@ -453,7 +452,7 @@ class Room
if error
log.warn 'SCORE POST ERROR', error
else
if response.statusCode != 204 or response.statusCode != 200
if response.statusCode != 204 and response.statusCode != 200
log.warn 'SCORE POST FAIL', response.statusCode, response.statusMessage, @name, body
else
log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
......@@ -888,7 +887,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else if !info.pass.length and !settings.modules.enable_random_duel and !settings.modules.enable_windbot
ygopro.stoc_die(client, "房间名不能为空,请在主机密码处填写房间名")
else if info.pass.length and settings.modules.mycard.enabled and info.pass[0...3] != 'AI_' and info.pass[0...3] != 'AI#'
else if info.pass.length and settings.modules.mycard.enabled and info.pass[0...3] != 'AI#'
ygopro.stoc_send_chat(client, '正在读取用户信息...', ygopro.constants.COLORS.BABYBLUE)
if info.pass.length <= 8
ygopro.stoc_die(client, '主机密码不正确 (Invalid Length)')
......@@ -1081,7 +1080,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN)
if room.welcome
ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE)
if settings.modules.arena_mode.get_score #and not client.score_shown
if settings.modules.arena_mode.enabled #and not client.score_shown
request
url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name),
json: true
......
......@@ -113,9 +113,10 @@
try {
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16');
log.info("ygopro version 0x" + settings.version.toString(16), "(from source code)");
} catch (error1) {
settings.version = settings.modules.default_version;
log.info("fail to read version from ygopro source code, using 0x" + settings.version.toString(16), "from config");
log.info("ygopro version 0x" + settings.version.toString(16), "(from config)");
}
settings.lflist = (function() {
......@@ -332,9 +333,6 @@
if (name === '') {
name = 'AI';
}
if (name.slice(0, 3) === 'AI_') {
name = 'AI#' + name.slice(3);
}
namea = name.split('#');
if (room = ROOM_find_by_name(name)) {
return room;
......@@ -586,7 +584,7 @@
if (this.deleted) {
return;
}
if (this.started && settings.modules.arena_mode.post_score) {
if (this.started && settings.modules.arena_mode.enabled) {
score_array = [];
ref = this.scores;
for (name in ref) {
......@@ -615,7 +613,7 @@
if (error) {
log.warn('SCORE POST ERROR', error);
} else {
if (response.statusCode !== 204 || response.statusCode !== 200) {
if (response.statusCode !== 204 && response.statusCode !== 200) {
log.warn('SCORE POST FAIL', response.statusCode, response.statusMessage, _this.name, body);
} else {
log.info('SCORE POST OK', response.statusCode, response.statusMessage, _this.name, body);
......@@ -1106,7 +1104,7 @@
client.destroy();
} else if (!info.pass.length && !settings.modules.enable_random_duel && !settings.modules.enable_windbot) {
ygopro.stoc_die(client, "房间名不能为空,请在主机密码处填写房间名");
} else if (info.pass.length && settings.modules.mycard.enabled && info.pass.slice(0, 3) !== 'AI_' && info.pass.slice(0, 3) !== 'AI#') {
} else if (info.pass.length && settings.modules.mycard.enabled && info.pass.slice(0, 3) !== 'AI#') {
ygopro.stoc_send_chat(client, '正在读取用户信息...', ygopro.constants.COLORS.BABYBLUE);
if (info.pass.length <= 8) {
ygopro.stoc_die(client, '主机密码不正确 (Invalid Length)');
......@@ -1314,7 +1312,7 @@
if (room.welcome) {
ygopro.stoc_send_chat(client, room.welcome, ygopro.constants.COLORS.BABYBLUE);
}
if (settings.modules.arena_mode.get_score) {
if (settings.modules.arena_mode.enabled) {
request({
url: settings.modules.arena_mode.get_score + encodeURIComponent(client.name),
json: true
......
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