{ "version": 3, "sources": ["../../../sim/dex-formats.ts"], "sourcesContent": ["import {Utils} from '../lib';\r\nimport {toID, BasicEffect} from './dex-data';\r\nimport {EventMethods} from './dex-conditions';\r\nimport {Tags} from '../data/tags';\r\n\r\nconst DEFAULT_MOD = 'gen9';\r\n\r\nexport interface FormatData extends Partial, EventMethods {\r\n\tname: string;\r\n}\r\n\r\nexport type FormatList = (FormatData | {section: string, column?: number})[];\r\nexport type ModdedFormatData = FormatData | Omit & {inherit: true};\r\n\r\ntype FormatEffectType = 'Format' | 'Ruleset' | 'Rule' | 'ValidatorRule';\r\n\r\n/** rule, source, limit, bans */\r\nexport type ComplexBan = [string, string, number, string[]];\r\nexport type ComplexTeamBan = ComplexBan;\r\n\r\n/**\r\n * A RuleTable keeps track of the rules that a format has. The key can be:\r\n * - '[ruleid]' the ID of a rule in effect\r\n * - '-[thing]' or '-[category]:[thing]' ban a thing\r\n * - '+[thing]' or '+[category]:[thing]' allow a thing (override a ban)\r\n * [category] is one of: item, move, ability, species, basespecies\r\n *\r\n * The value is the name of the parent rule (blank for the active format).\r\n */\r\nexport class RuleTable extends Map {\r\n\tcomplexBans: ComplexBan[];\r\n\tcomplexTeamBans: ComplexTeamBan[];\r\n\tcheckCanLearn: [TeamValidator['checkCanLearn'], string] | null;\r\n\ttimer: [Partial, string] | null;\r\n\ttagRules: string[];\r\n\tvalueRules: Map;\r\n\r\n\tminTeamSize!: number;\r\n\tmaxTeamSize!: number;\r\n\tpickedTeamSize!: number | null;\r\n\tmaxTotalLevel!: number | null;\r\n\tmaxMoveCount!: number;\r\n\tminSourceGen!: number;\r\n\tminLevel!: number;\r\n\tmaxLevel!: number;\r\n\tdefaultLevel!: number;\r\n\tadjustLevel!: number | null;\r\n\tadjustLevelDown!: number | null;\r\n\tevLimit!: number | null;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.complexBans = [];\r\n\t\tthis.complexTeamBans = [];\r\n\t\tthis.checkCanLearn = null;\r\n\t\tthis.timer = null;\r\n\t\tthis.tagRules = [];\r\n\t\tthis.valueRules = new Map();\r\n\t}\r\n\r\n\tisBanned(thing: string) {\r\n\t\tif (this.has(`+${thing}`)) return false;\r\n\t\treturn this.has(`-${thing}`);\r\n\t}\r\n\r\n\tisBannedSpecies(species: Species) {\r\n\t\tif (this.has(`+pokemon:${species.id}`)) return false;\r\n\t\tif (this.has(`-pokemon:${species.id}`)) return true;\r\n\t\tif (this.has(`+basepokemon:${toID(species.baseSpecies)}`)) return false;\r\n\t\tif (this.has(`-basepokemon:${toID(species.baseSpecies)}`)) return true;\r\n\t\tfor (const tagid in Tags) {\r\n\t\t\tconst tag = Tags[tagid];\r\n\t\t\tif (this.has(`-pokemontag:${tagid}`)) {\r\n\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) return true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const tagid in Tags) {\r\n\t\t\tconst tag = Tags[tagid];\r\n\t\t\tif (this.has(`+pokemontag:${tagid}`)) {\r\n\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) return false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this.has(`-pokemontag:allpokemon`);\r\n\t}\r\n\r\n\tisRestricted(thing: string) {\r\n\t\tif (this.has(`+${thing}`)) return false;\r\n\t\treturn this.has(`*${thing}`);\r\n\t}\r\n\r\n\tisRestrictedSpecies(species: Species) {\r\n\t\tif (this.has(`+pokemon:${species.id}`)) return false;\r\n\t\tif (this.has(`*pokemon:${species.id}`)) return true;\r\n\t\tif (this.has(`+basepokemon:${toID(species.baseSpecies)}`)) return false;\r\n\t\tif (this.has(`*basepokemon:${toID(species.baseSpecies)}`)) return true;\r\n\t\tfor (const tagid in Tags) {\r\n\t\t\tconst tag = Tags[tagid];\r\n\t\t\tif (this.has(`*pokemontag:${tagid}`)) {\r\n\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) return true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const tagid in Tags) {\r\n\t\t\tconst tag = Tags[tagid];\r\n\t\t\tif (this.has(`+pokemontag:${tagid}`)) {\r\n\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) return false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this.has(`*pokemontag:allpokemon`);\r\n\t}\r\n\r\n\tgetTagRules() {\r\n\t\tconst tagRules = [];\r\n\t\tfor (const ruleid of this.keys()) {\r\n\t\t\tif (/^[+*-]pokemontag:/.test(ruleid)) {\r\n\t\t\t\tconst banid = ruleid.slice(12);\r\n\t\t\t\tif (\r\n\t\t\t\t\tbanid === 'allpokemon' || banid === 'allitems' || banid === 'allmoves' ||\r\n\t\t\t\t\tbanid === 'allabilities' || banid === 'allnatures'\r\n\t\t\t\t) {\r\n\t\t\t\t\t// hardcoded and not a part of the ban rule system\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttagRules.push(ruleid);\r\n\t\t\t\t}\r\n\t\t\t} else if ('+*-'.includes(ruleid.charAt(0)) && ruleid.slice(1) === 'nonexistent') {\r\n\t\t\t\ttagRules.push(ruleid.charAt(0) + 'pokemontag:nonexistent');\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.tagRules = tagRules.reverse();\r\n\t\treturn this.tagRules;\r\n\t}\r\n\r\n\t/**\r\n\t * - non-empty string: banned, string is the reason\r\n\t * - '': whitelisted\r\n\t * - null: neither whitelisted nor banned\r\n\t */\r\n\tcheck(thing: string, setHas: {[id: string]: true} | null = null) {\r\n\t\tif (this.has(`+${thing}`)) return '';\r\n\t\tif (setHas) setHas[thing] = true;\r\n\t\treturn this.getReason(`-${thing}`);\r\n\t}\r\n\r\n\tgetReason(key: string): string | null {\r\n\t\tconst source = this.get(key);\r\n\t\tif (source === undefined) return null;\r\n\t\tif (key === '-nonexistent' || key.startsWith('obtainable')) {\r\n\t\t\treturn 'not obtainable';\r\n\t\t}\r\n\t\treturn source ? `banned by ${source}` : `banned`;\r\n\t}\r\n\r\n\tblame(key: string): string {\r\n\t\tconst source = this.get(key);\r\n\t\treturn source ? ` from ${source}` : ``;\r\n\t}\r\n\r\n\tgetComplexBanIndex(complexBans: ComplexBan[], rule: string): number {\r\n\t\tconst ruleId = toID(rule);\r\n\t\tlet complexBanIndex = -1;\r\n\t\tfor (let i = 0; i < complexBans.length; i++) {\r\n\t\t\tif (toID(complexBans[i][0]) === ruleId) {\r\n\t\t\t\tcomplexBanIndex = i;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn complexBanIndex;\r\n\t}\r\n\r\n\taddComplexBan(rule: string, source: string, limit: number, bans: string[]) {\r\n\t\tconst complexBanIndex = this.getComplexBanIndex(this.complexBans, rule);\r\n\t\tif (complexBanIndex !== -1) {\r\n\t\t\tif (this.complexBans[complexBanIndex][2] === Infinity) return;\r\n\t\t\tthis.complexBans[complexBanIndex] = [rule, source, limit, bans];\r\n\t\t} else {\r\n\t\t\tthis.complexBans.push([rule, source, limit, bans]);\r\n\t\t}\r\n\t}\r\n\r\n\taddComplexTeamBan(rule: string, source: string, limit: number, bans: string[]) {\r\n\t\tconst complexBanTeamIndex = this.getComplexBanIndex(this.complexTeamBans, rule);\r\n\t\tif (complexBanTeamIndex !== -1) {\r\n\t\t\tif (this.complexTeamBans[complexBanTeamIndex][2] === Infinity) return;\r\n\t\t\tthis.complexTeamBans[complexBanTeamIndex] = [rule, source, limit, bans];\r\n\t\t} else {\r\n\t\t\tthis.complexTeamBans.push([rule, source, limit, bans]);\r\n\t\t}\r\n\t}\r\n\r\n\t/** After a RuleTable has been filled out, resolve its hardcoded numeric properties */\r\n\tresolveNumbers(format: Format, dex: ModdedDex) {\r\n\t\tconst gameTypeMinTeamSize = ['triples', 'rotation'].includes(format.gameType as 'triples') ? 3 :\r\n\t\t\tformat.gameType === 'doubles' ? 2 :\r\n\t\t\t1;\r\n\r\n\t\t// NOTE: These numbers are pre-calculated here because they're hardcoded\r\n\t\t// into the team validator and battle engine, and can affect validation\r\n\t\t// in complicated ways.\r\n\r\n\t\t// If you're making your own rule, it nearly definitely does not not\r\n\t\t// belong here: `onValidateRule`, `onValidateSet`, and `onValidateTeam`\r\n\t\t// should be enough for a validator rule, and the battle event system\r\n\t\t// should be enough for a battle rule.\r\n\r\n\t\tthis.minTeamSize = Number(this.valueRules.get('minteamsize')) || 0;\r\n\t\tthis.maxTeamSize = Number(this.valueRules.get('maxteamsize')) || 6;\r\n\t\tthis.pickedTeamSize = Number(this.valueRules.get('pickedteamsize')) || null;\r\n\t\tthis.maxTotalLevel = Number(this.valueRules.get('maxtotallevel')) || null;\r\n\t\tthis.maxMoveCount = Number(this.valueRules.get('maxmovecount')) || 4;\r\n\t\tthis.minSourceGen = Number(this.valueRules.get('minsourcegen')) || 1;\r\n\t\tthis.minLevel = Number(this.valueRules.get('minlevel')) || 1;\r\n\t\tthis.maxLevel = Number(this.valueRules.get('maxlevel')) || 100;\r\n\t\tthis.defaultLevel = Number(this.valueRules.get('defaultlevel')) || 0;\r\n\t\tthis.adjustLevel = Number(this.valueRules.get('adjustlevel')) || null;\r\n\t\tthis.adjustLevelDown = Number(this.valueRules.get('adjustleveldown')) || null;\r\n\t\tthis.evLimit = Number(this.valueRules.get('evlimit')) || null;\r\n\r\n\t\tif (this.valueRules.get('pickedteamsize') === 'Auto') {\r\n\t\t\tthis.pickedTeamSize = (\r\n\t\t\t\t['doubles', 'rotation'].includes(format.gameType) ? 4 :\r\n\t\t\t\tformat.gameType === 'triples' ? 6 :\r\n\t\t\t\t3\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (this.valueRules.get('evlimit') === 'Auto') {\r\n\t\t\tthis.evLimit = dex.gen > 2 ? 510 : null;\r\n\t\t\tif (format.mod === 'gen7letsgo') {\r\n\t\t\t\tthis.evLimit = this.has('allowavs') ? null : 0;\r\n\t\t\t}\r\n\t\t\t// Gen 6 hackmons also has a limit, which is currently implemented\r\n\t\t\t// at the appropriate format.\r\n\t\t}\r\n\r\n\t\t// sanity checks; these _could_ be inside `onValidateRule` but this way\r\n\t\t// involves less string conversion.\r\n\r\n\t\t// engine hard limits\r\n\t\tif (this.maxTeamSize > 24) {\r\n\t\t\tthrow new Error(`Max team size ${this.maxTeamSize}${this.blame('maxteamsize')} is unsupported (we only support up to 24).`);\r\n\t\t}\r\n\t\tif (this.maxLevel > 99999) {\r\n\t\t\tthrow new Error(`Max level ${this.maxLevel}${this.blame('maxlevel')} is unsupported (we only support up to 99999)`);\r\n\t\t}\r\n\t\tif (this.maxMoveCount > 24) {\r\n\t\t\t// A limit is imposed here to prevent too much engine strain or\r\n\t\t\t// too much layout deformation - to be exact, this is the limit\r\n\t\t\t// allowed in Custom Game.\r\n\t\t\tthrow new Error(`Max move count ${this.maxMoveCount}${this.blame('maxmovecount')} is unsupported (we only support up to 24)`);\r\n\t\t}\r\n\r\n\t\tif (!this.defaultLevel) {\r\n\t\t\t// defaultLevel will set level 100 pokemon to the default level, which can break\r\n\t\t\t// Max Total Level if Max Level is above 100.\r\n\t\t\tconst maxTeamSize = this.pickedTeamSize || this.maxTeamSize;\r\n\t\t\tif (this.maxTotalLevel && this.maxLevel > 100 && this.maxLevel * maxTeamSize > this.maxTotalLevel) {\r\n\t\t\t\tthis.defaultLevel = 100;\r\n\t\t\t} else {\r\n\t\t\t\tthis.defaultLevel = this.maxLevel;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (this.minTeamSize && this.minTeamSize < gameTypeMinTeamSize) {\r\n\t\t\tthrow new Error(`Min team size ${this.minTeamSize}${this.blame('minteamsize')} must be at least ${gameTypeMinTeamSize} for a ${format.gameType} game.`);\r\n\t\t}\r\n\t\tif (this.pickedTeamSize && this.pickedTeamSize < gameTypeMinTeamSize) {\r\n\t\t\tthrow new Error(`Chosen team size ${this.pickedTeamSize}${this.blame('pickedteamsize')} must be at least ${gameTypeMinTeamSize} for a ${format.gameType} game.`);\r\n\t\t}\r\n\t\tif (this.minTeamSize && this.pickedTeamSize && this.minTeamSize < this.pickedTeamSize) {\r\n\t\t\tthrow new Error(`Min team size ${this.minTeamSize}${this.blame('minteamsize')} is lower than chosen team size ${this.pickedTeamSize}${this.blame('pickedteamsize')}.`);\r\n\t\t}\r\n\t\tif (!this.minTeamSize) this.minTeamSize = Math.max(gameTypeMinTeamSize, this.pickedTeamSize || 0);\r\n\t\tif (this.maxTeamSize < gameTypeMinTeamSize) {\r\n\t\t\tthrow new Error(`Max team size ${this.maxTeamSize}${this.blame('maxteamsize')} must be at least ${gameTypeMinTeamSize} for a ${format.gameType} game.`);\r\n\t\t}\r\n\t\tif (this.maxTeamSize < this.minTeamSize) {\r\n\t\t\tthrow new Error(`Max team size ${this.maxTeamSize}${this.blame('maxteamsize')} must be at least min team size ${this.minTeamSize}${this.blame('minteamsize')}.`);\r\n\t\t}\r\n\t\tif (this.minLevel > this.maxLevel) {\r\n\t\t\tthrow new Error(`Min level ${this.minLevel}${this.blame('minlevel')} should not be above max level ${this.maxLevel}${this.blame('maxlevel')}.`);\r\n\t\t}\r\n\t\tif (this.defaultLevel > this.maxLevel) {\r\n\t\t\tthrow new Error(`Default level ${this.defaultLevel}${this.blame('defaultlevel')} should not be above max level ${this.maxLevel}${this.blame('maxlevel')}.`);\r\n\t\t}\r\n\t\tif (this.defaultLevel < this.minLevel) {\r\n\t\t\tthrow new Error(`Default level ${this.defaultLevel}${this.blame('defaultlevel')} should not be below min level ${this.minLevel}${this.blame('minlevel')}.`);\r\n\t\t}\r\n\t\tif (this.adjustLevelDown && this.adjustLevelDown >= this.maxLevel) {\r\n\t\t\tthrow new Error(`Adjust Level Down ${this.adjustLevelDown}${this.blame('adjustleveldown')} will have no effect because it's not below max level ${this.maxLevel}${this.blame('maxlevel')}.`);\r\n\t\t}\r\n\t\tif (this.adjustLevel && this.valueRules.has('minlevel')) {\r\n\t\t\tthrow new Error(`Min Level ${this.minLevel}${this.blame('minlevel')} will have no effect because you're using Adjust Level ${this.adjustLevel}${this.blame('adjustlevel')}.`);\r\n\t\t}\r\n\t\tif (this.evLimit && this.evLimit >= 1512) {\r\n\t\t\tthrow new Error(`EV Limit ${this.evLimit}${this.blame('evlimit')} will have no effect because it's not lower than 1512, the maximum possible combination of 252 EVs in every stat (if you currently have an EV limit, use \"! EV Limit\" to remove the limit).`);\r\n\t\t}\r\n\t\tif (this.evLimit && this.evLimit < 0) {\r\n\t\t\tthrow new Error(`EV Limit ${this.evLimit}${this.blame('evlimit')} can't be less than 0 (you might have meant: \"! EV Limit\" to remove the limit, or \"EV Limit = 0\" to ban EVs).`);\r\n\t\t}\r\n\r\n\t\tif ((format as any).cupLevelLimit) {\r\n\t\t\tthrow new Error(`cupLevelLimit.range[0], cupLevelLimit.range[1], cupLevelLimit.total are now rules, respectively: \"Min Level = NUMBER\", \"Max Level = NUMBER\", and \"Max Total Level = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).teamLength) {\r\n\t\t\tthrow new Error(`teamLength.validate[0], teamLength.validate[1], teamLength.battle are now rules, respectively: \"Min Team Size = NUMBER\", \"Max Team Size = NUMBER\", and \"Picked Team Size = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).minSourceGen) {\r\n\t\t\tthrow new Error(`minSourceGen is now a rule: \"Min Source Gen = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).maxLevel) {\r\n\t\t\tthrow new Error(`maxLevel is now a rule: \"Max Level = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).defaultLevel) {\r\n\t\t\tthrow new Error(`defaultLevel is now a rule: \"Default Level = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).forcedLevel) {\r\n\t\t\tthrow new Error(`forcedLevel is now a rule: \"Adjust Level = NUMBER\"`);\r\n\t\t}\r\n\t\tif ((format as any).maxForcedLevel) {\r\n\t\t\tthrow new Error(`maxForcedLevel is now a rule: \"Adjust Level Down = NUMBER\"`);\r\n\t\t}\r\n\t}\r\n\r\n\thasComplexBans() {\r\n\t\treturn (this.complexBans?.length > 0) || (this.complexTeamBans?.length > 0);\r\n\t}\r\n}\r\n\r\nexport class Format extends BasicEffect implements Readonly {\r\n\treadonly mod: string;\r\n\t/**\r\n\t * Name of the team generator algorithm, if this format uses\r\n\t * random/fixed teams. null if players can bring teams.\r\n\t */\r\n\tdeclare readonly team?: string;\r\n\treadonly effectType: FormatEffectType;\r\n\treadonly debug: boolean;\r\n\t/**\r\n\t * Whether or not a format will update ladder points if searched\r\n\t * for using the \"Battle!\" button.\r\n\t * (Challenge and tournament games will never update ladder points.)\r\n\t * (Defaults to `true`.)\r\n\t */\r\n\treadonly rated: boolean | string;\r\n\t/** Game type. */\r\n\treadonly gameType: GameType;\r\n\t/** List of rule names. */\r\n\treadonly ruleset: string[];\r\n\t/**\r\n\t * Base list of rule names as specified in \"./config/formats.ts\".\r\n\t * Used in a custom format to correctly display the altered ruleset.\r\n\t */\r\n\treadonly baseRuleset: string[];\r\n\t/** List of banned effects. */\r\n\treadonly banlist: string[];\r\n\t/** List of effects that aren't completely banned. */\r\n\treadonly restricted: string[];\r\n\t/** List of inherited banned effects to override. */\r\n\treadonly unbanlist: string[];\r\n\t/** List of ruleset and banlist changes in a custom format. */\r\n\treadonly customRules: string[] | null;\r\n\t/** Table of rule names and banned effects. */\r\n\truleTable: RuleTable | null;\r\n\t/** An optional function that runs at the start of a battle. */\r\n\treadonly onBegin?: (this: Battle) => void;\r\n\treadonly noLog: boolean;\r\n\r\n\t/**\r\n\t * Only applies to rules, not formats\r\n\t */\r\n\tdeclare readonly hasValue?: boolean | 'integer' | 'positive-integer';\r\n\tdeclare readonly onValidateRule?: (\r\n\t\tthis: {format: Format, ruleTable: RuleTable, dex: ModdedDex}, value: string\r\n\t) => string | void;\r\n\t/** ID of rule that can't be combined with this rule */\r\n\tdeclare readonly mutuallyExclusiveWith?: string;\r\n\r\n\tdeclare readonly battle?: ModdedBattleScriptsData;\r\n\tdeclare readonly pokemon?: ModdedBattlePokemon;\r\n\tdeclare readonly queue?: ModdedBattleQueue;\r\n\tdeclare readonly field?: ModdedField;\r\n\tdeclare readonly actions?: ModdedBattleActions;\r\n\tdeclare readonly challengeShow?: boolean;\r\n\tdeclare readonly searchShow?: boolean;\r\n\tdeclare readonly threads?: string[];\r\n\tdeclare readonly timer?: Partial;\r\n\tdeclare readonly tournamentShow?: boolean;\r\n\tdeclare readonly checkCanLearn?: (\r\n\t\tthis: TeamValidator, move: Move, species: Species, setSources: PokemonSources, set: PokemonSet\r\n\t) => string | null;\r\n\tdeclare readonly getEvoFamily?: (this: Format, speciesid: string) => ID;\r\n\tdeclare readonly getSharedPower?: (this: Format, pokemon: Pokemon) => Set;\r\n\tdeclare readonly onChangeSet?: (\r\n\t\tthis: TeamValidator, set: PokemonSet, format: Format, setHas?: AnyObject, teamHas?: AnyObject\r\n\t) => string[] | void;\r\n\tdeclare readonly onModifySpeciesPriority?: number;\r\n\tdeclare readonly onModifySpecies?: (\r\n\t\tthis: Battle, species: Species, target?: Pokemon, source?: Pokemon, effect?: Effect\r\n\t) => Species | void;\r\n\tdeclare readonly onBattleStart?: (this: Battle) => void;\r\n\tdeclare readonly onTeamPreview?: (this: Battle) => void;\r\n\tdeclare readonly onValidateSet?: (\r\n\t\tthis: TeamValidator, set: PokemonSet, format: Format, setHas: AnyObject, teamHas: AnyObject\r\n\t) => string[] | void;\r\n\tdeclare readonly onValidateTeam?: (\r\n\t\tthis: TeamValidator, team: PokemonSet[], format: Format, teamHas: AnyObject\r\n\t) => string[] | void;\r\n\tdeclare readonly validateSet?: (this: TeamValidator, set: PokemonSet, teamHas: AnyObject) => string[] | null;\r\n\tdeclare readonly validateTeam?: (this: TeamValidator, team: PokemonSet[], options?: {\r\n\t\tremoveNicknames?: boolean,\r\n\t\tskipSets?: {[name: string]: {[key: string]: boolean}},\r\n\t}) => string[] | void;\r\n\tdeclare readonly section?: string;\r\n\tdeclare readonly column?: number;\r\n\r\n\tconstructor(data: AnyObject) {\r\n\t\tsuper(data);\r\n\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\r\n\t\tdata = this;\r\n\r\n\t\tthis.mod = Utils.getString(data.mod) || 'gen9';\r\n\t\tthis.effectType = Utils.getString(data.effectType) as FormatEffectType || 'Format';\r\n\t\tthis.debug = !!data.debug;\r\n\t\tthis.rated = (typeof data.rated === 'string' ? data.rated : data.rated !== false);\r\n\t\tthis.gameType = data.gameType || 'singles';\r\n\t\tthis.ruleset = data.ruleset || [];\r\n\t\tthis.baseRuleset = data.baseRuleset || [];\r\n\t\tthis.banlist = data.banlist || [];\r\n\t\tthis.restricted = data.restricted || [];\r\n\t\tthis.unbanlist = data.unbanlist || [];\r\n\t\tthis.customRules = data.customRules || null;\r\n\t\tthis.ruleTable = null;\r\n\t\tthis.onBegin = data.onBegin || undefined;\r\n\t\tthis.noLog = !!data.noLog;\r\n\t}\r\n}\r\n\r\n/** merges format lists from config/formats and config/custom-formats */\r\nfunction mergeFormatLists(main: FormatList, custom: FormatList | undefined): FormatList {\r\n\t// interface for the builder.\r\n\tinterface FormatSection {\r\n\t\tsection: string;\r\n\t\tcolumn?: number;\r\n\t\tformats: FormatData[];\r\n\t}\r\n\r\n\t// result that is return and makes the actual list for formats.\r\n\tconst result: FormatList = [];\r\n\r\n\t// used as a intermediary to build the final list.\r\n\tconst build: FormatSection[] = [];\r\n\r\n\t// used to track current section to keep formats under their sections.\r\n\tlet current: FormatSection | undefined = {section: \"\", formats: []};\r\n\r\n\t// populates the original sections and formats easily\r\n\t// there should be no repeat sections at this point.\r\n\tfor (const element of main) {\r\n\t\tif (element.section) {\r\n\t\t\tcurrent = {section: element.section, column: element.column, formats: []};\r\n\t\t\tbuild.push(current);\r\n\t\t} else if ((element as FormatData).name) {\r\n\t\t\tcurrent.formats.push((element as FormatData));\r\n\t\t}\r\n\t}\r\n\r\n\t// merges the second list the hard way. Accounts for repeats.\r\n\tif (custom !== undefined) {\r\n\t\tfor (const element of custom) {\r\n\t\t\t// finds the section and makes it if it doesn't exist.\r\n\t\t\tif (element.section) {\r\n\t\t\t\tcurrent = build.find(e => e.section === element.section);\r\n\r\n\t\t\t\t// if it's new it makes a new entry.\r\n\t\t\t\tif (current === undefined) {\r\n\t\t\t\t\tcurrent = {section: element.section, column: element.column, formats: []};\r\n\t\t\t\t\tbuild.push(current);\r\n\t\t\t\t}\r\n\t\t\t} else if ((element as FormatData).name) { // otherwise, adds the element to its section.\r\n\t\t\t\tcurrent.formats.push(element as FormatData);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// builds the final result.\r\n\tfor (const element of build) {\r\n\t\t// adds the section to the list.\r\n\t\tresult.push({section: element.section, column: element.column}, ...element.formats);\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nexport class DexFormats {\r\n\treadonly dex: ModdedDex;\r\n\trulesetCache = new Map();\r\n\tformatsListCache: readonly Format[] | null;\r\n\r\n\tconstructor(dex: ModdedDex) {\r\n\t\tthis.dex = dex;\r\n\t\tthis.formatsListCache = null;\r\n\t}\r\n\r\n\tload(): this {\r\n\t\tif (!this.dex.isBase) throw new Error(`This should only be run on the base mod`);\r\n\t\tthis.dex.includeMods();\r\n\t\tif (this.formatsListCache) return this;\r\n\r\n\t\tconst formatsList = [];\r\n\r\n\t\t// Load formats\r\n\t\tlet customFormats;\r\n\t\ttry {\r\n\t\t\tcustomFormats = require(`${__dirname}/../config/custom-formats`).Formats;\r\n\t\t\tif (!Array.isArray(customFormats)) {\r\n\t\t\t\tthrow new TypeError(`Exported property 'Formats' from \"./config/custom-formats.ts\" must be an array`);\r\n\t\t\t}\r\n\t\t} catch (e: any) {\r\n\t\t\tif (e.code !== 'MODULE_NOT_FOUND' && e.code !== 'ENOENT') {\r\n\t\t\t\tthrow e;\r\n\t\t\t}\r\n\t\t}\r\n\t\tlet Formats: AnyObject[] = require(`${__dirname}/../config/formats`).Formats;\r\n\t\tif (!Array.isArray(Formats)) {\r\n\t\t\tthrow new TypeError(`Exported property 'Formats' from \"./config/formats.ts\" must be an array`);\r\n\t\t}\r\n\t\tif (customFormats) Formats = mergeFormatLists(Formats as any, customFormats);\r\n\r\n\t\tlet section = '';\r\n\t\tlet column = 1;\r\n\t\tfor (const [i, format] of Formats.entries()) {\r\n\t\t\tconst id = toID(format.name);\r\n\t\t\tif (format.section) section = format.section;\r\n\t\t\tif (format.column) column = format.column;\r\n\t\t\tif (!format.name && format.section) continue;\r\n\t\t\tif (!id) {\r\n\t\t\t\tthrow new RangeError(`Format #${i + 1} must have a name with alphanumeric characters, not '${format.name}'`);\r\n\t\t\t}\r\n\t\t\tif (!format.section) format.section = section;\r\n\t\t\tif (!format.column) format.column = column;\r\n\t\t\tif (this.rulesetCache.has(id)) throw new Error(`Format #${i + 1} has a duplicate ID: '${id}'`);\r\n\t\t\tformat.effectType = 'Format';\r\n\t\t\tformat.baseRuleset = format.ruleset ? format.ruleset.slice() : [];\r\n\t\t\tif (format.challengeShow === undefined) format.challengeShow = true;\r\n\t\t\tif (format.searchShow === undefined) format.searchShow = true;\r\n\t\t\tif (format.tournamentShow === undefined) format.tournamentShow = true;\r\n\t\t\tif (format.mod === undefined) format.mod = 'gen9';\r\n\t\t\tif (!this.dex.dexes[format.mod]) throw new Error(`Format \"${format.name}\" requires nonexistent mod: '${format.mod}'`);\r\n\r\n\t\t\tconst ruleset = new Format(format);\r\n\t\t\tthis.rulesetCache.set(id, ruleset);\r\n\t\t\tformatsList.push(ruleset);\r\n\t\t}\r\n\r\n\t\tthis.formatsListCache = formatsList;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a sanitized format ID if valid, or throws if invalid.\r\n\t */\r\n\tvalidate(name: string) {\r\n\t\tconst [formatName, customRulesString] = name.split('@@@', 2);\r\n\t\tconst format = this.get(formatName);\r\n\t\tif (!format.exists) throw new Error(`Unrecognized format \"${formatName}\"`);\r\n\t\tif (!customRulesString) return format.id;\r\n\t\tconst ruleTable = this.getRuleTable(format);\r\n\t\tconst customRules = customRulesString.split(',').map(rule => {\r\n\t\t\trule = rule.replace(/[\\r\\n|]*/g, '').trim();\r\n\t\t\tconst ruleSpec = this.validateRule(rule);\r\n\t\t\tif (typeof ruleSpec === 'string' && ruleTable.has(ruleSpec)) return null;\r\n\t\t\treturn rule;\r\n\t\t}).filter(Boolean);\r\n\t\tif (!customRules.length) throw new Error(`The format already has your custom rules`);\r\n\t\tconst validatedFormatid = format.id + '@@@' + customRules.join(',');\r\n\t\tconst moddedFormat = this.get(validatedFormatid, true);\r\n\t\tthis.getRuleTable(moddedFormat);\r\n\t\treturn validatedFormatid;\r\n\t}\r\n\r\n\tget(name?: string | Format, isTrusted = false): Format {\r\n\t\tif (name && typeof name !== 'string') return name;\r\n\r\n\t\tname = (name || '').trim();\r\n\t\tlet id = toID(name);\r\n\r\n\t\tif (!name.includes('@@@')) {\r\n\t\t\tconst ruleset = this.rulesetCache.get(id);\r\n\t\t\tif (ruleset) return ruleset;\r\n\t\t}\r\n\r\n\t\tif (this.dex.data.Aliases.hasOwnProperty(id)) {\r\n\t\t\tname = this.dex.data.Aliases[id];\r\n\t\t\tid = toID(name);\r\n\t\t}\r\n\t\tif (this.dex.data.Rulesets.hasOwnProperty(DEFAULT_MOD + id)) {\r\n\t\t\tid = (DEFAULT_MOD + id) as ID;\r\n\t\t}\r\n\t\tlet supplementaryAttributes: AnyObject | null = null;\r\n\t\tif (name.includes('@@@')) {\r\n\t\t\tif (!isTrusted) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tname = this.validate(name);\r\n\t\t\t\t\tisTrusted = true;\r\n\t\t\t\t} catch {}\r\n\t\t\t}\r\n\t\t\tconst [newName, customRulesString] = name.split('@@@', 2);\r\n\t\t\tname = newName.trim();\r\n\t\t\tid = toID(name);\r\n\t\t\tif (isTrusted && customRulesString) {\r\n\t\t\t\tsupplementaryAttributes = {\r\n\t\t\t\t\tcustomRules: customRulesString.split(','),\r\n\t\t\t\t\tsearchShow: false,\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\tlet effect;\r\n\t\tif (this.dex.data.Rulesets.hasOwnProperty(id)) {\r\n\t\t\teffect = new Format({name, ...this.dex.data.Rulesets[id] as any, ...supplementaryAttributes});\r\n\t\t} else {\r\n\t\t\teffect = new Format({id, name, exists: false});\r\n\t\t}\r\n\t\treturn effect;\r\n\t}\r\n\r\n\tall() {\r\n\t\tthis.load();\r\n\t\treturn this.formatsListCache!;\r\n\t}\r\n\r\n\tgetRuleTable(format: Format, depth = 1, repeals?: Map): RuleTable {\r\n\t\tif (format.ruleTable && !repeals) return format.ruleTable;\r\n\t\tif (depth === 1) {\r\n\t\t\tconst dex = this.dex.mod(format.mod);\r\n\t\t\tif (dex !== this.dex) {\r\n\t\t\t\treturn dex.formats.getRuleTable(format, 2, repeals);\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst ruleTable = new RuleTable();\r\n\r\n\t\tconst ruleset = format.ruleset.slice();\r\n\t\tfor (const ban of format.banlist) {\r\n\t\t\truleset.push('-' + ban);\r\n\t\t}\r\n\t\tfor (const ban of format.restricted) {\r\n\t\t\truleset.push('*' + ban);\r\n\t\t}\r\n\t\tfor (const ban of format.unbanlist) {\r\n\t\t\truleset.push('+' + ban);\r\n\t\t}\r\n\t\tif (format.customRules) {\r\n\t\t\truleset.push(...format.customRules);\r\n\t\t}\r\n\t\tif (format.checkCanLearn) {\r\n\t\t\truleTable.checkCanLearn = [format.checkCanLearn, format.name];\r\n\t\t}\r\n\t\tif (format.timer) {\r\n\t\t\truleTable.timer = [format.timer, format.name];\r\n\t\t}\r\n\r\n\t\t// apply rule repeals before other rules\r\n\t\t// repeals is a ruleid:depth map (positive: unused, negative: used)\r\n\t\tfor (const rule of ruleset) {\r\n\t\t\tif (rule.startsWith('!') && !rule.startsWith('!!')) {\r\n\t\t\t\tconst ruleSpec = this.validateRule(rule, format) as string;\r\n\t\t\t\tif (!repeals) repeals = new Map();\r\n\t\t\t\trepeals.set(ruleSpec.slice(1), depth);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const rule of ruleset) {\r\n\t\t\tconst ruleSpec = this.validateRule(rule, format);\r\n\r\n\t\t\tif (typeof ruleSpec !== 'string') {\r\n\t\t\t\tif (ruleSpec[0] === 'complexTeamBan') {\r\n\t\t\t\t\tconst complexTeamBan: ComplexTeamBan = ruleSpec.slice(1) as ComplexTeamBan;\r\n\t\t\t\t\truleTable.addComplexTeamBan(complexTeamBan[0], complexTeamBan[1], complexTeamBan[2], complexTeamBan[3]);\r\n\t\t\t\t} else if (ruleSpec[0] === 'complexBan') {\r\n\t\t\t\t\tconst complexBan: ComplexBan = ruleSpec.slice(1) as ComplexBan;\r\n\t\t\t\t\truleTable.addComplexBan(complexBan[0], complexBan[1], complexBan[2], complexBan[3]);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthrow new Error(`Unrecognized rule spec ${ruleSpec}`);\r\n\t\t\t\t}\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (rule.startsWith('!') && !rule.startsWith('!!')) {\r\n\t\t\t\tconst repealDepth = repeals!.get(ruleSpec.slice(1));\r\n\t\t\t\tif (repealDepth === undefined) throw new Error(`Multiple \"${rule}\" rules in ${format.name}`);\r\n\t\t\t\tif (repealDepth === depth) {\r\n\t\t\t\t\tthrow new Error(`Rule \"${rule}\" did nothing because \"${rule.slice(1)}\" is not in effect`);\r\n\t\t\t\t}\r\n\t\t\t\tif (repealDepth === -depth) repeals!.delete(ruleSpec.slice(1));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif ('+*-'.includes(ruleSpec.charAt(0))) {\r\n\t\t\t\tif (ruleTable.has(ruleSpec)) {\r\n\t\t\t\t\tthrow new Error(`Rule \"${rule}\" in \"${format.name}\" already exists in \"${ruleTable.get(ruleSpec) || format.name}\"`);\r\n\t\t\t\t}\r\n\t\t\t\tfor (const prefix of '+*-') ruleTable.delete(prefix + ruleSpec.slice(1));\r\n\t\t\t\truleTable.set(ruleSpec, '');\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tlet [formatid, value] = ruleSpec.split('=');\r\n\t\t\tconst subformat = this.get(formatid);\r\n\t\t\tconst repealAndReplace = ruleSpec.startsWith('!!');\r\n\t\t\tif (repeals?.has(subformat.id)) {\r\n\t\t\t\trepeals.set(subformat.id, -Math.abs(repeals.get(subformat.id)!));\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tif (subformat.hasValue) {\r\n\t\t\t\tif (value === undefined) throw new Error(`Rule \"${ruleSpec}\" should have a value (like \"${ruleSpec} = something\")`);\r\n\t\t\t\tif (value === 'Current Gen') value = `${this.dex.gen}`;\r\n\t\t\t\tif ((subformat.id === 'pickedteamsize' || subformat.id === 'evlimit') && value === 'Auto') {\r\n\t\t\t\t\t// can't be resolved until later\r\n\t\t\t\t} else if (subformat.hasValue === 'integer' || subformat.hasValue === 'positive-integer') {\r\n\t\t\t\t\tconst intValue = parseInt(value);\r\n\t\t\t\t\tif (isNaN(intValue) || value !== `${intValue}`) {\r\n\t\t\t\t\t\tthrow new Error(`In rule \"${ruleSpec}\", \"${value}\" must be an integer number.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (subformat.hasValue === 'positive-integer') {\r\n\t\t\t\t\tif (parseInt(value) === 0) {\r\n\t\t\t\t\t\tthrow new Error(`In rule \"${ruleSpec}\", \"${value}\" must be positive (to remove it, use the rule \"! ${subformat.name}\").`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (parseInt(value) <= 0) {\r\n\t\t\t\t\t\tthrow new Error(`In rule \"${ruleSpec}\", \"${value}\" must be positive.`);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tconst oldValue = ruleTable.valueRules.get(subformat.id);\r\n\t\t\t\tif (oldValue === value) {\r\n\t\t\t\t\tthrow new Error(`Rule \"${ruleSpec}\" is redundant with existing rule \"${subformat.id}=${value}\"${ruleTable.blame(subformat.id)}.`);\r\n\t\t\t\t} else if (repealAndReplace) {\r\n\t\t\t\t\tif (oldValue === undefined) {\r\n\t\t\t\t\t\tif (subformat.mutuallyExclusiveWith && ruleTable.valueRules.has(subformat.mutuallyExclusiveWith)) {\r\n\t\t\t\t\t\t\tif (this.dex.formats.get(subformat.mutuallyExclusiveWith).ruleset.length) {\r\n\t\t\t\t\t\t\t\tthrow new Error(`This format does not support \"!!\"`);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\truleTable.valueRules.delete(subformat.mutuallyExclusiveWith);\r\n\t\t\t\t\t\t\truleTable.delete(subformat.mutuallyExclusiveWith);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tthrow new Error(`Rule \"${ruleSpec}\" is not replacing anything (it should not have \"!!\")`);\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\tif (oldValue !== undefined) {\r\n\t\t\t\t\t\tthrow new Error(`Rule \"${ruleSpec}\" conflicts with \"${subformat.id}=${oldValue}\"${ruleTable.blame(subformat.id)} (Use \"!! ${ruleSpec}\" to override \"${subformat.id}=${oldValue}\".)`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (subformat.mutuallyExclusiveWith && ruleTable.valueRules.has(subformat.mutuallyExclusiveWith)) {\r\n\t\t\t\t\t\tconst oldRule = `\"${subformat.mutuallyExclusiveWith}=${ruleTable.valueRules.get(subformat.mutuallyExclusiveWith)}\"`;\r\n\t\t\t\t\t\tthrow new Error(`Format can't simultaneously have \"${ruleSpec}\" and ${oldRule}${ruleTable.blame(subformat.mutuallyExclusiveWith)} (Use \"!! ${ruleSpec}\" to override ${oldRule}.)`);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\truleTable.valueRules.set(subformat.id, value);\r\n\t\t\t} else {\r\n\t\t\t\tif (value !== undefined) throw new Error(`Rule \"${ruleSpec}\" should not have a value (no equals sign)`);\r\n\t\t\t\tif (repealAndReplace) throw new Error(`\"!!\" is not supported for this rule`);\r\n\t\t\t\tif (ruleTable.has(subformat.id) && !repealAndReplace) {\r\n\t\t\t\t\tthrow new Error(`Rule \"${rule}\" in \"${format.name}\" already exists in \"${ruleTable.get(subformat.id) || format.name}\"`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\truleTable.set(subformat.id, '');\r\n\t\t\tif (depth > 16) {\r\n\t\t\t\tthrow new Error(`Excessive ruleTable recursion in ${format.name}: ${ruleSpec} of ${format.ruleset}`);\r\n\t\t\t}\r\n\t\t\tconst subRuleTable = this.getRuleTable(subformat, depth + 1, repeals);\r\n\t\t\tfor (const [ruleid, sourceFormat] of subRuleTable) {\r\n\t\t\t\t// don't check for \"already exists\" here; multiple inheritance is allowed\r\n\t\t\t\tif (!repeals?.has(ruleid)) {\r\n\t\t\t\t\tconst newValue = subRuleTable.valueRules.get(ruleid);\r\n\t\t\t\t\tconst oldValue = ruleTable.valueRules.get(ruleid);\r\n\t\t\t\t\tif (newValue !== undefined) {\r\n\t\t\t\t\t\t// set a value\r\n\t\t\t\t\t\tconst subSubFormat = this.get(ruleid);\r\n\t\t\t\t\t\tif (subSubFormat.mutuallyExclusiveWith && ruleTable.valueRules.has(subSubFormat.mutuallyExclusiveWith)) {\r\n\t\t\t\t\t\t\t// mutually exclusive conflict!\r\n\t\t\t\t\t\t\tthrow new Error(`Rule \"${ruleid}=${newValue}\" from ${subformat.name}${subRuleTable.blame(ruleid)} conflicts with \"${subSubFormat.mutuallyExclusiveWith}=${ruleTable.valueRules.get(subSubFormat.mutuallyExclusiveWith)}\"${ruleTable.blame(subSubFormat.mutuallyExclusiveWith)} (Repeal one with ! before adding another)`);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (newValue !== oldValue) {\r\n\t\t\t\t\t\t\tif (oldValue !== undefined) {\r\n\t\t\t\t\t\t\t\t// conflict!\r\n\t\t\t\t\t\t\t\tthrow new Error(`Rule \"${ruleid}=${newValue}\" from ${subformat.name}${subRuleTable.blame(ruleid)} conflicts with \"${ruleid}=${oldValue}\"${ruleTable.blame(ruleid)} (Repeal one with ! before adding another)`);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\truleTable.valueRules.set(ruleid, newValue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\truleTable.set(ruleid, sourceFormat || subformat.name);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tfor (const [subRule, source, limit, bans] of subRuleTable.complexBans) {\r\n\t\t\t\truleTable.addComplexBan(subRule, source || subformat.name, limit, bans);\r\n\t\t\t}\r\n\t\t\tfor (const [subRule, source, limit, bans] of subRuleTable.complexTeamBans) {\r\n\t\t\t\truleTable.addComplexTeamBan(subRule, source || subformat.name, limit, bans);\r\n\t\t\t}\r\n\t\t\tif (subRuleTable.checkCanLearn) {\r\n\t\t\t\tif (ruleTable.checkCanLearn) {\r\n\t\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\t`\"${format.name}\" has conflicting move validation rules from ` +\r\n\t\t\t\t\t\t`\"${ruleTable.checkCanLearn[1]}\" and \"${subRuleTable.checkCanLearn[1]}\"`\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\truleTable.checkCanLearn = subRuleTable.checkCanLearn;\r\n\t\t\t}\r\n\t\t\tif (subRuleTable.timer) {\r\n\t\t\t\tif (ruleTable.timer) {\r\n\t\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\t`\"${format.name}\" has conflicting timer validation rules from \"${ruleTable.timer[1]}\" and \"${subRuleTable.timer[1]}\"`\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\truleTable.timer = subRuleTable.timer;\r\n\t\t\t}\r\n\t\t}\r\n\t\truleTable.getTagRules();\r\n\r\n\t\truleTable.resolveNumbers(format, this.dex);\r\n\r\n\t\tconst canMegaEvo = this.dex.gen <= 7 || ruleTable.has('+pokemontag:past');\r\n\t\tif (ruleTable.has('obtainableformes') && canMegaEvo &&\r\n\t\t\truleTable.isBannedSpecies(this.dex.species.get('rayquazamega')) &&\r\n\t\t\t!ruleTable.isBannedSpecies(this.dex.species.get('rayquaza'))\r\n\t\t) {\r\n\t\t\t// Banning Rayquaza-Mega implicitly adds Mega Rayquaza Clause\r\n\t\t\t// note that already having it explicitly in the ruleset is ok\r\n\t\t\truleTable.set('megarayquazaclause', '');\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 = this.dex.formats.get(rule);\r\n\t\t\tif (subFormat.exists) {\r\n\t\t\t\tconst value = subFormat.onValidateRule?.call({format, ruleTable, dex: this.dex}, ruleTable.valueRules.get(rule as ID)!);\r\n\t\t\t\tif (typeof value === 'string') ruleTable.valueRules.set(subFormat.id, value);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!repeals) format.ruleTable = ruleTable;\r\n\t\treturn ruleTable;\r\n\t}\r\n\r\n\tvalidateRule(rule: string, format: Format | null = null) {\r\n\t\tif (rule !== rule.trim()) throw new Error(`Rule \"${rule}\" should be trimmed`);\r\n\t\tswitch (rule.charAt(0)) {\r\n\t\tcase '-':\r\n\t\tcase '*':\r\n\t\tcase '+':\r\n\t\t\tif (rule.slice(1).includes('>') || rule.slice(1).includes('+')) {\r\n\t\t\t\tlet buf = rule.slice(1);\r\n\t\t\t\tconst gtIndex = buf.lastIndexOf('>');\r\n\t\t\t\tlet limit = rule.startsWith('+') ? Infinity : 0;\r\n\t\t\t\tif (gtIndex >= 0 && /^[0-9]+$/.test(buf.slice(gtIndex + 1).trim())) {\r\n\t\t\t\t\tif (limit === 0) limit = parseInt(buf.slice(gtIndex + 1));\r\n\t\t\t\t\tbuf = buf.slice(0, gtIndex);\r\n\t\t\t\t}\r\n\t\t\t\tlet checkTeam = buf.includes('++');\r\n\t\t\t\tconst banNames = buf.split(checkTeam ? '++' : '+').map(v => v.trim());\r\n\t\t\t\tif (banNames.length === 1 && limit > 0) checkTeam = true;\r\n\t\t\t\tconst innerRule = banNames.join(checkTeam ? ' ++ ' : ' + ');\r\n\t\t\t\tconst bans = banNames.map(v => this.validateBanRule(v));\r\n\r\n\t\t\t\tif (checkTeam) {\r\n\t\t\t\t\treturn ['complexTeamBan', innerRule, '', limit, bans];\r\n\t\t\t\t}\r\n\t\t\t\tif (bans.length > 1 || limit > 0) {\r\n\t\t\t\t\treturn ['complexBan', innerRule, '', limit, bans];\r\n\t\t\t\t}\r\n\t\t\t\tthrow new Error(`Confusing rule ${rule}`);\r\n\t\t\t}\r\n\t\t\treturn rule.charAt(0) + this.validateBanRule(rule.slice(1));\r\n\t\tdefault:\r\n\t\t\tconst [ruleName, value] = rule.split('=');\r\n\t\t\tlet id: string = toID(ruleName);\r\n\t\t\tconst ruleset = this.dex.formats.get(id);\r\n\t\t\tif (!ruleset.exists) {\r\n\t\t\t\tthrow new Error(`Unrecognized rule \"${rule}\"`);\r\n\t\t\t}\r\n\t\t\tif (typeof value === 'string') id = `${id}=${value.trim()}`;\r\n\t\t\tif (rule.startsWith('!!')) return `!!${id}`;\r\n\t\t\tif (rule.startsWith('!')) return `!${id}`;\r\n\t\t\treturn id;\r\n\t\t}\r\n\t}\r\n\r\n\tvalidPokemonTag(tagid: ID) {\r\n\t\tconst tag = Tags.hasOwnProperty(tagid) && Tags[tagid];\r\n\t\tif (!tag) return false;\r\n\t\treturn !!(tag.speciesFilter || tag.genericFilter);\r\n\t}\r\n\r\n\tvalidateBanRule(rule: string) {\r\n\t\tlet id = toID(rule);\r\n\t\tif (id === 'unreleased') return 'unreleased';\r\n\t\tif (id === 'nonexistent') return 'nonexistent';\r\n\t\tconst matches = [];\r\n\t\tlet matchTypes = ['pokemon', 'move', 'ability', 'item', 'nature', 'pokemontag'];\r\n\t\tfor (const matchType of matchTypes) {\r\n\t\t\tif (rule.startsWith(`${matchType}:`)) {\r\n\t\t\t\tmatchTypes = [matchType];\r\n\t\t\t\tid = id.slice(matchType.length) as ID;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst ruleid = id;\r\n\t\tif (this.dex.data.Aliases.hasOwnProperty(id)) id = toID(this.dex.data.Aliases[id]);\r\n\t\tfor (const matchType of matchTypes) {\r\n\t\t\tif (matchType === 'item' && ruleid === 'noitem') return 'item:noitem';\r\n\t\t\tlet table;\r\n\t\t\tswitch (matchType) {\r\n\t\t\tcase 'pokemon': table = this.dex.data.Pokedex; break;\r\n\t\t\tcase 'move': table = this.dex.data.Moves; break;\r\n\t\t\tcase 'item': table = this.dex.data.Items; break;\r\n\t\t\tcase 'ability': table = this.dex.data.Abilities; break;\r\n\t\t\tcase 'nature': table = this.dex.data.Natures; break;\r\n\t\t\tcase 'pokemontag':\r\n\t\t\t\t// valid pokemontags\r\n\t\t\t\tconst validTags = [\r\n\t\t\t\t\t// all\r\n\t\t\t\t\t'allpokemon', 'allitems', 'allmoves', 'allabilities', 'allnatures',\r\n\t\t\t\t];\r\n\t\t\t\tif (validTags.includes(ruleid) || this.validPokemonTag(ruleid)) {\r\n\t\t\t\t\tmatches.push('pokemontag:' + ruleid);\r\n\t\t\t\t}\r\n\t\t\t\tcontinue;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(`Unrecognized match type.`);\r\n\t\t\t}\r\n\t\t\tif (table.hasOwnProperty(id)) {\r\n\t\t\t\tif (matchType === 'pokemon') {\r\n\t\t\t\t\tconst species: Species = table[id] as Species;\r\n\t\t\t\t\tif ((species.otherFormes || species.cosmeticFormes) && ruleid !== species.id + toID(species.baseForme)) {\r\n\t\t\t\t\t\tmatches.push('basepokemon:' + id);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tmatches.push(matchType + ':' + id);\r\n\t\t\t} else if (matchType === 'pokemon' && id.endsWith('base')) {\r\n\t\t\t\tid = id.slice(0, -4) as ID;\r\n\t\t\t\tif (table.hasOwnProperty(id)) {\r\n\t\t\t\t\tmatches.push('pokemon:' + id);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (matches.length > 1) {\r\n\t\t\tthrow new Error(`More than one thing matches \"${rule}\"; please specify one of: ` + matches.join(', '));\r\n\t\t}\r\n\t\tif (matches.length < 1) {\r\n\t\t\tthrow new Error(`Nothing matches \"${rule}\"`);\r\n\t\t}\r\n\t\treturn matches[0];\r\n\t}\r\n}\r\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,sBAAgC;AAEhC,kBAAmB;AAEnB,MAAM,cAAc;AAwBb,MAAM,kBAAkB,IAAoB;AAAA,EAqBlD,cAAc;AACb,UAAM;AACN,SAAK,cAAc,CAAC;AACpB,SAAK,kBAAkB,CAAC;AACxB,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,WAAW,CAAC;AACjB,SAAK,aAAa,oBAAI,IAAI;AAAA,EAC3B;AAAA,EAEA,SAAS,OAAe;AACvB,QAAI,KAAK,IAAI,IAAI,OAAO;AAAG,aAAO;AAClC,WAAO,KAAK,IAAI,IAAI,OAAO;AAAA,EAC5B;AAAA,EAEA,gBAAgB,SAAkB;AACjC,QAAI,KAAK,IAAI,YAAY,QAAQ,IAAI;AAAG,aAAO;AAC/C,QAAI,KAAK,IAAI,YAAY,QAAQ,IAAI;AAAG,aAAO;AAC/C,QAAI,KAAK,IAAI,oBAAgB,sBAAK,QAAQ,WAAW,GAAG;AAAG,aAAO;AAClE,QAAI,KAAK,IAAI,oBAAgB,sBAAK,QAAQ,WAAW,GAAG;AAAG,aAAO;AAClE,eAAW,SAAS,kBAAM;AACzB,YAAM,MAAM,iBAAK,KAAK;AACtB,UAAI,KAAK,IAAI,eAAe,OAAO,GAAG;AACrC,aAAK,IAAI,iBAAiB,IAAI,eAAgB,OAAO;AAAG,iBAAO;AAAA,MAChE;AAAA,IACD;AACA,eAAW,SAAS,kBAAM;AACzB,YAAM,MAAM,iBAAK,KAAK;AACtB,UAAI,KAAK,IAAI,eAAe,OAAO,GAAG;AACrC,aAAK,IAAI,iBAAiB,IA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