Skip to content

Commit

Permalink
Bo3: Add challenge checkbox for VGC formats (#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaWoblefet authored Oct 1, 2023
1 parent fd4c1ea commit 82ca9ec
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions js/client-mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@
buf += '<p><label class="label">Format:</label>' + this.renderFormats(format) + '</p>';
buf += '<p><label class="label">Team:</label>' + this.renderTeams(format) + '</p>';
buf += '<p><label class="checkbox"><input type="checkbox" name="private" ' + (Storage.prefs('disallowspectators') ? 'checked' : '') + ' /> <abbr title="You can still invite spectators by giving them the URL or using the /invite command">Don\'t allow spectators</abbr></label></p>';
buf += '<p' + (!(format && format.includes('vgc')) ? ' class="hidden">' : '>');
buf += '<label class="checkbox"><input type="checkbox" name="bestof" /> <abbr title="Start a team-locked best-of-3 series">Best-of-3</abbr></label></p>';
buf += '<p class="buttonbar"><button name="makeChallenge"><strong>Challenge</strong></button> <button type="button" name="dismissChallenge">Cancel</button></p></form>';
$challenge.html(buf);
},
Expand Down Expand Up @@ -935,6 +937,14 @@
var format = $pmWindow.find('button[name=format]').val();
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) {
format += hasCustomRules ? ', ' : '@@@';
format += 'Best of = 3';
}

var team = null;
if (Storage.teams[teamIndex]) team = Storage.teams[teamIndex];

Expand Down Expand Up @@ -1272,6 +1282,18 @@
app.rooms[''].curTeamIndex = -1;
var $teamButton = this.sourceEl.closest('form').find('button[name=team]');
if ($teamButton.length) $teamButton.replaceWith(app.rooms[''].renderTeams(format));

var $bestOfCheckbox = this.sourceEl.closest('form').find('input[name=bestof]');
if ($bestOfCheckbox) {
var $parentTag = $bestOfCheckbox.parent().parent();
if (format.includes('vgc')) {
$parentTag.removeClass('hidden');
} else {
$parentTag.addClass('hidden');
$bestOfCheckbox.prop('checked', false);
}
}

var $partnerLabels = $('label[name=partner]');
$partnerLabels.each(function (i, label) {
label.style.display = BattleFormats[format].partner ? '' : 'none';
Expand Down

0 comments on commit 82ca9ec

Please sign in to comment.