Commit 4a39b790 authored by mercury233's avatar mercury233

read default room info and default version from config

parent 783620b4
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
"dialogues": "http://mercury233.me/ygosrv233/dialogues.json", "dialogues": "http://mercury233.me/ygosrv233/dialogues.json",
"enable_random_duel": false, "enable_random_duel": false,
"enable_halfway_watch": true, "enable_halfway_watch": true,
"enable_TCG_as_default": false,
"enable_cloud_replay": false, "enable_cloud_replay": false,
"enable_windbot": false, "enable_windbot": false,
"enable_websocket_roomlist": false, "enable_websocket_roomlist": false,
...@@ -20,6 +19,20 @@ ...@@ -20,6 +19,20 @@
"mycard_auth": false, "mycard_auth": false,
"post_deck": false, "post_deck": false,
"hang_timeout": 90, "hang_timeout": 90,
"default_version": 4924,
"default_room_info": {
"lflist": 0,
"rule": 0,
"mode": 0,
"comment": "rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG",
"enable_priority": false,
"no_check_deck": false,
"no_shuffle_deck": false,
"start_lp": 8000,
"start_hand": 5,
"draw_count": 1,
"time_limit": 180
},
"arena_mode": { "arena_mode": {
"mode": "233", "mode": "233",
"post_score": false, "post_score": false,
......
...@@ -82,7 +82,11 @@ ban_user = (name) -> ...@@ -82,7 +82,11 @@ ban_user = (name) ->
continue continue
return return
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16') try
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16')
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"
# load the lflist of current date # load the lflist of current date
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\.]+)/)
...@@ -303,18 +307,13 @@ class Room ...@@ -303,18 +307,13 @@ class Room
@scores = {} @scores = {}
ROOM_all.push this ROOM_all.push this
@hostinfo ||= @hostinfo ||= settings.modules.default_room_info
lflist: if settings.lflist.length then 0 else -1 if settings.lflist.length
rule: if settings.modules.enable_TCG_as_default then 2 else 0 if @hostinfo.rule == 1 and @hostinfo.lflist == 0
mode: 0 @hostinfo.lflist = _.findIndex settings.lflist, (list)-> list.tcg
enable_priority: false else
no_check_deck: false @hostinfo.lflist = -1
no_shuffle_deck: false @hostinfo.replay_mode = if settings.modules.tournament_mode.enabled then 1 else 0
start_lp: 8000
start_hand: 5
draw_count: 1
time_limit: 180
replay_mode: if settings.modules.tournament_mode.enabled then 1 else 0
if name[0...2] == 'M#' if name[0...2] == 'M#'
@hostinfo.mode = 1 @hostinfo.mode = 1
......
...@@ -111,7 +111,12 @@ ...@@ -111,7 +111,12 @@
} }
}; };
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16'); try {
settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16');
} 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");
}
settings.lflist = (function() { settings.lflist = (function() {
var k, len, ref, results; var k, len, ref, results;
...@@ -416,19 +421,17 @@ ...@@ -416,19 +421,17 @@
this.welcome = ''; this.welcome = '';
this.scores = {}; this.scores = {};
ROOM_all.push(this); ROOM_all.push(this);
this.hostinfo || (this.hostinfo = { this.hostinfo || (this.hostinfo = settings.modules.default_room_info);
lflist: settings.lflist.length ? 0 : -1, if (settings.lflist.length) {
rule: settings.modules.enable_TCG_as_default ? 2 : 0, if (this.hostinfo.rule === 1 && this.hostinfo.lflist === 0) {
mode: 0, this.hostinfo.lflist = _.findIndex(settings.lflist, function(list) {
enable_priority: false, return list.tcg;
no_check_deck: false, });
no_shuffle_deck: false, }
start_lp: 8000, } else {
start_hand: 5, this.hostinfo.lflist = -1;
draw_count: 1, }
time_limit: 180, this.hostinfo.replay_mode = settings.modules.tournament_mode.enabled ? 1 : 0;
replay_mode: settings.modules.tournament_mode.enabled ? 1 : 0
});
if (name.slice(0, 2) === 'M#') { if (name.slice(0, 2) === 'M#') {
this.hostinfo.mode = 1; this.hostinfo.mode = 1;
} else if (name.slice(0, 2) === 'T#') { } else if (name.slice(0, 2) === 'T#') {
......
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