Set teambuilder sets to level 50 when server says so (#963)

This commit is contained in:
Konrad Borowski
2017-07-06 08:34:34 +02:00
committed by Guangcong Luo
parent cfd87a91c1
commit 235af5d527
2 changed files with 7 additions and 0 deletions

View File

@@ -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;

View File

@@ -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'