Commit 2edd956c authored by mercury233's avatar mercury233

add room name code

parent bba69ea7
......@@ -8,7 +8,7 @@
"tips": "http://mercury233.me/ygosrv233/tips.json",
"dialogues": "http://mercury233.me/ygosrv233/dialogues.json",
"post_start_watching": true,
"skip_empty_side": true,
"TCG_banlist_id": 7,
"http": {
"port": 7922,
"password": "123456",
......
......@@ -96,8 +96,55 @@ class Room
@hostinfo.start_lp = parseInt(param[6])
@hostinfo.start_hand = parseInt(param[7])
@hostinfo.draw_count = parseInt(param[8])
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'), (if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'), @hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count]
else if (param = name.match /(.+)#/)
rule=param[1]
log.info rule
if (rule.match /(^|,|,)(M|MATCH)(,|,|$)/i)
@hostinfo.mode = 1
if (rule.match /(^|,|,)(T|TAG)(,|,|$)/i)
@hostinfo.mode = 2
@hostinfo.start_lp = 16000
if (rule.match /(^|,|,)(TCGONLY|TO)(,|,|$)/i)
@hostinfo.rule = 1
@hostinfo.lflist = settings.modules.TCG_banlist_id
if (rule.match /(^|,|,)(OT|TCG)(,|,|$)/i)
@hostinfo.rule = 2
if (param = rule.match /(^|,|,)LP(\d+)(,|,|$)/i)
start_lp = parseInt(param[2])
if (start_lp <= 0) then start_lp = 1
if (start_lp >= 99999) then start_lp = 99999
@hostinfo.start_lp = start_lp
if (param = rule.match /(^|,|,)TIME(\d+)(,|,|$)/i)
time_limit = parseInt(param[2])
if (time_limit <= 0) then time_limit = 180
if (time_limit >= 1 and time_limit <= 60) then time_limit = time_limit*60
if (time_limit >= 999) then time_limit = 999
@hostinfo.time_limit = time_limit
if (param = rule.match /(^|,|,)START(\d+)(,|,|$)/i)
start_hand = parseInt(param[2])
if (start_hand <= 0) then start_hand = 1
if (start_hand >= 40) then start_hand = 40
@hostinfo.start_hand = start_hand
if (param = rule.match /(^|,|,)DRAW(\d+)(,|,|$)/i)
draw_count = parseInt(param[2])
if (draw_count >= 35) then draw_count = 35
@hostinfo.draw_count = draw_count
if (param = rule.match /(^|,|,)LFLIST(\d+)(,|,|$)/i)
lflist = parseInt(param[2])-1
@hostinfo.lflist = lflist
if (param = rule.match /(^|,|,)NOLFLIST(,|,|$)/i)
@hostinfo.lflist = -1
if (param = rule.match /(^|,|,)NOUNIQUE(,|,|$)/i)
@hostinfo.rule = 3
if (param = rule.match /(^|,|,)NOCHECK(,|,|$)/i)
@hostinfo.no_check_deck = "T"
if (param = rule.match /(^|,|,)NOSHUFFLE(,|,|$)/i)
@hostinfo.no_shuffle_deck = "T"
if (param = rule.match /(^|,|,)IGPRIORITY(,|,|$)/i)
@hostinfo.enable_priority = "T"
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'), (if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'), @hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit]
@process = spawn './ygopro', param, cwd: 'ygocore'
@process.on 'exit', (code)=>
......
......@@ -79,7 +79,7 @@
};
function Room(name) {
var param;
var draw_count, lflist, param, rule, start_hand, start_lp, time_limit;
this.name = name;
this.alive = true;
this.players = [];
......@@ -114,8 +114,84 @@
this.hostinfo.start_lp = parseInt(param[6]);
this.hostinfo.start_hand = parseInt(param[7]);
this.hostinfo.draw_count = parseInt(param[8]);
} else if ((param = name.match(/(.+)#/))) {
rule = param[1];
log.info(rule);
if (rule.match(/(^|,|,)(M|MATCH)(,|,|$)/i)) {
this.hostinfo.mode = 1;
}
if (rule.match(/(^|,|,)(T|TAG)(,|,|$)/i)) {
this.hostinfo.mode = 2;
this.hostinfo.start_lp = 16000;
}
if (rule.match(/(^|,|,)(TCGONLY|TO)(,|,|$)/i)) {
this.hostinfo.rule = 1;
this.hostinfo.lflist = settings.modules.TCG_banlist_id;
}
if (rule.match(/(^|,|,)(OT|TCG)(,|,|$)/i)) {
this.hostinfo.rule = 2;
}
if ((param = rule.match(/(^|,|,)LP(\d+)(,|,|$)/i))) {
start_lp = parseInt(param[2]);
if (start_lp <= 0) {
start_lp = 1;
}
if (start_lp >= 99999) {
start_lp = 99999;
}
this.hostinfo.start_lp = start_lp;
}
if ((param = rule.match(/(^|,|,)TIME(\d+)(,|,|$)/i))) {
time_limit = parseInt(param[2]);
if (time_limit <= 0) {
time_limit = 180;
}
if (time_limit >= 1 && time_limit <= 60) {
time_limit = time_limit * 60;
}
if (time_limit >= 999) {
time_limit = 999;
}
this.hostinfo.time_limit = time_limit;
}
if ((param = rule.match(/(^|,|,)START(\d+)(,|,|$)/i))) {
start_hand = parseInt(param[2]);
if (start_hand <= 0) {
start_hand = 1;
}
if (start_hand >= 40) {
start_hand = 40;
}
this.hostinfo.start_hand = start_hand;
}
if ((param = rule.match(/(^|,|,)DRAW(\d+)(,|,|$)/i))) {
draw_count = parseInt(param[2]);
if (draw_count >= 35) {
draw_count = 35;
}
this.hostinfo.draw_count = draw_count;
}
if ((param = rule.match(/(^|,|,)LFLIST(\d+)(,|,|$)/i))) {
lflist = parseInt(param[2]) - 1;
this.hostinfo.lflist = lflist;
}
if ((param = rule.match(/(^|,|,)NOLFLIST(,|,|$)/i))) {
this.hostinfo.lflist = -1;
}
if ((param = rule.match(/(^|,|,)NOUNIQUE(,|,|$)/i))) {
this.hostinfo.rule = 3;
}
if ((param = rule.match(/(^|,|,)NOCHECK(,|,|$)/i))) {
this.hostinfo.no_check_deck = "T";
}
if ((param = rule.match(/(^|,|,)NOSHUFFLE(,|,|$)/i))) {
this.hostinfo.no_shuffle_deck = "T";
}
if ((param = rule.match(/(^|,|,)IGPRIORITY(,|,|$)/i))) {
this.hostinfo.enable_priority = "T";
}
}
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count];
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit];
this.process = spawn('./ygopro', param, {
cwd: 'ygocore'
});
......
......@@ -507,12 +507,12 @@ if settings.modules.http
else if u.query.pass == settings.modules.http.password && u.query.stop
settings.modules.stop = u.query.stop
response.writeHead(200)
response.end("stop " + u.query.shout + " ok")
response.end("stop " + u.query.stop + " ok")
else if u.query.pass == settings.modules.http.password && u.query.welcome
settings.modules.welcome = u.query.welcome
response.writeHead(200)
response.end("welcome " + u.query.shout + " ok")
response.end("welcome " + u.query.stop + " ok")
else
response.writeHead(404);
......
......@@ -632,11 +632,11 @@
} else if (u.query.pass === settings.modules.http.password && u.query.stop) {
settings.modules.stop = u.query.stop;
response.writeHead(200);
response.end("stop " + u.query.shout + " ok");
response.end("stop " + u.query.stop + " ok");
} else if (u.query.pass === settings.modules.http.password && u.query.welcome) {
settings.modules.welcome = u.query.welcome;
response.writeHead(200);
response.end("welcome " + u.query.shout + " ok");
response.end("welcome " + u.query.stop + " ok");
} else {
response.writeHead(404);
response.end();
......
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