{ "version": 3, "sources": ["../../../sim/team-validator.ts"], "sourcesContent": ["/**\r\n * Team Validator\r\n * Pokemon Showdown - http://pokemonshowdown.com/\r\n *\r\n * Handles team validation, and specifically learnset checking.\r\n *\r\n * @license MIT\r\n */\r\n\r\nimport {Dex, toID} from './dex';\r\nimport {Utils} from '../lib';\r\nimport {Tags} from '../data/tags';\r\nimport {Teams} from './teams';\r\nimport {PRNG} from './prng';\r\n\r\n/**\r\n * Describes a possible way to get a pokemon. Is not exhaustive!\r\n * sourcesBefore covers all sources that do not have exclusive\r\n * moves (like catching wild pokemon).\r\n *\r\n * First character is a generation number, 1-8.\r\n * Second character is a source ID, one of:\r\n *\r\n * - E = egg, 3rd char+ is the father in gen 2-5, empty in gen 6-7\r\n * because egg moves aren't restricted to fathers anymore\r\n * - S = event, 3rd char+ is the index in .eventData\r\n * - D = Dream World, only 5D is valid\r\n * - V = Virtual Console or Let's Go transfer, only 7V/8V is valid\r\n *\r\n * Designed to match MoveSource where possible.\r\n */\r\nexport type PokemonSource = string;\r\n\r\n/**\r\n * Represents a set of possible ways to get a Pok\u00E9mon with a given\r\n * set.\r\n *\r\n * `new PokemonSources()` creates an empty set;\r\n * `new PokemonSources(dex.gen)` allows all Pokemon.\r\n *\r\n * The set mainly stored as an Array `sources`, but for sets that\r\n * could be sourced from anywhere (for instance, TM moves), we\r\n * instead just set `sourcesBefore` to a number meaning \"any\r\n * source at or before this gen is possible.\"\r\n *\r\n * In other words, this variable represents the set of all\r\n * sources in `sources`, union all sources at or before\r\n * gen `sourcesBefore`.\r\n */\r\nexport class PokemonSources {\r\n\t/**\r\n\t * A set of specific possible PokemonSources; implemented as\r\n\t * an Array rather than a Set for perf reasons.\r\n\t */\r\n\tsources: PokemonSource[];\r\n\t/**\r\n\t * if nonzero: the set also contains all possible sources from\r\n\t * this gen and earlier.\r\n\t */\r\n\tsourcesBefore: number;\r\n\t/**\r\n\t * the set requires sources from this gen or later\r\n\t * this should be unchanged from the format's minimum past gen\r\n\t * (3 in modern games, 6 if pentagon is required, etc)\r\n\t */\r\n\tsourcesAfter: number;\r\n\tisHidden: boolean | null;\r\n\t/**\r\n\t * `limitedEggMoves` is a list of moves that can only be obtained from an\r\n\t * egg with another father in gen 2-5. If there are multiple such moves,\r\n\t * potential fathers need to be checked to see if they can actually\r\n\t * learn the move combination in question.\r\n\t *\r\n\t * `null` = the current move is definitely not a limited egg move\r\n\t *\r\n\t * `undefined` = the current move may or may not be a limited egg move\r\n\t */\r\n\tlimitedEggMoves?: ID[] | null;\r\n\t/**\r\n\t * Some Pokemon evolve by having a move in their learnset (like Piloswine\r\n\t * with Ancient Power). These can only carry three other moves from their\r\n\t * prevo, because the fourth move must be the evo move. This restriction\r\n\t * doesn't apply to gen 6+ eggs, which can get around the restriction with\r\n\t * the relearner.\r\n\t */\r\n\tmoveEvoCarryCount: number;\r\n\r\n\tbabyOnly?: string;\r\n\tsketchMove?: string;\r\n\tdreamWorldMoveCount: number;\r\n\thm?: string;\r\n\trestrictiveMoves?: string[];\r\n\t/** Obscure learn methods */\r\n\trestrictedMove?: ID;\r\n\r\n\tconstructor(sourcesBefore = 0, sourcesAfter = 0) {\r\n\t\tthis.sources = [];\r\n\t\tthis.sourcesBefore = sourcesBefore;\r\n\t\tthis.sourcesAfter = sourcesAfter;\r\n\t\tthis.isHidden = null;\r\n\t\tthis.limitedEggMoves = undefined;\r\n\t\tthis.moveEvoCarryCount = 0;\r\n\t\tthis.dreamWorldMoveCount = 0;\r\n\t}\r\n\tsize() {\r\n\t\tif (this.sourcesBefore) return Infinity;\r\n\t\treturn this.sources.length;\r\n\t}\r\n\tadd(source: PokemonSource, limitedEggMove?: ID | null) {\r\n\t\tif (this.sources[this.sources.length - 1] !== source) this.sources.push(source);\r\n\t\tif (limitedEggMove && this.limitedEggMoves !== null) {\r\n\t\t\tthis.limitedEggMoves = [limitedEggMove];\r\n\t\t} else if (limitedEggMove === null) {\r\n\t\t\tthis.limitedEggMoves = null;\r\n\t\t}\r\n\t}\r\n\taddGen(sourceGen: number) {\r\n\t\tthis.sourcesBefore = Math.max(this.sourcesBefore, sourceGen);\r\n\t\tthis.limitedEggMoves = null;\r\n\t}\r\n\tminSourceGen() {\r\n\t\tif (this.sourcesBefore) return this.sourcesAfter || 1;\r\n\t\tlet min = 10;\r\n\t\tfor (const source of this.sources) {\r\n\t\t\tconst sourceGen = parseInt(source.charAt(0));\r\n\t\t\tif (sourceGen < min) min = sourceGen;\r\n\t\t}\r\n\t\tif (min === 10) return 0;\r\n\t\treturn min;\r\n\t}\r\n\tmaxSourceGen() {\r\n\t\tlet max = this.sourcesBefore;\r\n\t\tfor (const source of this.sources) {\r\n\t\t\tconst sourceGen = parseInt(source.charAt(0));\r\n\t\t\tif (sourceGen > max) max = sourceGen;\r\n\t\t}\r\n\t\treturn max;\r\n\t}\r\n\tintersectWith(other: PokemonSources) {\r\n\t\tif (other.sourcesBefore || this.sourcesBefore) {\r\n\t\t\t// having sourcesBefore is the equivalent of having everything before that gen\r\n\t\t\t// in sources, so we fill the other array in preparation for intersection\r\n\t\t\tif (other.sourcesBefore > this.sourcesBefore) {\r\n\t\t\t\tfor (const source of this.sources) {\r\n\t\t\t\t\tconst sourceGen = parseInt(source.charAt(0));\r\n\t\t\t\t\tif (sourceGen <= other.sourcesBefore) {\r\n\t\t\t\t\t\tother.sources.push(source);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (this.sourcesBefore > other.sourcesBefore) {\r\n\t\t\t\tfor (const source of other.sources) {\r\n\t\t\t\t\tconst sourceGen = parseInt(source.charAt(0));\r\n\t\t\t\t\tif (sourceGen <= this.sourcesBefore) {\r\n\t\t\t\t\t\tthis.sources.push(source);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.sourcesBefore = Math.min(other.sourcesBefore, this.sourcesBefore);\r\n\t\t}\r\n\t\tif (this.sources.length) {\r\n\t\t\tif (other.sources.length) {\r\n\t\t\t\tconst sourcesSet = new Set(other.sources);\r\n\t\t\t\tconst intersectSources = this.sources.filter(source => sourcesSet.has(source));\r\n\t\t\t\tthis.sources = intersectSources;\r\n\t\t\t} else {\r\n\t\t\t\tthis.sources = [];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (other.restrictedMove && other.restrictedMove !== this.restrictedMove) {\r\n\t\t\tif (this.restrictedMove) {\r\n\t\t\t\t// incompatible\r\n\t\t\t\tthis.sources = [];\r\n\t\t\t\tthis.sourcesBefore = 0;\r\n\t\t\t} else {\r\n\t\t\t\tthis.restrictedMove = other.restrictedMove;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (other.limitedEggMoves) {\r\n\t\t\tif (!this.limitedEggMoves) {\r\n\t\t\t\tthis.limitedEggMoves = other.limitedEggMoves;\r\n\t\t\t} else {\r\n\t\t\t\tthis.limitedEggMoves.push(...other.limitedEggMoves);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.moveEvoCarryCount += other.moveEvoCarryCount;\r\n\t\tthis.dreamWorldMoveCount += other.dreamWorldMoveCount;\r\n\t\tif (other.sourcesAfter > this.sourcesAfter) this.sourcesAfter = other.sourcesAfter;\r\n\t\tif (other.isHidden) this.isHidden = true;\r\n\t}\r\n}\r\n\r\nexport class TeamValidator {\r\n\treadonly format: Format;\r\n\treadonly dex: ModdedDex;\r\n\treadonly gen: number;\r\n\treadonly ruleTable: import('./dex-formats').RuleTable;\r\n\treadonly minSourceGen: number;\r\n\r\n\treadonly toID: (str: any) => ID;\r\n\tconstructor(format: string | Format, dex = Dex) {\r\n\t\tthis.format = dex.formats.get(format);\r\n\t\tthis.dex = dex.forFormat(this.format);\r\n\t\tthis.gen = this.dex.gen;\r\n\t\tthis.ruleTable = this.dex.formats.getRuleTable(this.format);\r\n\r\n\t\tthis.minSourceGen = this.ruleTable.minSourceGen;\r\n\r\n\t\tthis.toID = toID;\r\n\t}\r\n\r\n\tvalidateTeam(\r\n\t\tteam: PokemonSet[] | null,\r\n\t\toptions: {\r\n\t\t\tremoveNicknames?: boolean,\r\n\t\t\tskipSets?: {[name: string]: {[key: string]: boolean}},\r\n\t\t} = {}\r\n\t): string[] | null {\r\n\t\tif (team && this.format.validateTeam) {\r\n\t\t\treturn this.format.validateTeam.call(this, team, options) || null;\r\n\t\t}\r\n\t\treturn this.baseValidateTeam(team, options);\r\n\t}\r\n\r\n\tbaseValidateTeam(\r\n\t\tteam: PokemonSet[] | null,\r\n\t\toptions: {\r\n\t\t\tremoveNicknames?: boolean,\r\n\t\t\tskipSets?: {[name: string]: {[key: string]: boolean}},\r\n\t\t} = {}\r\n\t): string[] | null {\r\n\t\tconst format = this.format;\r\n\t\tconst dex = this.dex;\r\n\r\n\t\tlet problems: string[] = [];\r\n\t\tconst ruleTable = this.ruleTable;\r\n\t\tif (format.team) {\r\n\t\t\tif (team) {\r\n\t\t\t\treturn [\r\n\t\t\t\t\t`This format doesn't let you use your own team.`,\r\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.`,\r\n\t\t\t\t];\r\n\t\t\t}\r\n\t\t\tconst testTeamSeed = PRNG.generateSeed();\r\n\t\t\ttry {\r\n\t\t\t\tconst testTeamGenerator = Teams.getGenerator(format, testTeamSeed);\r\n\t\t\t\ttestTeamGenerator.getTeam(options); // Throws error if generation fails\r\n\t\t\t} catch (e) {\r\n\t\t\t\treturn [\r\n\t\t\t\t\t`${format.name}'s team generator (${format.team}) failed using these rules and seed (${testTeamSeed}):-`,\r\n\t\t\t\t\t`${e}`,\r\n\t\t\t\t];\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tif (!team) {\r\n\t\t\treturn [\r\n\t\t\t\t`This format requires you to use your own team.`,\r\n\t\t\t\t`If you're not using a custom client, please report this as a bug.`,\r\n\t\t\t];\r\n\t\t}\r\n\t\tif (!Array.isArray(team)) {\r\n\t\t\tthrow new Error(`Invalid team data`);\r\n\t\t}\r\n\r\n\t\tif (team.length < ruleTable.minTeamSize) {\r\n\t\t\tproblems.push(`You must bring at least ${ruleTable.minTeamSize} Pok\\u00E9mon (your team has ${team.length}).`);\r\n\t\t}\r\n\t\tif (team.length > ruleTable.maxTeamSize) {\r\n\t\t\treturn [`You may only bring up to ${ruleTable.maxTeamSize} Pok\\u00E9mon (your team has ${team.length}).`];\r\n\t\t}\r\n\r\n\t\t// A limit is imposed here to prevent too much engine strain or\r\n\t\t// too much layout deformation - to be exact, this is the limit\r\n\t\t// allowed in Custom Game.\r\n\t\tif (team.length > 24) {\r\n\t\t\tproblems.push(`Your team has more than than 24 Pok\\u00E9mon, which the simulator can't handle.`);\r\n\t\t\treturn problems;\r\n\t\t}\r\n\r\n\t\tconst teamHas: {[k: string]: number} = {};\r\n\t\tlet lgpeStarterCount = 0;\r\n\t\tlet deoxysType;\r\n\t\tfor (const set of team) {\r\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.`];\r\n\r\n\t\t\tlet setProblems: string[] | null = null;\r\n\t\t\tif (options.skipSets && options.skipSets[set.name]) {\r\n\t\t\t\tfor (const i in options.skipSets[set.name]) {\r\n\t\t\t\t\tteamHas[i] = (teamHas[i] || 0) + 1;\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tsetProblems = (format.validateSet || this.validateSet).call(this, set, teamHas);\r\n\t\t\t}\r\n\r\n\t\t\tif (set.species === 'Pikachu-Starter' || set.species === 'Eevee-Starter') {\r\n\t\t\t\tlgpeStarterCount++;\r\n\t\t\t\tif (lgpeStarterCount === 2 && ruleTable.isBanned('nonexistent')) {\r\n\t\t\t\t\tproblems.push(`You can only have one of Pikachu-Starter or Eevee-Starter on a team.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (dex.gen === 3 && set.species.startsWith('Deoxys')) {\r\n\t\t\t\tif (!deoxysType) {\r\n\t\t\t\t\tdeoxysType = set.species;\r\n\t\t\t\t} else if (deoxysType !== set.species && ruleTable.isBanned('nonexistent')) {\r\n\t\t\t\t\treturn [\r\n\t\t\t\t\t\t`You cannot have more than one type of Deoxys forme.`,\r\n\t\t\t\t\t\t`(Each game in Gen 3 supports only one forme of Deoxys.)`,\r\n\t\t\t\t\t];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (setProblems) {\r\n\t\t\t\tproblems = problems.concat(setProblems);\r\n\t\t\t}\r\n\t\t\tif (options.removeNicknames) {\r\n\t\t\t\tconst species = dex.species.get(set.species);\r\n\t\t\t\tlet crossSpecies: Species;\r\n\t\t\t\tif (format.name === '[Gen 9] Cross Evolution' && (crossSpecies = dex.species.get(set.name)).exists) {\r\n\t\t\t\t\tset.name = crossSpecies.name;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tset.name = species.baseSpecies;\r\n\t\t\t\t\tif (species.baseSpecies === 'Unown') set.species = 'Unown';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const [rule, source, limit, bans] of ruleTable.complexTeamBans) {\r\n\t\t\tlet count = 0;\r\n\t\t\tfor (const ban of bans) {\r\n\t\t\t\tif (teamHas[ban] > 0) {\r\n\t\t\t\t\tcount += limit ? teamHas[ban] : 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (limit && count > limit) {\r\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\r\n\t\t\t\tproblems.push(`You are limited to ${limit} of ${rule}${clause}.`);\r\n\t\t\t} else if (!limit && count >= bans.length) {\r\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\r\n\t\t\t\tproblems.push(`Your team has the combination of ${rule}, which is banned${clause}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const rule of ruleTable.keys()) {\r\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\r\n\t\t\tconst subformat = dex.formats.get(rule);\r\n\t\t\tif (subformat.onValidateTeam && ruleTable.has(subformat.id)) {\r\n\t\t\t\tproblems = problems.concat(subformat.onValidateTeam.call(this, team, format, teamHas) || []);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (format.onValidateTeam) {\r\n\t\t\tproblems = problems.concat(format.onValidateTeam.call(this, team, format, teamHas) || []);\r\n\t\t}\r\n\r\n\t\tif (!problems.length) return null;\r\n\t\treturn problems;\r\n\t}\r\n\r\n\tgetEventOnlyData(species: Species, noRecurse?: boolean): {species: Species, eventData: EventInfo[]} | null {\r\n\t\tconst dex = this.dex;\r\n\t\tconst learnset = dex.species.getLearnsetData(species.id);\r\n\t\tif (!learnset?.eventOnly) {\r\n\t\t\tif (noRecurse) return null;\r\n\t\t\treturn this.getEventOnlyData(dex.species.get(species.prevo), true);\r\n\t\t}\r\n\r\n\t\tif (!learnset.eventData && species.forme) {\r\n\t\t\treturn this.getEventOnlyData(dex.species.get(species.baseSpecies), true);\r\n\t\t}\r\n\t\tif (!learnset.eventData) {\r\n\t\t\tthrow new Error(`Event-only species ${species.name} has no eventData table`);\r\n\t\t}\r\n\r\n\t\treturn {species, eventData: learnset.eventData};\r\n\t}\r\n\r\n\tgetValidationSpecies(set: PokemonSet): [Species, Species] {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\t\tconst species = dex.species.get(set.species);\r\n\t\tconst item = dex.items.get(set.item);\r\n\t\tconst ability = dex.abilities.get(set.ability);\r\n\r\n\t\tlet outOfBattleSpecies = species;\r\n\t\tlet tierSpecies = species;\r\n\t\tif (ability.id === 'battlebond' && species.id === 'greninja') {\r\n\t\t\toutOfBattleSpecies = dex.species.get('greninjaash');\r\n\t\t\tif (ruleTable.has('obtainableformes')) {\r\n\t\t\t\ttierSpecies = outOfBattleSpecies;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (ability.id === 'owntempo' && species.id === 'rockruff') {\r\n\t\t\ttierSpecies = outOfBattleSpecies = dex.species.get('rockruffdusk');\r\n\t\t}\r\n\r\n\t\tif (ruleTable.has('obtainableformes')) {\r\n\t\t\tconst canMegaEvo = dex.gen <= 7 || ruleTable.has('+pokemontag:past');\r\n\t\t\tif (item.megaEvolves === species.name) {\r\n\t\t\t\tif (!item.megaStone) throw new Error(`Item ${item.name} has no base form for mega evolution`);\r\n\t\t\t\ttierSpecies = dex.species.get(item.megaStone);\r\n\t\t\t} else if (item.id === 'redorb' && species.id === 'groudon') {\r\n\t\t\t\ttierSpecies = dex.species.get('Groudon-Primal');\r\n\t\t\t} else if (item.id === 'blueorb' && species.id === 'kyogre') {\r\n\t\t\t\ttierSpecies = dex.species.get('Kyogre-Primal');\r\n\t\t\t} else if (canMegaEvo && species.id === 'rayquaza' && set.moves.map(toID).includes('dragonascent' as ID) &&\r\n\t\t\t\t\t!ruleTable.has('megarayquazaclause')) {\r\n\t\t\t\ttierSpecies = dex.species.get('Rayquaza-Mega');\r\n\t\t\t} else if (item.id === 'rustedsword' && species.id === 'zacian') {\r\n\t\t\t\ttierSpecies = dex.species.get('Zacian-Crowned');\r\n\t\t\t} else if (item.id === 'rustedshield' && species.id === 'zamazenta') {\r\n\t\t\t\ttierSpecies = dex.species.get('Zamazenta-Crowned');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn [outOfBattleSpecies, tierSpecies];\r\n\t}\r\n\r\n\tvalidateSet(set: PokemonSet, teamHas: AnyObject): string[] | null {\r\n\t\tconst format = this.format;\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tlet problems: string[] = [];\r\n\t\tif (!set) {\r\n\t\t\treturn [`This is not a Pokemon.`];\r\n\t\t}\r\n\r\n\t\tlet species = dex.species.get(set.species);\r\n\t\tset.species = species.name;\r\n\t\t// Backwards compatability with old Gmax format\r\n\t\tif (set.species.toLowerCase().endsWith('-gmax') && this.format.id !== 'gen8megamax') {\r\n\t\t\tset.species = set.species.slice(0, -5);\r\n\t\t\tspecies = dex.species.get(set.species);\r\n\t\t\tif (set.name && set.name.endsWith('-Gmax')) set.name = species.baseSpecies;\r\n\t\t\tset.gigantamax = true;\r\n\t\t}\r\n\t\tif (set.name && set.name.length > 18) {\r\n\t\t\tif (set.name === set.species) {\r\n\t\t\t\tset.name = species.baseSpecies;\r\n\t\t\t} else {\r\n\t\t\t\tproblems.push(`Nickname \"${set.name}\" too long (should be 18 characters or fewer)`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tset.name = dex.getName(set.name);\r\n\t\tlet item = dex.items.get(Utils.getString(set.item));\r\n\t\tset.item = item.name;\r\n\t\tlet ability = dex.abilities.get(Utils.getString(set.ability));\r\n\t\tset.ability = ability.name;\r\n\t\tlet nature = dex.natures.get(Utils.getString(set.nature));\r\n\t\tset.nature = nature.name;\r\n\t\tif (!Array.isArray(set.moves)) set.moves = [];\r\n\r\n\t\tset.name = set.name || species.baseSpecies;\r\n\t\tlet name = set.species;\r\n\t\tif (set.species !== set.name && species.baseSpecies !== set.name) {\r\n\t\t\tname = `${set.name} (${set.species})`;\r\n\t\t}\r\n\r\n\t\tif (!set.teraType && this.gen === 9) {\r\n\t\t\tset.teraType = species.types[0];\r\n\t\t}\r\n\r\n\t\tif (!set.level) set.level = ruleTable.defaultLevel;\r\n\r\n\t\tlet adjustLevel = ruleTable.adjustLevel;\r\n\t\tif (ruleTable.adjustLevelDown && set.level >= ruleTable.adjustLevelDown) {\r\n\t\t\tadjustLevel = ruleTable.adjustLevelDown;\r\n\t\t}\r\n\t\tif (set.level === adjustLevel || (set.level === 100 && ruleTable.maxLevel < 100)) {\r\n\t\t\t// Note that we're temporarily setting level 50 pokemon in VGC to level 100\r\n\t\t\t// This allows e.g. level 50 Hydreigon even though it doesn't evolve until level 64.\r\n\t\t\t// Leveling up can't make an obtainable pokemon unobtainable, so this is safe.\r\n\t\t\t// Just remember to set the level back to adjustLevel at the end of validation.\r\n\t\t\tset.level = ruleTable.maxLevel;\r\n\t\t}\r\n\t\tif (set.level < ruleTable.minLevel) {\r\n\t\t\tproblems.push(`${name} (level ${set.level}) is below the minimum level of ${ruleTable.minLevel}${ruleTable.blame('minlevel')}`);\r\n\t\t}\r\n\t\tif (set.level > ruleTable.maxLevel) {\r\n\t\t\tproblems.push(`${name} (level ${set.level}) is above the maximum level of ${ruleTable.maxLevel}${ruleTable.blame('maxlevel')}`);\r\n\t\t}\r\n\r\n\t\tconst setHas: {[k: string]: true} = {};\r\n\r\n\t\tif (!set.evs) set.evs = TeamValidator.fillStats(null, ruleTable.evLimit === null ? 252 : 0);\r\n\t\tif (!set.ivs) set.ivs = TeamValidator.fillStats(null, 31);\r\n\r\n\t\tif (ruleTable.has('obtainableformes')) {\r\n\t\t\tproblems.push(...this.validateForme(set));\r\n\t\t\tspecies = dex.species.get(set.species);\r\n\t\t}\r\n\t\tconst setSources = this.allSources(species);\r\n\r\n\t\tfor (const [rule] of ruleTable) {\r\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\r\n\t\t\tconst subformat = dex.formats.get(rule);\r\n\t\t\tif (subformat.onChangeSet && ruleTable.has(subformat.id)) {\r\n\t\t\t\tproblems = problems.concat(subformat.onChangeSet.call(this, set, format, setHas, teamHas) || []);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (format.onChangeSet) {\r\n\t\t\tproblems = problems.concat(format.onChangeSet.call(this, set, format, setHas, teamHas) || []);\r\n\t\t}\r\n\r\n\t\t// onChangeSet can modify set.species, set.item, set.ability\r\n\t\tspecies = dex.species.get(set.species);\r\n\t\titem = dex.items.get(set.item);\r\n\t\tability = dex.abilities.get(set.ability);\r\n\r\n\t\tconst [outOfBattleSpecies, tierSpecies] = this.getValidationSpecies(set);\r\n\t\tif (ability.id === 'battlebond' && species.id === 'greninja') {\r\n\t\t\tif (ruleTable.has('obtainablemisc')) {\r\n\t\t\t\tif (set.gender && set.gender !== 'M') {\r\n\t\t\t\t\tproblems.push(`Battle Bond Greninja must be male.`);\r\n\t\t\t\t}\r\n\t\t\t\tset.gender = 'M';\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (species.id === 'melmetal' && set.gigantamax && this.dex.species.getLearnsetData(species.id).eventData) {\r\n\t\t\tsetSources.sourcesBefore = 0;\r\n\t\t\tsetSources.sources = ['8S0 melmetal'];\r\n\t\t}\r\n\t\tif (!species.exists) {\r\n\t\t\treturn [`The Pokemon \"${set.species}\" does not exist.`];\r\n\t\t}\r\n\r\n\t\tif (item.id && !item.exists) {\r\n\t\t\treturn [`\"${set.item}\" is an invalid item.`];\r\n\t\t}\r\n\t\tif (ability.id && !ability.exists) {\r\n\t\t\tif (dex.gen < 3) {\r\n\t\t\t\t// gen 1-2 don't have abilities, just silently remove\r\n\t\t\t\tability = dex.abilities.get('');\r\n\t\t\t\tset.ability = '';\r\n\t\t\t} else {\r\n\t\t\t\treturn [`\"${set.ability}\" is an invalid ability.`];\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (nature.id && !nature.exists) {\r\n\t\t\tif (dex.gen < 3) {\r\n\t\t\t\t// gen 1-2 don't have natures, just remove them\r\n\t\t\t\tnature = dex.natures.get('');\r\n\t\t\t\tset.nature = '';\r\n\t\t\t} else {\r\n\t\t\t\tproblems.push(`\"${set.nature}\" is an invalid nature.`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (set.happiness !== undefined && isNaN(set.happiness)) {\r\n\t\t\tproblems.push(`${name} has an invalid happiness value.`);\r\n\t\t}\r\n\t\tif (set.hpType) {\r\n\t\t\tconst type = dex.types.get(set.hpType);\r\n\t\t\tif (!type.exists || ['normal', 'fairy'].includes(type.id)) {\r\n\t\t\t\tproblems.push(`${name}'s Hidden Power type (${set.hpType}) is invalid.`);\r\n\t\t\t} else {\r\n\t\t\t\tset.hpType = type.name;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (set.teraType) {\r\n\t\t\tconst type = dex.types.get(set.teraType);\r\n\t\t\tif (!type.exists) {\r\n\t\t\t\tproblems.push(`${name}'s Terastal type (${set.teraType}) is invalid.`);\r\n\t\t\t} else {\r\n\t\t\t\tset.teraType = type.name;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet problem = this.checkSpecies(set, species, tierSpecies, setHas);\r\n\t\tif (problem) problems.push(problem);\r\n\r\n\t\tproblem = this.checkItem(set, item, setHas);\r\n\t\tif (problem) problems.push(problem);\r\n\t\tif (ruleTable.has('obtainablemisc')) {\r\n\t\t\tif (dex.gen === 4 && item.id === 'griseousorb' && species.num !== 487) {\r\n\t\t\t\tproblems.push(`${set.name} cannot hold the Griseous Orb.`, `(In Gen 4, only Giratina could hold the Griseous Orb).`);\r\n\t\t\t}\r\n\t\t\tif (dex.gen <= 1) {\r\n\t\t\t\tif (item.id) {\r\n\t\t\t\t\t// no items allowed\r\n\t\t\t\t\tset.item = '';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!set.ability) set.ability = 'No Ability';\r\n\t\tif (ruleTable.has('obtainableabilities')) {\r\n\t\t\tif (dex.gen <= 2 || dex.currentMod === 'gen7letsgo') {\r\n\t\t\t\tset.ability = 'No Ability';\r\n\t\t\t} else {\r\n\t\t\t\tif (!ability.name || ability.name === 'No Ability') {\r\n\t\t\t\t\tproblems.push(`${name} needs to have an ability.`);\r\n\t\t\t\t} else if (!Object.values(species.abilities).includes(ability.name)) {\r\n\t\t\t\t\tif (tierSpecies.abilities[0] === ability.name) {\r\n\t\t\t\t\t\tset.ability = species.abilities[0];\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tproblems.push(`${name} can't have ${set.ability}.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (ability.name === species.abilities['H']) {\r\n\t\t\t\t\tsetSources.isHidden = true;\r\n\r\n\t\t\t\t\tlet unreleasedHidden = species.unreleasedHidden;\r\n\t\t\t\t\tif (unreleasedHidden === 'Past' && this.minSourceGen < dex.gen) unreleasedHidden = false;\r\n\r\n\t\t\t\t\tif (unreleasedHidden && ruleTable.has('-unreleased')) {\r\n\t\t\t\t\t\tproblems.push(`${name}'s Hidden Ability is unreleased.`);\r\n\t\t\t\t\t} else if (dex.gen === 7 && ['entei', 'suicune', 'raikou'].includes(species.id) && this.minSourceGen > 1) {\r\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.`);\r\n\t\t\t\t\t} else if (dex.gen === 6 && ability.name === 'Symbiosis' &&\r\n\t\t\t\t\t\t(set.species.endsWith('Orange') || set.species.endsWith('White'))) {\r\n\t\t\t\t\t\tproblems.push(`${name}'s Hidden Ability is unreleased for the Orange and White forms.`);\r\n\t\t\t\t\t} else if (dex.gen === 5 && set.level < 10 && (species.maleOnlyHidden || species.gender === 'N')) {\r\n\t\t\t\t\t\tproblems.push(`${name} must be at least level 10 to have a Hidden Ability.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (species.maleOnlyHidden) {\r\n\t\t\t\t\t\tif (set.gender && set.gender !== 'M') {\r\n\t\t\t\t\t\t\tproblems.push(`${name} must be male to have a Hidden Ability.`);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tset.gender = 'M';\r\n\t\t\t\t\t\tsetSources.sources = ['5D'];\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tsetSources.isHidden = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tability = dex.abilities.get(set.ability);\r\n\t\tproblem = this.checkAbility(set, ability, setHas);\r\n\t\tif (problem) problems.push(problem);\r\n\r\n\t\tif (!set.nature || dex.gen <= 2) {\r\n\t\t\tset.nature = '';\r\n\t\t}\r\n\t\tnature = dex.natures.get(set.nature);\r\n\t\tproblem = this.checkNature(set, nature, setHas);\r\n\t\tif (problem) problems.push(problem);\r\n\r\n\t\tif (set.moves && Array.isArray(set.moves)) {\r\n\t\t\tset.moves = set.moves.filter(val => val);\r\n\t\t}\r\n\t\tif (!set.moves?.length) {\r\n\t\t\tproblems.push(`${name} has no moves (it must have at least one to be usable).`);\r\n\t\t\tset.moves = [];\r\n\t\t}\r\n\t\tif (set.moves.length > ruleTable.maxMoveCount) {\r\n\t\t\tproblems.push(`${name} has ${set.moves.length} moves, which is more than the limit of ${ruleTable.maxMoveCount}.`);\r\n\t\t\treturn problems;\r\n\t\t}\r\n\r\n\t\tif (ruleTable.isBanned('nonexistent')) {\r\n\t\t\tproblems.push(...this.validateStats(set, species, setSources));\r\n\t\t}\r\n\r\n\t\tconst moveLegalityWhitelist: {[k: string]: true | undefined} = {};\r\n\t\tfor (const moveName of set.moves) {\r\n\t\t\tif (!moveName) continue;\r\n\t\t\tconst move = dex.moves.get(Utils.getString(moveName));\r\n\t\t\tif (!move.exists) return [`\"${move.name}\" is an invalid move.`];\r\n\r\n\t\t\tproblem = this.checkMove(set, move, setHas);\r\n\t\t\tif (problem) {\r\n\t\t\t\tlet allowedByOM;\r\n\t\t\t\tif (problem.includes('hacking or glitches') &&\r\n\t\t\t\t\truleTable.has('omunobtainablemoves')) {\r\n\t\t\t\t\tproblem = `${name}'s ${problem}`;\r\n\t\t\t\t\tallowedByOM = !this.omCheckCanLearn(move, outOfBattleSpecies, setSources, set, problem);\r\n\t\t\t\t}\r\n\t\t\t\tif (!allowedByOM) {\r\n\t\t\t\t\tproblems.push(problem);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tmoveLegalityWhitelist[move.id] = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (ruleTable.has('obtainablemoves')) {\r\n\t\t\tproblems.push(...this.validateMoves(outOfBattleSpecies, set.moves, setSources, set, name, moveLegalityWhitelist));\r\n\t\t}\r\n\r\n\t\tconst learnsetSpecies = dex.species.getLearnsetData(outOfBattleSpecies.id);\r\n\t\tlet eventOnlyData;\r\n\r\n\t\tif (!setSources.sourcesBefore && setSources.sources.length) {\r\n\t\t\tlet legal = false;\r\n\t\t\tfor (const source of setSources.sources) {\r\n\t\t\t\tif (this.validateSource(set, source, setSources, outOfBattleSpecies)) continue;\r\n\t\t\t\tlegal = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif (!legal) {\r\n\t\t\t\tlet nonEggSource = null;\r\n\t\t\t\tfor (const source of setSources.sources) {\r\n\t\t\t\t\tif (source.charAt(1) !== 'E') {\r\n\t\t\t\t\t\tnonEggSource = source;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (!nonEggSource) {\r\n\t\t\t\t\t// all egg moves\r\n\t\t\t\t\tproblems.push(`${name} can't get its egg move combination (${setSources.limitedEggMoves!.join(', ')}) from any possible father.`);\r\n\t\t\t\t\tproblems.push(`(Is this incorrect? If so, post the chainbreeding instructions in Bug Reports)`);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (setSources.sources.length > 1) {\r\n\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):`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tconst eventProblems = this.validateSource(\r\n\t\t\t\t\t\tset, nonEggSource, setSources, outOfBattleSpecies, ` because it has a move only available`\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (eventProblems) problems.push(...eventProblems);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else if (ruleTable.has('obtainablemisc') && (eventOnlyData = this.getEventOnlyData(outOfBattleSpecies))) {\r\n\t\t\tconst {species: eventSpecies, eventData} = eventOnlyData;\r\n\t\t\tlet legal = false;\r\n\t\t\tfor (const event of eventData) {\r\n\t\t\t\tif (this.validateEvent(set, setSources, event, eventSpecies)) continue;\r\n\t\t\t\tlegal = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (!legal && species.gen <= 2 && dex.gen >= 7 && !this.validateSource(set, '7V', setSources, species)) {\r\n\t\t\t\tlegal = true;\r\n\t\t\t}\r\n\t\t\tif (!legal) {\r\n\t\t\t\tif (eventData.length === 1) {\r\n\t\t\t\t\tproblems.push(`${species.name} is only obtainable from an event - it needs to match its event:`);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tproblems.push(`${species.name} is only obtainable from events - it needs to match one of its events:`);\r\n\t\t\t\t}\r\n\t\t\t\tfor (const [i, event] of eventData.entries()) {\r\n\t\t\t\t\tif (event.generation <= dex.gen && event.generation >= this.minSourceGen) {\r\n\t\t\t\t\t\tconst eventInfo = event;\r\n\t\t\t\t\t\tconst eventNum = i + 1;\r\n\t\t\t\t\t\tconst eventName = eventData.length > 1 ? ` #${eventNum}` : ``;\r\n\t\t\t\t\t\tconst eventProblems = this.validateEvent(\r\n\t\t\t\t\t\t\tset, setSources, eventInfo, eventSpecies, ` to be`, `from its event${eventName}`\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tif (eventProblems) problems.push(...eventProblems);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet isFromRBYEncounter = false;\r\n\t\tif (this.gen === 1 && ruleTable.has('obtainablemisc') && !this.ruleTable.has('allowtradeback')) {\r\n\t\t\tlet lowestEncounterLevel;\r\n\t\t\tfor (const encounter of learnsetSpecies.encounters || []) {\r\n\t\t\t\tif (encounter.generation !== 1) continue;\r\n\t\t\t\tif (!encounter.level) continue;\r\n\t\t\t\tif (lowestEncounterLevel && encounter.level > lowestEncounterLevel) continue;\r\n\r\n\t\t\t\tlowestEncounterLevel = encounter.level;\r\n\t\t\t}\r\n\r\n\t\t\tif (lowestEncounterLevel) {\r\n\t\t\t\tif (set.level < lowestEncounterLevel) {\r\n\t\t\t\t\tproblems.push(`${name} is not obtainable at levels below ${lowestEncounterLevel} in Gen 1.`);\r\n\t\t\t\t}\r\n\t\t\t\tisFromRBYEncounter = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (!isFromRBYEncounter && ruleTable.has('obtainablemisc')) {\r\n\t\t\t// FIXME: Event pokemon given at a level under what it normally can be attained at gives a false positive\r\n\t\t\tlet evoSpecies = species;\r\n\t\t\twhile (evoSpecies.prevo) {\r\n\t\t\t\tif (set.level < (evoSpecies.evoLevel || 0)) {\r\n\t\t\t\t\tproblems.push(`${name} must be at least level ${evoSpecies.evoLevel} to be evolved.`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tevoSpecies = dex.species.get(evoSpecies.prevo);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (ruleTable.has('obtainablemoves')) {\r\n\t\t\tif (species.id === 'keldeo' && set.moves.includes('secretsword') && this.minSourceGen > 5 && dex.gen <= 7) {\r\n\t\t\t\tproblems.push(`${name} has Secret Sword, which is only compatible with Keldeo-Ordinary obtained from Gen 5.`);\r\n\t\t\t}\r\n\t\t\tconst requiresGen3Source = setSources.maxSourceGen() <= 3;\r\n\t\t\tif (requiresGen3Source && dex.abilities.get(set.ability).gen === 4 && !species.prevo && dex.gen <= 5) {\r\n\t\t\t\t// Ability Capsule allows this in Gen 6+\r\n\t\t\t\tproblems.push(`${name} has a Gen 4 ability and isn't evolved - it can't use moves from Gen 3.`);\r\n\t\t\t}\r\n\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && format.mod !== 'gen8dlc1';\r\n\t\t\tif (setSources.isHidden && !canUseAbilityPatch && setSources.maxSourceGen() < 5) {\r\n\t\t\t\tproblems.push(`${name} has a Hidden Ability - it can't use moves from before Gen 5.`);\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tspecies.maleOnlyHidden && setSources.isHidden && setSources.sourcesBefore < 5 &&\r\n\t\t\t\tsetSources.sources.every(source => source.charAt(1) === 'E')\r\n\t\t\t) {\r\n\t\t\t\tproblems.push(`${name} has an unbreedable Hidden Ability - it can't use egg moves.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (teamHas) {\r\n\t\t\tfor (const i in setHas) {\r\n\t\t\t\tif (i in teamHas) {\r\n\t\t\t\t\tteamHas[i]++;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tteamHas[i] = 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const [rule, source, limit, bans] of ruleTable.complexBans) {\r\n\t\t\tlet count = 0;\r\n\t\t\tfor (const ban of bans) {\r\n\t\t\t\tif (setHas[ban]) count++;\r\n\t\t\t}\r\n\t\t\tif (limit && count > limit) {\r\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\r\n\t\t\t\tproblems.push(`${name} is limited to ${limit} of ${rule}${clause}.`);\r\n\t\t\t} else if (!limit && count >= bans.length) {\r\n\t\t\t\tconst clause = source ? ` by ${source}` : ``;\r\n\t\t\t\tif (source === 'Obtainable Moves') {\r\n\t\t\t\t\tproblems.push(`${name} has the combination of ${rule}, which is impossible to obtain legitimately.`);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tproblems.push(`${name} has the combination of ${rule}, which is banned${clause}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const [rule] of ruleTable) {\r\n\t\t\tif ('!+-'.includes(rule.charAt(0))) continue;\r\n\t\t\tconst subformat = dex.formats.get(rule);\r\n\t\t\tif (subformat.onValidateSet && ruleTable.has(subformat.id)) {\r\n\t\t\t\tproblems = problems.concat(subformat.onValidateSet.call(this, set, format, setHas, teamHas) || []);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (format.onValidateSet) {\r\n\t\t\tproblems = problems.concat(format.onValidateSet.call(this, set, format, setHas, teamHas) || []);\r\n\t\t}\r\n\r\n\t\tconst nameSpecies = dex.species.get(set.name);\r\n\t\tif (nameSpecies.exists && nameSpecies.name.toLowerCase() === set.name.toLowerCase()) {\r\n\t\t\t// nickname is the name of a species\r\n\t\t\tif (nameSpecies.baseSpecies === species.baseSpecies) {\r\n\t\t\t\tset.name = species.baseSpecies;\r\n\t\t\t} else if (nameSpecies.name !== species.name && nameSpecies.name !== species.baseSpecies) {\r\n\t\t\t\t// nickname species doesn't match actual species\r\n\t\t\t\t// Nickname Clause\r\n\t\t\t\tproblems.push(`${name} must not be nicknamed a different Pok\u00E9mon species than what it actually is.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!problems.length) {\r\n\t\t\tif (adjustLevel) set.level = adjustLevel;\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\treturn problems;\r\n\t}\r\n\r\n\tvalidateStats(set: PokemonSet, species: Species, setSources: PokemonSources) {\r\n\t\tconst ruleTable = this.ruleTable;\r\n\t\tconst dex = this.dex;\r\n\r\n\t\tconst allowAVs = ruleTable.has('allowavs');\r\n\t\tconst evLimit = ruleTable.evLimit;\r\n\t\tconst canBottleCap = dex.gen >= 7 && (set.level >= (dex.gen < 9 ? 100 : 50) || !ruleTable.has('obtainablemisc'));\r\n\r\n\t\tif (!set.evs) set.evs = TeamValidator.fillStats(null, evLimit === null ? 252 : 0);\r\n\t\tif (!set.ivs) set.ivs = TeamValidator.fillStats(null, 31);\r\n\r\n\t\tconst problems = [];\r\n\t\tconst name = set.name || set.species;\r\n\r\n\t\tconst maxedIVs = Object.values(set.ivs).every(stat => stat === 31);\r\n\t\tfor (const moveName of set.moves) {\r\n\t\t\tconst move = dex.moves.get(moveName);\r\n\t\t\tif (move.id === 'hiddenpower' && move.type !== 'Normal') {\r\n\t\t\t\tif (!set.hpType) {\r\n\t\t\t\t\tset.hpType = move.type;\r\n\t\t\t\t} else if (set.hpType !== move.type && ruleTable.has('obtainablemisc')) {\r\n\t\t\t\t\tproblems.push(`${name}'s Hidden Power type ${set.hpType} is incompatible with Hidden Power ${move.type}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (set.hpType && maxedIVs && ruleTable.has('obtainablemisc')) {\r\n\t\t\tif (dex.gen <= 2) {\r\n\t\t\t\tconst HPdvs = dex.types.get(set.hpType).HPdvs;\r\n\t\t\t\tset.ivs = {hp: 30, atk: 30, def: 30, spa: 30, spd: 30, spe: 30};\r\n\t\t\t\tlet statName: StatID;\r\n\t\t\t\tfor (statName in HPdvs) {\r\n\t\t\t\t\tset.ivs[statName] = HPdvs[statName]! * 2;\r\n\t\t\t\t}\r\n\t\t\t\tset.ivs.hp = -1;\r\n\t\t\t} else if (!canBottleCap) {\r\n\t\t\t\tset.ivs = TeamValidator.fillStats(dex.types.get(set.hpType).HPivs, 31);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst cantBreedNorEvolve = (species.eggGroups[0] === 'Undiscovered' && !species.prevo && !species.nfe);\r\n\t\tconst isLegendary = (cantBreedNorEvolve && !species.tags.includes('Paradox') && ![\r\n\t\t\t'Pikachu', 'Unown', 'Dracozolt', 'Arctozolt', 'Dracovish', 'Arctovish',\r\n\t\t].includes(species.baseSpecies)) || [\r\n\t\t\t'Manaphy', 'Cosmog', 'Cosmoem', 'Solgaleo', 'Lunala',\r\n\t\t].includes(species.baseSpecies);\r\n\t\tconst diancieException = species.name === 'Diancie' && !set.shiny;\r\n\t\tconst has3PerfectIVs = setSources.minSourceGen() >= 6 && isLegendary && !diancieException;\r\n\r\n\t\tif (set.hpType === 'Fighting' && ruleTable.has('obtainablemisc')) {\r\n\t\t\tif (has3PerfectIVs) {\r\n\t\t\t\t// Legendary Pokemon must have at least 3 perfect IVs in gen 6+\r\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.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (has3PerfectIVs && ruleTable.has('obtainablemisc')) {\r\n\t\t\tlet perfectIVs = 0;\r\n\t\t\tfor (const stat in set.ivs) {\r\n\t\t\t\tif (set.ivs[stat as 'hp'] >= 31) perfectIVs++;\r\n\t\t\t}\r\n\t\t\tif (perfectIVs < 3) {\r\n\t\t\t\tconst reason = (this.minSourceGen === 6 ? ` and this format requires Gen ${dex.gen} Pok\u00E9mon` : ` in Gen 6 or later`);\r\n\t\t\t\tproblems.push(`${name} must have at least three perfect IVs because it's a legendary${reason}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (set.hpType && !canBottleCap) {\r\n\t\t\tconst ivHpType = dex.getHiddenPower(set.ivs).type;\r\n\t\t\tif (set.hpType !== ivHpType) {\r\n\t\t\t\tproblems.push(`${name} has Hidden Power ${set.hpType}, but its IVs are for Hidden Power ${ivHpType}.`);\r\n\t\t\t}\r\n\t\t} else if (set.hpType) {\r\n\t\t\tif (!this.possibleBottleCapHpType(set.hpType, set.ivs)) {\r\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.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (dex.gen <= 2) {\r\n\t\t\t// validate DVs\r\n\t\t\tconst ivs = set.ivs;\r\n\t\t\tconst atkDV = Math.floor(ivs.atk / 2);\r\n\t\t\tconst defDV = Math.floor(ivs.def / 2);\r\n\t\t\tconst speDV = Math.floor(ivs.spe / 2);\r\n\t\t\tconst spcDV = Math.floor(ivs.spa / 2);\r\n\t\t\tconst expectedHpDV = (atkDV % 2) * 8 + (defDV % 2) * 4 + (speDV % 2) * 2 + (spcDV % 2);\r\n\t\t\tif (ivs.hp === -1) ivs.hp = expectedHpDV * 2;\r\n\t\t\tconst hpDV = Math.floor(ivs.hp / 2);\r\n\t\t\tif (expectedHpDV !== hpDV) {\r\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}.`);\r\n\t\t\t}\r\n\t\t\tif (ivs.spa !== ivs.spd) {\r\n\t\t\t\tif (dex.gen === 2) {\r\n\t\t\t\t\tproblems.push(`${name} has different SpA and SpD DVs, which is not possible in Gen 2.`);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tivs.spd = ivs.spa;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (dex.gen > 1 && !species.gender) {\r\n\t\t\t\t// Gen 2 gender is calculated from the Atk DV.\r\n\t\t\t\t// High Atk DV <-> M. The meaning of \"high\" depends on the gender ratio.\r\n\t\t\t\tconst genderThreshold = species.genderRatio.F * 16;\r\n\r\n\t\t\t\tconst expectedGender = (atkDV >= genderThreshold ? 'M' : 'F');\r\n\t\t\t\tif (set.gender && set.gender !== expectedGender) {\r\n\t\t\t\t\tproblems.push(`${name} is ${set.gender}, but it has an Atk DV of ${atkDV}, which makes its gender ${expectedGender}.`);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tset.gender = expectedGender;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tset.species === 'Marowak' && toID(set.item) === 'thickclub' &&\r\n\t\t\t\tset.moves.map(toID).includes('swordsdance' as ID) && set.level === 100\r\n\t\t\t) {\r\n\t\t\t\t// Marowak hack\r\n\t\t\t\tset.ivs.atk = Math.floor(set.ivs.atk / 2) * 2;\r\n\t\t\t\twhile (set.evs.atk > 0 && 2 * 80 + set.ivs.atk + Math.floor(set.evs.atk / 4) + 5 > 255) {\r\n\t\t\t\t\tset.evs.atk -= 4;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (dex.gen > 1) {\r\n\t\t\t\tconst expectedShiny = !!(defDV === 10 && speDV === 10 && spcDV === 10 && atkDV % 4 >= 2);\r\n\t\t\t\tif (expectedShiny && !set.shiny) {\r\n\t\t\t\t\tproblems.push(`${name} is not shiny, which does not match its DVs.`);\r\n\t\t\t\t} else if (!expectedShiny && set.shiny) {\r\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).`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tset.nature = 'Serious';\r\n\t\t}\r\n\r\n\t\tfor (const stat in set.evs) {\r\n\t\t\tif (set.evs[stat as 'hp'] < 0) {\r\n\t\t\t\tproblems.push(`${name} has less than 0 ${allowAVs ? 'Awakening Values' : 'EVs'} in ${Dex.stats.names[stat as 'hp']}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (dex.currentMod === 'gen7letsgo') { // AVs\r\n\t\t\tfor (const stat in set.evs) {\r\n\t\t\t\tif (set.evs[stat as 'hp'] > 0 && !allowAVs) {\r\n\t\t\t\t\tproblems.push(`${name} has Awakening Values but this format doesn't allow them.`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t} else if (set.evs[stat as 'hp'] > 200) {\r\n\t\t\t\t\tproblems.push(`${name} has more than 200 Awakening Values in ${Dex.stats.names[stat as 'hp']}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else { // EVs\r\n\t\t\tfor (const stat in set.evs) {\r\n\t\t\t\tif (set.evs[stat as StatID] > 255) {\r\n\t\t\t\t\tproblems.push(`${name} has more than 255 EVs in ${Dex.stats.names[stat as 'hp']}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (dex.gen <= 2) {\r\n\t\t\t\tif (set.evs.spa !== set.evs.spd) {\r\n\t\t\t\t\tif (dex.gen === 2) {\r\n\t\t\t\t\t\tproblems.push(`${name} has different SpA and SpD EVs, which is not possible in Gen 2.`);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tset.evs.spd = set.evs.spa;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet totalEV = 0;\r\n\t\tfor (const stat in set.evs) totalEV += set.evs[stat as 'hp'];\r\n\t\tif (!this.format.debug) {\r\n\t\t\tif (set.level > 1 && evLimit !== 0 && totalEV === 0) {\r\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).`);\r\n\t\t\t} else if (![508, 510].includes(evLimit!) && [508, 510].includes(totalEV)) {\r\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).`);\r\n\t\t\t}\r\n\t\t\t// Check for level import errors from user in VGC -> DOU, etc.\r\n\t\t\t// Note that in VGC etc (Adjust Level Down = 50), `set.level` will be 100 here for validation purposes\r\n\t\t\tif (set.level === 50 && ruleTable.maxLevel !== 50 && !ruleTable.maxTotalLevel && evLimit !== 0 && totalEV % 4 === 0) {\r\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).`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (evLimit !== null && totalEV > evLimit) {\r\n\t\t\tif (!evLimit) {\r\n\t\t\t\tproblems.push(`${name} has EVs, which is not allowed by this format.`);\r\n\t\t\t} else {\r\n\t\t\t\tproblems.push(`${name} has ${totalEV} total EVs, which is more than this format's limit of ${evLimit}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn problems;\r\n\t}\r\n\r\n\t/**\r\n\t * Not exhaustive, just checks Atk and Spe, which are the only competitively\r\n\t * relevant IVs outside of extremely obscure situations.\r\n\t */\r\n\tpossibleBottleCapHpType(type: string, ivs: StatsTable) {\r\n\t\tif (!type) return true;\r\n\t\tif (['Dark', 'Dragon', 'Grass', 'Ghost', 'Poison'].includes(type)) {\r\n\t\t\t// Spe must be odd\r\n\t\t\tif (ivs.spe % 2 === 0) return false;\r\n\t\t}\r\n\t\tif (['Psychic', 'Fire', 'Rock', 'Fighting'].includes(type)) {\r\n\t\t\t// Spe must be even\r\n\t\t\tif (ivs.spe !== 31 && ivs.spe % 2 === 1) return false;\r\n\t\t}\r\n\t\tif (type === 'Dark') {\r\n\t\t\t// Atk must be odd\r\n\t\t\tif (ivs.atk % 2 === 0) return false;\r\n\t\t}\r\n\t\tif (['Ice', 'Water'].includes(type)) {\r\n\t\t\t// Spe or Atk must be odd\r\n\t\t\tif (ivs.spe % 2 === 0 && ivs.atk % 2 === 0) return false;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\tvalidateSource(\r\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species, because: string\r\n\t): string[] | undefined;\r\n\tvalidateSource(\r\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species\r\n\t): true | undefined;\r\n\t/**\r\n\t * Returns array of error messages if invalid, undefined if valid\r\n\t *\r\n\t * If `because` is not passed, instead returns true if invalid.\r\n\t */\r\n\tvalidateSource(\r\n\t\tset: PokemonSet, source: PokemonSource, setSources: PokemonSources, species: Species, because?: string\r\n\t) {\r\n\t\tlet eventData: EventInfo | undefined;\r\n\t\tlet eventSpecies = species;\r\n\t\tif (source.charAt(1) === 'S') {\r\n\t\t\tconst splitSource = source.substr(source.charAt(2) === 'T' ? 3 : 2).split(' ');\r\n\t\t\tconst dex = (this.dex.gen === 1 ? this.dex.mod('gen2') : this.dex);\r\n\t\t\teventSpecies = dex.species.get(splitSource[1]);\r\n\t\t\tconst eventLsetData = this.dex.species.getLearnsetData(eventSpecies.id);\r\n\t\t\teventData = eventLsetData.eventData?.[parseInt(splitSource[0])];\r\n\t\t\tif (!eventData) {\r\n\t\t\t\tthrow new Error(`${eventSpecies.name} from ${species.name} doesn't have data for event ${source}`);\r\n\t\t\t}\r\n\t\t} else if (source === '7V') {\r\n\t\t\tconst isMew = species.id === 'mew';\r\n\t\t\tconst isCelebi = species.id === 'celebi';\r\n\t\t\tconst g7speciesName = (species.gen > 2 && species.prevo) ? species.prevo : species.id;\r\n\t\t\tconst isHidden = !!this.dex.mod('gen7').species.get(g7speciesName).abilities['H'];\r\n\t\t\teventData = {\r\n\t\t\t\tgeneration: 2,\r\n\t\t\t\tlevel: isMew ? 5 : isCelebi ? 30 : 3, // Level 1/2 Pok\u00E9mon can't be obtained by transfer from RBY/GSC\r\n\t\t\t\tperfectIVs: isMew || isCelebi ? 5 : 3,\r\n\t\t\t\tisHidden,\r\n\t\t\t\tshiny: isMew ? undefined : 1,\r\n\t\t\t\tpokeball: 'pokeball',\r\n\t\t\t\tfrom: 'Gen 1-2 Virtual Console transfer',\r\n\t\t\t};\r\n\t\t} else if (source === '8V') {\r\n\t\t\tconst isMew = species.id === 'mew';\r\n\t\t\teventData = {\r\n\t\t\t\tgeneration: 8,\r\n\t\t\t\tperfectIVs: isMew ? 3 : undefined,\r\n\t\t\t\tshiny: isMew ? undefined : 1,\r\n\t\t\t\tfrom: 'Gen 7 Let\\'s Go! HOME transfer',\r\n\t\t\t};\r\n\t\t} else if (source.charAt(1) === 'D') {\r\n\t\t\teventData = {\r\n\t\t\t\tgeneration: 5,\r\n\t\t\t\tlevel: 10,\r\n\t\t\t\tfrom: 'Gen 5 Dream World',\r\n\t\t\t\tisHidden: !!this.dex.mod('gen5').species.get(species.id).abilities['H'],\r\n\t\t\t};\r\n\t\t} else if (source.charAt(1) === 'E') {\r\n\t\t\tif (this.findEggMoveFathers(source, species, setSources)) {\r\n\t\t\t\treturn undefined;\r\n\t\t\t}\r\n\t\t\tif (because) throw new Error(`Wrong place to get an egg incompatibility message`);\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\tthrow new Error(`Unidentified source ${source} passed to validateSource`);\r\n\t\t}\r\n\r\n\t\t// complicated fancy return signature\r\n\t\treturn this.validateEvent(set, setSources, eventData, eventSpecies, because as any) as any;\r\n\t}\r\n\r\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources): boolean;\r\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources, getAll: true): ID[] | null;\r\n\tfindEggMoveFathers(source: PokemonSource, species: Species, setSources: PokemonSources, getAll = false) {\r\n\t\t// tradebacks have an eggGen of 2 even though the source is 1ET\r\n\t\tconst eggGen = Math.max(parseInt(source.charAt(0)), 2);\r\n\t\tconst fathers: ID[] = [];\r\n\t\t// Gen 6+ don't have egg move incompatibilities\r\n\t\t// (except for certain cases with baby Pokemon not handled here)\r\n\t\tif (!getAll && eggGen >= 6) return true;\r\n\r\n\t\tconst eggMoves = setSources.limitedEggMoves;\r\n\t\t// must have 2 or more egg moves to have egg move incompatibilities\r\n\t\tif (!eggMoves) {\r\n\t\t\t// happens often in gen 1-6 LC if your only egg moves are level-up moves,\r\n\t\t\t// which aren't limited and so aren't in `limitedEggMoves`\r\n\t\t\treturn getAll ? ['*'] : true;\r\n\t\t}\r\n\t\tif (!getAll && eggMoves.length <= 1) return true;\r\n\r\n\t\t// gen 1 eggs come from gen 2 breeding\r\n\t\tconst dex = this.dex.gen === 1 ? this.dex.mod('gen2') : this.dex;\r\n\t\t// In Gen 5 and earlier, egg moves can only be inherited from the father\r\n\t\t// we'll test each possible father separately\r\n\t\tlet eggGroups = species.eggGroups;\r\n\t\tif (species.id === 'nidoqueen' || species.id === 'nidorina') {\r\n\t\t\teggGroups = dex.species.get('nidoranf').eggGroups;\r\n\t\t} else if (species.id === 'shedinja') {\r\n\t\t\t// Shedinja and Nincada are different Egg groups; Shedinja itself is genderless\r\n\t\t\teggGroups = dex.species.get('nincada').eggGroups;\r\n\t\t} else if (dex !== this.dex) {\r\n\t\t\t// Gen 1 tradeback; grab the egg groups from Gen 2\r\n\t\t\teggGroups = dex.species.get(species.id).eggGroups;\r\n\t\t}\r\n\t\tif (eggGroups[0] === 'Undiscovered') eggGroups = dex.species.get(species.evos[0]).eggGroups;\r\n\t\tif (eggGroups[0] === 'Undiscovered' || !eggGroups.length) {\r\n\t\t\tthrow new Error(`${species.name} has no egg groups for source ${source}`);\r\n\t\t}\r\n\t\t// no chainbreeding necessary if the father can be Smeargle\r\n\t\tif (!getAll && eggGroups.includes('Field')) return true;\r\n\r\n\t\t// try to find a father to inherit the egg move combination from\r\n\t\tfor (const father of dex.species.all()) {\r\n\t\t\t// can't inherit from CAP pokemon\r\n\t\t\tif (father.isNonstandard) continue;\r\n\t\t\t// can't breed mons from future gens\r\n\t\t\tif (father.gen > eggGen) continue;\r\n\t\t\t// father must be male\r\n\t\t\tif (father.gender === 'N' || father.gender === 'F') continue;\r\n\t\t\t// can't inherit from dex entries with no learnsets\r\n\t\t\tif (!dex.species.getLearnset(father.id)) continue;\r\n\t\t\t// something is clearly wrong if its only possible father is itself\r\n\t\t\t// (exceptions: ExtremeSpeed Dragonite, Self-destruct Snorlax)\r\n\t\t\tif (species.id === father.id && !['dragonite', 'snorlax'].includes(father.id)) continue;\r\n\t\t\t// don't check NFE Pok\u00E9mon - their evolutions will know all their moves and more\r\n\t\t\t// exception: Combee/Salandit, because their evos can't be fathers\r\n\t\t\tif (father.evos.length) {\r\n\t\t\t\tconst evolvedFather = dex.species.get(father.evos[0]);\r\n\t\t\t\tif (evolvedFather.gen <= eggGen && evolvedFather.gender !== 'F') continue;\r\n\t\t\t}\r\n\r\n\t\t\t// must be able to breed with father\r\n\t\t\tif (!father.eggGroups.some(eggGroup => eggGroups.includes(eggGroup))) continue;\r\n\r\n\t\t\t// father must be able to learn the move\r\n\t\t\tif (!this.fatherCanLearn(father, eggMoves, eggGen)) continue;\r\n\r\n\t\t\t// father found!\r\n\t\t\tif (!getAll) return true;\r\n\t\t\tfathers.push(father.id);\r\n\t\t}\r\n\t\tif (!getAll) return false;\r\n\t\treturn (!fathers.length && eggGen < 6) ? null : fathers;\r\n\t}\r\n\r\n\t/**\r\n\t * We could, if we wanted, do a complete move validation of the father's\r\n\t * moveset to see if it's valid. This would recurse and be NP-Hard so\r\n\t * instead we won't. We'll instead use a simplified algorithm: The father\r\n\t * can learn the moveset if it has at most one egg/event move.\r\n\t *\r\n\t * `eggGen` should be 5 or earlier. Later gens should never call this\r\n\t * function (the answer is always yes).\r\n\t */\r\n\tfatherCanLearn(species: Species, moves: ID[], eggGen: number) {\r\n\t\tlet learnset = this.dex.species.getLearnset(species.id);\r\n\t\tif (!learnset) return false;\r\n\r\n\t\tif (species.id === 'smeargle') return true;\r\n\t\tconst canBreedWithSmeargle = species.eggGroups.includes('Field');\r\n\r\n\t\tlet eggMoveCount = 0;\r\n\t\tfor (const move of moves) {\r\n\t\t\tlet curSpecies: Species | null = species;\r\n\t\t\t/** 1 = can learn from egg, 2 = can learn unrestricted */\r\n\t\t\tlet canLearn: 0 | 1 | 2 = 0;\r\n\r\n\t\t\twhile (curSpecies) {\r\n\t\t\t\tlearnset = this.dex.species.getLearnset(curSpecies.id);\r\n\t\t\t\tif (learnset && learnset[move]) {\r\n\t\t\t\t\tfor (const moveSource of learnset[move]) {\r\n\t\t\t\t\t\tif (parseInt(moveSource.charAt(0)) > eggGen) continue;\r\n\t\t\t\t\t\tconst canLearnFromSmeargle = moveSource.charAt(1) === 'E' && canBreedWithSmeargle;\r\n\t\t\t\t\t\tif (!'ESDV'.includes(moveSource.charAt(1)) || canLearnFromSmeargle) {\r\n\t\t\t\t\t\t\tcanLearn = 2;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tcanLearn = 1;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (canLearn === 2) break;\r\n\t\t\t\tcurSpecies = this.learnsetParent(curSpecies);\r\n\t\t\t}\r\n\r\n\t\t\tif (!canLearn) return false;\r\n\t\t\tif (canLearn === 1) {\r\n\t\t\t\teggMoveCount++;\r\n\t\t\t\tif (eggMoveCount > 1) return false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\tvalidateForme(set: PokemonSet) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst name = set.name || set.species;\r\n\r\n\t\tconst problems = [];\r\n\t\tconst item = dex.items.get(set.item);\r\n\t\tconst species = dex.species.get(set.species);\r\n\r\n\t\tif (species.name === 'Necrozma-Ultra') {\r\n\t\t\tconst whichMoves = (set.moves.includes('sunsteelstrike') ? 1 : 0) +\r\n\t\t\t\t(set.moves.includes('moongeistbeam') ? 2 : 0);\r\n\t\t\tif (item.name !== 'Ultranecrozium Z') {\r\n\t\t\t\t// Necrozma-Ultra transforms from one of two formes, and neither one is the base forme\r\n\t\t\t\tproblems.push(`Necrozma-Ultra must start the battle holding Ultranecrozium Z.`);\r\n\t\t\t} else if (whichMoves === 1) {\r\n\t\t\t\tset.species = 'Necrozma-Dusk-Mane';\r\n\t\t\t} else if (whichMoves === 2) {\r\n\t\t\t\tset.species = 'Necrozma-Dawn-Wings';\r\n\t\t\t} else {\r\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.`);\r\n\t\t\t}\r\n\t\t} else if (species.name === 'Zygarde-Complete') {\r\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.`);\r\n\t\t} else if (species.battleOnly) {\r\n\t\t\tif (species.requiredAbility && set.ability !== species.requiredAbility) {\r\n\t\t\t\t// Darmanitan-Zen\r\n\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredAbility}, please fix its ability.`);\r\n\t\t\t}\r\n\t\t\tif (species.requiredItems) {\r\n\t\t\t\tif (!species.requiredItems.includes(item.name)) {\r\n\t\t\t\t\t// Mega or Primal\r\n\t\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredItem}, please fix its item.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (species.requiredMove && !set.moves.map(toID).includes(toID(species.requiredMove))) {\r\n\t\t\t\t// Meloetta-Pirouette, Rayquaza-Mega\r\n\t\t\t\tproblems.push(`${species.name} transforms in-battle with ${species.requiredMove}, please fix its moves.`);\r\n\t\t\t}\r\n\t\t\tif (typeof species.battleOnly !== 'string') {\r\n\t\t\t\t// Ultra Necrozma and Complete Zygarde are already checked above\r\n\t\t\t\tthrow new Error(`${species.name} should have a string battleOnly`);\r\n\t\t\t}\r\n\t\t\t// Set to out-of-battle forme\r\n\t\t\tset.species = species.battleOnly;\r\n\t\t} else {\r\n\t\t\tif (species.requiredAbility) {\r\n\t\t\t\t// Impossible!\r\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.`);\r\n\t\t\t}\r\n\t\t\tif (species.requiredItems && !species.requiredItems.includes(item.name)) {\r\n\t\t\t\tif (dex.gen >= 8 && (species.baseSpecies === 'Arceus' || species.baseSpecies === 'Silvally')) {\r\n\t\t\t\t\t// Arceus/Silvally formes in gen 8 only require the item with Multitype/RKS System\r\n\t\t\t\t\tif (set.ability === species.abilities[0]) {\r\n\t\t\t\t\t\tproblems.push(\r\n\t\t\t\t\t\t\t`${name} needs to hold ${species.requiredItems.join(' or ')}.`,\r\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.)`\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Memory/Drive/Griseous Orb/Plate/Z-Crystal - Forme mismatch\r\n\t\t\t\t\tconst baseSpecies = this.dex.species.get(species.changesFrom);\r\n\t\t\t\t\tproblems.push(\r\n\t\t\t\t\t\t`${name} needs to hold ${species.requiredItems.join(' or ')} to be in its ${species.forme} forme.`,\r\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.)`\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (species.requiredMove && !set.moves.map(toID).includes(toID(species.requiredMove))) {\r\n\t\t\t\tconst baseSpecies = this.dex.species.get(species.changesFrom);\r\n\t\t\t\tproblems.push(\r\n\t\t\t\t\t`${name} needs to know the move ${species.requiredMove} to be in its ${species.forme} forme.`,\r\n\t\t\t\t\t`(It will revert to its ${baseSpecies.baseForme} forme if it forgets the move.)`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t// Mismatches between the set forme (if not base) and the item signature forme will have been rejected already.\r\n\t\t\t// It only remains to assign the right forme to a set with the base species (Arceus/Genesect/Giratina/Silvally).\r\n\t\t\tif (item.forcedForme && species.name === dex.species.get(item.forcedForme).baseSpecies) {\r\n\t\t\t\tset.species = item.forcedForme;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (species.name === 'Pikachu-Cosplay') {\r\n\t\t\tconst cosplay: {[k: string]: string} = {\r\n\t\t\t\tmeteormash: 'Pikachu-Rock-Star', iciclecrash: 'Pikachu-Belle', drainingkiss: 'Pikachu-Pop-Star',\r\n\t\t\t\telectricterrain: 'Pikachu-PhD', flyingpress: 'Pikachu-Libre',\r\n\t\t\t};\r\n\t\t\tfor (const moveid of set.moves) {\r\n\t\t\t\tif (moveid in cosplay) {\r\n\t\t\t\t\tset.species = cosplay[moveid];\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (species.name === 'Keldeo' && set.moves.map(toID).includes('secretsword' as ID) && dex.gen >= 8) {\r\n\t\t\tset.species = 'Keldeo-Resolute';\r\n\t\t}\r\n\r\n\t\tconst crowned: {[k: string]: string} = {\r\n\t\t\t'Zacian-Crowned': 'behemothblade', 'Zamazenta-Crowned': 'behemothbash',\r\n\t\t};\r\n\t\tif (species.name in crowned) {\r\n\t\t\tconst behemothMove = set.moves.map(toID).indexOf(crowned[species.name] as ID);\r\n\t\t\tif (behemothMove >= 0) {\r\n\t\t\t\tset.moves[behemothMove] = 'ironhead';\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn problems;\r\n\t}\r\n\r\n\tcheckSpecies(set: PokemonSet, species: Species, tierSpecies: Species, setHas: {[k: string]: true}) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\t// https://www.smogon.com/forums/posts/8659168\r\n\t\tif (\r\n\t\t\t(tierSpecies.id === 'zamazentacrowned' && species.id === 'zamazenta') ||\r\n\t\t\t(tierSpecies.id === 'zaciancrowned' && species.id === 'zacian')\r\n\t\t) {\r\n\t\t\tspecies = tierSpecies;\r\n\t\t}\r\n\r\n\t\tsetHas['pokemon:' + species.id] = true;\r\n\t\tsetHas['basepokemon:' + toID(species.baseSpecies)] = true;\r\n\r\n\t\tlet isMega = false;\r\n\t\tif (tierSpecies !== species) {\r\n\t\t\tsetHas['pokemon:' + tierSpecies.id] = true;\r\n\t\t\tif (tierSpecies.isMega || tierSpecies.isPrimal) {\r\n\t\t\t\tsetHas['pokemontag:mega'] = true;\r\n\t\t\t\tisMega = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet isGmax = false;\r\n\t\tif (tierSpecies.canGigantamax && set.gigantamax) {\r\n\t\t\tsetHas['pokemon:' + tierSpecies.id + 'gmax'] = true;\r\n\t\t\tisGmax = true;\r\n\t\t}\r\n\r\n\t\tconst tier = tierSpecies.tier === '(PU)' ? 'ZU' : tierSpecies.tier === '(NU)' ? 'PU' : tierSpecies.tier;\r\n\t\tconst tierTag = 'pokemontag:' + toID(tier);\r\n\t\tsetHas[tierTag] = true;\r\n\r\n\t\tconst doublesTier = tierSpecies.doublesTier === '(DUU)' ? 'DNU' : tierSpecies.doublesTier;\r\n\t\tconst doublesTierTag = 'pokemontag:' + toID(doublesTier);\r\n\t\tsetHas[doublesTierTag] = true;\r\n\r\n\t\tconst ndTier = tierSpecies.natDexTier === '(PU)' ? 'ZU' :\r\n\t\t\ttierSpecies.natDexTier === '(NU)' ? 'PU' : tierSpecies.natDexTier;\r\n\t\tconst ndTierTag = 'pokemontag:nd' + toID(ndTier);\r\n\t\tsetHas[ndTierTag] = true;\r\n\r\n\t\t// Only pokemon that can gigantamax should have the Gmax flag\r\n\t\tif (!tierSpecies.canGigantamax && set.gigantamax) {\r\n\t\t\treturn `${tierSpecies.name} cannot Gigantamax but is flagged as being able to.`;\r\n\t\t}\r\n\r\n\t\tlet banReason = ruleTable.check('pokemon:' + species.id);\r\n\t\tif (banReason) {\r\n\t\t\treturn `${species.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') return null;\r\n\r\n\t\tif (tierSpecies !== species) {\r\n\t\t\tbanReason = ruleTable.check('pokemon:' + tierSpecies.id);\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `${tierSpecies.name} is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\tif (isMega) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:mega', setHas);\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `Mega evolutions are ${banReason}.`;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (isGmax) {\r\n\t\t\tbanReason = ruleTable.check('pokemon:' + tierSpecies.id + 'gmax');\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `Gigantamaxing ${species.name} is ${banReason}.`;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tbanReason = ruleTable.check('basepokemon:' + toID(species.baseSpecies));\r\n\t\tif (banReason) {\r\n\t\t\treturn `${species.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') {\r\n\t\t\t// don't allow nonstandard speciess when whitelisting standard base species\r\n\t\t\t// i.e. unbanning Pichu doesn't mean allowing Pichu-Spiky-Eared outside of Gen 4\r\n\t\t\tconst baseSpecies = dex.species.get(species.baseSpecies);\r\n\t\t\tif (baseSpecies.isNonstandard === species.isNonstandard) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// We can't return here because the `-nonexistent` rule is a bit\r\n\t\t// complicated in terms of what trumps it. We don't want e.g.\r\n\t\t// +Mythical to unban Shaymin in Gen 1, for instance.\r\n\t\tlet nonexistentCheck = Tags.nonexistent.genericFilter!(tierSpecies) && ruleTable.check('nonexistent');\r\n\r\n\t\tconst EXISTENCE_TAG = ['past', 'future', 'lgpe', 'unobtainable', 'cap', 'custom', 'nonexistent'];\r\n\r\n\t\tfor (const ruleid of ruleTable.tagRules) {\r\n\t\t\tif (ruleid.startsWith('*')) continue;\r\n\t\t\tconst tagid = ruleid.slice(12);\r\n\t\t\tconst tag = Tags[tagid];\r\n\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(tierSpecies)) {\r\n\t\t\t\tconst existenceTag = EXISTENCE_TAG.includes(tagid);\r\n\t\t\t\tif (ruleid.startsWith('+')) {\r\n\t\t\t\t\t// we want rules like +CAP to trump -Nonexistent, but most tags shouldn't\r\n\t\t\t\t\tif (!existenceTag && nonexistentCheck) continue;\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t}\r\n\t\t\t\tif (existenceTag) {\r\n\t\t\t\t\t// for a nicer error message\r\n\t\t\t\t\tnonexistentCheck = 'banned';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${species.name} is tagged ${tag.name}, which is ${ruleTable.check(ruleid.slice(1)) || \"banned\"}.`;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (nonexistentCheck) {\r\n\t\t\tif (tierSpecies.isNonstandard === 'Past' || tierSpecies.isNonstandard === 'Future') {\r\n\t\t\t\treturn `${tierSpecies.name} does not exist in Gen ${dex.gen}.`;\r\n\t\t\t}\r\n\t\t\tif (tierSpecies.isNonstandard === 'LGPE') {\r\n\t\t\t\treturn `${tierSpecies.name} does not exist in this game, only in Let's Go Pikachu/Eevee.`;\r\n\t\t\t}\r\n\t\t\tif (tierSpecies.isNonstandard === 'CAP') {\r\n\t\t\t\treturn `${tierSpecies.name} is a CAP and does not exist in this game.`;\r\n\t\t\t}\r\n\t\t\tif (tierSpecies.isNonstandard === 'Unobtainable') {\r\n\t\t\t\treturn `${tierSpecies.name} is not possible to obtain in this game.`;\r\n\t\t\t}\r\n\t\t\tif (tierSpecies.isNonstandard === 'Gigantamax') {\r\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.)`;\r\n\t\t\t}\r\n\t\t\treturn `${tierSpecies.name} does not exist in this game.`;\r\n\t\t}\r\n\t\tif (nonexistentCheck === '') return null;\r\n\r\n\t\t// Special casing for Pokemon that can Gmax, but their Gmax factor cannot be legally obtained\r\n\t\tif (tierSpecies.gmaxUnreleased && set.gigantamax) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:unobtainable');\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `${tierSpecies.name} is flagged as gigantamax, but it cannot gigantamax without hacking or glitches.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\tbanReason = ruleTable.check('pokemontag:allpokemon');\r\n\t\tif (banReason) {\r\n\t\t\treturn `${species.name} is not in the list of allowed pokemon.`;\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tcheckItem(set: PokemonSet, item: Item, setHas: {[k: string]: true}) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tsetHas['item:' + item.id] = true;\r\n\r\n\t\tlet banReason = ruleTable.check('item:' + (item.id || 'noitem'));\r\n\t\tif (banReason) {\r\n\t\t\tif (!item.id) {\r\n\t\t\t\treturn `${set.name} not holding an item is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\treturn `${set.name}'s item ${item.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') return null;\r\n\r\n\t\tif (!item.id) return null;\r\n\r\n\t\tbanReason = ruleTable.check('pokemontag:allitems');\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s item ${item.name} is not in the list of allowed items.`;\r\n\t\t}\r\n\r\n\t\t// obtainability\r\n\t\tif (item.isNonstandard) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(item.isNonstandard));\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (item.isNonstandard === 'Unobtainable') {\r\n\t\t\t\t\treturn `${item.name} is not obtainable without hacking or glitches.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s item ${item.name} is tagged ${item.isNonstandard}, which is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\tif (item.isNonstandard && item.isNonstandard !== 'Unobtainable') {\r\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (['Past', 'Future'].includes(item.isNonstandard)) {\r\n\t\t\t\t\treturn `${set.name}'s item ${item.name} does not exist in Gen ${dex.gen}.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s item ${item.name} does not exist in this game.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tcheckMove(set: PokemonSet, move: Move, setHas: {[k: string]: true}) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tsetHas['move:' + move.id] = true;\r\n\r\n\t\tlet banReason = ruleTable.check('move:' + move.id);\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s move ${move.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') return null;\r\n\r\n\t\tbanReason = ruleTable.check('pokemontag:allmoves');\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s move ${move.name} is not in the list of allowed moves.`;\r\n\t\t}\r\n\r\n\t\t// obtainability\r\n\t\tif (move.isNonstandard) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(move.isNonstandard));\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (move.isNonstandard === 'Unobtainable') {\r\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}` : ``}.`;\r\n\t\t\t\t}\r\n\t\t\t\tif (move.isNonstandard === 'Gigantamax') {\r\n\t\t\t\t\treturn `${move.name} is not usable without Gigantamaxing its user, ${move.isMax}.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s move ${move.name} is tagged ${move.isNonstandard}, which is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\tif (move.isNonstandard && move.isNonstandard !== 'Unobtainable') {\r\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (['Past', 'Future'].includes(move.isNonstandard)) {\r\n\t\t\t\t\treturn `${set.name}'s move ${move.name} does not exist in Gen ${dex.gen}.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s move ${move.name} does not exist in this game.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tcheckAbility(set: PokemonSet, ability: Ability, setHas: {[k: string]: true}) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tsetHas['ability:' + ability.id] = true;\r\n\r\n\t\tif (this.format.id.startsWith('gen9pokebilities')) {\r\n\t\t\tconst species = dex.species.get(set.species);\r\n\t\t\tconst unSeenAbilities = Object.keys(species.abilities)\r\n\t\t\t\t.filter(key => key !== 'S' && (key !== 'H' || !species.unreleasedHidden))\r\n\t\t\t\t.map(key => species.abilities[key as \"0\" | \"1\" | \"H\" | \"S\"]);\r\n\r\n\t\t\tif (ability.id !== this.toID(species.abilities['S'])) {\r\n\t\t\t\tfor (const abilityName of unSeenAbilities) {\r\n\t\t\t\t\tsetHas['ability:' + toID(abilityName)] = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet banReason = ruleTable.check('ability:' + ability.id);\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s ability ${ability.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') return null;\r\n\r\n\t\tbanReason = ruleTable.check('pokemontag:allabilities');\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s ability ${ability.name} is not in the list of allowed abilities.`;\r\n\t\t}\r\n\r\n\t\t// obtainability\r\n\t\tif (ability.isNonstandard) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(ability.isNonstandard));\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `${set.name}'s ability ${ability.name} is tagged ${ability.isNonstandard}, which is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\r\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (['Past', 'Future'].includes(ability.isNonstandard)) {\r\n\t\t\t\t\treturn `${set.name}'s ability ${ability.name} does not exist in Gen ${dex.gen}.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s ability ${ability.name} does not exist in this game.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tcheckNature(set: PokemonSet, nature: Nature, setHas: {[k: string]: true}) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tsetHas['nature:' + nature.id] = true;\r\n\r\n\t\tlet banReason = ruleTable.check('nature:' + nature.id);\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s nature ${nature.name} is ${banReason}.`;\r\n\t\t}\r\n\t\tif (banReason === '') return null;\r\n\r\n\t\tbanReason = ruleTable.check('allnatures');\r\n\t\tif (banReason) {\r\n\t\t\treturn `${set.name}'s nature ${nature.name} is not in the list of allowed natures.`;\r\n\t\t}\r\n\r\n\t\t// obtainability\r\n\t\tif (nature.isNonstandard) {\r\n\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(nature.isNonstandard));\r\n\t\t\tif (banReason) {\r\n\t\t\t\treturn `${set.name}'s nature ${nature.name} is tagged ${nature.isNonstandard}, which is ${banReason}.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\r\n\t\t\tbanReason = ruleTable.check('nonexistent', setHas);\r\n\t\t\tif (banReason) {\r\n\t\t\t\tif (['Past', 'Future'].includes(nature.isNonstandard)) {\r\n\t\t\t\t\treturn `${set.name}'s nature ${nature.name} does not exist in Gen ${dex.gen}.`;\r\n\t\t\t\t}\r\n\t\t\t\treturn `${set.name}'s nature ${nature.name} does not exist in this game.`;\r\n\t\t\t}\r\n\t\t\tif (banReason === '') return null;\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\tvalidateEvent(\r\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species\r\n\t): true | undefined;\r\n\tvalidateEvent(\r\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species,\r\n\t\tbecause: string, from?: string\r\n\t): string[] | undefined;\r\n\t/**\r\n\t * Returns array of error messages if invalid, undefined if valid\r\n\t *\r\n\t * If `because` is not passed, instead returns true if invalid.\r\n\t */\r\n\tvalidateEvent(\r\n\t\tset: PokemonSet, setSources: PokemonSources, eventData: EventInfo, eventSpecies: Species,\r\n\t\tbecause = ``, from = `from an event`\r\n\t) {\r\n\t\tconst dex = this.dex;\r\n\t\tlet name = set.species;\r\n\t\tconst species = dex.species.get(set.species);\r\n\t\tconst maxSourceGen = this.ruleTable.has('allowtradeback') ? Utils.clampIntRange(dex.gen + 1, 1, 8) : dex.gen;\r\n\t\tif (!eventSpecies) eventSpecies = species;\r\n\t\tif (set.name && set.species !== set.name && species.baseSpecies !== set.name) name = `${set.name} (${set.species})`;\r\n\r\n\t\tconst fastReturn = !because;\r\n\t\tif (eventData.from) from = `from ${eventData.from}`;\r\n\t\tconst etc = `${because} ${from}`;\r\n\r\n\t\tconst problems = [];\r\n\r\n\t\tif (dex.gen < 8 && this.minSourceGen > eventData.generation) {\r\n\t\t\tif (fastReturn) return true;\r\n\t\t\tproblems.push(`This format requires Pokemon from gen ${this.minSourceGen} or later and ${name} is from gen ${eventData.generation}${etc}.`);\r\n\t\t}\r\n\t\tif (maxSourceGen < eventData.generation) {\r\n\t\t\tif (fastReturn) return true;\r\n\t\t\tproblems.push(`This format is in gen ${dex.gen} and ${name} is from gen ${eventData.generation}${etc}.`);\r\n\t\t}\r\n\r\n\t\tif (eventData.japan && dex.currentMod !== 'gen1jpn') {\r\n\t\t\tif (fastReturn) return true;\r\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.`);\r\n\t\t}\r\n\r\n\t\tif (eventData.level && (set.level || 0) < eventData.level) {\r\n\t\t\tif (fastReturn) return true;\r\n\t\t\tproblems.push(`${name} must be at least level ${eventData.level}${etc}.`);\r\n\t\t}\r\n\t\tif ((eventData.shiny === true && !set.shiny) || (!eventData.shiny && set.shiny)) {\r\n\t\t\tif (fastReturn) return true;\r\n\t\t\tconst shinyReq = eventData.shiny ? ` be shiny` : ` not be shiny`;\r\n\t\t\tproblems.push(`${name} must${shinyReq}${etc}.`);\r\n\t\t}\r\n\t\tif (eventData.gender) {\r\n\t\t\tif (set.gender && eventData.gender !== set.gender) {\r\n\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\tproblems.push(`${name}'s gender must be ${eventData.gender}${etc}.`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst canMint = dex.gen > 7;\r\n\t\tif (eventData.nature && eventData.nature !== set.nature && !canMint) {\r\n\t\t\tif (fastReturn) return true;\r\n\t\t\tproblems.push(`${name} must have a ${eventData.nature} nature${etc} - Mints are only available starting gen 8.`);\r\n\t\t}\r\n\t\tlet requiredIVs = 0;\r\n\t\tif (eventData.ivs) {\r\n\t\t\t/** In Gen 7+, IVs can be changed to 31 */\r\n\t\t\tconst canBottleCap = dex.gen >= 7 && set.level >= (dex.gen < 9 ? 100 : 50);\r\n\r\n\t\t\tif (!set.ivs) set.ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};\r\n\t\t\tlet statName: StatID;\r\n\t\t\tfor (statName in eventData.ivs) {\r\n\t\t\t\tif (canBottleCap && set.ivs[statName] === 31) continue;\r\n\t\t\t\tif (set.ivs[statName] !== eventData.ivs[statName]) {\r\n\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\tproblems.push(`${name} must have ${eventData.ivs[statName]} ${Dex.stats.names[statName]} IVs${etc}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (canBottleCap) {\r\n\t\t\t\t// IVs can be overridden but Hidden Power type can't\r\n\t\t\t\tif (Object.keys(eventData.ivs).length >= 6) {\r\n\t\t\t\t\tconst requiredHpType = dex.getHiddenPower(eventData.ivs).type;\r\n\t\t\t\t\tif (set.hpType && set.hpType !== requiredHpType) {\r\n\t\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\t\tproblems.push(`${name} can only have Hidden Power ${requiredHpType}${etc}.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tset.hpType = requiredHpType;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\trequiredIVs = eventData.perfectIVs || 0;\r\n\t\t}\r\n\t\tif (requiredIVs && set.ivs) {\r\n\t\t\t// Legendary Pokemon must have at least 3 perfect IVs in gen 6\r\n\t\t\t// Events can also have a certain amount of guaranteed perfect IVs\r\n\t\t\tlet perfectIVs = 0;\r\n\t\t\tlet statName: StatID;\r\n\t\t\tfor (statName in set.ivs) {\r\n\t\t\t\tif (set.ivs[statName] >= 31) perfectIVs++;\r\n\t\t\t}\r\n\t\t\tif (perfectIVs < requiredIVs) {\r\n\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\tif (eventData.perfectIVs) {\r\n\t\t\t\t\tproblems.push(`${name} must have at least ${requiredIVs} perfect IVs${etc}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// The perfect IV count affects Hidden Power availability\r\n\t\t\tif (dex.gen >= 3 && requiredIVs >= 3 && set.hpType === 'Fighting') {\r\n\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\tproblems.push(`${name} can't use Hidden Power Fighting because it must have at least three perfect IVs${etc}.`);\r\n\t\t\t} else if (dex.gen >= 3 && requiredIVs >= 5 && set.hpType &&\r\n\t\t\t\t\t!['Dark', 'Dragon', 'Electric', 'Steel', 'Ice'].includes(set.hpType)) {\r\n\t\t\t\tif (fastReturn) return true;\r\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}.`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst ruleTable = this.ruleTable;\r\n\t\tif (ruleTable.has('obtainablemoves')) {\r\n\t\t\tconst ssMaxSourceGen = setSources.maxSourceGen();\r\n\t\t\tconst tradebackEligible = dex.gen === 2 && (species.gen === 1 || eventSpecies.gen === 1);\r\n\t\t\tif (ssMaxSourceGen && eventData.generation > ssMaxSourceGen && !tradebackEligible) {\r\n\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\tproblems.push(`${name} must not have moves only learnable in gen ${ssMaxSourceGen}${etc}.`);\r\n\t\t\t}\r\n\r\n\t\t\tif (eventData.from === \"Gen 5 Dream World\" && setSources.dreamWorldMoveCount > 1) {\r\n\t\t\t\tproblems.push(`${name} can only have one Dream World move.`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (ruleTable.has('obtainableabilities')) {\r\n\t\t\tif (dex.gen <= 5 && eventData.abilities && eventData.abilities.length === 1 && !eventData.isHidden) {\r\n\t\t\t\tif (species.name === eventSpecies.name) {\r\n\t\t\t\t\t// has not evolved, abilities must match\r\n\t\t\t\t\tconst requiredAbility = dex.abilities.get(eventData.abilities[0]).name;\r\n\t\t\t\t\tif (set.ability !== requiredAbility) {\r\n\t\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\t\tproblems.push(`${name} must have ${requiredAbility}${etc}.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// has evolved\r\n\t\t\t\t\tconst ability1 = dex.abilities.get(eventSpecies.abilities['1']);\r\n\t\t\t\t\tif (ability1.gen && eventData.generation >= ability1.gen) {\r\n\t\t\t\t\t\t// pokemon had 2 available abilities in the gen the event happened\r\n\t\t\t\t\t\t// ability is restricted to a single ability slot\r\n\t\t\t\t\t\tconst requiredAbilitySlot = (toID(eventData.abilities[0]) === ability1.id ? 1 : 0);\r\n\t\t\t\t\t\tconst requiredAbility = dex.abilities.get(species.abilities[requiredAbilitySlot] || species.abilities['0']).name;\r\n\t\t\t\t\t\tif (set.ability !== requiredAbility) {\r\n\t\t\t\t\t\t\tconst originalAbility = dex.abilities.get(eventData.abilities[0]).name;\r\n\t\t\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\t\t\tproblems.push(`${name} must have ${requiredAbility}${because} from a ${originalAbility} ${eventSpecies.name} event.`);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (species.abilities['H']) {\r\n\t\t\t\tconst isHidden = (set.ability === species.abilities['H']);\r\n\t\t\t\tif (!isHidden && eventData.isHidden && dex.gen <= 8) {\r\n\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\tproblems.push(`${name} must have its Hidden Ability${etc}.`);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && this.format.mod !== 'gen8dlc1';\r\n\t\t\t\tif (isHidden && !eventData.isHidden && !canUseAbilityPatch) {\r\n\t\t\t\t\tif (fastReturn) return true;\r\n\t\t\t\t\tproblems.push(`${name} must not have its Hidden Ability${etc}.`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (problems.length) return problems;\r\n\t\tif (eventData.gender) set.gender = eventData.gender;\r\n\t}\r\n\r\n\tallSources(species?: Species) {\r\n\t\tlet minSourceGen = this.minSourceGen;\r\n\t\tif (this.dex.gen >= 3 && minSourceGen < 3) minSourceGen = 3;\r\n\t\tif (species) minSourceGen = Math.max(minSourceGen, species.gen);\r\n\t\tconst maxSourceGen = this.ruleTable.has('allowtradeback') ? Utils.clampIntRange(this.dex.gen + 1, 1, 8) : this.dex.gen;\r\n\t\treturn new PokemonSources(maxSourceGen, minSourceGen);\r\n\t}\r\n\r\n\tvalidateMoves(\r\n\t\tspecies: Species, moves: string[], setSources: PokemonSources, set?: Partial,\r\n\t\tname: string = species.name, moveLegalityWhitelist: {[k: string]: true | undefined} = {}\r\n\t) {\r\n\t\tconst dex = this.dex;\r\n\t\tconst ruleTable = this.ruleTable;\r\n\r\n\t\tconst problems = [];\r\n\r\n\t\tconst checkCanLearn = (ruleTable.checkCanLearn?.[0] || this.checkCanLearn);\r\n\t\tfor (const moveName of moves) {\r\n\t\t\tconst move = dex.moves.get(moveName);\r\n\t\t\tif (moveLegalityWhitelist[move.id]) continue;\r\n\t\t\tconst problem = checkCanLearn.call(this, move, species, setSources, set);\r\n\t\t\tif (problem) {\r\n\t\t\t\tproblems.push(`${name}${problem}`);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (setSources.size() && setSources.moveEvoCarryCount > 3) {\r\n\t\t\tif (setSources.sourcesBefore < 6) setSources.sourcesBefore = 0;\r\n\t\t\tsetSources.sources = setSources.sources.filter(\r\n\t\t\t\tsource => source.charAt(1) === 'E' && parseInt(source.charAt(0)) >= 6\r\n\t\t\t);\r\n\t\t\tif (!setSources.size()) {\r\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}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (problems.length) return problems;\r\n\r\n\t\tif (setSources.isHidden) {\r\n\t\t\tsetSources.sources = setSources.sources.filter(\r\n\t\t\t\tsource => parseInt(source.charAt(0)) >= 5\r\n\t\t\t);\r\n\t\t\tif (setSources.sourcesBefore < 5) setSources.sourcesBefore = 0;\r\n\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && this.format.mod !== 'gen8dlc1';\r\n\t\t\tif (!setSources.size() && !canUseAbilityPatch) {\r\n\t\t\t\tproblems.push(`${name} has a hidden ability - it can't have moves only learned before gen 5.`);\r\n\t\t\t\treturn problems;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (setSources.babyOnly && setSources.sources.length) {\r\n\t\t\tconst baby = dex.species.get(setSources.babyOnly);\r\n\t\t\tconst babyEvo = toID(baby.evos[0]);\r\n\t\t\tsetSources.sources = setSources.sources.filter(source => {\r\n\t\t\t\tif (source.charAt(1) === 'S') {\r\n\t\t\t\t\tconst sourceId = source.split(' ')[1];\r\n\t\t\t\t\tif (sourceId !== baby.id) return false;\r\n\t\t\t\t}\r\n\t\t\t\tif (source.charAt(1) === 'E') {\r\n\t\t\t\t\tif (babyEvo && source.slice(2) === babyEvo) return false;\r\n\t\t\t\t}\r\n\t\t\t\tif (source.charAt(1) === 'D') {\r\n\t\t\t\t\tif (babyEvo && source.slice(2) === babyEvo) return false;\r\n\t\t\t\t}\r\n\t\t\t\treturn true;\r\n\t\t\t});\r\n\t\t\tif (!setSources.size()) {\r\n\t\t\t\tproblems.push(`${name}'s event/egg moves are from an evolution, and are incompatible with its moves from ${baby.name}.`);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (setSources.babyOnly && setSources.size() && this.gen > 2) {\r\n\t\t\t// there do theoretically exist evo/tradeback incompatibilities in\r\n\t\t\t// gen 2, but those are very complicated to validate and should be\r\n\t\t\t// handled separately anyway, so for now we just treat them all as\r\n\t\t\t// legal (competitively relevant ones can be manually banned)\r\n\t\t\tconst baby = dex.species.get(setSources.babyOnly);\r\n\t\t\tsetSources.sources = setSources.sources.filter(source => {\r\n\t\t\t\tif (baby.gen > parseInt(source.charAt(0)) && !source.startsWith('1ST')) return false;\r\n\t\t\t\tif (baby.gen > 2 && source === '7V') return false;\r\n\t\t\t\treturn true;\r\n\t\t\t});\r\n\t\t\tif (setSources.sourcesBefore < baby.gen) setSources.sourcesBefore = 0;\r\n\t\t\tif (!setSources.size()) {\r\n\t\t\t\tproblems.push(`${name} has moves from before Gen ${baby.gen}, which are incompatible with its moves from ${baby.name}.`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn problems;\r\n\t}\r\n\r\n\tomCheckCanLearn(\r\n\t\tmove: Move,\r\n\t\ts: Species,\r\n\t\tsetSources = this.allSources(s),\r\n\t\tset: Partial = {},\r\n\t\tproblem = `${set.name || s.name} can't learn ${move.name}`,\r\n\t): string | null {\r\n\t\tif (!this.ruleTable.checkCanLearn?.[0]) return problem;\r\n\t\tconst baseCheckCanLearn = this.checkCanLearn;\r\n\t\t// tell the custom move legality check that the move is illegal by default\r\n\t\tthis.checkCanLearn = () => problem;\r\n\t\tconst omVerdict = this.ruleTable.checkCanLearn[0].call(this, move, s, setSources, set);\r\n\t\tthis.checkCanLearn = baseCheckCanLearn;\r\n\t\treturn omVerdict;\r\n\t}\r\n\r\n\t/** Returns null if you can learn the move, or a string explaining why you can't learn it */\r\n\tcheckCanLearn(\r\n\t\tmove: Move,\r\n\t\ts: Species,\r\n\t\tsetSources = this.allSources(s),\r\n\t\tset: Partial = {}\r\n\t): string | null {\r\n\t\tconst dex = this.dex;\r\n\t\tif (!setSources.size()) throw new Error(`Bad sources passed to checkCanLearn`);\r\n\r\n\t\tmove = dex.moves.get(move);\r\n\t\tconst moveid = move.id;\r\n\t\tconst baseSpecies = dex.species.get(s);\r\n\t\tlet species: Species | null = baseSpecies;\r\n\r\n\t\tconst format = this.format;\r\n\t\tconst ruleTable = dex.formats.getRuleTable(format);\r\n\t\tconst alreadyChecked: {[k: string]: boolean} = {};\r\n\t\tconst level = set.level || 100;\r\n\r\n\t\tlet cantLearnReason = null;\r\n\r\n\t\tlet limit1 = true;\r\n\t\tlet sketch = false;\r\n\t\tlet blockedHM = false;\r\n\r\n\t\tlet babyOnly = '';\r\n\r\n\t\t// This is a pretty complicated algorithm\r\n\r\n\t\t// Abstractly, what it does is construct the union of sets of all\r\n\t\t// possible ways this pokemon could be obtained, and then intersect\r\n\t\t// it with a the pokemon's existing set of all possible ways it could\r\n\t\t// be obtained. If this intersection is non-empty, the move is legal.\r\n\r\n\t\t// set of possible sources of a pokemon with this move\r\n\t\tconst moveSources = new PokemonSources();\r\n\r\n\t\t/**\r\n\t\t * The format doesn't allow Pokemon traded from the future\r\n\t\t * (This is everything except in Gen 1 Tradeback)\r\n\t\t */\r\n\t\tconst noFutureGen = !ruleTable.has('allowtradeback');\r\n\t\t/**\r\n\t\t * The format allows Sketch to copy moves in Gen 8\r\n\t\t */\r\n\t\tconst canSketchPostGen7Moves = ruleTable.has('sketchpostgen7moves') || this.dex.currentMod === 'gen8bdsp';\r\n\r\n\t\tlet tradebackEligible = false;\r\n\t\twhile (species?.name && !alreadyChecked[species.id]) {\r\n\t\t\talreadyChecked[species.id] = true;\r\n\t\t\tif (dex.gen <= 2 && species.gen === 1) tradebackEligible = true;\r\n\t\t\tlet learnset = dex.species.getLearnset(species.id);\r\n\t\t\tif (!learnset) {\r\n\t\t\t\tif ((species.changesFrom || species.baseSpecies) !== species.name) {\r\n\t\t\t\t\t// forme without its own learnset\r\n\t\t\t\t\tspecies = dex.species.get(species.changesFrom || species.baseSpecies);\r\n\t\t\t\t\t// warning: formes with their own learnset, like Wormadam, should NOT\r\n\t\t\t\t\t// inherit from their base forme unless they're freely switchable\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tif (species.isNonstandard) {\r\n\t\t\t\t\t// It's normal for a nonstandard species not to have learnset data\r\n\r\n\t\t\t\t\t// Formats should replace the `Obtainable Moves` rule if they want to\r\n\t\t\t\t\t// allow pokemon without learnsets.\r\n\t\t\t\t\treturn ` can't learn any moves at all.`;\r\n\t\t\t\t}\r\n\t\t\t\tif (species.prevo && dex.species.getLearnset(toID(species.prevo))) {\r\n\t\t\t\t\tlearnset = dex.species.getLearnset(toID(species.prevo));\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\t// should never happen\r\n\t\t\t\tthrow new Error(`Species with no learnset data: ${species.id}`);\r\n\t\t\t}\r\n\t\t\tconst checkingPrevo = species.baseSpecies !== s.baseSpecies;\r\n\t\t\tif (checkingPrevo && !moveSources.size()) {\r\n\t\t\t\tif (!setSources.babyOnly || !species.prevo) {\r\n\t\t\t\t\tbabyOnly = species.id;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlet sources = learnset[moveid];\r\n\t\t\tif (moveid === 'sketch') {\r\n\t\t\t\tsketch = true;\r\n\t\t\t} else if (learnset['sketch']) {\r\n\t\t\t\tif (move.noSketch || move.isZ || move.isMax) {\r\n\t\t\t\t\tcantLearnReason = `can't be Sketched.`;\r\n\t\t\t\t} else if (move.gen > 7 && !canSketchPostGen7Moves) {\r\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}.`;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (!sources || !moveSources.size()) sketch = true;\r\n\t\t\t\t\tsources = learnset['sketch'].concat(sources || []);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (typeof sources === 'string') sources = [sources];\r\n\t\t\tif (sources) {\r\n\t\t\t\tfor (let learned of sources) {\r\n\t\t\t\t\t// Every `learned` represents a single way a pokemon might\r\n\t\t\t\t\t// learn a move. This can be handled one of several ways:\r\n\t\t\t\t\t// `continue`\r\n\t\t\t\t\t// means we can't learn it\r\n\t\t\t\t\t// `return null`\r\n\t\t\t\t\t// means we can learn it with no restrictions\r\n\t\t\t\t\t// (there's a way to just teach any pokemon of this species\r\n\t\t\t\t\t// the move in the current gen, like a TM.)\r\n\t\t\t\t\t// `moveSources.add(source)`\r\n\t\t\t\t\t// means we can learn it only if obtained that exact way described\r\n\t\t\t\t\t// in source\r\n\t\t\t\t\t// `moveSources.addGen(learnedGen)`\r\n\t\t\t\t\t// means we can learn it only if obtained at or before learnedGen\r\n\t\t\t\t\t// (i.e. get the pokemon however you want, transfer to that gen,\r\n\t\t\t\t\t// teach it, and transfer it to the current gen.)\r\n\r\n\t\t\t\t\tconst learnedGen = parseInt(learned.charAt(0));\r\n\t\t\t\t\tif (learnedGen < this.minSourceGen) {\r\n\t\t\t\t\t\tif (!cantLearnReason) {\r\n\t\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen ${learnedGen} to ${this.minSourceGen}.`;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (noFutureGen && learnedGen > dex.gen) {\r\n\t\t\t\t\t\tif (!cantLearnReason) {\r\n\t\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen ${learnedGen} to ${dex.gen}.`;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// redundant\r\n\t\t\t\t\tif (learnedGen <= moveSources.sourcesBefore) continue;\r\n\r\n\t\t\t\t\tif (baseSpecies.evoRegion === 'Alola' && checkingPrevo && learnedGen >= 8) {\r\n\t\t\t\t\t\tcantLearnReason = `is from a ${species.name} that can't be transferred to USUM to evolve into ${baseSpecies.name}.`;\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tconst canUseAbilityPatch = dex.gen >= 8 && format.mod !== 'gen8dlc1';\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tlearnedGen < 7 && setSources.isHidden && !canUseAbilityPatch &&\r\n\t\t\t\t\t\t!dex.mod('gen' + learnedGen).species.get(baseSpecies.name).abilities['H']\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tcantLearnReason = `can only be learned in gens without Hidden Abilities.`;\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (!species.isNonstandard) {\r\n\t\t\t\t\t\t// HMs can't be transferred\r\n\t\t\t\t\t\tif (dex.gen >= 4 && learnedGen <= 3 && [\r\n\t\t\t\t\t\t\t'cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive',\r\n\t\t\t\t\t\t].includes(moveid)) {\r\n\t\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen 3 to 4 because it's an HM move.`;\r\n\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (dex.gen >= 5 && learnedGen <= 4 && [\r\n\t\t\t\t\t\t\t'cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb',\r\n\t\t\t\t\t\t].includes(moveid)) {\r\n\t\t\t\t\t\t\tcantLearnReason = `can't be transferred from Gen 4 to 5 because it's an HM move.`;\r\n\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Defog and Whirlpool can't be transferred together\r\n\t\t\t\t\t\tif (dex.gen >= 5 && ['defog', 'whirlpool'].includes(moveid) && learnedGen <= 4) blockedHM = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (learned.charAt(1) === 'L') {\r\n\t\t\t\t\t\t// special checking for level-up moves\r\n\t\t\t\t\t\tif (level >= parseInt(learned.substr(2)) || learnedGen === 7) {\r\n\t\t\t\t\t\t\t// we're past the required level to learn it\r\n\t\t\t\t\t\t\t// (gen 7 level-up moves can be relearnered at any level)\r\n\t\t\t\t\t\t\t// falls through to LMT check below\r\n\t\t\t\t\t\t} else if (level >= 5 && learnedGen === 3 && species.canHatch) {\r\n\t\t\t\t\t\t\t// Pomeg Glitch\r\n\t\t\t\t\t\t} else if ((!species.gender || species.gender === 'F') && learnedGen >= 2 && species.canHatch) {\r\n\t\t\t\t\t\t\t// available as egg move\r\n\t\t\t\t\t\t\tlearned = learnedGen + 'Eany';\r\n\t\t\t\t\t\t\t// falls through to E check below\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t// this move is unavailable, skip it\r\n\t\t\t\t\t\t\tcantLearnReason = `is learned at level ${parseInt(learned.substr(2))}.`;\r\n\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Gen 8+ egg moves can be taught to any pokemon from any source\r\n\t\t\t\t\tif (learnedGen >= 8 && learned.charAt(1) === 'E' || 'LMTR'.includes(learned.charAt(1))) {\r\n\t\t\t\t\t\tif (learnedGen === dex.gen && learned.charAt(1) !== 'R') {\r\n\t\t\t\t\t\t\t// current-gen level-up, TM or tutor moves:\r\n\t\t\t\t\t\t\t// always available\r\n\t\t\t\t\t\t\tif (!(learnedGen >= 8 && learned.charAt(1) === 'E') && babyOnly) setSources.babyOnly = babyOnly;\r\n\t\t\t\t\t\t\tif (!moveSources.moveEvoCarryCount) return null;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// past-gen level-up, TM, or tutor moves:\r\n\t\t\t\t\t\t// available as long as the source gen was or was before this gen\r\n\t\t\t\t\t\tif (learned.charAt(1) === 'R') {\r\n\t\t\t\t\t\t\tmoveSources.restrictedMove = moveid;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tlimit1 = false;\r\n\t\t\t\t\t\tmoveSources.addGen(learnedGen);\r\n\t\t\t\t\t} else if (learned.charAt(1) === 'E') {\r\n\t\t\t\t\t\t// egg moves:\r\n\t\t\t\t\t\t// only if hatched from an egg\r\n\t\t\t\t\t\tlet limitedEggMove: ID | null | undefined = undefined;\r\n\t\t\t\t\t\tif (learned.slice(1) === 'Eany') {\r\n\t\t\t\t\t\t\tlimitedEggMove = null;\r\n\t\t\t\t\t\t} else if (learnedGen < 6) {\r\n\t\t\t\t\t\t\tlimitedEggMove = move.id;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tlearned = learnedGen + 'E' + (species.prevo ? species.id : '');\r\n\t\t\t\t\t\tif (tradebackEligible && learnedGen === 2 && move.gen <= 1) {\r\n\t\t\t\t\t\t\t// can tradeback\r\n\t\t\t\t\t\t\tmoveSources.add('1ET' + learned.slice(2));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tmoveSources.add(learned, limitedEggMove);\r\n\t\t\t\t\t} else if (learned.charAt(1) === 'S') {\r\n\t\t\t\t\t\t// event moves:\r\n\t\t\t\t\t\t// only if that was the source\r\n\t\t\t\t\t\t// Event Pok\u00E9mon:\r\n\t\t\t\t\t\t// \tAvailable as long as the past gen can get the Pok\u00E9mon and then trade it back.\r\n\t\t\t\t\t\tif (tradebackEligible && learnedGen === 2 && move.gen <= 1) {\r\n\t\t\t\t\t\t\t// can tradeback\r\n\t\t\t\t\t\t\tmoveSources.add('1ST' + learned.slice(2) + ' ' + species.id);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tmoveSources.add(learned + ' ' + species.id);\r\n\t\t\t\t\t} else if (learned.charAt(1) === 'D') {\r\n\t\t\t\t\t\t// DW moves:\r\n\t\t\t\t\t\t// only if that was the source\r\n\t\t\t\t\t\tmoveSources.add(learned + species.id);\r\n\t\t\t\t\t\tmoveSources.dreamWorldMoveCount++;\r\n\t\t\t\t\t} else if (learned.charAt(1) === 'V' && this.minSourceGen < learnedGen) {\r\n\t\t\t\t\t\t// Virtual Console or Let's Go transfer moves:\r\n\t\t\t\t\t\t// only if that was the source\r\n\t\t\t\t\t\tmoveSources.add(learned);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (ruleTable.has('mimicglitch') && species.gen < 5) {\r\n\t\t\t\t// include the Mimic Glitch when checking this mon's learnset\r\n\t\t\t\tconst glitchMoves = ['metronome', 'copycat', 'transform', 'mimic', 'assist'];\r\n\t\t\t\tlet getGlitch = false;\r\n\t\t\t\tfor (const i of glitchMoves) {\r\n\t\t\t\t\tif (learnset[i]) {\r\n\t\t\t\t\t\tif (!(i === 'mimic' && dex.abilities.get(set.ability).gen === 4 && !species.prevo)) {\r\n\t\t\t\t\t\t\tgetGlitch = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (getGlitch) {\r\n\t\t\t\t\tmoveSources.addGen(4);\r\n\t\t\t\t\tif (move.gen < 5) {\r\n\t\t\t\t\t\tlimit1 = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (!moveSources.size()) {\r\n\t\t\t\tif (\r\n\t\t\t\t\t(species.evoType === 'levelMove' && species.evoMove !== move.name) ||\r\n\t\t\t\t\t(species.id === 'sylveon' && move.type !== 'Fairy')\r\n\t\t\t\t) {\r\n\t\t\t\t\tmoveSources.moveEvoCarryCount = 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// also check to see if the mon's prevo or freely switchable formes can learn this move\r\n\t\t\tspecies = this.learnsetParent(species);\r\n\t\t}\r\n\r\n\t\tif (limit1 && sketch) {\r\n\t\t\t// limit 1 sketch move\r\n\t\t\tif (setSources.sketchMove) {\r\n\t\t\t\treturn ` can't Sketch ${move.name} and ${setSources.sketchMove} because it can only Sketch 1 move.`;\r\n\t\t\t}\r\n\t\t\tsetSources.sketchMove = move.name;\r\n\t\t}\r\n\r\n\t\tif (blockedHM) {\r\n\t\t\t// Limit one of Defog/Whirlpool to be transferred\r\n\t\t\tif (setSources.hm) return ` can't simultaneously transfer Defog and Whirlpool from Gen 4 to 5.`;\r\n\t\t\tsetSources.hm = moveid;\r\n\t\t}\r\n\r\n\t\tif (!setSources.restrictiveMoves) {\r\n\t\t\tsetSources.restrictiveMoves = [];\r\n\t\t}\r\n\t\tsetSources.restrictiveMoves.push(move.name);\r\n\r\n\t\t// Now that we have our list of possible sources, intersect it with the current list\r\n\t\tif (!moveSources.size()) {\r\n\t\t\tif (cantLearnReason) return `'s move ${move.name} ${cantLearnReason}`;\r\n\t\t\treturn ` can't learn ${move.name}.`;\r\n\t\t}\r\n\t\tconst backupSources = setSources.sources;\r\n\t\tconst backupSourcesBefore = setSources.sourcesBefore;\r\n\t\tsetSources.intersectWith(moveSources);\r\n\t\tif (!setSources.size()) {\r\n\t\t\t// pretend this pokemon didn't have this move:\r\n\t\t\t// prevents a crash if OMs override `checkCanLearn` to keep validating after an error\r\n\t\t\tsetSources.sources = backupSources;\r\n\t\t\tsetSources.sourcesBefore = backupSourcesBefore;\r\n\t\t\treturn `'s moves ${(setSources.restrictiveMoves || []).join(', ')} are incompatible.`;\r\n\t\t}\r\n\r\n\t\tif (babyOnly) setSources.babyOnly = babyOnly;\r\n\t\treturn null;\r\n\t}\r\n\r\n\tlearnsetParent(species: Species) {\r\n\t\t// Own Tempo Rockruff and Battle Bond Greninja are special event formes\r\n\t\t// that are visually indistinguishable from their base forme but have\r\n\t\t// different learnsets. To prevent a leak, we make them show up as their\r\n\t\t// base forme, but hardcode their learnsets into Rockruff-Dusk and\r\n\t\t// Greninja-Ash\r\n\t\tif (['Gastrodon', 'Pumpkaboo', 'Sinistea'].includes(species.baseSpecies) && species.forme) {\r\n\t\t\treturn this.dex.species.get(species.baseSpecies);\r\n\t\t} else if (species.name === 'Lycanroc-Dusk') {\r\n\t\t\treturn this.dex.species.get('Rockruff-Dusk');\r\n\t\t} else if (species.name === 'Greninja-Ash') {\r\n\t\t\treturn null;\r\n\t\t} else if (species.prevo) {\r\n\t\t\t// there used to be a check for Hidden Ability here, but apparently it's unnecessary\r\n\t\t\t// Shed Skin Pupitar can definitely evolve into Unnerve Tyranitar\r\n\t\t\tspecies = this.dex.species.get(species.prevo);\r\n\t\t\tif (species.gen > Math.max(2, this.dex.gen)) return null;\r\n\t\t\treturn species;\r\n\t\t} else if (species.changesFrom && species.baseSpecies !== 'Kyurem') {\r\n\t\t\t// For Pokemon like Rotom and Necrozma whose movesets are extensions are their base formes\r\n\t\t\treturn this.dex.species.get(species.changesFrom);\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\tstatic fillStats(stats: SparseStatsTable | null, fillNum = 0): StatsTable {\r\n\t\tconst filledStats: StatsTable = {hp: fillNum, atk: fillNum, def: fillNum, spa: fillNum, spd: fillNum, spe: fillNum};\r\n\t\tif (stats) {\r\n\t\t\tlet statName: StatID;\r\n\t\t\tfor (statName in filledStats) {\r\n\t\t\t\tconst stat = stats[statName];\r\n\t\t\t\tif (typeof stat === 'number') filledStats[statName] = stat;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn filledStats;\r\n\t}\r\n\r\n\tstatic get(format: string | Format) {\r\n\t\treturn new TeamValidator(format);\r\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