-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = (pokemon) => { | ||
let pokemonID = pokemon.num; | ||
let pokemonName = pokemon.name; | ||
let pokemonTypes = pokemon.types; | ||
const leadingZeros = require('../leadingZeros'); | ||
const correctionID = require('../../objects/pokemon/correctionID.json'); | ||
pokemonID = leadingZeros(pokemonID.toString(), 3); // Turn this number into 4 when Showdown and Serebii switch to 4 digit IDs consistently | ||
// Forms | ||
const primalString = "-Primal"; | ||
const totemString = "-Totem"; | ||
const gmaxString = "-Gmax"; | ||
const eternamaxString = "-Eternamax"; | ||
const primalBool = pokemonName.endsWith(primalString); | ||
const totemBool = pokemonName.endsWith(totemString); | ||
const gmaxBool = pokemonName.endsWith(gmaxString); | ||
const eternamaxBool = pokemonName.endsWith(eternamaxString); | ||
const dynamaxBool = Boolean(gmaxBool || eternamaxBool); | ||
const totemAlolaBool = totemBool && pokemonName.split("-")[1] == "Alola"; | ||
let formChar; | ||
|
||
if (primalBool || gmaxBool) { | ||
if (primalBool) formChar = "-m"; | ||
if (gmaxBool) formChar = "-gi"; | ||
pokemonID = `${pokemonID}${formChar}`; | ||
} else if (!totemBool || totemAlolaBool) { | ||
// Catches all forms where the form extension on Serebii is just the first letter of the form name | ||
if (pokemonName.split("-")[1]) pokemonID = `${pokemonID}-${pokemonName.split("-")[1].split("", 1)[0].toLowerCase()}`; | ||
}; | ||
// Edgecase ID corrections | ||
// TODO: add a bunch of meaningless forms like Unown and Vivillon | ||
pokemonID = correctValue(correctionID, pokemonName, pokemonID); | ||
if (pokemonName.startsWith("Arceus-") || pokemonName.startsWith("Silvally-")) pokemonID = `${pokemonID.split("-")[0]}-${pokemonTypes[0].toLowerCase()}`; | ||
return pokemonID; | ||
|
||
function correctValue(object, key, input) { | ||
key = key.toLowerCase(); | ||
if (object[key]) return object[key]; | ||
return input; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters