From 235af5d527611af32b86ff06d6ea7e97ffd677f8 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Thu, 6 Jul 2017 08:34:34 +0200 Subject: [PATCH] Set teambuilder sets to level 50 when server says so (#963) --- js/client-teambuilder.js | 4 ++++ js/client.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index cbc1d8d94..3141565dc 100644 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -2784,11 +2784,15 @@ if (set.level) delete set.level; if (this.curTeam && this.curTeam.format) { var baseFormat = this.curTeam.format; + var format = window.BattleFormats && window.BattleFormats[baseFormat]; if (baseFormat.substr(0, 3) === 'gen') baseFormat = baseFormat.substr(4); if (baseFormat.substr(0, 8) === 'pokebank') baseFormat = baseFormat.substr(8); if (this.curTeam && this.curTeam.format) { if (baseFormat.substr(0, 10) === 'battlespot' || baseFormat.substr(0, 3) === 'vgc') set.level = 50; if (baseFormat.substr(0, 2) === 'lc' || baseFormat.substr(0, 5) === 'caplc') set.level = 5; + if (format && format.teambuilderLevel) { + set.level = format.teambuilderLevel; + } } } if (set.gender) delete set.gender; diff --git a/js/client.js b/js/client.js index f03ea9790..abc8ecb35 100644 --- a/js/client.js +++ b/js/client.js @@ -1085,6 +1085,7 @@ var challengeShow = true; var tournamentShow = true; var team = null; + var teambuilderLevel = null; var lastCommaIndex = name.lastIndexOf(','); var code = lastCommaIndex >= 0 ? parseInt(name.substr(lastCommaIndex + 1), 16) : NaN; if (!isNaN(code)) { @@ -1093,6 +1094,7 @@ if (!(code & 2)) searchShow = false; if (!(code & 4)) challengeShow = false; if (!(code & 8)) tournamentShow = false; + if (code & 16) teambuilderLevel = 50; } else { // Backwards compatibility: late 0.9.0 -> 0.10.0 if (name.substr(name.length - 2) === ',#') { // preset teams @@ -1155,6 +1157,7 @@ challengeShow: challengeShow, tournamentShow: tournamentShow, rated: searchShow && id.substr(0, 7) !== 'unrated', + teambuilderLevel: teambuilderLevel, teambuilderFormat: teambuilderFormat, isTeambuilderFormat: isTeambuilderFormat, effectType: 'Format'