Skip to content

Commit

Permalink
Account for custom challenges with best of default checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Nov 2, 2023
1 parent 463948f commit b64f891
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/client-mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@
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>';
var bestOfDefault = format ? BattleFormats[format].bestOfDefault : false;
var bestOfDefault = format && BattleFormats[format] ? BattleFormats[format].bestOfDefault : false;
buf += '<p' + (!bestOfDefault ? ' class="hidden">' : '>');
buf += '<label class="checkbox"><input type="checkbox" name="bestof" /> <abbr title="Start a team-locked best-of-n series">Best-of-<input name="bestofvalue" type="number" min="3" max="9" step="2" value="3" style="width: 28px; vertical-align: initial;"></abbr></label></p>';
buf += '<p class="buttonbar"><button name="makeChallenge"><strong>Challenge</strong></button> <button type="button" name="dismissChallenge">Cancel</button></p></form>';
Expand Down Expand Up @@ -1386,7 +1386,7 @@
var $bestOfValueInput = this.sourceEl.closest('form').find('input[name=bestofvalue]');
if ($bestOfCheckbox && $bestOfValueInput) {
var $parentTag = $bestOfCheckbox.parent().parent();
var bestOfDefault = BattleFormats[format].bestOfDefault;
var bestOfDefault = BattleFormats[format] && BattleFormats[format].bestOfDefault;
if (bestOfDefault) {
$parentTag.removeClass('hidden');
$bestOfValueInput.val(3);
Expand Down

0 comments on commit b64f891

Please sign in to comment.