Teambuilder: Add Champions NatDex Draft support (#2706)
Some checks are pending
Node.js CI / build (22.x) (push) Waiting to run

This commit is contained in:
Kris Johnson
2026-06-21 14:53:18 -06:00
committed by GitHub
parent 39a5ca792d
commit 6cf6066033
2 changed files with 56 additions and 20 deletions

View File

@@ -261,8 +261,10 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const LC = GENS.map(num => num + 0.7);
const STADIUM = [2.04, 1.04];
const NATDEX = [9.1, 8.1];
// 68 = natdex champs
const CHAMPIONS = [9.67, 9.68];
const OTHER = [
9.9, 9.67, 9.6, 9.411, 9.41, 9.401, 9.4, 9.33, 9.2, -9.4, -9.401,
9.9, 9.6, 9.411, 9.41, 9.401, 9.4, 9.33, 9.2, -9.4, -9.401,
8.6, 8.4, 8.2, -8.4, -8.6,
7.1,
5.1,
@@ -270,7 +272,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
];
// process.stdout.write("\n ");
for (const genIdent of [...GENS, ...DOUBLES, ...VGC, ...NFE, ...STADIUM, ...OTHER, ...NATDEX, ...LC]) {
for (const genIdent of [...GENS, ...DOUBLES, ...VGC, ...NFE, ...STADIUM, ...OTHER, ...NATDEX, ...CHAMPIONS, ...LC]) {
const isLetsGo = (genIdent === 7.1);
const isBDSP = (genIdent === 8.6 || genIdent === -8.6);
const isMetBattle = ('' + genIdent).endsWith('.2');
@@ -286,6 +288,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
const isGen9BH = genIdent === 9.9;
const isSSB = genIdent === 9.6;
const isChampions = genIdent === 9.67;
const isNDChampions = genIdent === 9.68;
const genNum = Math.floor(isDoubles ? -genIdent : genIdent);
const isBW1 = genIdent === 5.1;
const isRS = genIdent === 3.1;
@@ -302,7 +305,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (isBW1) genStr += 'bw1';
if (isRS) genStr += 'rs';
if (isFRLG) genStr += 'frlg';
if (isChampions) genStr = 'champions';
if (isChampions || isNDChampions) genStr = 'champions';
return genStr;
})();
// process.stdout.write("" + gen + (isDoubles ? " doubles" : "") + "... ");
@@ -413,6 +416,10 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
if (isNatDex || (isPreDLC && genNum === 9.41) || (isSVDLC1 && genNum === 9.411)) {
return species.natDexTier;
}
if (isNDChampions) {
if (species.tier === 'Illegal') return Dex.mod('gen9').species.get(species.id).natDexTier;
return species.tier;
}
return species.tier;
})();
overrideTier[species.id] = speciesTier;
@@ -536,6 +543,14 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
BattleTeambuilderTable['champions'].metagameBans = metagameBans;
BattleTeambuilderTable['champions'].overrideTier = overrideTier;
BattleTeambuilderTable['champions'].formatSlices = formatSlices;
} else if (isNDChampions) {
BattleTeambuilderTable['natdexchampions'] = {};
BattleTeambuilderTable['natdexchampions'].learnsets = {};
BattleTeambuilderTable['natdexchampions'].tiers = tiers;
BattleTeambuilderTable['natdexchampions'].items = items;
BattleTeambuilderTable['natdexchampions'].metagameBans = metagameBans;
BattleTeambuilderTable['natdexchampions'].overrideTier = overrideTier;
BattleTeambuilderTable['natdexchampions'].formatSlices = formatSlices;
} else if (isVGC) {
BattleTeambuilderTable[gen + 'vgc'] = {};
BattleTeambuilderTable[gen + 'vgc'].tiers = tiers;
@@ -649,7 +664,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
continue;
}
if (item.isNonstandard && !isMetBattle) {
if (isNatDex) {
if (isNatDex || isNDChampions) {
let curItem = item;
let curGen = genNum;
while (curItem.isNonstandard && curGen >= 7) {
@@ -1036,6 +1051,21 @@ process.stdout.write("Building `data/teambuilder-tables.js`... ");
BattleTeambuilderTable['champions'].learnsets[id][moveid] = '9a';
}
}
for (const id in learnsets) {
BattleTeambuilderTable['natdexchampions'].learnsets[id] = Object.assign({}, learnsets[id]);
const species = Dex.mod('champions').species.get(id);
if (species.isNonstandard) continue;
const learnset = ChampionsLearnsets[id].learnset;
if (!learnset) continue;
for (const moveid in learnset) {
if (moveid in BattleTeambuilderTable['natdexchampions'].learnsets[id]) {
if (BattleTeambuilderTable['natdexchampions'].learnsets[id][moveid].includes('9')) continue;
BattleTeambuilderTable['natdexchampions'].learnsets[id][moveid] += '9a';
} else {
BattleTeambuilderTable['natdexchampions'].learnsets[id][moveid] = '9a';
}
}
}
const SSDLC1Learnsets = Dex.mod('gen8dlc1').data.Learnsets;
for (const id in SSDLC1Learnsets) {
const learnset = SSDLC1Learnsets[id].learnset;

View File

@@ -581,8 +581,8 @@ abstract class BattleTypedSearch<T extends SearchType> {
set: Dex.PokemonSet | null = null;
protected formatType: 'doubles' | 'bdsp' | 'bdspdoubles' | 'rs' | 'frlg' | 'bw1' | 'letsgo' | 'metronome' | 'natdex' |
'nfe' | 'ssdlc1' | 'ssdlc1doubles' | 'predlc' | 'predlcdoubles' | 'predlcnatdex' | 'svdlc1' | 'svdlc1doubles' |
'svdlc1natdex' | 'stadium' | 'lc' | 'champions' | null = null;
'nfe' | 'ssdlc1' | 'ssdlc1doubles' | 'predlc' | 'predlcdoubles' | 'svdlc1' | 'svdlc1doubles' | 'stadium' | 'lc' |
'champions' | 'natdexchampions' | null = null;
isDoubles = false;
/**
@@ -624,22 +624,18 @@ abstract class BattleTypedSearch<T extends SearchType> {
format = format.slice(4) as ID;
}
if (format.startsWith('predlc')) {
if (format.includes('doubles') && !format.includes('nationaldex')) {
if (format.includes('doubles')) {
this.formatType = 'predlcdoubles';
this.isDoubles = true;
} else if (format.includes('nationaldex')) {
this.formatType = 'predlcnatdex';
} else {
this.formatType = 'predlc';
}
format = format.slice(6) as ID;
}
if (format.startsWith('dlc1') && this.dex.gen === 9) {
if (format.includes('doubles') && !format.includes('nationaldex')) {
if (format.includes('doubles')) {
this.formatType = 'svdlc1doubles';
this.isDoubles = true;
} else if (format.includes('nationaldex')) {
this.formatType = 'svdlc1natdex';
} else {
this.formatType = 'svdlc1';
}
@@ -654,7 +650,11 @@ abstract class BattleTypedSearch<T extends SearchType> {
this.formatType = 'champions';
this.dex = Dex.mod('champions' as ID);
format = format.slice(9) as ID;
if (format.startsWith('natdex') || format.startsWith('nationaldex')) this.formatType = 'natdexchampions';
if (format.startsWith('natdex')) format = format.slice(6) as ID;
if (format.startsWith('nationaldex')) format = format.slice(11) as ID;
if (format.startsWith('vgc') || format.startsWith('bss')) format = 'ubers' as ID;
if (format.endsWith('draft')) format = 'ag' as ID;
}
if (format.startsWith('vgc')) {
this.formatType = 'doubles';
@@ -819,6 +819,7 @@ abstract class BattleTypedSearch<T extends SearchType> {
if (this.formatType === 'rs') table = table['gen3rs'];
if (this.formatType === 'frlg') table = table['gen3frlg'];
if (this.formatType === 'champions') table = table['champions'];
if (this.formatType === 'natdexchampions') table = table['natdexchampions'];
if (speciesid in table.learnsets) return speciesid;
const species = this.dex.species.get(speciesid);
if (!species.exists) return '' as ID;
@@ -858,7 +859,7 @@ abstract class BattleTypedSearch<T extends SearchType> {
}
protected canLearn(speciesid: ID, moveid: ID) {
const move = this.dex.moves.get(moveid);
if (this.formatType === 'natdex' && move.isNonstandard && move.isNonstandard !== 'Past') {
if (this.formatType?.includes('natdex') && move.isNonstandard && move.isNonstandard !== 'Past') {
return false;
}
const gen = this.dex.gen;
@@ -869,7 +870,7 @@ abstract class BattleTypedSearch<T extends SearchType> {
this.format.startsWith('battlespot') ||
this.format.startsWith('battlestadium') ||
this.format.startsWith('battlefestival') ||
(this.dex.gen === 9 && this.formatType !== 'natdex')
(this.dex.gen === 9 && !this.formatType?.includes('natdex'))
) {
if (gen === 9) {
genChar = 'a';
@@ -890,6 +891,7 @@ abstract class BattleTypedSearch<T extends SearchType> {
if (this.formatType === 'rs') table = table['gen3rs'];
if (this.formatType === 'frlg') table = table['gen3frlg'];
if (this.formatType === 'champions') table = table['champions'];
if (this.formatType === 'natdexchampions') table = table['natdexchampions'];
let learnset = table.learnsets[learnsetid];
const eggMovesOnly = this.eggMovesOnly(learnsetid, speciesid);
if (learnset && (moveid in learnset) && (!this.format.startsWith('tradebacks') ? learnset[moveid].includes(genChar) :
@@ -921,13 +923,12 @@ abstract class BattleTypedSearch<T extends SearchType> {
this.formatType === 'ssdlc1doubles' ? 'gen8dlc1doubles' :
this.formatType === 'predlc' ? 'gen9predlc' :
this.formatType === 'predlcdoubles' ? 'gen9predlcdoubles' :
this.formatType === 'predlcnatdex' ? 'gen9predlcnatdex' :
this.formatType === 'svdlc1' ? 'gen9dlc1' :
this.formatType === 'svdlc1doubles' ? 'gen9dlc1doubles' :
this.formatType === 'svdlc1natdex' ? 'gen9dlc1natdex' :
this.formatType === 'natdex' ? `gen${gen}natdex` :
this.formatType === 'stadium' ? `gen${gen}stadium${gen > 1 ? gen : ''}` :
this.formatType === 'champions' ? `champions` :
this.formatType === 'natdexchampions' ? `natdexchampions` :
`gen${gen}`;
if (table?.[tableKey]) {
table = table[tableKey];
@@ -1028,6 +1029,8 @@ class BattlePokemonSearch extends BattleTypedSearch<'pokemon'> {
table = table[`gen${dex.gen}`];
} else if (this.formatType === 'champions') {
table = table[`champions`];
} else if (this.formatType === 'natdexchampions') {
table = table[`natdexchampions`];
} else if (isVGCOrBS) {
table = table[`gen${dex.gen}vgc`];
} else if (dex.gen === 9 && isHackmons && !this.formatType) {
@@ -1407,6 +1410,8 @@ class BattleItemSearch extends BattleTypedSearch<'item'> {
table = table[`gen${this.dex.gen}metronome`];
} else if (this.formatType === 'champions') {
table = table[`champions`];
} else if (this.formatType === 'natdexchampions') {
table = table[`natdexchampions`];
} else if (this.dex.gen < 9) {
table = table[`gen${this.dex.gen}`];
}
@@ -1781,7 +1786,7 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> {
const isTradebacks = format.includes('tradebacks');
const regionBornLegality = dex.gen >= 6 &&
(/^battle(spot|stadium|festival)/.test(format) || format.startsWith('bss') ||
format.startsWith('vgc') || (dex.gen === 9 && this.formatType !== 'natdex'));
format.startsWith('vgc') || (dex.gen === 9 && !this.formatType?.includes('natdex')));
let learnsetid = this.firstLearnsetid(species.id);
let moves: string[] = [];
@@ -1795,6 +1800,7 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> {
if (this.formatType === 'rs') lsetTable = lsetTable['gen3rs'];
if (this.formatType === 'frlg') lsetTable = lsetTable['gen3frlg'];
if (this.formatType === 'champions') lsetTable = lsetTable['champions'];
if (this.formatType === 'natdexchampions') lsetTable = lsetTable['natdexchampions'];
if (this.formatType?.startsWith('ssdlc1')) lsetTable = lsetTable['gen8dlc1'];
if (this.formatType?.startsWith('predlc')) lsetTable = lsetTable['gen9predlc'];
if (this.formatType?.startsWith('svdlc1')) lsetTable = lsetTable['gen9dlc1'];
@@ -1820,7 +1826,7 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> {
) {
continue;
}
if (this.formatType !== 'natdex' && move.isNonstandard === "Past") {
if (!this.formatType?.includes('natdex') && move.isNonstandard === "Past") {
continue;
}
if (
@@ -1830,13 +1836,13 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> {
continue;
}
if (
this.formatType?.includes('predlc') && this.formatType !== 'predlcnatdex' &&
this.formatType?.includes('predlc') &&
BattleTeambuilderTable['gen9predlc']?.nonstandardMoves.includes(moveid)
) {
continue;
}
if (
this.formatType?.includes('svdlc1') && this.formatType !== 'svdlc1natdex' &&
this.formatType?.includes('svdlc1') &&
BattleTeambuilderTable['gen9dlc1']?.nonstandardMoves.includes(moveid)
) {
continue;