Commit 6bd7354c authored by nanahira's avatar nanahira

add MR param supporting all duel rules

parent 91b209c0
......@@ -7,7 +7,7 @@
"rule": 0,
"mode": 0,
"comment": "rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG",
"enable_priority": false,
"duel_rule": 4,
"no_check_deck": false,
"no_shuffle_deck": false,
"start_lp": 8000,
......
......@@ -207,6 +207,14 @@ if settings.modules.update_util.password
})
delete settings.modules.update_util.password
imported = true
#import the old enable_priority hostinfo
if settings.hostinfo.enable_priority or settings.hostinfo.enable_priority == false
if settings.hostinfo.enable_priority
settings.hostinfo.duel_rule = 3
else
settings.hostinfo.duel_rule = 4
delete settings.hostinfo.enable_priority
imported = true
#finish
if imported
setting_save(settings)
......@@ -1002,7 +1010,7 @@ class Room
else if (param = name.match /^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i)
@hostinfo.rule = parseInt(param[1])
@hostinfo.mode = parseInt(param[2])
@hostinfo.enable_priority = param[3] == 'T'
@hostinfo.duel_rule = (if param[3] == 'T' then 3 else 4)
@hostinfo.no_check_deck = param[4] == 'T'
@hostinfo.no_shuffle_deck = param[5] == 'T'
@hostinfo.start_lp = parseInt(param[6])
......@@ -1070,8 +1078,13 @@ class Room
if (rule.match /(^|,|,)(NOSHUFFLE|NS)(,|,|$)/)
@hostinfo.no_shuffle_deck = true
if (rule.match /(^|,|,)(IGPRIORITY|PR)(,|,|$)/)
@hostinfo.enable_priority = true
if (rule.match /(^|,|,)(IGPRIORITY|PR)(,|,|$)/) # deprecated
@hostinfo.duel_rule = 3
if (param = rule.match /(^|,|,)(DUELRULE|MR)(\d+)(,|,|$)/)
duel_rule = parseInt(param[3])
if duel_rule and duel_rule > 0 and duel_rule <= 4
@hostinfo.duel_rule = duel_rule
if (rule.match /(^|,|,)(NOWATCH|NW)(,|,|$)/)
@hostinfo.no_watch = true
......@@ -1090,7 +1103,7 @@ class Room
if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe) or (@hostinfo.mode == 1 and settings.modules.replay_delay)
@hostinfo.replay_mode |= 0x2
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'),
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, @hostinfo.duel_rule,
(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, @hostinfo.replay_mode]
......@@ -1875,7 +1888,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
time_limit: 180
rule: (opt1 >> 5) & 3
mode: (opt1 >> 3) & 3
enable_priority: !!((opt1 >> 2) & 1)
enable_priority: (if !!((opt1 >> 2) & 1) then 3 else 4)
no_check_deck: !!((opt1 >> 1) & 1)
no_shuffle_deck: !!(opt1 & 1)
start_lp: opt2
......
......@@ -223,6 +223,16 @@
imported = true;
}
if (settings.hostinfo.enable_priority || settings.hostinfo.enable_priority === false) {
if (settings.hostinfo.enable_priority) {
settings.hostinfo.duel_rule = 3;
} else {
settings.hostinfo.duel_rule = 4;
}
delete settings.hostinfo.enable_priority;
imported = true;
}
if (imported) {
setting_save(settings);
}
......@@ -1233,7 +1243,7 @@
Room = (function() {
function Room(name, hostinfo) {
var death_time, draw_count, lflist, param, rule, start_hand, start_lp, time_limit;
var death_time, draw_count, duel_rule, lflist, param, rule, start_hand, start_lp, time_limit;
this.hostinfo = hostinfo;
this.name = name;
this.players = [];
......@@ -1277,7 +1287,7 @@
} else if ((param = name.match(/^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i))) {
this.hostinfo.rule = parseInt(param[1]);
this.hostinfo.mode = parseInt(param[2]);
this.hostinfo.enable_priority = param[3] === 'T';
this.hostinfo.duel_rule = (param[3] === 'T' ? 3 : 4);
this.hostinfo.no_check_deck = param[4] === 'T';
this.hostinfo.no_shuffle_deck = param[5] === 'T';
this.hostinfo.start_lp = parseInt(param[6]);
......@@ -1362,7 +1372,13 @@
this.hostinfo.no_shuffle_deck = true;
}
if (rule.match(/(^|,|,)(IGPRIORITY|PR)(,|,|$)/)) {
this.hostinfo.enable_priority = true;
this.hostinfo.duel_rule = 3;
}
if ((param = rule.match(/(^|,|,)(DUELRULE|MR)(\d+)(,|,|$)/))) {
duel_rule = parseInt(param[3]);
if (duel_rule && duel_rule > 0 && duel_rule <= 4) {
this.hostinfo.duel_rule = duel_rule;
}
}
if (rule.match(/(^|,|,)(NOWATCH|NW)(,|,|$)/)) {
this.hostinfo.no_watch = true;
......@@ -1383,7 +1399,7 @@
if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) {
this.hostinfo.replay_mode |= 0x2;
}
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.hostinfo.replay_mode];
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, this.hostinfo.duel_rule, (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.hostinfo.replay_mode];
try {
this.process = spawn('./ygopro', param, {
cwd: 'ygopro'
......@@ -2343,7 +2359,7 @@
time_limit: 180,
rule: (opt1 >> 5) & 3,
mode: (opt1 >> 3) & 3,
enable_priority: !!((opt1 >> 2) & 1),
enable_priority: (!!((opt1 >> 2) & 1) ? 3 : 4),
no_check_deck: !!((opt1 >> 1) & 1),
no_shuffle_deck: !!(opt1 & 1),
start_lp: opt2,
......
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