Skip to content

Commit

Permalink
Import SV VGC/BSS usage sets
Browse files Browse the repository at this point in the history
  • Loading branch information
thejetou committed Nov 17, 2023
1 parent 68cdf7c commit 2e35283
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions import/src/set-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ function getSpecie(gen: Generation, specieName: SpeciesName): Specie | PSSpecie
return gen.species.get(specieName) ?? ModdedDex.forGen(gen.num).species.get(specieName);
}

function toPSFormat(formatID: ID): ID {
if (formatID === 'gen9vgc2023' || formatID === 'gen9battlestadiumsingles') {
return `${formatID}regulatione` as ID;
}
return formatID;
}

function dexToPset(
gen: Generation, formatID: ID, specie: Specie | PSSpecie, dset: DexSet
): PokemonSet {
Expand Down Expand Up @@ -405,16 +412,14 @@ async function importGen(
const statsIgnore: {[specie: string]: Set<ID>} = {};
for (const [specieName, formats] of Object.entries(dexSets)) {
for (let [formatID, sets] of Object.entries(formats) as unknown as [ID, DexSet][]) {
if (formatID === 'vgc2023' || formatID === 'battlestadiumsingles') {
formatID = `${formatID}regulatione` as ID;
}
formatID = `gen${gen.num}${formatID}` as ID;
const format = UNSUPPORTED[formatID] ? null : Dex.formats.get(formatID);
const psFormat = toPSFormat(formatID);
const format = UNSUPPORTED[psFormat] ? null : Dex.formats.get(psFormat);
if (format && !format.exists) {
continue;
}
formatIDs.add(formatID);
const formatName = format?.name ?? UNSUPPORTED[formatID];
const formatName = format?.name ?? UNSUPPORTED[psFormat];
const specie = getSpecie(gen, specieName as SpeciesName);
for (const [name, set] of Object.entries(sets)) {
const pset = dexToPset(gen, formatID, specie, set);
Expand Down Expand Up @@ -443,11 +448,12 @@ async function importGen(
}
}
for (const formatID of formatIDs) {
const format = UNSUPPORTED[formatID] ? null : Dex.formats.get(formatID);
const formatName = format ? format.name : UNSUPPORTED[formatID];
const psFormat = toPSFormat(formatID);
const format = UNSUPPORTED[psFormat] ? null : Dex.formats.get(psFormat);
if (format && !format.exists) {
continue;
}
const formatName = format ? format.name : UNSUPPORTED[psFormat];
let stats: DisplayStatistics | false = false;
try {
stats = await fetchStats(formatID);
Expand Down

0 comments on commit 2e35283

Please sign in to comment.