diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index a992382ae5..a241984106 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -896,8 +896,9 @@ buf += '
' + this.renderFormats(format) + '
'; buf += '' + this.renderTeams(format) + '
'; buf += ''; - buf += '' : '>'); - buf += '
'; + var bestOfDefault = format ? BattleFormats[format].bestOfDefault : false; + buf += '' : '>'); + buf += '
'; buf += ' '; $challenge.html(buf); }, @@ -942,11 +943,12 @@ var teamIndex = $pmWindow.find('button[name=team]').val(); var privacy = this.adjustPrivacy($pmWindow.find('input[name=private]').is(':checked')); - var bestof = $pmWindow.find('input[name=bestof]').is(':checked'); - var hasCustomRules = format.includes('@@@'); - if (bestof) { + var bestOf = $pmWindow.find('input[name=bestof]').is(':checked'); + var bestOfValue = $pmWindow.find('input[name=bestofvalue]').val(); + if (bestOf && bestOfValue) { + var hasCustomRules = format.includes('@@@'); format += hasCustomRules ? ', ' : '@@@'; - format += 'Best of = 3'; + format += 'Best of = ' + bestOfValue; } var team = null; @@ -1381,10 +1383,13 @@ if ($teamButton.length) $teamButton.replaceWith(app.rooms[''].renderTeams(format)); var $bestOfCheckbox = this.sourceEl.closest('form').find('input[name=bestof]'); - if ($bestOfCheckbox) { + var $bestOfValueInput = this.sourceEl.closest('form').find('input[name=bestofvalue]'); + if ($bestOfCheckbox && $bestOfValueInput) { var $parentTag = $bestOfCheckbox.parent().parent(); - if (format.includes('vgc')) { + var bestOfDefault = BattleFormats[format].bestOfDefault; + if (bestOfDefault) { $parentTag.removeClass('hidden'); + $bestOfValueInput.val(3); } else { $parentTag.addClass('hidden'); $bestOfCheckbox.prop('checked', false); diff --git a/js/client.js b/js/client.js index 5830583bd0..26147c0471 100644 --- a/js/client.js +++ b/js/client.js @@ -1328,6 +1328,7 @@ function toId() { var challengeShow = true; var tournamentShow = true; var partner = false; + var bestOfDefault = false; var team = null; var teambuilderLevel = null; var lastCommaIndex = name.lastIndexOf(','); @@ -1340,6 +1341,7 @@ function toId() { if (!(code & 8)) tournamentShow = false; if (code & 16) teambuilderLevel = 50; if (code & 32) partner = true; + if (code & 64) bestOfDefault = true; } else { // Backwards compatibility: late 0.9.0 -> 0.10.0 if (name.substr(name.length - 2) === ',#') { // preset teams @@ -1403,6 +1405,7 @@ function toId() { searchShow: searchShow, challengeShow: challengeShow, tournamentShow: tournamentShow, + bestOfDefault: bestOfDefault, rated: searchShow && id.substr(4, 7) !== 'unrated', teambuilderLevel: teambuilderLevel, partner: partner,