Commit 4a39b790 authored by mercury233's avatar mercury233

read default room info and default version from config

parent 783620b4
......@@ -8,7 +8,6 @@
"dialogues": "http://mercury233.me/ygosrv233/dialogues.json",
"enable_random_duel": false,
"enable_halfway_watch": true,
"enable_TCG_as_default": false,
"enable_cloud_replay": false,
"enable_windbot": false,
"enable_websocket_roomlist": false,
......@@ -20,6 +19,20 @@
"mycard_auth": false,
"post_deck": false,
"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": {
"mode": "233",
"post_score": false,
......
......@@ -82,7 +82,11 @@ ban_user = (name) ->
continue
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
settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
......@@ -303,18 +307,13 @@ class Room
@scores = {}
ROOM_all.push this
@hostinfo ||=
lflist: if settings.lflist.length then 0 else -1
rule: if settings.modules.enable_TCG_as_default then 2 else 0
mode: 0
enable_priority: false
no_check_deck: false
no_shuffle_deck: false
start_lp: 8000
start_hand: 5
draw_count: 1
time_limit: 180
replay_mode: if settings.modules.tournament_mode.enabled then 1 else 0
@hostinfo ||= settings.modules.default_room_info
if settings.lflist.length
if @hostinfo.rule == 1 and @hostinfo.lflist == 0
@hostinfo.lflist = _.findIndex settings.lflist, (list)-> list.tcg
else
@hostinfo.lflist = -1
@hostinfo.replay_mode = if settings.modules.tournament_mode.enabled then 1 else 0
if name[0...2] == 'M#'
@hostinfo.mode = 1
......
......@@ -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() {
var k, len, ref, results;
......@@ -416,19 +421,17 @@
this.welcome = '';
this.scores = {};
ROOM_all.push(this);
this.hostinfo || (this.hostinfo = {
lflist: settings.lflist.length ? 0 : -1,
rule: settings.modules.enable_TCG_as_default ? 2 : 0,
mode: 0,
enable_priority: false,
no_check_deck: false,
no_shuffle_deck: false,
start_lp: 8000,
start_hand: 5,
draw_count: 1,
time_limit: 180,
replay_mode: settings.modules.tournament_mode.enabled ? 1 : 0
});
this.hostinfo || (this.hostinfo = settings.modules.default_room_info);
if (settings.lflist.length) {
if (this.hostinfo.rule === 1 && this.hostinfo.lflist === 0) {
this.hostinfo.lflist = _.findIndex(settings.lflist, function(list) {
return list.tcg;
});
}
} else {
this.hostinfo.lflist = -1;
}
this.hostinfo.replay_mode = settings.modules.tournament_mode.enabled ? 1 : 0;
if (name.slice(0, 2) === 'M#') {
this.hostinfo.mode = 1;
} 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