{ "version": 3, "sources": ["../../../sim/team-validator.ts"], "sourcesContent": ["/**\n * Team Validator\n * Pokemon Showdown - http://pokemonshowdown.com/\n *\n * Handles team validation, and specifically learnset checking.\n *\n * @license MIT\n */\n\nimport {Dex, toID} from './dex';\nimport {Utils} from '../lib';\nimport {Tags} from '../data/tags';\nimport {Teams} from './teams';\nimport {PRNG} from './prng';\n\n/**\n * Describes a possible way to get a pokemon. Is not exhaustive!\n * sourcesBefore covers all sources that do not have exclusive\n * moves (like catching wild pokemon).\n *\n * First character is a generation number, 1-8.\n * Second character is a source ID, one of:\n *\n * - E = egg, 3rd char+ is the father in gen 2-5, empty in gen 6-7\n * because egg moves aren't restricted to fathers anymore\n * - S = event, 3rd char+ is the index in .eventData\n * - D = Dream World, only 5D is valid\n * - V = Virtual Console or Let's Go transfer, only 7V/8V is valid\n *\n * Designed to match MoveSource where possible.\n */\nexport type PokemonSource = string;\n\n/**\n * Represents a set of possible ways to get a Pok\u00E9mon with a given\n * set.\n *\n * `new PokemonSources()` creates an empty set;\n * `new PokemonSources(dex.gen)` allows all Pokemon.\n *\n * The set mainly stored as an Array `sources`, but for sets that\n * could be sourced from anywhere (for instance, TM moves), we\n * instead just set `sourcesBefore` to a number meaning \"any\n * source at or before this gen is possible.\"\n *\n * In other words, this variable represents the set of all\n * sources in `sources`, union all sources at or before\n * gen `sourcesBefore`.\n */\nexport class PokemonSources {\n\t/**\n\t * A set of specific possible PokemonSources; implemented as\n\t * an Array rather than a Set for perf reasons.\n\t */\n\tsources: PokemonSource[];\n\t/**\n\t * if nonzero: the set also contains all possible sources from\n\t * this gen and earlier.\n\t */\n\tsourcesBefore: number;\n\t/**\n\t * the set requires sources from this gen or later\n\t * this should be unchanged from the format's minimum past gen\n\t * (3 in modern games, 6 if pentagon is required, etc)\n\t */\n\tsourcesAfter: number;\n\tisHidden: boolean | null;\n\t/**\n\t * `limitedEggMoves` is a list of moves that can only be obtained from an\n\t * egg with another father in gen 2-5. If there are multiple such moves,\n\t * potential fathers need to be checked to see if they can actually\n\t * learn the move combination in question.\n\t *\n\t * `null` = the current move is definitely not a limited egg move\n\t *\n\t * `undefined` = the current move may or may not be a limited egg move\n\t */\n\tlimitedEggMoves?: ID[] | null;\n\t/**\n\t * Moves that should be in limitedEggMoves that would otherwise be skipped\n\t * because they can be learned universally in a past generation\n\t */\n\tpossiblyLimitedEggMoves?: ID[] | null;\n\t/**\n\t * Moves that should be in limitedEggMoves that would otherwise be skipped\n\t * because they can be learned via Gen 1-2 tradeback\n\t */\n\ttradebackLimitedEggMoves?: ID[] | null;\n\t/**\n\t * Tracks level up egg moves for female-only Pokemon\n\t */\n\tlevelUpEggMoves?: ID[] | null;\n\t/**\n\t * Moves that can be learned via Pomeg glitch and does not require a\n\t * particular parent to learn\n\t */\n\tpomegEggMoves?: ID[] | null;\n\t/**\n\t * Event egg source that may be used with the Pomeg glitch\n\t *\n\t * `null` = definitely not an event egg that can be used with the Pomeg glitch\n\t */\n\tpomegEventEgg?: string | null;\n\t/**\n\t * Some Pokemon evolve by having a move in their learnset (like Piloswine\n\t * with Ancient Power). These can only carry three other moves from their\n\t * prevo, because the fourth move must be the evo move. This restriction\n\t * doesn't apply to gen 6+ eggs, which can get around the restriction with\n\t * the relearner.\n\t */\n\tmoveEvoCarryCount: number;\n\n\tbabyOnly?: string;\n\tsketchMove?: string;\n\tdreamWorldMoveCount: number;\n\thm?: string;\n\tisFromPokemonGo?: boolean;\n\tpokemonGoSource?: string;\n\trestrictiveMoves?: string[];\n\t/** Obscure learn methods */\n\trestrictedMove?: ID;\n\n\tconstructor(sourcesBefore = 0, sourcesAfter = 0) {\n\t\tthis.sources = [];\n\t\tthis.sourcesBefore = sourcesBefore;\n\t\tthis.sourcesAfter = sourcesAfter;\n\t\tthis.isHidden = null;\n\t\tthis.limitedEggMoves = undefined;\n\t\tthis.moveEvoCarryCount = 0;\n\t\tthis.dreamWorldMoveCount = 0;\n\t}\n\tsize() {\n\t\tif (this.sourcesBefore) return Infinity;\n\t\treturn this.sources.length;\n\t}\n\tadd(source: PokemonSource, limitedEggMove?: ID | null) {\n\t\tif (this.sources[this.sources.length - 1] !== source) this.sources.push(source);\n\t\tif (limitedEggMove) {\n\t\t\tif (source.substr(0, 3) === '1ET') {\n\t\t\t\tthis.tradebackLimitedEggMoves = [limitedEggMove];\n\t\t\t}\n\t\t}\n\t\tif (limitedEggMove && this.limitedEggMoves !== null) {\n\t\t\tthis.limitedEggMoves = [limitedEggMove];\n\t\t} else if (limitedEggMove === null) {\n\t\t\tthis.limitedEggMoves = null;\n\t\t}\n\t}\n\taddGen(sourceGen: number) {\n\t\tthis.sourcesBefore = Math.max(this.sourcesBefore, sourceGen);\n\t\tthis.limitedEggMoves = null;\n\t}\n\tminSourceGen() {\n\t\tif (this.sourcesBefore) return this.sourcesAfter || 1;\n\t\tlet min = 10;\n\t\tfor (const source of this.sources) {\n\t\t\tconst sourceGen = parseInt(source.charAt(0));\n\t\t\tif (sourceGen < min) min = sourceGen;\n\t\t}\n\t\tif (min === 10) return 0;\n\t\treturn min;\n\t}\n\tmaxSourceGen() {\n\t\tlet max = this.sourcesBefore;\n\t\tfor (const source of this.sources) {\n\t\t\tconst sourceGen = parseInt(source.charAt(0));\n\t\t\tif (sourceGen > max) max = sourceGen;\n\t\t}\n\t\treturn max;\n\t}\n\tintersectWith(other: PokemonSources) {\n\t\tif (this.pomegEventEgg && other.pomegEggMoves) {\n\t\t\tconst newSources = [];\n\t\t\tfor (const source of other.sources) {\n\t\t\t\tnewSources.push(source.substr(0, 2) === '3E' ? this.pomegEventEgg : source);\n\t\t\t}\n\t\t\tother.sources = newSources;\n\t\t} else if (other.pomegEventEgg && this.pomegEventEgg !== null) {\n\t\t\tconst newSources = [];\n\t\t\tfor (const source of this.sources) {\n\t\t\t\tnewSources.push(source.substr(0, 2) === '3E' ? other.pomegEventEgg : source);\n\t\t\t}\n\t\t\tthis.sources = newSources;\n\t\t\tthis.pomegEventEgg = other.pomegEventEgg;\n\t\t} else if (!other.pomegEggMoves && !other.sourcesBefore) {\n\t\t\tthis.pomegEventEgg = null;\n\t\t}\n\t\tif (other.sourcesBefore || this.sourcesBefore) {\n\t\t\t// having sourcesBefore is the equivalent of having everything before that gen\n\t\t\t// in sources, so we fill the other array in preparation for intersection\n\t\t\tif (other.sourcesBefore > this.sourcesBefore) {\n\t\t\t\tfor (const source of this.sources) {\n\t\t\t\t\tconst sourceGen = parseInt(source.charAt(0));\n\t\t\t\t\tif (sourceGen <= other.sourcesBefore) {\n\t\t\t\t\t\tother.sources.push(source);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (this.sourcesBefore > other.sourcesBefore) {\n\t\t\t\tfor (const source of other.sources) {\n\t\t\t\t\tconst sourceGen = parseInt(source.charAt(0));\n\t\t\t\t\tif (sourceGen <= this.sourcesBefore) {\n\t\t\t\t\t\tthis.sources.push(source);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.sourcesBefore = Math.min(other.sourcesBefore, this.sourcesBefore);\n\t\t}\n\t\tif (this.sources.length) {\n\t\t\tif (other.sources.length) {\n\t\t\t\tconst sourcesSet = new Set(other.sources);\n\t\t\t\tconst intersectSources = this.sources.filter(source => sourcesSet.has(source));\n\t\t\t\tthis.sources = intersectSources;\n\t\t\t} else {\n\t\t\t\tthis.sources = [];\n\t\t\t}\n\t\t}\n\n\t\tif (other.restrictedMove && other.restrictedMove !== this.restrictedMove) {\n\t\t\tif (this.restrictedMove) {\n\t\t\t\t// incompatible\n\t\t\t\tthis.sources = [];\n\t\t\t\tthis.sourcesBefore = 0;\n\t\t\t} else {\n\t\t\t\tthis.restrictedMove = other.restrictedMove;\n\t\t\t}\n\t\t}\n\t\tif (other.limitedEggMoves) {\n\t\t\tif (!this.limitedEggMoves) {\n\t\t\t\tthis.limitedEggMoves = other.limitedEggMoves;\n\t\t\t} else {\n\t\t\t\tthis.limitedEggMoves.push(...other.limitedEggMoves);\n\t\t\t}\n\t\t}\n\t\tif (other.possiblyLimitedEggMoves) {\n\t\t\tif (!this.possiblyLimitedEggMoves) {\n\t\t\t\tthis.possiblyLimitedEggMoves = other.possiblyLimitedEggMoves;\n\t\t\t} else {\n\t\t\t\tthis.possiblyLimitedEggMoves.push(...other.possiblyLimitedEggMoves);\n\t\t\t}\n\t\t}\n\t\tif (other.tradebackLimitedEggMoves) {\n\t\t\tif (!this.tradebackLimitedEggMoves) {\n\t\t\t\tthis.tradebackLimitedEggMoves = other.tradebackLimitedEggMoves;\n\t\t\t} else {\n\t\t\t\tthis.tradebackLimitedEggMoves.push(...other.tradebackLimitedEggMoves);\n\t\t\t}\n\t\t}\n\t\tif (other.levelUpEggMoves) {\n\t\t\tif (!this.levelUpEggMoves) {\n\t\t\t\tthis.levelUpEggMoves = other.levelUpEggMoves;\n\t\t\t} else {\n\t\t\t\tthis.levelUpEggMoves.push(...other.levelUpEggMoves);\n\t\t\t}\n\t\t}\n\t\tif (other.pomegEggMoves) {\n\t\t\tif (!this.pomegEggMoves) {\n\t\t\t\tthis.pomegEggMoves = other.pomegEggMoves;\n\t\t\t} else {\n\t\t\t\tthis.pomegEggMoves.push(...other.pomegEggMoves);\n\t\t\t}\n\t\t}\n\t\tif (this.possiblyLimitedEggMoves && !this.sourcesBefore) {\n\t\t\tconst eggSources = this.sources.filter(source => source.charAt(1) === 'E');\n\t\t\tlet minEggGen = parseInt(eggSources[0]);\n\t\t\tfor (const source of eggSources) {\n\t\t\t\tminEggGen = Math.min(minEggGen, parseInt(source.charAt(0)));\n\t\t\t}\n\t\t\tif (minEggGen) {\n\t\t\t\tfor (const eggMoveAndGen of this.possiblyLimitedEggMoves) {\n\t\t\t\t\tif (!this.limitedEggMoves) this.limitedEggMoves = [];\n\t\t\t\t\tif (parseInt(eggMoveAndGen.charAt(0)) < minEggGen) {\n\t\t\t\t\t\tconst eggMove = toID(eggMoveAndGen.substr(1));\n\t\t\t\t\t\tif (!this.limitedEggMoves.includes(eggMove)) this.limitedEggMoves.push(eggMove);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlet eggTradebackLegal = false;\n\t\tfor (const source of this.sources) {\n\t\t\tif (source.substr(0, 3) === '1ET') {\n\t\t\t\teggTradebackLegal = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!eggTradebackLegal && this.tradebackLimitedEggMoves) {\n\t\t\tfor (const eggMove of this.tradebackLimitedEggMoves) {\n\t\t\t\tif (!this.limitedEggMoves) this.limitedEggMoves = [];\n\t\t\t\tif (!this.limitedEggMoves.includes(eggMove)) this.limitedEggMoves.push(eggMove);\n\t\t\t}\n\t\t}\n\t\tthis.moveEvoCarryCount += other.moveEvoCarryCount;\n\t\tthis.dreamWorldMoveCount += other.dreamWorldMoveCount;\n\t\tif (other.sourcesAfter > this.sourcesAfter) this.sourcesAfter = other.sourcesAfter;\n\t\tif (other.isHidden) this.isHidden = true;\n\t}\n}\n\nexport class TeamValidator {\n\treadonly format: Format;\n\treadonly dex: ModdedDex;\n\treadonly gen: number;\n\treadonly ruleTable: import('./dex-formats').RuleTable;\n\treadonly minSourceGen: number;\n\n\treadonly toID: (str: any) => ID;\n\tconstructor(format: string | Format, dex = Dex) {\n\t\tthis.format = dex.formats.get(format);\n\t\tthis.dex = dex.forFormat(this.format);\n\t\tthis.gen = this.dex.gen;\n\t\tthis.ruleTable = this.dex.formats.getRuleTable(this.format);\n\n\t\tthis.minSourceGen = this.ruleTable.minSourceGen;\n\n\t\tthis.toID = toID;\n\t}\n\n\tvalidateTeam(\n\t\tteam: PokemonSet[] | null,\n\t\toptions: {\n\t\t\tremoveNicknames?: boolean,\n\t\t\tskipSets?: {[name: string]: {[key: string]: boolean}},\n\t\t} = {}\n\t): string[] | null {\n\t\tif (team && this.format.validateTeam) {\n\t\t\treturn this.format.validateTeam.call(this, team, options) || null;\n\t\t}\n\t\treturn this.baseValidateTeam(team, options);\n\t}\n\n\tbaseValidateTeam(\n\t\tteam: PokemonSet[] | null,\n\t\toptions: {\n\t\t\tremoveNicknames?: boolean,\n\t\t\tskipSets?: {[name: string]: {[key: string]: boolean}},\n\t\t} = {}\n\t): string[] | null {\n\t\tconst format = this.format;\n\t\tconst dex = this.dex;\n\n\t\tlet problems: string[] = [];\n\t\tconst ruleTable = this.ruleTable;\n\t\tif (format.team) {\n\t\t\tif (team) {\n\t\t\t\treturn [\n\t\t\t\t\t`This format doesn't let you use your own team.`,\n\t\t\t\t\t`If you're not using a custom client, please report this as a bug. If you are, remember to use \\`/utm null\\` before starting a game in this format.`,\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst testTeamSeed = PRNG.generateSeed();\n\t\t\ttry {\n\t\t\t\tconst testTeamGenerator = Teams.getGenerator(format, testTeamSeed);\n\t\t\t\ttestTeamGenerator.getTeam(options); // Throws error if generation fails\n\t\t\t} catch (e) {\n\t\t\t\treturn [\n\t\t\t\t\t`${format.name}'s team generator (${format.team}) failed using these rules and seed (${testTeamSeed}):-`,\n\t\t\t\t\t`${e}`,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tif (!team) {\n\t\t\treturn [\n\t\t\t\t`This format requires you to use your own team.`,\n\t\t\t\t`If you're not using a custom client, please report this as a bug.`,\n\t\t\t];\n\t\t}\n\t\tif (!Array.isArray(team)) {\n\t\t\tthrow new Error(`Invalid team data`);\n\t\t}\n\n\t\tif (team.length < ruleTable.minTeamSize) {\n\t\t\tproblems.push(`You must bring at least ${ruleTable.minTeamSize} Pok\\u00E9mon (your team has ${team.length}).`);\n\t\t}\n\t\tif (team.length > ruleTable.maxTeamSize) {\n\t\t\treturn [`You may only bring up to ${ruleTable.maxTeamSize} Pok\\u00E9mon (your team has ${team.length}).`];\n\t\t}\n\n\t\t// A limit is imposed here to prevent too much engine strain or\n\t\t// too much layout deformation - to be exact, this is the limit\n\t\t// allowed in Custom Game.\n\t\tif (team.length > 24) {\n\t\t\tproblems.push(`Your team has more than than 24 Pok\\u00E9mon, which the simulator can't handle.`);\n\t\t\treturn problems;\n\t\t}\n\n\t\tconst teamHas: {[k: string]: number} = {};\n\t\tlet lgpeStarterCount = 0;\n\t\tlet deoxysType;\n\t\tfor (const set of team) {\n\t\t\tif (!set) return [`You sent invalid team data. If you're not using a custom client, please report this as a bug.`];\n\n\t\t\tlet setProblems: string[] | null = null;\n\t\t\tif (options.skipSets && options.skipSets[set.name]) {\n\t\t\t\tfor (const i in options.skipSets[set.name]) {\n\t\t\t\t\tteamHas[i] = (teamHas[i] || 0) + 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsetProblems = (format.validateSet || this.validateSet).call(this, set, teamHas);\n\t\t\t}\n\n\t\t\tif (set.species === 'Pikachu-Starter' || set.species === 'Eevee-Starter') {\n\t\t\t\tlgpeStarterCount++;\n\t\t\t\tif (lgpeStarterCount === 2 && ruleTable.isBanned('nonexistent')) {\n\t\t\t\t\tproblems.push(`You can only have one of Pikachu-Starter or Eevee-Starter on a team.`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dex.gen === 3 && set.species.startsWith('Deoxys')) {\n\t\t\t\tif (!deoxysType) {\n\t\t\t\t\tdeoxysType = set.species;\n\t\t\t\t} else if (deoxysType !== set.species && ruleTable.isBanned('nonexistent')) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t`You cannot have more than one type of Deoxys forme.`,\n\t\t\t\t\t\t`(Each game in Gen 3 supports only one forme of Deoxys.)`,\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (setProblems) {\n\t\t\t\tproblems = problems.concat(setProblems);\n\t\t\t}\n\t\t\tif (options.removeNicknames) {\n\t\t\t\tconst useCrossSpeciesNicknames = format.name.includes('Cross Evolution') || ruleTable.has('franticfusionsmod');\n\t\t\t\tconst species = dex.species.get(set.species);\n\t\t\t\tlet crossSpecies: Species;\n\t\t\t\tif (useCrossSpeciesNicknames && (crossSpecies = dex.species.get(set.name)).exists) {\n\t\t\t\t\tset.name = crossSpecies.name;\n\t\t\t\t} else {\n\t\t\t\t\tset.name = species.baseSpecies;\n\t\t\t\t\tif (species.baseSpecies === 'Unown') set.species = 'Unown';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const [rule, source, limit, bans] of ruleTable.complexTeamBans) {\n\t\t\tlet count = 0;\n\t\t\tfor (const ban of bans) {\n\t\t\t\tif (teamHas[ban] > 0) {\n\t\t\t\t\tcount += limit ? teamHas[ban] : 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (limit && count > limit) {\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\n\t\t\t\tproblems.push(`You are limited to ${limit} of ${rule}${clause}.`);\n\t\t\t} else if (!limit && count >= bans.length) {\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\n\t\t\t\tproblems.push(`Your team has the combination of ${rule}, which is banned${clause}.`);\n\t\t\t}\n\t\t}\n\n\t\tfor (const rule of ruleTable.keys()) {\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\n\t\t\tconst subformat = dex.formats.get(rule);\n\t\t\tif (subformat.onValidateTeam && ruleTable.has(subformat.id)) {\n\t\t\t\tproblems = problems.concat(subformat.onValidateTeam.call(this, team, format, teamHas) || []);\n\t\t\t}\n\t\t}\n\t\tif (format.onValidateTeam) {\n\t\t\tproblems = problems.concat(format.onValidateTeam.call(this, team, format, teamHas) || []);\n\t\t}\n\n\t\tif (!problems.length) return null;\n\t\treturn problems;\n\t}\n\n\tgetEventOnlyData(species: Species, noRecurse?: boolean): {species: Species, eventData: EventInfo[]} | null {\n\t\tconst dex = this.dex;\n\t\tconst learnset = dex.species.getLearnsetData(species.id);\n\t\tif (!learnset?.eventOnly) {\n\t\t\tif (noRecurse) return null;\n\t\t\treturn this.getEventOnlyData(dex.species.get(species.prevo), true);\n\t\t}\n\n\t\tif (!learnset.eventData && species.forme) {\n\t\t\treturn this.getEventOnlyData(dex.species.get(species.baseSpecies), true);\n\t\t}\n\t\tif (!learnset.eventData) {\n\t\t\tthrow new Error(`Event-only species ${species.name} has no eventData table`);\n\t\t}\n\n\t\treturn {species, eventData: learnset.eventData};\n\t}\n\n\tgetValidationSpecies(set: PokemonSet): [Species, Species] {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\t\tconst species = dex.species.get(set.species);\n\t\tconst item = dex.items.get(set.item);\n\t\tconst ability = dex.abilities.get(set.ability);\n\n\t\tlet outOfBattleSpecies = species;\n\t\tlet tierSpecies = species;\n\t\tif (ability.id === 'battlebond' && toID(species.baseSpecies) === 'greninja') {\n\t\t\toutOfBattleSpecies = dex.species.get('greninjabond');\n\t\t\tif (ruleTable.has('obtainableformes')) {\n\t\t\t\ttierSpecies = outOfBattleSpecies;\n\t\t\t}\n\t\t}\n\t\tif (ability.id === 'owntempo' && species.id === 'rockruff') {\n\t\t\ttierSpecies = outOfBattleSpecies = dex.species.get('rockruffdusk');\n\t\t}\n\n\t\tif (ruleTable.has('obtainableformes')) {\n\t\t\tconst canMegaEvo = dex.gen <= 7 || ruleTable.has('+pokemontag:past');\n\t\t\tif (item.megaEvolves === species.name) {\n\t\t\t\tif (!item.megaStone) throw new Error(`Item ${item.name} has no base form for mega evolution`);\n\t\t\t\ttierSpecies = dex.species.get(item.megaStone);\n\t\t\t} else if (item.id === 'redorb' && species.id === 'groudon') {\n\t\t\t\ttierSpecies = dex.species.get('Groudon-Primal');\n\t\t\t} else if (item.id === 'blueorb' && species.id === 'kyogre') {\n\t\t\t\ttierSpecies = dex.species.get('Kyogre-Primal');\n\t\t\t} else if (canMegaEvo && species.id === 'rayquaza' && set.moves.map(toID).includes('dragonascent' as ID) &&\n\t\t\t\t\t!ruleTable.has('megarayquazaclause')) {\n\t\t\t\ttierSpecies = dex.species.get('Rayquaza-Mega');\n\t\t\t} else if (item.id === 'rustedsword' && species.id === 'zacian') {\n\t\t\t\ttierSpecies = dex.species.get('Zacian-Crowned');\n\t\t\t} else if (item.id === 'rustedshield' && species.id === 'zamazenta') {\n\t\t\t\ttierSpecies = dex.species.get('Zamazenta-Crowned');\n\t\t\t}\n\t\t}\n\n\t\treturn [outOfBattleSpecies, tierSpecies];\n\t}\n\n\tvalidateSet(set: PokemonSet, teamHas: AnyObject): string[] | null {\n\t\tconst format = this.format;\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tlet problems: string[] = [];\n\t\tif (!set) {\n\t\t\treturn [`This is not a Pokemon.`];\n\t\t}\n\n\t\tlet species = dex.species.get(set.species);\n\t\tset.species = species.name;\n\t\t// Backwards compatability with old Gmax format\n\t\tif (set.species.toLowerCase().endsWith('-gmax') && this.format.id !== 'gen8megamax') {\n\t\t\tset.species = set.species.slice(0, -5);\n\t\t\tspecies = dex.species.get(set.species);\n\t\t\tif (set.name && set.name.endsWith('-Gmax')) set.name = species.baseSpecies;\n\t\t\tset.gigantamax = true;\n\t\t}\n\t\tif (set.name && set.name.length > 18) {\n\t\t\tif (set.name === set.species) {\n\t\t\t\tset.name = species.baseSpecies;\n\t\t\t} else {\n\t\t\t\tproblems.push(`Nickname \"${set.name}\" too long (should be 18 characters or fewer)`);\n\t\t\t}\n\t\t}\n\t\tset.name = dex.getName(set.name);\n\t\tlet item = dex.items.get(Utils.getString(set.item));\n\t\tset.item = item.name;\n\t\tlet ability = dex.abilities.get(Utils.getString(set.ability));\n\t\tset.ability = ability.name;\n\t\tlet nature = dex.natures.get(Utils.getString(set.nature));\n\t\tset.nature = nature.name;\n\t\tif (!Array.isArray(set.moves)) set.moves = [];\n\n\t\tset.name = set.name || species.baseSpecies;\n\t\tlet name = set.species;\n\t\tif (set.species !== set.name && species.baseSpecies !== set.name) {\n\t\t\tname = `${set.name} (${set.species})`;\n\t\t}\n\n\t\tif (!set.teraType && this.gen === 9) {\n\t\t\tset.teraType = species.types[0];\n\t\t}\n\n\t\tif (!set.level) set.level = ruleTable.defaultLevel;\n\n\t\tlet adjustLevel = ruleTable.adjustLevel;\n\t\tif (ruleTable.adjustLevelDown && set.level >= ruleTable.adjustLevelDown) {\n\t\t\tadjustLevel = ruleTable.adjustLevelDown;\n\t\t}\n\t\tif (set.level === adjustLevel || (set.level === 100 && ruleTable.maxLevel < 100)) {\n\t\t\t// Note that we're temporarily setting level 50 pokemon in VGC to level 100\n\t\t\t// This allows e.g. level 50 Hydreigon even though it doesn't evolve until level 64.\n\t\t\t// Leveling up can't make an obtainable pokemon unobtainable, so this is safe.\n\t\t\t// Just remember to set the level back to adjustLevel at the end of validation.\n\t\t\tset.level = ruleTable.maxLevel;\n\t\t}\n\t\tif (set.level < ruleTable.minLevel) {\n\t\t\tproblems.push(`${name} (level ${set.level}) is below the minimum level of ${ruleTable.minLevel}${ruleTable.blame('minlevel')}`);\n\t\t}\n\t\tif (set.level > ruleTable.maxLevel) {\n\t\t\tproblems.push(`${name} (level ${set.level}) is above the maximum level of ${ruleTable.maxLevel}${ruleTable.blame('maxlevel')}`);\n\t\t}\n\n\t\tconst setHas: {[k: string]: true} = {};\n\n\t\tif (!set.evs) set.evs = TeamValidator.fillStats(null, ruleTable.evLimit === null ? 252 : 0);\n\t\tif (!set.ivs) set.ivs = TeamValidator.fillStats(null, 31);\n\n\t\tif (ruleTable.has('obtainableformes')) {\n\t\t\tproblems.push(...this.validateForme(set));\n\t\t\tspecies = dex.species.get(set.species);\n\t\t}\n\t\tconst setSources = this.allSources(species);\n\n\t\tfor (const [rule] of ruleTable) {\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\n\t\t\tconst subformat = dex.formats.get(rule);\n\t\t\tif (subformat.onChangeSet && ruleTable.has(subformat.id)) {\n\t\t\t\tproblems = problems.concat(subformat.onChangeSet.call(this, set, format, setHas, teamHas) || []);\n\t\t\t}\n\t\t}\n\t\tif (format.onChangeSet) {\n\t\t\tproblems = problems.concat(format.onChangeSet.call(this, set, format, setHas, teamHas) || []);\n\t\t}\n\n\t\t// onChangeSet can modify set.species, set.item, set.ability\n\t\tspecies = dex.species.get(set.species);\n\t\titem = dex.items.get(set.item);\n\t\tability = dex.abilities.get(set.ability);\n\n\t\tconst [outOfBattleSpecies, tierSpecies] = this.getValidationSpecies(set);\n\t\tif (ability.id === 'battlebond' && toID(species.baseSpecies) === 'greninja') {\n\t\t\tif (ruleTable.has('obtainablemisc')) {\n\t\t\t\tif (set.gender && set.gender !== 'M') {\n\t\t\t\t\tproblems.push(`Battle Bond Greninja must be male.`);\n\t\t\t\t}\n\t\t\t\tset.gender = 'M';\n\t\t\t}\n\t\t}\n\t\tif (species.id === 'melmetal' && set.gigantamax && this.dex.species.getLearnsetData(species.id).eventData) {\n\t\t\tsetSources.sourcesBefore = 0;\n\t\t\tsetSources.sources = ['8S0 melmetal'];\n\t\t}\n\t\tif (!species.exists) {\n\t\t\treturn [`The Pokemon \"${set.species}\" does not exist.`];\n\t\t}\n\n\t\tif (item.id && !item.exists) {\n\t\t\treturn [`\"${set.item}\" is an invalid item.`];\n\t\t}\n\t\tif (ability.id && !ability.exists) {\n\t\t\tif (dex.gen < 3) {\n\t\t\t\t// gen 1-2 don't have abilities, just silently remove\n\t\t\t\tability = dex.abilities.get('');\n\t\t\t\tset.ability = '';\n\t\t\t} else {\n\t\t\t\treturn [`\"${set.ability}\" is an invalid ability.`];\n\t\t\t}\n\t\t}\n\t\tif (nature.id && !nature.exists) {\n\t\t\tif (dex.gen < 3) {\n\t\t\t\t// gen 1-2 don't have natures, just remove them\n\t\t\t\tnature = dex.natures.get('');\n\t\t\t\tset.nature = '';\n\t\t\t} else {\n\t\t\t\tproblems.push(`\"${set.nature}\" is an invalid nature.`);\n\t\t\t}\n\t\t}\n\t\tif (set.happiness !== undefined && isNaN(set.happiness)) {\n\t\t\tproblems.push(`${name} has an invalid happiness value.`);\n\t\t}\n\t\tif (set.hpType) {\n\t\t\tconst type = dex.types.get(set.hpType);\n\t\t\tif (!type.exists || ['normal', 'fairy'].includes(type.id)) {\n\t\t\t\tproblems.push(`${name}'s Hidden Power type (${set.hpType}) is invalid.`);\n\t\t\t} else {\n\t\t\t\tset.hpType = type.name;\n\t\t\t}\n\t\t}\n\t\tif (species.forceTeraType) {\n\t\t\tset.teraType = species.forceTeraType;\n\t\t}\n\t\tif (set.teraType) {\n\t\t\tconst type = dex.types.get(set.teraType);\n\t\t\tif (!type.exists) {\n\t\t\t\tproblems.push(`${name}'s Terastal type (${set.teraType}) is invalid.`);\n\t\t\t} else {\n\t\t\t\tset.teraType = type.name;\n\t\t\t}\n\t\t}\n\n\t\tlet problem = this.checkSpecies(set, species, tierSpecies, setHas);\n\t\tif (problem) problems.push(problem);\n\n\t\tproblem = this.checkItem(set, item, setHas);\n\t\tif (problem) problems.push(problem);\n\t\tif (ruleTable.has('obtainablemisc')) {\n\t\t\tif (dex.gen === 4 && item.id === 'griseousorb' && species.num !== 487) {\n\t\t\t\tproblems.push(`${set.name} cannot hold the Griseous Orb.`, `(In Gen 4, only Giratina could hold the Griseous Orb).`);\n\t\t\t}\n\t\t\tif (dex.gen <= 1) {\n\t\t\t\tif (item.id) {\n\t\t\t\t\t// no items allowed\n\t\t\t\t\tset.item = '';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!set.ability) set.ability = 'No Ability';\n\t\tif (ruleTable.has('obtainableabilities')) {\n\t\t\tif (dex.gen <= 2 || dex.currentMod === 'gen7letsgo') {\n\t\t\t\tset.ability = 'No Ability';\n\t\t\t} else {\n\t\t\t\tif (!ability.name || ability.name === 'No Ability') {\n\t\t\t\t\tproblems.push(`${name} needs to have an ability.`);\n\t\t\t\t} else if (!Object.values(species.abilities).includes(ability.name)) {\n\t\t\t\t\tif (tierSpecies.abilities[0] === ability.name) {\n\t\t\t\t\t\tset.ability = species.abilities[0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tproblems.push(`${name} can't have ${set.ability}.`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ability.name === species.abilities['H']) {\n\t\t\t\t\tsetSources.isHidden = true;\n\n\t\t\t\t\tlet unreleasedHidden = species.unreleasedHidden;\n\t\t\t\t\tif (unreleasedHidden === 'Past' && this.minSourceGen < dex.gen) unreleasedHidden = false;\n\n\t\t\t\t\tif (unreleasedHidden && ruleTable.has('-unreleased')) {\n\t\t\t\t\t\tproblems.push(`${name}'s Hidden Ability is unreleased.`);\n\t\t\t\t\t} else if (dex.gen === 7 && ['entei', 'suicune', 'raikou'].includes(species.id) && this.minSourceGen > 1) {\n\t\t\t\t\t\tproblems.push(`${name}'s Hidden Ability is only available from Virtual Console, which is not allowed in this format.`);\n\t\t\t\t\t} else if (dex.gen === 6 && ability.name === 'Symbiosis' &&\n\t\t\t\t\t\t(set.species.endsWith('Orange') || set.species.endsWith('White'))) {\n\t\t\t\t\t\tproblems.push(`${name}'s Hidden Ability is unreleased for the Orange and White forms.`);\n\t\t\t\t\t} else if (dex.gen === 5 && set.level < 10 && (species.maleOnlyHidden || species.gender === 'N')) {\n\t\t\t\t\t\tproblems.push(`${name} must be at least level 10 to have a Hidden Ability.`);\n\t\t\t\t\t}\n\t\t\t\t\tif (species.maleOnlyHidden) {\n\t\t\t\t\t\tif (set.gender && set.gender !== 'M') {\n\t\t\t\t\t\t\tproblems.push(`${name} must be male to have a Hidden Ability.`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tset.gender = 'M';\n\t\t\t\t\t\tsetSources.sources = ['5D'];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsetSources.isHidden = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tability = dex.abilities.get(set.ability);\n\t\tproblem = this.checkAbility(set, ability, setHas);\n\t\tif (problem) problems.push(problem);\n\n\t\tif (!set.nature || dex.gen <= 2) {\n\t\t\tset.nature = '';\n\t\t}\n\t\tnature = dex.natures.get(set.nature);\n\t\tproblem = this.checkNature(set, nature, setHas);\n\t\tif (problem) problems.push(problem);\n\n\t\tif (set.moves && Array.isArray(set.moves)) {\n\t\t\tset.moves = set.moves.filter(val => val);\n\t\t}\n\t\tif (!set.moves?.length) {\n\t\t\tproblems.push(`${name} has no moves (it must have at least one to be usable).`);\n\t\t\tset.moves = [];\n\t\t}\n\t\tif (set.moves.length > ruleTable.maxMoveCount) {\n\t\t\tproblems.push(`${name} has ${set.moves.length} moves, which is more than the limit of ${ruleTable.maxMoveCount}.`);\n\t\t\treturn problems;\n\t\t}\n\n\t\tconst moveLegalityWhitelist: {[k: string]: true | undefined} = {};\n\t\tfor (const moveName of set.moves) {\n\t\t\tif (!moveName) continue;\n\t\t\tconst move = dex.moves.get(Utils.getString(moveName));\n\t\t\tif (!move.exists) return [`\"${move.name}\" is an invalid move.`];\n\n\t\t\tproblem = this.checkMove(set, move, setHas);\n\t\t\tif (problem) {\n\t\t\t\tlet allowedByOM;\n\t\t\t\tif (problem.includes('hacking or glitches') &&\n\t\t\t\t\truleTable.has('omunobtainablemoves')) {\n\t\t\t\t\tproblem = `${name}'s ${problem}`;\n\t\t\t\t\tallowedByOM = !this.omCheckCanLearn(move, outOfBattleSpecies, setSources, set, problem);\n\t\t\t\t}\n\t\t\t\tif (!allowedByOM) {\n\t\t\t\t\tproblems.push(problem);\n\t\t\t\t} else {\n\t\t\t\t\tmoveLegalityWhitelist[move.id] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst pokemonGoProblems = this.validatePokemonGo(outOfBattleSpecies, set, setSources);\n\t\tconst learnsetSpecies = dex.species.getLearnsetData(outOfBattleSpecies.id);\n\t\tlet isFromRBYEncounter = false;\n\t\tif (this.gen === 1 && ruleTable.has('obtainablemisc') && !this.ruleTable.has('allowtradeback')) {\n\t\t\tlet lowestEncounterLevel;\n\t\t\tfor (const encounter of learnsetSpecies.encounters || []) {\n\t\t\t\tif (encounter.generation !== 1) continue;\n\t\t\t\tif (!encounter.level) continue;\n\t\t\t\tif (lowestEncounterLevel && encounter.level > lowestEncounterLevel) continue;\n\n\t\t\t\tlowestEncounterLevel = encounter.level;\n\t\t\t}\n\n\t\t\tif (lowestEncounterLevel) {\n\t\t\t\tif (set.level < lowestEncounterLevel) {\n\t\t\t\t\tproblems.push(`${name} is not obtainable at levels below ${lowestEncounterLevel} in Gen 1.`);\n\t\t\t\t}\n\t\t\t\tisFromRBYEncounter = true;\n\t\t\t}\n\t\t}\n\t\tif (!isFromRBYEncounter && ruleTable.has('obtainablemisc')) {\n\t\t\t// FIXME: Event pokemon given at a level under what it normally can be attained at gives a false positive\n\t\t\tlet evoSpecies = species;\n\t\t\twhile (evoSpecies.prevo) {\n\t\t\t\tif (set.level < (evoSpecies.evoLevel || 0)) {\n\t\t\t\t\tif (!pokemonGoProblems || (pokemonGoProblems && pokemonGoProblems.length)) {\n\t\t\t\t\t\tproblems.push(`${name} must be at least level ${evoSpecies.evoLevel} to be evolved.`);\n\t\t\t\t\t\tif (pokemonGoProblems && pokemonGoProblems.length) {\n\t\t\t\t\t\t\tproblems.push(`It failed to validate as a Pokemon from Pokemon GO because:`);\n\t\t\t\t\t\t\tfor (const pokemonGoProblem of pokemonGoProblems) {\n\t\t\t\t\t\t\t\tproblems.push(pokemonGoProblem);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Pokemon from Pokemon GO can be transferred to LGPE\n\t\t\t\t\t\tsetSources.isFromPokemonGo = true;\n\t\t\t\t\t\tsetSources.sources.push('8V');\n\t\t\t\t\t\tsetSources.sourcesBefore = 0;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tevoSpecies = dex.species.get(evoSpecies.prevo);\n\t\t\t}\n\t\t}\n\n\t\tlet moveProblems;\n\t\tif (ruleTable.has('obtainablemoves')) {\n\t\t\tmoveProblems = this.validateMoves(outOfBattleSpecies, set.moves, setSources, set, name, moveLegalityWhitelist);\n\t\t\tproblems.push(...moveProblems);\n\t\t}\n\n\t\tlet eventOnlyData;\n\n\t\tif (!setSources.sourcesBefore && setSources.sources.length) {\n\t\t\tconst legalSources = [];\n\t\t\tfor (const source of setSources.sources) {\n\t\t\t\tif (this.validateSource(set, source, setSources, outOfBattleSpecies)) continue;\n\t\t\t\tlegalSources.push(source);\n\t\t\t}\n\t\t\tif (legalSources.length) {\n\t\t\t\tsetSources.sources = legalSources;\n\t\t\t} else {\n\t\t\t\tlet nonEggSource = null;\n\t\t\t\tfor (const source of setSources.sources) {\n\t\t\t\t\tif (source.charAt(1) !== 'E') {\n\t\t\t\t\t\tnonEggSource = source;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!nonEggSource) {\n\t\t\t\t\t// all egg moves\n\t\t\t\t\tproblems.push(`${name} can't get its egg move combination (${setSources.limitedEggMoves!.join(', ')}) from any possible father.`);\n\t\t\t\t\tproblems.push(`(Is this incorrect? If so, post the chainbreeding instructions in Bug Reports)`);\n\t\t\t\t} else {\n\t\t\t\t\tif (species.id === 'mew' && pokemonGoProblems && !pokemonGoProblems.length) {\n\t\t\t\t\t\t// Whitelist Pokemon GO Mew, which cannot be sent to Let's Go\n\t\t\t\t\t\tsetSources.isFromPokemonGo = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (setSources.sources.length > 1) {\n\t\t\t\t\t\t\tproblems.push(`${name} has an event-exclusive move that it doesn't qualify for (only one of several ways to get the move will be listed):`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst eventProblems = this.validateSource(\n\t\t\t\t\t\t\tset, nonEggSource, setSources, outOfBattleSpecies, ` because it has a move only available`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (eventProblems) problems.push(...eventProblems);\n\t\t\t\t\t\tif (species.id === 'mew' && pokemonGoProblems && pokemonGoProblems.length) {\n\t\t\t\t\t\t\tproblems.push(`Additionally, it failed to validate as a Pokemon from Pokemon GO because:`);\n\t\t\t\t\t\t\tfor (const pokemonGoProblem of pokemonGoProblems) {\n\t\t\t\t\t\t\t\tproblems.push(pokemonGoProblem);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (ruleTable.has('obtainablemisc') && (eventOnlyData = this.getEventOnlyData(outOfBattleSpecies))) {\n\t\t\tconst {species: eventSpecies, eventData} = eventOnlyData;\n\t\t\tlet legal = false;\n\t\t\tfor (const event of eventData) {\n\t\t\t\tif (this.validateEvent(set, setSources, event, eventSpecies)) continue;\n\t\t\t\tlegal = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!legal && species.gen <= 2 && dex.gen >= 7 && !this.validateSource(set, '7V', setSources, species)) {\n\t\t\t\tlegal = true;\n\t\t\t}\n\t\t\tif (!legal) {\n\t\t\t\tif (!pokemonGoProblems || (pokemonGoProblems && pokemonGoProblems.length)) {\n\t\t\t\t\tif (eventData.length === 1) {\n\t\t\t\t\t\tproblems.push(`${species.name} is only obtainable from an event - it needs to match its event:`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tproblems.push(`${species.name} is only obtainable from events - it needs to match one of its events:`);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [i, event] of eventData.entries()) {\n\t\t\t\t\t\tif (event.generation <= dex.gen && event.generation >= this.minSourceGen) {\n\t\t\t\t\t\t\tconst eventInfo = event;\n\t\t\t\t\t\t\tconst eventNum = i + 1;\n\t\t\t\t\t\t\tconst eventName = eventData.length > 1 ? ` #${eventNum}` : ``;\n\t\t\t\t\t\t\tconst eventProblems = this.validateEvent(\n\t\t\t\t\t\t\t\tset, setSources, eventInfo, eventSpecies, ` to be`, `from its event${eventName}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (eventProblems) problems.push(...eventProblems);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (pokemonGoProblems && pokemonGoProblems.length) {\n\t\t\t\t\t\tproblems.push(`Additionally, it failed to validate as a Pokemon from Pokemon GO because:`);\n\t\t\t\t\t\tfor (const pokemonGoProblem of pokemonGoProblems) {\n\t\t\t\t\t\t\tproblems.push(pokemonGoProblem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsetSources.isFromPokemonGo = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Hardcoded forced validation for Pokemon GO\n\t\tconst pokemonGoOnlySpecies = ['meltan', 'melmetal', 'gimmighoulroaming'];\n\t\tif (ruleTable.has('obtainablemisc') && (pokemonGoOnlySpecies.includes(species.id))) {\n\t\t\tsetSources.isFromPokemonGo = true;\n\t\t\tif (pokemonGoProblems && pokemonGoProblems.length) {\n\t\t\t\tproblems.push(`${name} is only obtainable from Pokemon GO, and failed to validate because:`);\n\t\t\t\tfor (const pokemonGoProblem of pokemonGoProblems) {\n\t\t\t\t\tproblems.push(pokemonGoProblem);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ruleTable.isBanned('nonexistent')) {\n\t\t\tproblems.push(...this.validateStats(set, species, setSources, pokemonGoProblems));\n\t\t}\n\n\t\t// Attempt move validation again after verifying Pokemon GO origin\n\t\tif (ruleTable.has('obtainablemoves') && setSources.isFromPokemonGo) {\n\t\t\tsetSources.restrictiveMoves = [];\n\t\t\tsetSources.sources = ['8V'];\n\t\t\tsetSources.sourcesBefore = 0;\n\t\t\tif (moveProblems && !moveProblems.length) {\n\t\t\t\tproblems.push(...this.validateMoves(outOfBattleSpecies, set.moves, setSources, set, name,\n\t\t\t\t\tmoveLegalityWhitelist));\n\t\t\t}\n\t\t}\n\n\t\tif (ruleTable.has('obtainablemoves')) {\n\t\t\tif (species.id === 'keldeo' && set.moves.includes('secretsword') && this.minSourceGen > 5 && dex.gen <= 7) {\n\t\t\t\tproblems.push(`${name} has Secret Sword, which is only compatible with Keldeo-Ordinary obtained from Gen 5.`);\n\t\t\t}\n\t\t\tconst requiresGen3Source = setSources.maxSourceGen() <= 3;\n\t\t\tif (requiresGen3Source && dex.abilities.get(set.ability).gen === 4 && !species.prevo && dex.gen <= 5) {\n\t\t\t\t// Ability Capsule allows this in Gen 6+\n\t\t\t\tproblems.push(`${name} has a Gen 4 ability and isn't evolved - it can't use moves from Gen 3.`);\n\t\t\t}\n\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && format.mod !== 'gen8dlc1';\n\t\t\tif (setSources.isHidden && !canUseAbilityPatch && setSources.maxSourceGen() < 5) {\n\t\t\t\tproblems.push(`${name} has a Hidden Ability - it can't use moves from before Gen 5.`);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tspecies.maleOnlyHidden && setSources.isHidden && setSources.sourcesBefore < 5 &&\n\t\t\t\tsetSources.sources.every(source => source.charAt(1) === 'E')\n\t\t\t) {\n\t\t\t\tproblems.push(`${name} has an unbreedable Hidden Ability - it can't use egg moves.`);\n\t\t\t}\n\t\t}\n\n\t\tif (teamHas) {\n\t\t\tfor (const i in setHas) {\n\t\t\t\tif (i in teamHas) {\n\t\t\t\t\tteamHas[i]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamHas[i] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const [rule, source, limit, bans] of ruleTable.complexBans) {\n\t\t\tlet count = 0;\n\t\t\tfor (const ban of bans) {\n\t\t\t\tif (setHas[ban]) count++;\n\t\t\t}\n\t\t\tif (limit && count > limit) {\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\n\t\t\t\tproblems.push(`${name} is limited to ${limit} of ${rule}${clause}.`);\n\t\t\t} else if (!limit && count >= bans.length) {\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\n\t\t\t\tif (source === 'Obtainable Moves') {\n\t\t\t\t\tproblems.push(`${name} has the combination of ${rule}, which is impossible to obtain legitimately.`);\n\t\t\t\t} else {\n\t\t\t\t\tproblems.push(`${name} has the combination of ${rule}, which is banned${clause}.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const [rule] of ruleTable) {\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\n\t\t\tconst subformat = dex.formats.get(rule);\n\t\t\tif (subformat.onValidateSet && ruleTable.has(subformat.id)) {\n\t\t\t\tproblems = problems.concat(subformat.onValidateSet.call(this, set, format, setHas, teamHas) || []);\n\t\t\t}\n\t\t}\n\t\tif (format.onValidateSet) {\n\t\t\tproblems = problems.concat(format.onValidateSet.call(this, set, format, setHas, teamHas) || []);\n\t\t}\n\n\t\tconst nameSpecies = dex.species.get(set.name);\n\t\tif (nameSpecies.exists && nameSpecies.name.toLowerCase() === set.name.toLowerCase()) {\n\t\t\t// nickname is the name of a species\n\t\t\tif (nameSpecies.baseSpecies === species.baseSpecies) {\n\t\t\t\tset.name = species.baseSpecies;\n\t\t\t} else if (nameSpecies.name !== species.name &&\n\t\t\t\tnameSpecies.name !== species.baseSpecies && ruleTable.has('nicknameclause')) {\n\t\t\t\t// nickname species doesn't match actual species\n\t\t\t\t// Nickname Clause\n\t\t\t\tproblems.push(`${name} must not be nicknamed a different Pok\u00E9mon species than what it actually is.`);\n\t\t\t}\n\t\t}\n\n\t\tif (!problems.length) {\n\t\t\tif (set.gender === '' && !species.gender) {\n\t\t\t\tset.gender = ['M', 'F'][Math.floor(Math.random() * 2)];\n\t\t\t}\n\t\t\tif (adjustLevel) set.level = adjustLevel;\n\t\t\treturn null;\n\t\t}\n\n\t\treturn problems;\n\t}\n\n\tvalidateStats(set: PokemonSet, species: Species, setSources: PokemonSources, pokemonGoProblems: string[] | null) {\n\t\tconst ruleTable = this.ruleTable;\n\t\tconst dex = this.dex;\n\n\t\tconst allowAVs = ruleTable.has('allowavs');\n\t\tconst evLimit = ruleTable.evLimit;\n\t\tconst canBottleCap = dex.gen >= 7 && (set.level >= (dex.gen < 9 ? 100 : 50) || !ruleTable.has('obtainablemisc'));\n\n\t\tif (!set.evs) set.evs = TeamValidator.fillStats(null, evLimit === null ? 252 : 0);\n\t\tif (!set.ivs) set.ivs = TeamValidator.fillStats(null, 31);\n\n\t\tconst problems = [];\n\t\tconst name = set.name || set.species;\n\n\t\tconst maxedIVs = Object.values(set.ivs).every(stat => stat === 31);\n\t\tfor (const moveName of set.moves) {\n\t\t\tconst move = dex.moves.get(moveName);\n\t\t\tif (move.id === 'hiddenpower' && move.type !== 'Normal') {\n\t\t\t\tif (!set.hpType) {\n\t\t\t\t\tset.hpType = move.type;\n\t\t\t\t} else if (set.hpType !== move.type && ruleTable.has('obtainablemisc')) {\n\t\t\t\t\tproblems.push(`${name}'s Hidden Power type ${set.hpType} is incompatible with Hidden Power ${move.type}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (set.hpType && maxedIVs && ruleTable.has('obtainablemisc')) {\n\t\t\tif (dex.gen <= 2) {\n\t\t\t\tconst HPdvs = dex.types.get(set.hpType).HPdvs;\n\t\t\t\tset.ivs = {hp: 30, atk: 30, def: 30, spa: 30, spd: 30, spe: 30};\n\t\t\t\tlet statName: StatID;\n\t\t\t\tfor (statName in HPdvs) {\n\t\t\t\t\tset.ivs[statName] = HPdvs[statName]! * 2;\n\t\t\t\t}\n\t\t\t\tset.ivs.hp = -1;\n\t\t\t} else if (!canBottleCap) {\n\t\t\t\tset.ivs = TeamValidator.fillStats(dex.types.get(set.hpType).HPivs, 31);\n\t\t\t}\n\t\t}\n\t\tif (!set.hpType && set.moves.some(m => dex.moves.get(m).id === 'hiddenpower')) {\n\t\t\tset.hpType = dex.getHiddenPower(set.ivs).type;\n\t\t}\n\n\t\tconst cantBreedNorEvolve = (species.eggGroups[0] === 'Undiscovered' && !species.prevo && !species.nfe);\n\t\tconst isLegendary = (cantBreedNorEvolve && !species.tags.includes('Paradox') && ![\n\t\t\t'Pikachu', 'Unown', 'Dracozolt', 'Arctozolt', 'Dracovish', 'Arctovish', 'Gouging Fire', 'Raging Bolt', 'Iron Boulder', 'Iron Crown', 'Terapagos',\n\t\t].includes(species.baseSpecies)) || [\n\t\t\t'Manaphy', 'Cosmog', 'Cosmoem', 'Solgaleo', 'Lunala',\n\t\t].includes(species.baseSpecies);\n\t\tconst diancieException = species.name === 'Diancie' && !set.shiny;\n\t\tconst has3PerfectIVs = setSources.minSourceGen() >= 6 && isLegendary && !diancieException;\n\n\t\tif (set.hpType === 'Fighting' && ruleTable.has('obtainablemisc')) {\n\t\t\tif (has3PerfectIVs) {\n\t\t\t\t// Legendary Pokemon must have at least 3 perfect IVs in gen 6+\n\t\t\t\tproblems.push(`${name} must not have Hidden Power Fighting because it starts with 3 perfect IVs because it's a Gen 6+ legendary.`);\n\t\t\t}\n\t\t}\n\n\t\tif (has3PerfectIVs && ruleTable.has('obtainablemisc')) {\n\t\t\tlet perfectIVs = 0;\n\t\t\tfor (const stat in set.ivs) {\n\t\t\t\tif (set.ivs[stat as 'hp'] >= 31) perfectIVs++;\n\t\t\t}\n\t\t\tif (perfectIVs < 3) {\n\t\t\t\tif (!pokemonGoProblems || (pokemonGoProblems && pokemonGoProblems.length)) {\n\t\t\t\t\tconst reason = (this.minSourceGen === 6 ? ` and this format requires Gen ${dex.gen} Pok\u00E9mon` : ` in Gen 6 or later`);\n\t\t\t\t\tproblems.push(`${name} must have at least three perfect IVs because it's a legendary${reason}.`);\n\t\t\t\t\tif (pokemonGoProblems && pokemonGoProblems.length) {\n\t\t\t\t\t\tproblems.push(`Additionally, it failed to validate as a Pokemon from Pokemon GO because:`);\n\t\t\t\t\t\tfor (const pokemonGoProblem of pokemonGoProblems) {\n\t\t\t\t\t\t\tproblems.push(pokemonGoProblem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsetSources.isFromPokemonGo = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (set.hpType && !canBottleCap) {\n\t\t\tconst ivHpType = dex.getHiddenPower(set.ivs).type;\n\t\t\tif (set.hpType !== ivHpType) {\n\t\t\t\tproblems.push(`${name} has Hidden Power ${set.hpType}, but its IVs are for Hidden Power ${ivHpType}.`);\n\t\t\t}\n\t\t} else if (set.hpType) {\n\t\t\tif (!this.possibleBottleCapHpType(set.hpType, set.ivs)) {\n\t\t\t\tproblems.push(`${name} has Hidden Power ${set.hpType}, but its IVs don't allow this even with (Bottle Cap) Hyper Training.`);\n\t\t\t}\n\t\t}\n\n\t\tif (setSources.isFromPokemonGo) {\n\t\t\t// Pokemon from Pokemon GO must have odd IVs in non-Spe stats\n\t\t\t// Since the set can be fixed while making minimal changes, it does not force the IVs to be manually fixed\n\t\t\tfor (const stat in set.ivs) {\n\t\t\t\tif (set.ivs[stat as 'hp'] % 2 === 0 && stat !== 'spe') {\n\t\t\t\t\tset.ivs[stat as 'hp']++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (set.ivs.atk !== set.ivs.spa && !(canBottleCap && (set.ivs.atk === 31 || set.ivs.spa === 31))) {\n\t\t\t\tproblems.push(`${name}'s Atk and Spa IVs must match because it is from Pokemon GO.`);\n\t\t\t}\n\t\t\tif (set.ivs.def !== set.ivs.spd && !(canBottleCap && (set.ivs.def === 31 || set.ivs.spd === 31))) {\n\t\t\t\tproblems.push(`${name}'s Def and Spd IVs must match because it is from Pokemon GO.`);\n\t\t\t}\n\t\t\tif (set.hpType && set.hpType !== 'Dark' && set.hpType !== 'Ice') {\n\t\t\t\tproblems.push(`${name} must have Hidden Power Dark or Ice because it is from Pokemon GO.`);\n\t\t\t}\n\t\t}\n\n\t\tif (dex.gen <= 2) {\n\t\t\t// validate DVs\n\t\t\tconst ivs = set.ivs;\n\t\t\tconst atkDV = Math.floor(ivs.atk / 2);\n\t\t\tconst defDV = Math.floor(ivs.def / 2);\n\t\t\tconst speDV = Math.floor(ivs.spe / 2);\n\t\t\tconst spcDV = Math.floor(ivs.spa / 2);\n\t\t\tconst expectedHpDV = (atkDV % 2) * 8 + (defDV % 2) * 4 + (speDV % 2) * 2 + (spcDV % 2);\n\t\t\tif (ivs.hp === -1) ivs.hp = expectedHpDV * 2;\n\t\t\tconst hpDV = Math.floor(ivs.hp / 2);\n\t\t\tif (expectedHpDV !== hpDV) {\n\t\t\t\tproblems.push(`${name} has an HP DV of ${hpDV}, but its Atk, Def, Spe, and Spc DVs give it an HP DV of ${expectedHpDV}.`);\n\t\t\t}\n\t\t\tif (ivs.spa !== ivs.spd) {\n\t\t\t\tif (dex.gen === 2) {\n\t\t\t\t\tproblems.push(`${name} has different SpA and SpD DVs, which is not possible in Gen 2.`);\n\t\t\t\t} else {\n\t\t\t\t\tivs.spd = ivs.spa;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dex.gen > 1 && !species.gender) {\n\t\t\t\t// Gen 2 gender is calculated from the Atk DV.\n\t\t\t\t// High Atk DV <-> M. The meaning of \"high\" depends on the gender ratio.\n\t\t\t\tconst genderThreshold = species.genderRatio.F * 16;\n\n\t\t\t\tconst expectedGender = (atkDV >= genderThreshold ? 'M' : 'F');\n\t\t\t\tif (set.gender && set.gender !== expectedGender) {\n\t\t\t\t\tproblems.push(`${name} is ${set.gender}, but it has an Atk DV of ${atkDV}, which makes its gender ${expectedGender}.`);\n\t\t\t\t} else {\n\t\t\t\t\tset.gender = expectedGender;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tset.species === 'Marowak' && toID(set.item) === 'thickclub' &&\n\t\t\t\tset.moves.map(toID).includes('swordsdance' as ID) && set.level === 100\n\t\t\t) {\n\t\t\t\t// Marowak hack\n\t\t\t\tset.ivs.atk = Math.floor(set.ivs.atk / 2) * 2;\n\t\t\t\twhile (set.evs.atk > 0 && 2 * 80 + set.ivs.atk + Math.floor(set.evs.atk / 4) + 5 > 255) {\n\t\t\t\t\tset.evs.atk -= 4;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dex.gen > 1) {\n\t\t\t\tconst expectedShiny = !!(defDV === 10 && speDV === 10 && spcDV === 10 && atkDV % 4 >= 2);\n\t\t\t\tif (expectedShiny && !set.shiny) {\n\t\t\t\t\tproblems.push(`${name} is not shiny, which does not match its DVs.`);\n\t\t\t\t} else if (!expectedShiny && set.shiny) {\n\t\t\t\t\tproblems.push(`${name} is shiny, which does not match its DVs (its DVs must all be 10, except Atk which must be 2, 3, 6, 7, 10, 11, 14, or 15).`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tset.nature = 'Serious';\n\t\t}\n\n\t\tfor (const stat in set.evs) {\n\t\t\tif (set.evs[stat as 'hp'] < 0) {\n\t\t\t\tproblems.push(`${name} has less than 0 ${allowAVs ? 'Awakening Values' : 'EVs'} in ${Dex.stats.names[stat as 'hp']}.`);\n\t\t\t}\n\t\t}\n\n\t\tif (dex.currentMod === 'gen7letsgo') { // AVs\n\t\t\tfor (const stat in set.evs) {\n\t\t\t\tif (set.evs[stat as 'hp'] > 0 && !allowAVs) {\n\t\t\t\t\tproblems.push(`${name} has Awakening Values but this format doesn't allow them.`);\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (set.evs[stat as 'hp'] > 200) {\n\t\t\t\t\tproblems.push(`${name} has more than 200 Awakening Values in ${Dex.stats.names[stat as 'hp']}.`);\n\t\t\t\t}\n\t\t\t}\n\t\t} else { // EVs\n\t\t\tfor (const stat in set.evs) {\n\t\t\t\tif (set.evs[stat as StatID] > 255) {\n\t\t\t\t\tproblems.push(`${name} has more than 255 EVs in ${Dex.stats.names[stat as 'hp']}.`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dex.gen <= 2) {\n\t\t\t\tif (set.evs.spa !== set.evs.spd) {\n\t\t\t\t\tif (dex.gen === 2) {\n\t\t\t\t\t\tproblems.push(`${name} has different SpA and SpD EVs, which is not possible in Gen 2.`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tset.evs.spd = set.evs.spa;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet totalEV = 0;\n\t\tfor (const stat in set.evs) totalEV += set.evs[stat as 'hp'];\n\t\tif (!this.format.debug) {\n\t\t\tif (set.level > 1 && evLimit !== 0 && totalEV === 0) {\n\t\t\t\tproblems.push(`${name} has exactly 0 EVs - did you forget to EV it? (If this was intentional, add exactly 1 to one of your EVs, which won't change its stats but will tell us that it wasn't a mistake).`);\n\t\t\t} else if (![508, 510].includes(evLimit!) && [508, 510].includes(totalEV)) {\n\t\t\t\tproblems.push(`${name} has exactly ${totalEV} EVs, but this format does not restrict you to 510 EVs (If this was intentional, add exactly 1 to one of your EVs, which won't change its stats but will tell us that it wasn't a mistake).`);\n\t\t\t}\n\t\t\t// Check for level import errors from user in VGC -> DOU, etc.\n\t\t\t// Note that in VGC etc (Adjust Level Down = 50), `set.level` will be 100 here for validation purposes\n\t\t\tif (set.level === 50 && ruleTable.maxLevel !== 50 && !ruleTable.maxTotalLevel && evLimit !== 0 && totalEV % 4 === 0) {\n\t\t\t\tproblems.push(`${name} is level 50, but this format allows level ${ruleTable.maxLevel} Pok\u00E9mon. (If this was intentional, add exactly 1 to one of your EVs, which won't change its stats but will tell us that it wasn't a mistake).`);\n\t\t\t}\n\t\t}\n\n\t\tif (evLimit !== null && totalEV > evLimit) {\n\t\t\tif (!evLimit) {\n\t\t\t\tproblems.push(`${name} has EVs, which is not allowed by this format.`);\n\t\t\t} else {\n\t\t\t\tproblems.push(`${name} has ${totalEV} total EVs, which is more than this format's limit of ${evLimit}.`);\n\t\t\t}\n\t\t}\n\n\t\treturn problems;\n\t}\n\n\t/**\n\t * Not exhaustive, just checks Atk and Spe, which are the only competitively\n\t * relevant IVs outside of extremely obscure situations.\n\t */\n\tpossibleBottleCapHpType(type: string, ivs: StatsTable) {\n\t\tif (!type) return true;\n\t\tif (['Dark', 'Dragon', 'Grass', 'Ghost', 'Poison'].includes(type)) {\n\t\t\t// Spe must be odd\n\t\t\tif (ivs.spe % 2 === 0) return false;\n\t\t}\n\t\tif (['Psychic', 'Fire', 'Rock', 'Fighting'].includes(type)) {\n\t\t\t// Spe must be even\n\t\t\tif (ivs.spe !== 31 && ivs.spe % 2 === 1) return false;\n\t\t}\n\t\tif (type === 'Dark') {\n\t\t\t// Atk must be odd\n\t\t\tif (ivs.atk % 2 === 0) return false;\n\t\t}\n\t\tif (['Ice', 'Water'].includes(type)) {\n\t\t\t// Spe or Atk must be odd\n\t\t\tif (ivs.spe % 2 === 0 && ivs.atk % 2 === 0) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tvalidateSource(\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species, because: string\n\t): string[] | undefined;\n\tvalidateSource(\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species\n\t): true | undefined;\n\t/**\n\t * Returns array of error messages if invalid, undefined if valid\n\t *\n\t * If `because` is not passed, instead returns true if invalid.\n\t */\n\tvalidateSource(\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species, because?: string\n\t) {\n\t\tlet eventData: EventInfo | undefined;\n\t\tlet eventSpecies = species;\n\t\tif (source.charAt(1) === 'S') {\n\t\t\tconst splitSource = source.substr(source.charAt(2) === 'T' ? 3 : 2).split(' ');\n\t\t\tconst dex = (this.dex.gen === 1 ? this.dex.mod('gen2') : this.dex);\n\t\t\teventSpecies = dex.species.get(splitSource[1]);\n\t\t\tconst eventLsetData = this.dex.species.getLearnsetData(eventSpecies.id);\n\t\t\teventData = eventLsetData.eventData?.[parseInt(splitSource[0])];\n\t\t\tif (!eventData) {\n\t\t\t\tthrow new Error(`${eventSpecies.name} from ${species.name} doesn't have data for event ${source}`);\n\t\t\t}\n\t\t} else if (source === '7V') {\n\t\t\tconst isMew = species.id === 'mew';\n\t\t\tconst isCelebi = species.id === 'celebi';\n\t\t\tconst g7speciesName = (species.gen > 2 && species.prevo) ? species.prevo : species.id;\n\t\t\tconst isHidden = !!this.dex.mod('gen7').species.get(g7speciesName).abilities['H'];\n\t\t\teventData = {\n\t\t\t\tgeneration: 2,\n\t\t\t\tlevel: isMew ? 5 : isCelebi ? 30 : 3, // Level 1/2 Pok\u00E9mon can't be obtained by transfer from RBY/GSC\n\t\t\t\tperfectIVs: isMew || isCelebi ? 5 : 3,\n\t\t\t\tisHidden,\n\t\t\t\tshiny: isMew ? undefined : 1,\n\t\t\t\tpokeball: 'pokeball',\n\t\t\t\tfrom: 'Gen 1-2 Virtual Console transfer',\n\t\t\t};\n\t\t} else if (source === '8V') {\n\t\t\tconst isMew = species.id === 'mew';\n\t\t\teventData = {\n\t\t\t\tgeneration: 8,\n\t\t\t\tperfectIVs: isMew ? 3 : undefined,\n\t\t\t\tshiny: isMew ? undefined : 1,\n\t\t\t\tfrom: 'Gen 7 Let\\'s Go! HOME transfer',\n\t\t\t};\n\t\t} else if (source.charAt(1) === 'D') {\n\t\t\teventData = {\n\t\t\t\tgeneration: 5,\n\t\t\t\tlevel: 10,\n\t\t\t\tfrom: 'Gen 5 Dream World',\n\t\t\t\tisHidden: !!this.dex.mod('gen5').species.get(species.id).abilities['H'],\n\t\t\t};\n\t\t} else if (source.charAt(1) === 'E') {\n\t\t\tif (this.findEggMoveFathers(source, species, setSources)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (because) throw new Error(`Wrong place to get an egg incompatibility message`);\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthrow new Error(`Unidentified source ${source} passed to validateSource`);\n\t\t}\n\n\t\t// complicated fancy return signature\n\t\treturn this.validateEvent(set, setSources, eventData, eventSpecies, because as any) as any;\n\t}\n\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources,\n\t\tgetAll?: false, pokemonBlacklist?: ID[], noRecurse?: true): boolean;\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources, getAll?: true): ID[] | null;\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources,\n\t\tgetAll?: boolean, pokemonBlacklist?: ID[], noRecurse?: boolean) {\n\t\tif (!pokemonBlacklist) pokemonBlacklist = [];\n\t\tif (!pokemonBlacklist.includes(species.id)) pokemonBlacklist.push(species.id);\n\t\t// tradebacks have an eggGen of 2 even though the source is 1ET\n\t\tconst eggGen = Math.max(parseInt(source.charAt(0)), 2);\n\t\tconst fathers: ID[] = [];\n\t\t// Gen 6+ don't have egg move incompatibilities\n\t\t// (except for certain cases with baby Pokemon not handled here)\n\t\tif (!getAll && eggGen >= 6 && !setSources.levelUpEggMoves) return true;\n\n\t\tlet eggMoves = setSources.limitedEggMoves;\n\t\tif (eggGen === 3) eggMoves = eggMoves?.filter(eggMove => !setSources.pomegEggMoves?.includes(eggMove));\n\t\t// must have 2 or more egg moves to have egg move incompatibilities\n\t\tif (!eggMoves) {\n\t\t\t// happens often in gen 1-6 LC if your only egg moves are level-up moves,\n\t\t\t// which aren't limited and so aren't in `limitedEggMoves`\n\t\t\treturn getAll ? ['*'] : true;\n\t\t}\n\t\tif (!getAll && eggMoves.length <= 1 && !setSources.levelUpEggMoves) return true;\n\t\tif (setSources.levelUpEggMoves && eggGen >= 6) eggMoves = setSources.levelUpEggMoves;\n\n\t\t// gen 1 eggs come from gen 2 breeding\n\t\tconst dex = this.dex.gen === 1 ? this.dex.mod('gen2') : this.dex;\n\t\t// In Gen 5 and earlier, egg moves can only be inherited from the father\n\t\t// we'll test each possible father separately\n\t\tlet eggGroups = species.eggGroups;\n\t\tif (species.id === 'nidoqueen' || species.id === 'nidorina') {\n\t\t\teggGroups = dex.species.get('nidoranf').eggGroups;\n\t\t} else if (species.id === 'shedinja') {\n\t\t\t// Shedinja and Nincada are different Egg groups; Shedinja itself is genderless\n\t\t\teggGroups = dex.species.get('nincada').eggGroups;\n\t\t} else if (dex !== this.dex) {\n\t\t\t// Gen 1 tradeback; grab the egg groups from Gen 2\n\t\t\teggGroups = dex.species.get(species.id).eggGroups;\n\t\t}\n\t\tif (eggGroups[0] === 'Undiscovered') eggGroups = dex.species.get(species.evos[0]).eggGroups;\n\t\tif (eggGroups[0] === 'Undiscovered' || !eggGroups.length) {\n\t\t\tthrow new Error(`${species.name} has no egg groups for source ${source}`);\n\t\t}\n\t\t// no chainbreeding necessary if the father can be Smeargle\n\t\tif (!getAll && eggGroups.includes('Field')) return true;\n\n\t\t// try to find a father to inherit the egg move combination from\n\t\tfor (const father of dex.species.all()) {\n\t\t\t// can't inherit from CAP pokemon\n\t\t\tif (father.isNonstandard) continue;\n\t\t\t// can't breed mons from future gens\n\t\t\tif (father.gen > eggGen) continue;\n\t\t\t// father must be male\n\t\t\tif (father.gender === 'N' || father.gender === 'F') continue;\n\t\t\t// can't inherit from dex entries with no learnsets\n\t\t\tif (!dex.species.getLearnsetData(father.id).learnset) continue;\n\t\t\t// something is clearly wrong if its only possible father is itself\n\t\t\t// (exceptions: ExtremeSpeed Dragonite, Self-destruct Snorlax)\n\t\t\tif (pokemonBlacklist.includes(father.id) && !['dragonite', 'snorlax'].includes(father.id)) continue;\n\t\t\t// don't check NFE Pok\u00E9mon - their evolutions will know all their moves and more\n\t\t\t// exception: Combee/Salandit, because their evos can't be fathers\n\t\t\tif (father.evos.length) {\n\t\t\t\tconst evolvedFather = dex.species.get(father.evos[0]);\n\t\t\t\tif (evolvedFather.gen <= eggGen && evolvedFather.gender !== 'F') continue;\n\t\t\t}\n\n\t\t\t// must be able to breed with father\n\t\t\tif (!father.eggGroups.some(eggGroup => eggGroups.includes(eggGroup))) continue;\n\n\t\t\t// father must be able to learn the move\n\t\t\tif (!this.fatherCanLearn(species, father, eggMoves, eggGen, pokemonBlacklist, noRecurse)) continue;\n\n\t\t\t// father found!\n\t\t\tif (!getAll) return true;\n\t\t\tfathers.push(father.id);\n\t\t}\n\t\tif (!getAll) return false;\n\t\treturn (!fathers.length && eggGen < 6) ? null : fathers;\n\t}\n\n\t/**\n\t * We could, if we wanted, do a complete move validation of the father's\n\t * moveset to see if it's valid. This would recurse and be NP-Hard so\n\t * instead we won't. We'll instead use a simplified algorithm: The father\n\t * is allowed to have multiple egg moves and a maximum of one move from\n\t * any other restrictive source; recursion is done only if there are less\n\t * egg moves to validate or if the father has an egg group it doesn't\n\t * share with the egg Pokemon. Recursion is also limited to two iterations\n\t * of calling findEggMoveFathers.\n\t */\n\tfatherCanLearn(baseSpecies: Species, species: Species, moves: ID[], eggGen: number, pokemonBlacklist: ID[],\n\t\tnoRecurse: boolean | undefined) {\n\t\tif (!this.dex.species.getLearnsetData(species.id).learnset) return false;\n\n\t\tif (species.id === 'smeargle') return true;\n\t\tconst canBreedWithSmeargle = species.eggGroups.includes('Field');\n\n\t\tconst allEggSources = new PokemonSources();\n\t\tallEggSources.sourcesBefore = eggGen;\n\t\tfor (const move of moves) {\n\t\t\tconst eggSources = new PokemonSources();\n\t\t\tfor (const {learnset, species: curSpecies} of this.dex.species.getFullLearnset(species.id)) {\n\t\t\t\tconst eggPokemon = curSpecies.prevo ? curSpecies.id : '';\n\t\t\t\tif (learnset[move]) {\n\t\t\t\t\tfor (const moveSource of learnset[move]) {\n\t\t\t\t\t\tif (eggGen > 8 && parseInt(moveSource.charAt(0)) <= 8) continue;\n\t\t\t\t\t\tif (parseInt(moveSource.charAt(0)) > eggGen) continue;\n\t\t\t\t\t\tconst canLearnFromSmeargle = moveSource.charAt(1) === 'E' && canBreedWithSmeargle;\n\t\t\t\t\t\tif (!'ESDV'.includes(moveSource.charAt(1)) || canLearnFromSmeargle) {\n\t\t\t\t\t\t\teggSources.addGen(parseInt(moveSource.charAt(0)));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (moveSource.charAt(1) === 'E') {\n\t\t\t\t\t\t\t\teggSources.add(moveSource + eggPokemon, move);\n\t\t\t\t\t\t\t\tif (eggGen === 2 && this.dex.moves.getByID(move).gen === 1) eggSources.add('1ET' + eggPokemon, move);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\teggSources.add(moveSource + eggPokemon);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (eggSources.sourcesBefore === eggGen) break;\n\t\t\t}\n\n\t\t\tif (eggSources.sourcesBefore === eggGen) continue;\n\t\t\tif (!eggSources.sourcesBefore && !eggSources.sources.length) return false;\n\t\t\tconst onlyEggSources = eggSources.sources.filter(source => source.charAt(1) === 'E');\n\t\t\tif (eggGen >= 3 && onlyEggSources.length && eggSources.limitedEggMoves === null && eggSources.sourcesBefore) {\n\t\t\t\teggSources.possiblyLimitedEggMoves = [toID(eggSources.sourcesBefore + move)];\n\t\t\t}\n\t\t\tallEggSources.intersectWith(eggSources);\n\t\t\tif (!allEggSources.size()) return false;\n\t\t}\n\t\tpokemonBlacklist.push(species.id);\n\t\tif (allEggSources.limitedEggMoves && allEggSources.limitedEggMoves.length > 1) {\n\t\t\tif (noRecurse) return false;\n\t\t\tlet canChainbreed = false;\n\t\t\tfor (const fatherEggGroup of species.eggGroups) {\n\t\t\t\tif (!baseSpecies.eggGroups.includes(fatherEggGroup)) {\n\t\t\t\t\tcanChainbreed = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!canChainbreed && allEggSources.limitedEggMoves.length === moves.length) return false;\n\t\t\tconst setSources = new PokemonSources();\n\t\t\tsetSources.limitedEggMoves = allEggSources.limitedEggMoves;\n\t\t\treturn this.findEggMoveFathers(allEggSources.sources[0], species, setSources, false, pokemonBlacklist, true);\n\t\t}\n\t\treturn true;\n\t}\n\n\tvalidateForme(set: PokemonSet) {\n\t\tconst dex = this.dex;\n\t\tconst name = set.name || set.species;\n\n\t\tconst problems = [];\n\t\tconst item = dex.items.get(set.item);\n\t\tconst species = dex.species.get(set.species);\n\n\t\tif (species.name === 'Necrozma-Ultra') {\n\t\t\tconst whichMoves = (set.moves.includes('sunsteelstrike') ? 1 : 0) +\n\t\t\t\t(set.moves.includes('moongeistbeam') ? 2 : 0);\n\t\t\tif (item.name !== 'Ultranecrozium Z') {\n\t\t\t\t// Necrozma-Ultra transforms from one of two formes, and neither one is the base forme\n\t\t\t\tproblems.push(`Necrozma-Ultra must start the battle holding Ultranecrozium Z.`);\n\t\t\t} else if (whichMoves === 1) {\n\t\t\t\tset.species = 'Necrozma-Dusk-Mane';\n\t\t\t} else if (whichMoves === 2) {\n\t\t\t\tset.species = 'Necrozma-Dawn-Wings';\n\t\t\t} else {\n\t\t\t\tproblems.push(`Necrozma-Ultra must start the battle as Necrozma-Dusk-Mane or Necrozma-Dawn-Wings holding Ultranecrozium Z. Please specify which Necrozma it should start as.`);\n\t\t\t}\n\t\t} else if (species.name === 'Zygarde-Complete') {\n\t\t\tproblems.push(`Zygarde-Complete must start the battle as Zygarde or Zygarde-10% with Power Construct. Please specify which Zygarde it should start as.`);\n\t\t} else if (species.battleOnly) {\n\t\t\tif (species.requiredAbility && set.ability !== species.requiredAbility) {\n\t\t\t\t// Darmanitan-Zen\n\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredAbility}, please fix its ability.`);\n\t\t\t}\n\t\t\tif (species.requiredItems) {\n\t\t\t\tif (!species.requiredItems.includes(item.name)) {\n\t\t\t\t\t// Mega or Primal\n\t\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredItem}, please fix its item.`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (species.requiredMove && !set.moves.map(toID).includes(toID(species.requiredMove))) {\n\t\t\t\t// Meloetta-Pirouette, Rayquaza-Mega\n\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredMove}, please fix its moves.`);\n\t\t\t}\n\t\t\tif (typeof species.battleOnly !== 'string') {\n\t\t\t\t// Ultra Necrozma and Complete Zygarde are already checked above\n\t\t\t\tthrow new Error(`${species.name} should have a string battleOnly`);\n\t\t\t}\n\t\t\t// Set to out-of-battle forme\n\t\t\tset.species = species.battleOnly;\n\t\t} else {\n\t\t\tif (species.requiredAbility) {\n\t\t\t\t// Impossible!\n\t\t\t\tthrow new Error(`Species ${species.name} has a required ability despite not being a battle-only forme; it should just be in its abilities table.`);\n\t\t\t}\n\t\t\tif (species.requiredItems && !species.requiredItems.includes(item.name)) {\n\t\t\t\tif (dex.gen >= 8 && (species.baseSpecies === 'Arceus' || species.baseSpecies === 'Silvally')) {\n\t\t\t\t\t// Arceus/Silvally formes in gen 8 only require the item with Multitype/RKS System\n\t\t\t\t\tif (set.ability === species.abilities[0]) {\n\t\t\t\t\t\tproblems.push(\n\t\t\t\t\t\t\t`${name} needs to hold ${species.requiredItems.join(' or ')}.`,\n\t\t\t\t\t\t\t`(It will revert to its Normal forme if you remove the item or give it a different item.)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Memory/Drive/Griseous Orb/Plate/Z-Crystal - Forme mismatch\n\t\t\t\t\tconst baseSpecies = this.dex.species.get(species.changesFrom);\n\t\t\t\t\tproblems.push(\n\t\t\t\t\t\t`${name} needs to hold ${species.requiredItems.join(' or ')} to be in its ${species.forme} forme.`,\n\t\t\t\t\t\t`(It will revert to its ${baseSpecies.baseForme || 'base'} forme if you remove the item or give it a different item.)`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (species.requiredMove && !set.moves.map(toID).includes(toID(species.requiredMove))) {\n\t\t\t\tconst baseSpecies = this.dex.species.get(species.changesFrom);\n\t\t\t\tproblems.push(\n\t\t\t\t\t`${name} needs to know the move ${species.requiredMove} to be in its ${species.forme} forme.`,\n\t\t\t\t\t`(It will revert to its ${baseSpecies.baseForme} forme if it forgets the move.)`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Mismatches between the set forme (if not base) and the item signature forme will have been rejected already.\n\t\t\t// It only remains to assign the right forme to a set with the base species (Arceus/Genesect/Giratina/Silvally).\n\t\t\tif (item.forcedForme && species.name === dex.species.get(item.forcedForme).baseSpecies) {\n\t\t\t\tset.species = item.forcedForme;\n\t\t\t}\n\t\t}\n\n\t\tif (species.name === 'Pikachu-Cosplay') {\n\t\t\tconst cosplay: {[k: string]: string} = {\n\t\t\t\tmeteormash: 'Pikachu-Rock-Star', iciclecrash: 'Pikachu-Belle', drainingkiss: 'Pikachu-Pop-Star',\n\t\t\t\telectricterrain: 'Pikachu-PhD', flyingpress: 'Pikachu-Libre',\n\t\t\t};\n\t\t\tfor (const moveid of set.moves) {\n\t\t\t\tif (moveid in cosplay) {\n\t\t\t\t\tset.species = cosplay[moveid];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (species.name === 'Keldeo' && set.moves.map(toID).includes('secretsword' as ID) && dex.gen >= 8) {\n\t\t\tset.species = 'Keldeo-Resolute';\n\t\t}\n\n\t\tconst crowned: {[k: string]: string} = {\n\t\t\t'Zacian-Crowned': 'behemothblade', 'Zamazenta-Crowned': 'behemothbash',\n\t\t};\n\t\tif (species.name in crowned) {\n\t\t\tconst behemothMove = set.moves.map(toID).indexOf(crowned[species.name] as ID);\n\t\t\tif (behemothMove >= 0) {\n\t\t\t\tset.moves[behemothMove] = 'ironhead';\n\t\t\t}\n\t\t}\n\t\tif (species.baseSpecies === \"Hoopa\" && dex.gen >= 9) {\n\t\t\tconst moves = set.moves.map(toID);\n\t\t\tconst hyperspaceHole = moves.indexOf('hyperspacehole' as ID);\n\t\t\tconst hyperspaceFury = moves.indexOf('hyperspacefury' as ID);\n\t\t\tif (species.name === \"Hoopa\" && hyperspaceFury >= 0) {\n\t\t\t\tproblems.push(`In Generation 9, Hoopa cannot run Hyperspace Fury because it gets replaced with Hyperspace Hole upon changing forme.`);\n\t\t\t} else if (species.name === \"Hoopa-Unbound\" && hyperspaceHole >= 0) {\n\t\t\t\tproblems.push(`In Generation 9, Hoopa-Unbound cannot run Hyperspace Hole because it gets replaced with Hyperspace Fury upon changing forme.`);\n\t\t\t}\n\t\t}\n\n\t\tif (species.baseSpecies === \"Greninja\" && toID(set.ability) === 'battlebond') {\n\t\t\tset.species = \"Greninja-Bond\";\n\t\t}\n\n\t\tif (species.baseSpecies === \"Unown\" && dex.gen === 2) {\n\t\t\tlet resultBinary = '';\n\t\t\tfor (const iv of ['atk', 'def', 'spe', 'spa'] as const) {\n\t\t\t\tresultBinary += set.ivs[iv].toString(2).padStart(5, '0').slice(1, 3);\n\t\t\t}\n\t\t\tconst resultDecimal = Math.floor(parseInt(resultBinary, 2) / 10);\n\t\t\tconst expectedLetter = String.fromCharCode(resultDecimal + 65);\n\t\t\tconst unownLetter = species.forme || \"A\";\n\t\t\tif (unownLetter !== expectedLetter) {\n\t\t\t\tproblems.push(`Unown has forme ${unownLetter}, but its DVs give it the forme ${expectedLetter}.`);\n\t\t\t}\n\t\t}\n\t\treturn problems;\n\t}\n\n\tcheckSpecies(set: PokemonSet, species: Species, tierSpecies: Species, setHas: {[k: string]: true}) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\t// https://www.smogon.com/forums/posts/8659168\n\t\tif (\n\t\t\t(tierSpecies.id === 'zamazentacrowned' && species.id === 'zamazenta') ||\n\t\t\t(tierSpecies.id === 'zaciancrowned' && species.id === 'zacian')\n\t\t) {\n\t\t\tspecies = tierSpecies;\n\t\t}\n\n\t\tsetHas['pokemon:' + species.id] = true;\n\t\tsetHas['basepokemon:' + toID(species.baseSpecies)] = true;\n\n\t\tlet isMega = false;\n\t\tif (tierSpecies !== species) {\n\t\t\tsetHas['pokemon:' + tierSpecies.id] = true;\n\t\t\tif (tierSpecies.isMega || tierSpecies.isPrimal) {\n\t\t\t\tsetHas['pokemontag:mega'] = true;\n\t\t\t\tisMega = true;\n\t\t\t}\n\t\t}\n\n\t\tlet isGmax = false;\n\t\tif (tierSpecies.canGigantamax && set.gigantamax) {\n\t\t\tsetHas['pokemon:' + tierSpecies.id + 'gmax'] = true;\n\t\t\tisGmax = true;\n\t\t}\n\t\tif (tierSpecies.baseSpecies === 'Greninja' && toID(set.ability) === 'battlebond') {\n\t\t\tsetHas['pokemon:greninjabond'] = true;\n\t\t}\n\n\t\tconst tier = tierSpecies.tier === '(PU)' ? 'ZU' : tierSpecies.tier === '(NU)' ? 'PU' : tierSpecies.tier;\n\t\tconst tierTag = 'pokemontag:' + toID(tier);\n\t\tsetHas[tierTag] = true;\n\n\t\tconst doublesTier = tierSpecies.doublesTier === '(DUU)' ? 'DNU' : tierSpecies.doublesTier;\n\t\tconst doublesTierTag = 'pokemontag:' + toID(doublesTier);\n\t\tsetHas[doublesTierTag] = true;\n\n\t\tconst ndTier = tierSpecies.natDexTier === '(PU)' ? 'ZU' :\n\t\t\ttierSpecies.natDexTier === '(NU)' ? 'PU' : tierSpecies.natDexTier;\n\t\tconst ndTierTag = 'pokemontag:nd' + toID(ndTier);\n\t\tsetHas[ndTierTag] = true;\n\n\t\t// Only pokemon that can gigantamax should have the Gmax flag\n\t\tif (!tierSpecies.canGigantamax && set.gigantamax) {\n\t\t\treturn `${tierSpecies.name} cannot Gigantamax but is flagged as being able to.`;\n\t\t}\n\n\t\tlet banReason = ruleTable.check('pokemon:' + species.id);\n\t\tif (banReason) {\n\t\t\treturn `${species.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') return null;\n\n\t\tif (tierSpecies !== species) {\n\t\t\tbanReason = ruleTable.check('pokemon:' + tierSpecies.id);\n\t\t\tif (banReason) {\n\t\t\t\treturn `${tierSpecies.name} is ${banReason}.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\tif (isMega) {\n\t\t\tbanReason = ruleTable.check('pokemontag:mega', setHas);\n\t\t\tif (banReason) {\n\t\t\t\treturn `Mega evolutions are ${banReason}.`;\n\t\t\t}\n\t\t}\n\n\t\tif (isGmax) {\n\t\t\tbanReason = ruleTable.check('pokemon:' + tierSpecies.id + 'gmax');\n\t\t\tif (banReason) {\n\t\t\t\treturn `Gigantamaxing ${species.name} is ${banReason}.`;\n\t\t\t}\n\t\t}\n\n\t\tbanReason = ruleTable.check('basepokemon:' + toID(species.baseSpecies));\n\t\tif (banReason) {\n\t\t\treturn `${species.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') {\n\t\t\t// don't allow nonstandard speciess when whitelisting standard base species\n\t\t\t// i.e. unbanning Pichu doesn't mean allowing Pichu-Spiky-Eared outside of Gen 4\n\t\t\tconst baseSpecies = dex.species.get(species.baseSpecies);\n\t\t\tif (baseSpecies.isNonstandard === species.isNonstandard) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// We can't return here because the `-nonexistent` rule is a bit\n\t\t// complicated in terms of what trumps it. We don't want e.g.\n\t\t// +Mythical to unban Shaymin in Gen 1, for instance.\n\t\tlet nonexistentCheck = Tags.nonexistent.genericFilter!(tierSpecies) && ruleTable.check('nonexistent');\n\n\t\tconst EXISTENCE_TAG = ['past', 'future', 'lgpe', 'unobtainable', 'cap', 'custom', 'nonexistent'];\n\n\t\tfor (const ruleid of ruleTable.tagRules) {\n\t\t\tif (ruleid.startsWith('*')) continue;\n\t\t\tconst tagid = ruleid.slice(12);\n\t\t\tconst tag = Tags[tagid];\n\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(tierSpecies)) {\n\t\t\t\tconst existenceTag = EXISTENCE_TAG.includes(tagid);\n\t\t\t\tif (ruleid.startsWith('+')) {\n\t\t\t\t\t// we want rules like +CAP to trump -Nonexistent, but most tags shouldn't\n\t\t\t\t\tif (!existenceTag && nonexistentCheck) continue;\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (existenceTag) {\n\t\t\t\t\t// for a nicer error message\n\t\t\t\t\tnonexistentCheck = 'banned';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn `${species.name} is tagged ${tag.name}, which is ${ruleTable.check(ruleid.slice(1)) || \"banned\"}.`;\n\t\t\t}\n\t\t}\n\n\t\tif (nonexistentCheck) {\n\t\t\tif (tierSpecies.isNonstandard === 'Past' || tierSpecies.isNonstandard === 'Future') {\n\t\t\t\treturn `${tierSpecies.name} does not exist in Gen ${dex.gen}.`;\n\t\t\t}\n\t\t\tif (tierSpecies.isNonstandard === 'LGPE') {\n\t\t\t\treturn `${tierSpecies.name} does not exist in this game, only in Let's Go Pikachu/Eevee.`;\n\t\t\t}\n\t\t\tif (tierSpecies.isNonstandard === 'CAP') {\n\t\t\t\treturn `${tierSpecies.name} is a CAP and does not exist in this game.`;\n\t\t\t}\n\t\t\tif (tierSpecies.isNonstandard === 'Unobtainable') {\n\t\t\t\treturn `${tierSpecies.name} is not possible to obtain in this game.`;\n\t\t\t}\n\t\t\tif (tierSpecies.isNonstandard === 'Gigantamax') {\n\t\t\t\treturn `${tierSpecies.name} is a placeholder for a Gigantamax sprite, not a real Pok\u00E9mon. (This message is likely to be a validator bug.)`;\n\t\t\t}\n\t\t\treturn `${tierSpecies.name} does not exist in this game.`;\n\t\t}\n\t\tif (nonexistentCheck === '') return null;\n\n\t\t// Special casing for Pokemon that can Gmax, but their Gmax factor cannot be legally obtained\n\t\tif (tierSpecies.gmaxUnreleased && set.gigantamax) {\n\t\t\tbanReason = ruleTable.check('pokemontag:unobtainable');\n\t\t\tif (banReason) {\n\t\t\t\treturn `${tierSpecies.name} is flagged as gigantamax, but it cannot gigantamax without hacking or glitches.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\tbanReason = ruleTable.check('pokemontag:allpokemon');\n\t\tif (banReason) {\n\t\t\treturn `${species.name} is not in the list of allowed pokemon.`;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tcheckItem(set: PokemonSet, item: Item, setHas: {[k: string]: true}) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tsetHas['item:' + item.id] = true;\n\n\t\tlet banReason = ruleTable.check('item:' + (item.id || 'noitem'));\n\t\tif (banReason) {\n\t\t\tif (!item.id) {\n\t\t\t\treturn `${set.name} not holding an item is ${banReason}.`;\n\t\t\t}\n\t\t\treturn `${set.name}'s item ${item.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') return null;\n\n\t\tif (!item.id) return null;\n\n\t\tbanReason = ruleTable.check('pokemontag:allitems');\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s item ${item.name} is not in the list of allowed items.`;\n\t\t}\n\n\t\t// obtainability\n\t\tif (item.isNonstandard) {\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(item.isNonstandard));\n\t\t\tif (banReason) {\n\t\t\t\tif (item.isNonstandard === 'Unobtainable') {\n\t\t\t\t\treturn `${item.name} is not obtainable without hacking or glitches.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s item ${item.name} is tagged ${item.isNonstandard}, which is ${banReason}.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\tif (item.isNonstandard && item.isNonstandard !== 'Unobtainable') {\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\n\t\t\tif (banReason) {\n\t\t\t\tif (['Past', 'Future'].includes(item.isNonstandard)) {\n\t\t\t\t\treturn `${set.name}'s item ${item.name} does not exist in Gen ${dex.gen}.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s item ${item.name} does not exist in this game.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tcheckMove(set: PokemonSet, move: Move, setHas: {[k: string]: true}) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tsetHas['move:' + move.id] = true;\n\n\t\tlet banReason = ruleTable.check('move:' + move.id);\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s move ${move.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') return null;\n\n\t\tbanReason = ruleTable.check('pokemontag:allmoves');\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s move ${move.name} is not in the list of allowed moves.`;\n\t\t}\n\n\t\t// obtainability\n\t\tif (move.isNonstandard) {\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(move.isNonstandard));\n\t\t\tif (banReason) {\n\t\t\t\tif (move.isNonstandard === 'Unobtainable') {\n\t\t\t\t\treturn `${move.name} is not obtainable without hacking or glitches${dex.gen >= 9 && move.gen < dex.gen ? ` in Gen ${dex.gen}` : ``}.`;\n\t\t\t\t}\n\t\t\t\tif (move.isNonstandard === 'Gigantamax') {\n\t\t\t\t\treturn `${move.name} is not usable without Gigantamaxing its user, ${move.isMax}.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s move ${move.name} is tagged ${move.isNonstandard}, which is ${banReason}.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\tif (move.isNonstandard && move.isNonstandard !== 'Unobtainable') {\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\n\t\t\tif (banReason) {\n\t\t\t\tif (['Past', 'Future'].includes(move.isNonstandard)) {\n\t\t\t\t\treturn `${set.name}'s move ${move.name} does not exist in Gen ${dex.gen}.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s move ${move.name} does not exist in this game.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tcheckAbility(set: PokemonSet, ability: Ability, setHas: {[k: string]: true}) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tsetHas['ability:' + ability.id] = true;\n\n\t\tif (this.format.id.startsWith('gen9pokebilities')) {\n\t\t\tconst species = dex.species.get(set.species);\n\t\t\tconst unSeenAbilities = Object.keys(species.abilities)\n\t\t\t\t.filter(key => key !== 'S' && (key !== 'H' || !species.unreleasedHidden))\n\t\t\t\t.map(key => species.abilities[key as \"0\" | \"1\" | \"H\" | \"S\"]);\n\n\t\t\tif (ability.id !== this.toID(species.abilities['S'])) {\n\t\t\t\tfor (const abilityName of unSeenAbilities) {\n\t\t\t\t\tsetHas['ability:' + toID(abilityName)] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet banReason = ruleTable.check('ability:' + ability.id);\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s ability ${ability.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') return null;\n\n\t\tbanReason = ruleTable.check('pokemontag:allabilities');\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s ability ${ability.name} is not in the list of allowed abilities.`;\n\t\t}\n\n\t\t// obtainability\n\t\tif (ability.isNonstandard) {\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(ability.isNonstandard));\n\t\t\tif (banReason) {\n\t\t\t\treturn `${set.name}'s ability ${ability.name} is tagged ${ability.isNonstandard}, which is ${banReason}.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\n\t\t\tif (banReason) {\n\t\t\t\tif (['Past', 'Future'].includes(ability.isNonstandard)) {\n\t\t\t\t\treturn `${set.name}'s ability ${ability.name} does not exist in Gen ${dex.gen}.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s ability ${ability.name} does not exist in this game.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tcheckNature(set: PokemonSet, nature: Nature, setHas: {[k: string]: true}) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tsetHas['nature:' + nature.id] = true;\n\n\t\tlet banReason = ruleTable.check('nature:' + nature.id);\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s nature ${nature.name} is ${banReason}.`;\n\t\t}\n\t\tif (banReason === '') return null;\n\n\t\tbanReason = ruleTable.check('allnatures');\n\t\tif (banReason) {\n\t\t\treturn `${set.name}'s nature ${nature.name} is not in the list of allowed natures.`;\n\t\t}\n\n\t\t// obtainability\n\t\tif (nature.isNonstandard) {\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(nature.isNonstandard));\n\t\t\tif (banReason) {\n\t\t\t\treturn `${set.name}'s nature ${nature.name} is tagged ${nature.isNonstandard}, which is ${banReason}.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\n\t\t\tif (banReason) {\n\t\t\t\tif (['Past', 'Future'].includes(nature.isNonstandard)) {\n\t\t\t\t\treturn `${set.name}'s nature ${nature.name} does not exist in Gen ${dex.gen}.`;\n\t\t\t\t}\n\t\t\t\treturn `${set.name}'s nature ${nature.name} does not exist in this game.`;\n\t\t\t}\n\t\t\tif (banReason === '') return null;\n\t\t}\n\t\treturn null;\n\t}\n\n\tvalidateEvent(\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species\n\t): true | undefined;\n\tvalidateEvent(\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species,\n\t\tbecause: string, from?: string\n\t): string[] | undefined;\n\t/**\n\t * Returns array of error messages if invalid, undefined if valid\n\t *\n\t * If `because` is not passed, instead returns true if invalid.\n\t */\n\tvalidateEvent(\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species,\n\t\tbecause = ``, from = `from an event`\n\t) {\n\t\tconst dex = this.dex;\n\t\tlet name = set.species;\n\t\tconst species = dex.species.get(set.species);\n\t\tconst maxSourceGen = this.ruleTable.has('allowtradeback') ? Utils.clampIntRange(dex.gen + 1, 1, 8) : dex.gen;\n\t\tif (!eventSpecies) eventSpecies = species;\n\t\tif (set.name && set.species !== set.name && species.baseSpecies !== set.name) name = `${set.name} (${set.species})`;\n\n\t\tconst fastReturn = !because;\n\t\tif (eventData.from) from = `from ${eventData.from}`;\n\t\tconst etc = `${because} ${from}`;\n\n\t\tconst problems = [];\n\n\t\tif (dex.gen < 8 && this.minSourceGen > eventData.generation) {\n\t\t\tif (fastReturn) return true;\n\t\t\tproblems.push(`This format requires Pokemon from gen ${this.minSourceGen} or later and ${name} is from gen ${eventData.generation}${etc}.`);\n\t\t}\n\t\tif (maxSourceGen < eventData.generation) {\n\t\t\tif (fastReturn) return true;\n\t\t\tproblems.push(`This format is in gen ${dex.gen} and ${name} is from gen ${eventData.generation}${etc}.`);\n\t\t}\n\n\t\tif (eventData.japan && dex.currentMod !== 'gen1jpn') {\n\t\t\tif (fastReturn) return true;\n\t\t\tproblems.push(`${name} has moves from Japan-only events, but this format simulates International Yellow/Crystal which can't trade with Japanese games.`);\n\t\t}\n\n\t\tif (eventData.level && (set.level || 0) < eventData.level) {\n\t\t\tif (fastReturn) return true;\n\t\t\tproblems.push(`${name} must be at least level ${eventData.level}${etc}.`);\n\t\t}\n\t\tif ((eventData.shiny === true && !set.shiny) || (!eventData.shiny && set.shiny)) {\n\t\t\tif (fastReturn) return true;\n\t\t\tconst shinyReq = eventData.shiny ? ` be shiny` : ` not be shiny`;\n\t\t\tproblems.push(`${name} must${shinyReq}${etc}.`);\n\t\t}\n\t\tif (eventData.gender) {\n\t\t\tif (set.gender && eventData.gender !== set.gender) {\n\t\t\t\tif (fastReturn) return true;\n\t\t\t\tproblems.push(`${name}'s gender must be ${eventData.gender}${etc}.`);\n\t\t\t}\n\t\t}\n\t\tconst canMint = dex.gen > 7;\n\t\tif (eventData.nature && eventData.nature !== set.nature && !canMint) {\n\t\t\tif (fastReturn) return true;\n\t\t\tproblems.push(`${name} must have a ${eventData.nature} nature${etc} - Mints are only available starting gen 8.`);\n\t\t}\n\t\tlet requiredIVs = 0;\n\t\tif (eventData.ivs) {\n\t\t\t/** In Gen 7+, IVs can be changed to 31 */\n\t\t\tconst canBottleCap = dex.gen >= 7 && set.level >= (dex.gen < 9 ? 100 : 50);\n\n\t\t\tif (!set.ivs) set.ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};\n\t\t\tlet statName: StatID;\n\t\t\tfor (statName in eventData.ivs) {\n\t\t\t\tif (canBottleCap && set.ivs[statName] === 31) continue;\n\t\t\t\tif (set.ivs[statName] !== eventData.ivs[statName]) {\n\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\tproblems.push(`${name} must have ${eventData.ivs[statName]} ${Dex.stats.names[statName]} IVs${etc}.`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (canBottleCap) {\n\t\t\t\t// IVs can be overridden but Hidden Power type can't\n\t\t\t\tif (Object.keys(eventData.ivs).length >= 6) {\n\t\t\t\t\tconst requiredHpType = dex.getHiddenPower(eventData.ivs).type;\n\t\t\t\t\tif (set.hpType && set.hpType !== requiredHpType) {\n\t\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\t\tproblems.push(`${name} can only have Hidden Power ${requiredHpType}${etc}.`);\n\t\t\t\t\t}\n\t\t\t\t\tset.hpType = requiredHpType;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trequiredIVs = eventData.perfectIVs || 0;\n\t\t}\n\t\tif (requiredIVs && set.ivs) {\n\t\t\t// Legendary Pokemon must have at least 3 perfect IVs in gen 6\n\t\t\t// Events can also have a certain amount of guaranteed perfect IVs\n\t\t\tlet perfectIVs = 0;\n\t\t\tlet statName: StatID;\n\t\t\tfor (statName in set.ivs) {\n\t\t\t\tif (set.ivs[statName] >= 31) perfectIVs++;\n\t\t\t}\n\t\t\tif (perfectIVs < requiredIVs) {\n\t\t\t\tif (fastReturn) return true;\n\t\t\t\tif (eventData.perfectIVs) {\n\t\t\t\t\tproblems.push(`${name} must have at least ${requiredIVs} perfect IVs${etc}.`);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The perfect IV count affects Hidden Power availability\n\t\t\tif (dex.gen >= 3 && requiredIVs >= 3 && set.hpType === 'Fighting') {\n\t\t\t\tif (fastReturn) return true;\n\t\t\t\tproblems.push(`${name} can't use Hidden Power Fighting because it must have at least three perfect IVs${etc}.`);\n\t\t\t} else if (dex.gen >= 3 && requiredIVs >= 5 && set.hpType &&\n\t\t\t\t\t!['Dark', 'Dragon', 'Electric', 'Steel', 'Ice'].includes(set.hpType)) {\n\t\t\t\tif (fastReturn) return true;\n\t\t\t\tproblems.push(`${name} can only use Hidden Power Dark/Dragon/Electric/Steel/Ice because it must have at least 5 perfect IVs${etc}.`);\n\t\t\t}\n\t\t}\n\t\tconst ruleTable = this.ruleTable;\n\t\tif (ruleTable.has('obtainablemoves')) {\n\t\t\tconst ssMaxSourceGen = setSources.maxSourceGen();\n\t\t\tconst tradebackEligible = dex.gen === 2 && (species.gen === 1 || eventSpecies.gen === 1);\n\t\t\tif (ssMaxSourceGen && eventData.generation > ssMaxSourceGen && !tradebackEligible) {\n\t\t\t\tif (fastReturn) return true;\n\t\t\t\tproblems.push(`${name} must not have moves only learnable in gen ${ssMaxSourceGen}${etc}.`);\n\t\t\t}\n\n\t\t\tif (eventData.from === \"Gen 5 Dream World\" && setSources.dreamWorldMoveCount > 1) {\n\t\t\t\tproblems.push(`${name} can only have one Dream World move.`);\n\t\t\t}\n\t\t}\n\t\tif (ruleTable.has('obtainableabilities')) {\n\t\t\tif (dex.gen <= 5 && eventData.abilities && eventData.abilities.length === 1 && !eventData.isHidden) {\n\t\t\t\tif (species.name === eventSpecies.name) {\n\t\t\t\t\t// has not evolved, abilities must match\n\t\t\t\t\tconst requiredAbility = dex.abilities.get(eventData.abilities[0]).name;\n\t\t\t\t\tif (set.ability !== requiredAbility) {\n\t\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\t\tproblems.push(`${name} must have ${requiredAbility}${etc}.`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// has evolved\n\t\t\t\t\tconst ability1 = dex.abilities.get(eventSpecies.abilities['1']);\n\t\t\t\t\tif (ability1.gen && eventData.generation >= ability1.gen) {\n\t\t\t\t\t\t// pokemon had 2 available abilities in the gen the event happened\n\t\t\t\t\t\t// ability is restricted to a single ability slot\n\t\t\t\t\t\tconst requiredAbilitySlot = (toID(eventData.abilities[0]) === ability1.id ? 1 : 0);\n\t\t\t\t\t\tconst requiredAbility = dex.abilities.get(species.abilities[requiredAbilitySlot] || species.abilities['0']).name;\n\t\t\t\t\t\tif (set.ability !== requiredAbility) {\n\t\t\t\t\t\t\tconst originalAbility = dex.abilities.get(eventData.abilities[0]).name;\n\t\t\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\t\t\tproblems.push(`${name} must have ${requiredAbility}${because} from a ${originalAbility} ${eventSpecies.name} event.`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (species.abilities['H']) {\n\t\t\t\tconst isHidden = (set.ability === species.abilities['H']);\n\t\t\t\tif (!isHidden && eventData.isHidden && dex.gen <= 8) {\n\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\tproblems.push(`${name} must have its Hidden Ability${etc}.`);\n\t\t\t\t}\n\n\t\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && this.format.mod !== 'gen8dlc1';\n\t\t\t\tif (isHidden && !eventData.isHidden && !canUseAbilityPatch) {\n\t\t\t\t\tif (fastReturn) return true;\n\t\t\t\t\tproblems.push(`${name} must not have its Hidden Ability${etc}.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (problems.length) return problems;\n\t\tif (eventData.gender) set.gender = eventData.gender;\n\t}\n\n\tallSources(species?: Species) {\n\t\tlet minSourceGen = this.minSourceGen;\n\t\tif (this.dex.gen >= 3 && minSourceGen < 3) minSourceGen = 3;\n\t\tif (species) minSourceGen = Math.max(minSourceGen, species.gen);\n\t\tconst maxSourceGen = this.ruleTable.has('allowtradeback') ? Utils.clampIntRange(this.dex.gen + 1, 1, 8) : this.dex.gen;\n\t\treturn new PokemonSources(maxSourceGen, minSourceGen);\n\t}\n\n\tvalidateMoves(\n\t\tspecies: Species, moves: string[], setSources: PokemonSources, set?: Partial,\n\t\tname: string = species.name, moveLegalityWhitelist: {[k: string]: true | undefined} = {}\n\t) {\n\t\tconst dex = this.dex;\n\t\tconst ruleTable = this.ruleTable;\n\n\t\tconst problems = [];\n\n\t\tconst checkCanLearn = (ruleTable.checkCanLearn?.[0] || this.checkCanLearn);\n\t\tfor (const moveName of moves) {\n\t\t\tconst move = dex.moves.get(moveName);\n\t\t\tif (moveLegalityWhitelist[move.id]) continue;\n\t\t\tconst problem = checkCanLearn.call(this, move, species, setSources, set);\n\t\t\tif (problem) {\n\t\t\t\tproblems.push(`${name}${problem}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (setSources.size() && setSources.moveEvoCarryCount > 3) {\n\t\t\tif (setSources.sourcesBefore < 6) setSources.sourcesBefore = 0;\n\t\t\tsetSources.sources = setSources.sources.filter(\n\t\t\t\tsource => source.charAt(1) === 'E' && parseInt(source.charAt(0)) >= 6\n\t\t\t);\n\t\t\tif (!setSources.size()) {\n\t\t\t\tproblems.push(`${name} needs to know ${species.evoMove || 'a Fairy-type move'} to evolve, so it can only know 3 other moves from ${species.prevo}.`);\n\t\t\t}\n\t\t}\n\n\t\tif (problems.length) return problems;\n\n\t\tif (setSources.isHidden) {\n\t\t\tsetSources.sources = setSources.sources.filter(\n\t\t\t\tsource => parseInt(source.charAt(0)) >= 5\n\t\t\t);\n\t\t\tif (setSources.sourcesBefore < 5) setSources.sourcesBefore = 0;\n\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && this.format.mod !== 'gen8dlc1';\n\t\t\tif (!setSources.size() && !canUseAbilityPatch) {\n\t\t\t\tproblems.push(`${name} has a hidden ability - it can't have moves only learned before gen 5.`);\n\t\t\t\treturn problems;\n\t\t\t}\n\t\t}\n\n\t\tif (setSources.babyOnly && setSources.sources.length) {\n\t\t\tconst baby = dex.species.get(setSources.babyOnly);\n\t\t\tconst babyEvo = toID(baby.evos[0]);\n\t\t\tsetSources.sources = setSources.sources.filter(source => {\n\t\t\t\tif (source.charAt(1) === 'S') {\n\t\t\t\t\tconst sourceId = source.split(' ')[1];\n\t\t\t\t\tif (sourceId !== baby.id) return false;\n\t\t\t\t}\n\t\t\t\tif (source.charAt(1) === 'E') {\n\t\t\t\t\tif (babyEvo && source.slice(2) === babyEvo) return false;\n\t\t\t\t}\n\t\t\t\tif (source.charAt(1) === 'D') {\n\t\t\t\t\tif (babyEvo && source.slice(2) === babyEvo) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t});\n\t\t\tif (!setSources.size()) {\n\t\t\t\tproblems.push(`${name}'s event/egg moves are from an evolution, and are incompatible with its moves from ${baby.name}.`);\n\t\t\t}\n\t\t}\n\t\tif (setSources.babyOnly && setSources.size() && this.gen > 2) {\n\t\t\t// there do theoretically exist evo/tradeback incompatibilities in\n\t\t\t// gen 2, but those are very complicated to validate and should be\n\t\t\t// handled separately anyway, so for now we just treat them all as\n\t\t\t// legal (competitively relevant ones can be manually banned)\n\t\t\tconst baby = dex.species.get(setSources.babyOnly);\n\t\t\tsetSources.sources = setSources.sources.filter(source => {\n\t\t\t\tif (baby.gen > parseInt(source.charAt(0)) && !source.startsWith('1ST')) return false;\n\t\t\t\tif (baby.gen > 2 && source === '7V') return false;\n\t\t\t\treturn true;\n\t\t\t});\n\t\t\tif (setSources.sourcesBefore < baby.gen) setSources.sourcesBefore = 0;\n\t\t\tif (!setSources.size()) {\n\t\t\t\tproblems.push(`${name} has moves from before Gen ${baby.gen}, which are incompatible with its moves from ${baby.name}.`);\n\t\t\t}\n\t\t}\n\n\t\treturn problems;\n\t}\n\t/**\n\t * Returns a list of problems regarding a Pokemon's avilability in Pokemon GO (empty list if no problems)\n\t * If the Pokemon cannot be obtained from Pokemon GO, returns null\n\t */\n\tvalidatePokemonGo(\n\t\tspecies: Species, set: Partial, setSources: PokemonSources, name: string = species.name,\n\t): string[] | null {\n\t\tlet problems = [];\n\t\tlet minLevel = 50; // maximum level a Pokemon can be in Pokemon GO\n\t\tlet minIVs = 15; // IVs range from 0 to 15 in Pokemon GO\n\t\tconst dex = this.dex;\n\t\tconst pokemonGoData = dex.species.getPokemonGoData(species.id);\n\t\tif (dex.gen < 8 || this.format.mod === 'gen8dlc1') return null;\n\t\tif (!pokemonGoData) {\n\t\t\t// Handles forms and evolutions not obtainable from Pokemon GO\n\t\t\tconst otherSpecies = this.dex.species.learnsetParent(species);\n\t\t\t// If a Pokemon is somehow not obtainable from Pokemon GO and it must be leveled up to be evolved,\n\t\t\t// validation for the game should stop because it's more optimal to get the Pokemon outside of the game\n\t\t\tif (otherSpecies && !species.evoLevel) {\n\t\t\t\tconst otherProblems = this.validatePokemonGo(otherSpecies, set, setSources, name);\n\t\t\t\tif (otherProblems) {\n\t\t\t\t\tproblems = otherProblems;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} else {\n\t\t\tconst pokemonGoSources = pokemonGoData.encounters;\n\t\t\t// should never happen\n\t\t\tif (!pokemonGoSources) throw new Error(`Species with no Pokemon GO data: ${species.id}`);\n\t\t\tif (set.shiny) name = \"Shiny \" + name;\n\t\t\tif (set.shiny && pokemonGoSources.includes('noshiny')) {\n\t\t\t\tproblems.push(`${name} is not obtainable from Pokemon GO.`);\n\t\t\t} else {\n\t\t\t\tif (pokemonGoSources.includes('wild') && !((set.shiny && pokemonGoSources.includes('nowildshiny')))) {\n\t\t\t\t\tminLevel = 1;\n\t\t\t\t\tminIVs = 0;\n\t\t\t\t}\n\t\t\t\tif (pokemonGoSources.includes('egg')) {\n\t\t\t\t\t/**\n\t\t\t\t\t * A Pokemon's level when hatched is determined by the trainer's level when it is obtained\n\t\t\t\t\t * It is no longer possible for new accounts to obtain eggs at level 1 because they will have reached\n\t\t\t\t\t * level 2 by the time they can spin a PokeStop. However, it might be possible for a sleeper account\n\t\t\t\t\t * from before XP changes to get a level 1 egg from spinning a PokeStop that sends the account to\n\t\t\t\t\t * level 2, but this needs research\n\t\t\t\t\t*/\n\t\t\t\t\tminLevel = Math.min(minLevel, 2);\n\t\t\t\t\tminIVs = Math.min(minIVs, 10);\n\t\t\t\t}\n\t\t\t\tif (pokemonGoSources.includes('12kmegg')) {\n\t\t\t\t\tminLevel = Math.min(minLevel, 8);\n\t\t\t\t\tminIVs = Math.min(minIVs, 10);\n\t\t\t\t}\n\t\t\t\tif (pokemonGoSources.includes('raid')) {\n\t\t\t\t\tminLevel = Math.min(minLevel, 20);\n\t\t\t\t\tminIVs = Math.min(minIVs, 10);\n\t\t\t\t}\n\t\t\t\tif (species.id === 'mewtwo' && set.level && set.level >= 20) {\n\t\t\t\t\t// A bug allowed Mewtwo to be encountered with an IV floor of 0 from GO Battle League\n\t\t\t\t\tminIVs = Math.min(minIVs, 0);\n\t\t\t\t}\n\t\t\t\tif (pokemonGoSources.includes('research')) {\n\t\t\t\t\tminLevel = Math.min(minLevel, 15);\n\t\t\t\t\tminIVs = Math.min(minIVs, 10);\n\t\t\t\t}\n\t\t\t\tif (pokemonGoSources.includes('giovanni') && !set.shiny) {\n\t\t\t\t\t/**\n\t\t\t\t\t * Purified Pokemon can be leveled down to level 8 after trading; they are forced to\n\t\t\t\t\t * special trades, but currently all Giovanni Shadow Pokemon are already forced special trades\n\t\t\t\t\t*/\n\t\t\t\t\tminLevel = Math.min(minLevel, 8);\n\t\t\t\t\tminIVs = Math.min(minIVs, 1);\n\t\t\t\t\tif (set.level && set.level < 12) setSources.pokemonGoSource = \"purified\";\n\t\t\t\t}\n\t\t\t\t// Attempt to trade the Pokemon to reduce level and IVs\n\t\t\t\tif (!pokemonGoSources.includes('notrade')) {\n\t\t\t\t\t// Special trades require a good friend\n\t\t\t\t\t// Trading with a friend of this level has an IV floor of 1\n\t\t\t\t\t// Note that (non-shiny) Deoxys could be traded for a short time when it was introduced\n\t\t\t\t\tif (!set.shiny || species.id !== 'deoxys') {\n\t\t\t\t\t\tconst specialTrade = pokemonGoSources.includes('specialtrade') || set.shiny;\n\t\t\t\t\t\tminLevel = Math.min(minLevel, 12);\n\t\t\t\t\t\tminIVs = Math.min(minIVs, specialTrade ? 1 : 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (set.level && set.level < minLevel) {\n\t\t\t\t\tproblems.push(`${name} must be at least level ${minLevel} to be from Pokemon GO.`);\n\t\t\t\t}\n\t\t\t\tconst ivs = set.ivs || TeamValidator.fillStats(null, 31);\n\t\t\t\tfor (const stat in ivs) {\n\t\t\t\t\tif (Math.floor(ivs[stat as 'hp'] / 2) < minIVs && stat !== 'spe') {\n\t\t\t\t\t\tproblems.push(`${name} must have at least ${minIVs} ` +\n\t\t\t\t\t\t(minIVs === 1 ? `IV` : `IVs`) + ` in non-Speed stats to be from Pokemon GO.`);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn problems;\n\t}\n\n\tomCheckCanLearn(\n\t\tmove: Move,\n\t\ts: Species,\n\t\tsetSources = this.allSources(s),\n\t\tset: Partial = {},\n\t\tproblem = `${set.name || s.name} can't learn ${move.name}`,\n\t): string | null {\n\t\tif (!this.ruleTable.checkCanLearn?.[0]) return problem;\n\t\tconst baseCheckCanLearn = this.checkCanLearn;\n\t\t// tell the custom move legality check that the move is illegal by default\n\t\tthis.checkCanLearn = () => problem;\n\t\tconst omVerdict = this.ruleTable.checkCanLearn[0].call(this, move, s, setSources, set);\n\t\tthis.checkCanLearn = baseCheckCanLearn;\n\t\treturn omVerdict;\n\t}\n\n\t/** Returns null if you can learn the move, or a string explaining why you can't learn it */\n\tcheckCanLearn(\n\t\tmove: Move,\n\t\toriginalSpecies: Species,\n\t\tsetSources = this.allSources(originalSpecies),\n\t\tset: Partial = {}\n\t): string | null {\n\t\tconst dex = this.dex;\n\t\tif (!setSources.size()) throw new Error(`Bad sources passed to checkCanLearn`);\n\n\t\tmove = dex.moves.get(move);\n\t\tconst moveid = move.id;\n\t\tconst baseSpecies = dex.species.get(originalSpecies);\n\n\t\tconst format = this.format;\n\t\tconst ruleTable = dex.formats.getRuleTable(format);\n\t\tconst level = set.level || 100;\n\n\t\tlet cantLearnReason = null;\n\n\t\tlet limit1 = true;\n\t\tlet sketch = false;\n\t\tlet blockedHM = false;\n\n\t\tlet babyOnly = '';\n\n\t\t// This is a pretty complicated algorithm\n\n\t\t// Abstractly, what it does is construct the union of sets of all\n\t\t// possible ways this pokemon could be obtained, and then intersect\n\t\t// it with a the pokemon's existing set of all possible ways it could\n\t\t// be obtained. If this intersection is non-empty, the move is legal.\n\n\t\t// set of possible sources of a pokemon with this move\n\t\tconst moveSources = new PokemonSources();\n\n\t\t/**\n\t\t * The format doesn't allow Pokemon traded from the future\n\t\t * (This is everything except in Gen 1 Tradeback)\n\t\t */\n\t\tconst noFutureGen = !ruleTable.has('allowtradeback');\n\t\t/**\n\t\t * The format allows Sketch to copy moves in Gen 8\n\t\t */\n\t\tconst canSketchPostGen7Moves = ruleTable.has('sketchpostgen7moves') || this.dex.currentMod === 'gen8bdsp';\n\n\t\tlet tradebackEligible = false;\n\t\tconst fullLearnset = dex.species.getFullLearnset(originalSpecies.id);\n\t\tif (!fullLearnset.length) {\n\t\t\t// It's normal for a nonstandard species not to have learnset data\n\n\t\t\t// Formats should replace the `Obtainable Moves` rule if they want to\n\t\t\t// allow pokemon without learnsets.\n\t\t\treturn ` can't learn any moves at all.`;\n\t\t}\n\n\t\tfor (const {species, learnset} of fullLearnset) {\n\t\t\tif (dex.gen <= 2 && species.gen === 1) tradebackEligible = true;\n\t\t\tconst checkingPrevo = species.baseSpecies !== originalSpecies.baseSpecies;\n\t\t\tif (checkingPrevo && !moveSources.size()) {\n\t\t\t\tif (!setSources.babyOnly || !species.prevo) {\n\t\t\t\t\tbabyOnly = species.id;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sources = learnset[moveid] || [];\n\t\t\tif (moveid === 'sketch') {\n\t\t\t\tsketch = true;\n\t\t\t} else if (learnset['sketch']) {\n\t\t\t\tif (move.noSketch || move.isZ || move.isMax) {\n\t\t\t\t\tcantLearnReason = `can't be Sketched.`;\n\t\t\t\t} else if (move.gen > 7 && !canSketchPostGen7Moves &&\n\t\t\t\t\t(dex.gen === 8 ||\n\t\t\t\t\t\t(dex.gen === 9 && ['gen9dlc1', 'gen9predlc'].includes(format.mod)))) {\n\t\t\t\t\tcantLearnReason = `can't be Sketched because it's a Gen ${move.gen} move and Sketch isn't available in Gen ${move.gen}.`;\n\t\t\t\t} else {\n\t\t\t\t\tif (!sources.length || !moveSources.size()) sketch = true;\n\t\t\t\t\tsources = [...learnset['sketch'], ...sources];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let learned of sources) {\n\t\t\t\t// Every `learned` represents a single way a pokemon might\n\t\t\t\t// learn a move. This can be handled one of several ways:\n\t\t\t\t// `continue`\n\t\t\t\t// means we can't learn it\n\t\t\t\t// `return null`\n\t\t\t\t// means we can learn it with no restrictions\n\t\t\t\t// (there's a way to just teach any pokemon of this species\n\t\t\t\t// the move in the current gen, like a TM.)\n\t\t\t\t// `moveSources.add(source)`\n\t\t\t\t// means we can learn it only if obtained that exact way described\n\t\t\t\t// in source\n\t\t\t\t// `moveSources.addGen(learnedGen)`\n\t\t\t\t// means we can learn it only if obtained at or before learnedGen\n\t\t\t\t// (i.e. get the pokemon however you want, transfer to that gen,\n\t\t\t\t// teach it, and transfer it to the current gen.)\n\n\t\t\t\tconst learnedGen = parseInt(learned.charAt(0));\n\t\t\t\tif (learnedGen < this.minSourceGen) {\n\t\t\t\t\tif (!cantLearnReason) {\n\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen ${learnedGen} to ${this.minSourceGen}.`;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (noFutureGen && learnedGen > dex.gen) {\n\t\t\t\t\tif (!cantLearnReason) {\n\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen ${learnedGen} to ${dex.gen}.`;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// redundant\n\t\t\t\tif (learnedGen <= moveSources.sourcesBefore) continue;\n\n\t\t\t\tif (\n\t\t\t\t\tbaseSpecies.evoRegion === 'Alola' && checkingPrevo && learnedGen >= 8 &&\n\t\t\t\t\t(dex.gen < 9 || learned.charAt(1) !== 'E')\n\t\t\t\t) {\n\t\t\t\t\tcantLearnReason = `is from a ${species.name} that can't be transferred to USUM to evolve into ${baseSpecies.name}.`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && format.mod !== 'gen8dlc1';\n\t\t\t\tif (\n\t\t\t\t\tlearnedGen < 7 && setSources.isHidden && !canUseAbilityPatch &&\n\t\t\t\t\t!dex.mod('gen' + learnedGen).species.get(baseSpecies.name).abilities['H']\n\t\t\t\t) {\n\t\t\t\t\tcantLearnReason = `can only be learned in gens without Hidden Abilities.`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst ability = dex.abilities.get(set.ability);\n\t\t\t\tif (dex.gen < 6 && ability.gen > learnedGen && !checkingPrevo) {\n\t\t\t\t\t// You can evolve a transfered mon to reroll for its new Ability.\n\t\t\t\t\tcantLearnReason = `is learned in gen ${learnedGen}, but the Ability ${ability.name} did not exist then.`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!species.isNonstandard) {\n\t\t\t\t\t// HMs can't be transferred\n\t\t\t\t\tif (dex.gen >= 4 && learnedGen <= 3 && [\n\t\t\t\t\t\t'cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive',\n\t\t\t\t\t].includes(moveid)) {\n\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen 3 to 4 because it's an HM move.`;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (dex.gen >= 5 && learnedGen <= 4 && [\n\t\t\t\t\t\t'cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb',\n\t\t\t\t\t].includes(moveid)) {\n\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen 4 to 5 because it's an HM move.`;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// Defog and Whirlpool can't be transferred together\n\t\t\t\t\tif (dex.gen >= 5 && ['defog', 'whirlpool'].includes(moveid) && learnedGen <= 4) blockedHM = true;\n\t\t\t\t}\n\n\t\t\t\tif (learned.charAt(1) === 'L') {\n\t\t\t\t\t// special checking for level-up moves\n\t\t\t\t\tif (level >= parseInt(learned.substr(2)) || learnedGen === 7) {\n\t\t\t\t\t\t// we're past the required level to learn it\n\t\t\t\t\t\t// (gen 7 level-up moves can be relearnered at any level)\n\t\t\t\t\t\t// falls through to LMT check below\n\t\t\t\t\t} else if (level >= 5 && learnedGen === 3 && species.canHatch) {\n\t\t\t\t\t\t// Pomeg Glitch\n\t\t\t\t\t\tlearned = learnedGen + 'Epomeg';\n\t\t\t\t\t} else if ((!species.gender || species.gender === 'F') &&\n\t\t\t\t\t\tlearnedGen >= 2 && species.canHatch && !setSources.isFromPokemonGo) {\n\t\t\t\t\t\t// available as egg move\n\t\t\t\t\t\tlearned = learnedGen + 'Eany';\n\t\t\t\t\t\t// falls through to E check below\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// this move is unavailable, skip it\n\t\t\t\t\t\tcantLearnReason = `is learned at level ${parseInt(learned.substr(2))}.`;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Gen 8+ egg moves can be taught to any pokemon from any source\n\t\t\t\tif (learnedGen >= 8 && learned.charAt(1) === 'E' && learned.slice(1) !== 'Eany' &&\n\t\t\t\t\tlearned.slice(1) !== 'Epomeg' || 'LMTR'.includes(learned.charAt(1))) {\n\t\t\t\t\tif (learnedGen === dex.gen && learned.charAt(1) !== 'R') {\n\t\t\t\t\t\t// current-gen level-up, TM or tutor moves:\n\t\t\t\t\t\t// always available\n\t\t\t\t\t\tif (!(learnedGen >= 8 && learned.charAt(1) === 'E') && babyOnly) {\n\t\t\t\t\t\t\tif (setSources.isFromPokemonGo && species.evoLevel) {\n\t\t\t\t\t\t\t\tcantLearnReason = `is from a prevo, which is incompatible with its Pokemon GO origin.`;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetSources.babyOnly = babyOnly;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!moveSources.moveEvoCarryCount) return null;\n\t\t\t\t\t}\n\t\t\t\t\t// past-gen level-up, TM, or tutor moves:\n\t\t\t\t\t// available as long as the source gen was or was before this gen\n\t\t\t\t\tif (learned.charAt(1) === 'R') {\n\t\t\t\t\t\tmoveSources.restrictedMove = moveid;\n\t\t\t\t\t}\n\t\t\t\t\tlimit1 = false;\n\t\t\t\t\tmoveSources.addGen(learnedGen);\n\t\t\t\t} else if (learned.charAt(1) === 'E') {\n\t\t\t\t\t// egg moves:\n\t\t\t\t\t// only if hatched from an egg\n\t\t\t\t\tlet limitedEggMove: ID | null | undefined = undefined;\n\t\t\t\t\tif (learned.slice(1) === 'Eany') {\n\t\t\t\t\t\tif (species.gender === 'F') {\n\t\t\t\t\t\t\tlimitedEggMove = move.id;\n\t\t\t\t\t\t\tmoveSources.levelUpEggMoves = [move.id];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlimitedEggMove = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (learned.slice(1) === 'Epomeg') {\n\t\t\t\t\t\t// Pomeg glitched moves have to be from an egg but since they aren't true egg moves,\n\t\t\t\t\t\t// there should be no breeding restrictions\n\t\t\t\t\t\tmoveSources.pomegEggMoves = [move.id];\n\t\t\t\t\t} else if (learnedGen < 6) {\n\t\t\t\t\t\tlimitedEggMove = move.id;\n\t\t\t\t\t}\n\t\t\t\t\tlearned = learnedGen + 'E' + (species.prevo ? species.id : '');\n\t\t\t\t\tif (tradebackEligible && learnedGen === 2 && move.gen <= 1) {\n\t\t\t\t\t\t// can tradeback\n\t\t\t\t\t\tmoveSources.add('1ET' + learned.slice(2), limitedEggMove);\n\t\t\t\t\t}\n\t\t\t\t\tmoveSources.add(learned, limitedEggMove);\n\t\t\t\t} else if (learned.charAt(1) === 'S') {\n\t\t\t\t\t// event moves:\n\t\t\t\t\t// only if that was the source\n\t\t\t\t\t// Event Pok\u00E9mon:\n\t\t\t\t\t// \tAvailable as long as the past gen can get the Pok\u00E9mon and then trade it back.\n\t\t\t\t\tif (tradebackEligible && learnedGen === 2 && move.gen <= 1) {\n\t\t\t\t\t\t// can tradeback\n\t\t\t\t\t\tmoveSources.add('1ST' + learned.slice(2) + ' ' + species.id);\n\t\t\t\t\t}\n\t\t\t\t\tmoveSources.add(learned + ' ' + species.id);\n\t\t\t\t\tconst eventLearnset = dex.species.getLearnsetData(species.id);\n\t\t\t\t\tif (eventLearnset.eventData?.[parseInt(learned.charAt(2))].emeraldEventEgg && learnedGen === 3) {\n\t\t\t\t\t\tmoveSources.pomegEventEgg = learned + ' ' + species.id;\n\t\t\t\t\t}\n\t\t\t\t} else if (learned.charAt(1) === 'D') {\n\t\t\t\t\t// DW moves:\n\t\t\t\t\t// only if that was the source\n\t\t\t\t\tmoveSources.add(learned + species.id);\n\t\t\t\t\tmoveSources.dreamWorldMoveCount++;\n\t\t\t\t} else if (learned.charAt(1) === 'V' && this.minSourceGen < learnedGen) {\n\t\t\t\t\t// Virtual Console or Let's Go transfer moves:\n\t\t\t\t\t// only if that was the source\n\t\t\t\t\tif (learned === '8V' && setSources.isFromPokemonGo && babyOnly && species.evoLevel) {\n\t\t\t\t\t\tcantLearnReason = `is from a prevo, which is incompatible with its Pokemon GO origin.`;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tmoveSources.add(learned);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ruleTable.has('mimicglitch') && species.gen < 5) {\n\t\t\t\t// include the Mimic Glitch when checking this mon's learnset\n\t\t\t\tconst glitchMoves = ['metronome', 'copycat', 'transform', 'mimic', 'assist'];\n\t\t\t\tlet getGlitch = false;\n\t\t\t\tfor (const i of glitchMoves) {\n\t\t\t\t\tif (learnset[i]) {\n\t\t\t\t\t\tif (!(i === 'mimic' && dex.abilities.get(set.ability).gen === 4 && !species.prevo)) {\n\t\t\t\t\t\t\tgetGlitch = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (getGlitch) {\n\t\t\t\t\tmoveSources.addGen(4);\n\t\t\t\t\tif (move.gen < 5) {\n\t\t\t\t\t\tlimit1 = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!moveSources.size()) {\n\t\t\t\tif (\n\t\t\t\t\t(species.evoType === 'levelMove' && species.evoMove !== move.name) ||\n\t\t\t\t\t(species.id === 'sylveon' && move.type !== 'Fairy')\n\t\t\t\t) {\n\t\t\t\t\tmoveSources.moveEvoCarryCount = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (limit1 && sketch) {\n\t\t\t// limit 1 sketch move\n\t\t\tif (setSources.sketchMove) {\n\t\t\t\treturn ` can't Sketch ${move.name} and ${setSources.sketchMove} because it can only Sketch 1 move.`;\n\t\t\t}\n\t\t\tsetSources.sketchMove = move.name;\n\t\t}\n\n\t\tif (blockedHM) {\n\t\t\t// Limit one of Defog/Whirlpool to be transferred\n\t\t\tif (setSources.hm) return ` can't simultaneously transfer Defog and Whirlpool from Gen 4 to 5.`;\n\t\t\tsetSources.hm = moveid;\n\t\t}\n\n\t\tif (!setSources.restrictiveMoves) {\n\t\t\tsetSources.restrictiveMoves = [];\n\t\t}\n\t\tsetSources.restrictiveMoves.push(move.name);\n\n\t\tconst checkedSpecies = babyOnly ? fullLearnset[fullLearnset.length - 1].species : baseSpecies;\n\t\tif (checkedSpecies && setSources.isFromPokemonGo &&\n\t\t\t(setSources.pokemonGoSource === 'purified' || checkedSpecies.id === 'mew')) {\n\t\t\t// Pokemon that cannot be sent from Pokemon GO to Let's Go can only access Let's Go moves through HOME\n\t\t\t// It can only obtain a chain of four level up moves and cannot have TM moves\n\t\t\tconst pokemonGoData = dex.species.getPokemonGoData(checkedSpecies.id);\n\t\t\tif (pokemonGoData.LGPERestrictiveMoves) {\n\t\t\t\tlet levelUpMoveCount = 0;\n\t\t\t\tconst restrictiveMovesToID = [];\n\t\t\t\tfor (const moveName of setSources.restrictiveMoves) {\n\t\t\t\t\trestrictiveMovesToID.push(toID(moveName));\n\t\t\t\t}\n\t\t\t\tfor (const restrictiveMove in pokemonGoData.LGPERestrictiveMoves) {\n\t\t\t\t\tconst moveLevel = pokemonGoData.LGPERestrictiveMoves[restrictiveMove];\n\t\t\t\t\tif (toID(move) === restrictiveMove) {\n\t\t\t\t\t\tif (!moveLevel) {\n\t\t\t\t\t\t\treturn `'s move ${move.name} is incompatible with its Pokemon GO origin.`;\n\t\t\t\t\t\t} else if (set.level && set.level < moveLevel) {\n\t\t\t\t\t\t\treturn ` must be at least level ${moveLevel} to learn ${move.name} due to its Pokemon GO origin.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (levelUpMoveCount) levelUpMoveCount++;\n\t\t\t\t\tif (restrictiveMovesToID.includes(restrictiveMove)) {\n\t\t\t\t\t\tif (!levelUpMoveCount) {\n\t\t\t\t\t\t\tlevelUpMoveCount++;\n\t\t\t\t\t\t} else if (levelUpMoveCount > 4) {\n\t\t\t\t\t\t\treturn `'s moves ${(setSources.restrictiveMoves || []).join(', ')} are incompatible with its Pokemon GO origin.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Now that we have our list of possible sources, intersect it with the current list\n\t\tif (!moveSources.size()) {\n\t\t\tif (cantLearnReason) return `'s move ${move.name} ${cantLearnReason}`;\n\t\t\treturn ` can't learn ${move.name}.`;\n\t\t}\n\t\tconst eggSources = moveSources.sources.filter(source => source.charAt(1) === 'E');\n\t\tif (dex.gen >= 3 && eggSources.length && moveSources.limitedEggMoves === null && moveSources.sourcesBefore) {\n\t\t\tmoveSources.possiblyLimitedEggMoves = [toID(moveSources.sourcesBefore + move.id)];\n\t\t}\n\t\tconst backupSources = setSources.sources;\n\t\tconst backupSourcesBefore = setSources.sourcesBefore;\n\t\tsetSources.intersectWith(moveSources);\n\t\tif (!setSources.size()) {\n\t\t\t// pretend this pokemon didn't have this move:\n\t\t\t// prevents a crash if OMs override `checkCanLearn` to keep validating after an error\n\t\t\tsetSources.sources = backupSources;\n\t\t\tsetSources.sourcesBefore = backupSourcesBefore;\n\t\t\tif (setSources.isFromPokemonGo) return `'s move ${move.name} is incompatible with its Pokemon GO origin.`;\n\t\t\treturn `'s moves ${(setSources.restrictiveMoves || []).join(', ')} are incompatible.`;\n\t\t}\n\n\t\tif (babyOnly) setSources.babyOnly = babyOnly;\n\t\treturn null;\n\t}\n\n\tstatic fillStats(stats: SparseStatsTable | null, fillNum = 0): StatsTable {\n\t\tconst filledStats: StatsTable = {hp: fillNum, atk: fillNum, def: fillNum, spa: fillNum, spd: fillNum, spe: fillNum};\n\t\tif (stats) {\n\t\t\tlet statName: StatID;\n\t\t\tfor (statName in filledStats) {\n\t\t\t\tconst stat = stats[statName];\n\t\t\t\tif (typeof stat === 'number') filledStats[statName] = stat;\n\t\t\t}\n\t\t}\n\t\treturn filledStats;\n\t}\n\n\tstatic get(format: string | Format) {\n\t\treturn new TeamValidator(format);\n\t}\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,iBAAwB;AACxB,iBAAoB;AACpB,kBAAmB;AACnB,mBAAoB;AACpB,kBAAmB;AAbnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiDO,MAAM,eAAe;AAAA,EAyE3B,YAAY,gBAAgB,GAAG,eAAe,GAAG;AAChD,SAAK,UAAU,CAAC;AAChB,SAAK,gBAAgB;AACrB,SAAK,eAAe;AACpB,SAAK,WAAW;AAChB,SAAK,kBAAkB;AACvB,SAAK,oBAAoB;AACzB,SAAK,sBAAsB;AAAA,EAC5B;AAAA,EACA,OAAO;AACN,QAAI,KAAK;AAAe,aAAO;AAC/B,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EACA,IAAI,QAAuB,gBAA4B;AACtD,QAAI,KAAK,QAAQ,KAAK,QAAQ,SAAS,CAAC,MAAM;AAAQ,WAAK,QAAQ,KAAK,MAAM;AAC9E,QAAI,gBAAgB;AACnB,UAAI,OAAO,OAAO,GAAG,CAAC,MAAM,OAAO;AAClC,aAAK,2BAA2B,CAAC,cAAc;AAAA,MAChD;AAAA,IACD;AACA,QAAI,kBAAkB,KAAK,oBAAoB,MAAM;AACpD,WAAK,kBAAkB,CAAC,cAAc;AAAA,IACvC,WAAW,mBAAmB,MAAM;AACnC,WAAK,kBAAkB;AAAA,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