From 44d669f74dfda1126adb69ad086ccda87171a657 Mon Sep 17 00:00:00 2001 From: Kris Johnson <11083252+KrisXV@users.noreply.github.com> Date: Wed, 21 Nov 2018 23:10:23 -0700 Subject: [PATCH] Add more teambuilder support for Let's Go (#1169) --- build-tools/build-indexes | 32 +++++++++++++++++-- build-tools/build-minidex | 3 +- js/client-battle-tooltips.js | 5 +++ js/client-teambuilder.js | 59 +++++++++++++++++++++++------------- js/search.js | 7 ++++- 5 files changed, 79 insertions(+), 27 deletions(-) diff --git a/build-tools/build-indexes b/build-tools/build-indexes index 7b53b7ad2..d342b503c 100755 --- a/build-tools/build-indexes +++ b/build-tools/build-indexes @@ -285,11 +285,12 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); let buf = '// DO NOT EDIT - automatically built with build-tools/build-indexes\n\n'; // process.stdout.write("\n "); - for (const genIdent of [7, -7.5, -7, 6, -6, 5, 4, 3, 2, 1]) { + for (const genIdent of [7, 7.1, -7.5, -7, 6, -6, 5, 4, 3, 2, 1]) { + const isLetsGo = (genIdent === 7.1); const isDoubles = (genIdent < 0); const isVGC = (genIdent === -7.5); const genNum = Math.floor(isDoubles ? -genIdent : genIdent); - const gen = 'gen' + genNum; + const gen = isLetsGo ? 'letsgo' : 'gen' + genNum; // process.stdout.write("" + gen + (isDoubles ? " doubles" : "") + "... "); const pokemon = Object.keys(Tools.data.Pokedex); pokemon.sort(); @@ -301,6 +302,13 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); if (template.tier === 'CAP' || template.tier === 'CAP NFE' || template.tier === 'CAP LC') { return template.tier; } + if (isLetsGo) { + let baseTemplate = Tools.mod(gen).getTemplate(template.baseSpecies); + let validNum = (baseTemplate.num <= 151 && baseTemplate.num >= 1) || [808, 809].includes(baseTemplate.num); + if (!validNum) return 'Illegal'; + if (template.forme && !['Alola', 'Mega', 'Mega-X', 'Mega-Y', 'Starter'].includes(template.forme)) return 'Illegal'; + return template.tier; + } if (isVGC) { if (template.tier === 'NFE') return 'NFE'; if (template.tier === 'LC') return 'NFE'; @@ -342,7 +350,11 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); const items = []; const formatSlices = {}; - if (isVGC) { + if (isLetsGo) { + BattleTeambuilderTable['letsgo'] = {}; + BattleTeambuilderTable['letsgo'].tiers = tiers; + BattleTeambuilderTable['letsgo'].formatSlices = formatSlices; + } else if (isVGC) { BattleTeambuilderTable[gen + 'vgc'] = {}; BattleTeambuilderTable[gen + 'vgc'].tiers = tiers; BattleTeambuilderTable[gen + 'vgc'].formatSlices = formatSlices; @@ -362,6 +374,9 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); } const tierOrder = (() => { + if (isLetsGo) { + return ["Uber", "OU", "NFE", "LC"]; + } if (isVGC) { return ["Mythical", "Restricted Legendary", "Regular", "NFE", "LC"]; } @@ -615,6 +630,17 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); if (minGen === 1) learnsets[id][moveid] = '12' + learnsets[id][moveid]; } } + /* + * Commented out until it can be done without mutating main data + const LGLearnsets = Tools.mod('letsgo').data.Learnsets; + for (const id in LGLearnsets) { + const learnset = LGLearnsets[id].learnset; + learnsets[id] = {}; + for (const moveid in learnset) { + learnsets[id][moveid] = '7'; + } + } + */ // // Past gen table diff --git a/build-tools/build-minidex b/build-tools/build-minidex index fbef09359..5656100bd 100755 --- a/build-tools/build-minidex +++ b/build-tools/build-minidex @@ -35,7 +35,7 @@ function sizeObj(path) { let size = imageSize(path); return { w: size.width, - h: size.height + h: size.height, }; } catch (e) {} } @@ -76,7 +76,6 @@ for (let baseid in Tools.data.Pokedex) { g5buf += `\t${id}:` + JSON.stringify(g5row).replace(/"/g, '') + `,\n`; } } - } } diff --git a/js/client-battle-tooltips.js b/js/client-battle-tooltips.js index 29315b043..4d2d4736e 100644 --- a/js/client-battle-tooltips.js +++ b/js/client-battle-tooltips.js @@ -853,6 +853,11 @@ var BattleTooltips = (function () { var isRandomBattle = tier.indexOf('Random Battle') >= 0 || (tier.indexOf('Random') >= 0 && tier.indexOf('Battle') >= 0 && gen >= 6); var value = iv + ((isRandomBattle && gen >= 3) ? 21 : 63); var nature = (isRandomBattle || gen < 3) ? 1 : 1.1; + if (tier.indexOf("Let's Go") >= 0) { + var maxStat = Math.floor(Math.floor(Math.floor(Math.floor(2 * baseSpe + iv) * level / 100 + 5) * nature) * 1.1); + if (tier.indexOf('No Restrictions') >= 0) return maxStat + 200; + return maxStat; + } return Math.floor(Math.floor(Math.floor(2 * baseSpe + value) * level / 100 + 5) * nature); }; diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index cd20a6cc8..e95436f03 100644 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -125,7 +125,7 @@ update: function () { teams = Storage.teams; if (this.curTeam) { - this.ignoreEVLimits = (this.curTeam.gen < 3 || this.curTeam.format === 'gen7balancedhackmons'); + this.ignoreEVLimits = (this.curTeam.gen < 3 || this.curTeam.format === 'gen7balancedhackmons' || this.curTeam.format.endsWith('norestrictions')); if (this.curSet) { return this.updateSetView(); } @@ -1069,6 +1069,7 @@ }, renderSet: function (set, i) { var template = Tools.getTemplate(set.species); + var isLetsGo = this.curTeam.format.startsWith('gen7letsgo'); var buf = '
  • '; if (!set.species) { if (this.deletedSet) { @@ -1131,8 +1132,9 @@ buf += ''; buf += '
    '; + // if (this.curTeam.gen > 1 && !isLetsGo) buf += '
    '; if (this.curTeam.gen > 1) buf += '
    '; - if (this.curTeam.gen > 2) buf += '
    '; + if (this.curTeam.gen > 2 && !isLetsGo) buf += '
    '; buf += '
    '; // moves @@ -1144,11 +1146,9 @@ buf += '
    '; buf += ''; - var supportsEVs = !this.curTeam.format.startsWith('gen7letsgo'); - // stats buf += '