{ "version": 3, "sources": ["../../../data/random-teams.ts"], "sourcesContent": ["import {Dex, toID} from '../sim/dex';\r\nimport {Utils} from '../lib';\r\nimport {PRNG, PRNGSeed} from '../sim/prng';\r\nimport {RuleTable} from '../sim/dex-formats';\r\nimport {Tags} from './tags';\r\n\r\nexport interface TeamData {\r\n\ttypeCount: {[k: string]: number};\r\n\ttypeComboCount: {[k: string]: number};\r\n\tbaseFormes: {[k: string]: number};\r\n\tmegaCount?: number;\r\n\tzCount?: number;\r\n\thas: {[k: string]: number};\r\n\tforceResult: boolean;\r\n\tweaknesses: {[k: string]: number};\r\n\tresistances: {[k: string]: number};\r\n\tweather?: string;\r\n\teeveeLimCount?: number;\r\n\tgigantamax?: boolean;\r\n}\r\nexport interface BattleFactorySpecies {\r\n\tflags: {limEevee?: 1};\r\n\tsets: BattleFactorySet[];\r\n}\r\ninterface BattleFactorySet {\r\n\tspecies: string;\r\n\titem: string;\r\n\tability: string;\r\n\tnature: string;\r\n\tmoves: string[];\r\n\tevs?: Partial;\r\n\tivs?: Partial;\r\n}\r\nexport class MoveCounter extends Utils.Multiset {\r\n\tdamagingMoves: Set;\r\n\tstabCounter: number;\r\n\tironFist: number;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.damagingMoves = new Set();\r\n\t\tthis.stabCounter = 0;\r\n\t\tthis.ironFist = 0;\r\n\t}\r\n\r\n\tget(key: string): number {\r\n\t\treturn super.get(key) || 0;\r\n\t}\r\n}\r\n\r\ntype MoveEnforcementChecker = (\r\n\tmovePool: string[], moves: Set, abilities: Set, types: string[],\r\n\tcounter: MoveCounter, species: Species, teamDetails: RandomTeamsTypes.TeamDetails,\r\n\tisLead: boolean, isDoubles: boolean, teraType: string, role: string,\r\n) => boolean;\r\n\r\n// Moves that restore HP:\r\nconst RecoveryMove = [\r\n\t'healorder', 'milkdrink', 'moonlight', 'morningsun', 'recover', 'roost', 'shoreup', 'slackoff', 'softboiled', 'strengthsap', 'synthesis',\r\n];\r\n// Moves that drop stats:\r\nconst ContraryMoves = [\r\n\t'armorcannon', 'closecombat', 'leafstorm', 'makeitrain', 'overheat', 'spinout', 'superpower', 'vcreate',\r\n];\r\n// Moves that boost Attack:\r\nconst PhysicalSetup = [\r\n\t'bellydrum', 'bulkup', 'coil', 'curse', 'dragondance', 'honeclaws', 'howl', 'meditate', 'poweruppunch', 'swordsdance', 'tidyup',\r\n];\r\n// Moves which boost Special Attack:\r\nconst SpecialSetup = [\r\n\t'calmmind', 'chargebeam', 'geomancy', 'nastyplot', 'quiverdance', 'tailglow', 'torchsong',\r\n];\r\n// Moves that boost Attack AND Special Attack:\r\nconst MixedSetup = [\r\n\t'clangoroussoul', 'growth', 'happyhour', 'holdhands', 'noretreat', 'shellsmash', 'workup',\r\n];\r\n// Some moves that only boost Speed:\r\nconst SpeedSetup = [\r\n\t'agility', 'autotomize', 'rockpolish',\r\n];\r\n// Conglomerate for ease of access\r\nconst Setup = [\r\n\t'acidarmor', 'agility', 'autotomize', 'bellydrum', 'bulkup', 'calmmind', 'coil', 'curse', 'dragondance', 'flamecharge',\r\n\t'growth', 'honeclaws', 'howl', 'irondefense', 'meditate', 'nastyplot', 'noretreat', 'poweruppunch', 'quiverdance', 'rockpolish',\r\n\t'shellsmash', 'shiftgear', 'swordsdance', 'tailglow', 'tidyup', 'trailblaze', 'workup',\r\n];\r\n// Moves that shouldn't be the only STAB moves:\r\nconst NoStab = [\r\n\t'accelerock', 'aquajet', 'beakblast', 'bounce', 'breakingswipe', 'chatter', 'chloroblast', 'clearsmog', 'dragontail', 'eruption',\r\n\t'explosion', 'fakeout', 'flamecharge', 'flipturn', 'iceshard', 'icywind', 'incinerate', 'machpunch', 'meteorbeam',\r\n\t'mortalspin', 'pluck', 'pursuit', 'quickattack', 'rapidspin', 'reversal', 'selfdestruct', 'shadowsneak',\r\n\t'skydrop', 'snarl', 'suckerpunch', 'uturn', 'watershuriken', 'vacuumwave', 'voltswitch', 'waterspout',\r\n];\r\n// Hazard-setting moves\r\nconst Hazards = [\r\n\t'spikes', 'stealthrock', 'stickyweb', 'toxicspikes',\r\n];\r\n\r\n// Moves that should be paired together when possible\r\nconst MovePairs = [\r\n\t['lightscreen', 'reflect'],\r\n\t['sleeptalk', 'rest'],\r\n\t['protect', 'wish'],\r\n\t['leechseed', 'protect'],\r\n];\r\n\r\n// Pokemon who always want priority STAB, and are fine with it as its only STAB move of that type\r\nconst PriorityPokemon = [\r\n\t'banette', 'breloom', 'brutebonnet', 'cacturne', 'giratinaorigin', 'lycanrocdusk', 'mimikyu', 'scizor',\r\n];\r\n\r\nfunction sereneGraceBenefits(move: Move) {\r\n\treturn move.secondary?.chance && move.secondary.chance > 20 && move.secondary.chance < 100;\r\n}\r\n\r\nexport class RandomTeams {\r\n\tdex: ModdedDex;\r\n\tgen: number;\r\n\tfactoryTier: string;\r\n\tformat: Format;\r\n\tprng: PRNG;\r\n\tnoStab: string[];\r\n\treadonly maxTeamSize: number;\r\n\treadonly adjustLevel: number | null;\r\n\treadonly maxMoveCount: number;\r\n\treadonly forceMonotype: string | undefined;\r\n\r\n\t/**\r\n\t * Checkers for move enforcement based on types or other factors\r\n\t *\r\n\t * returns true to try to force the move type, false otherwise.\r\n\t */\r\n\tmoveEnforcementCheckers: {[k: string]: MoveEnforcementChecker};\r\n\r\n\tconstructor(format: Format | string, prng: PRNG | PRNGSeed | null) {\r\n\t\tformat = Dex.formats.get(format);\r\n\t\tthis.dex = Dex.forFormat(format);\r\n\t\tthis.gen = this.dex.gen;\r\n\t\tthis.noStab = NoStab;\r\n\r\n\t\tconst ruleTable = Dex.formats.getRuleTable(format);\r\n\t\tthis.maxTeamSize = ruleTable.maxTeamSize;\r\n\t\tthis.adjustLevel = ruleTable.adjustLevel;\r\n\t\tthis.maxMoveCount = ruleTable.maxMoveCount;\r\n\t\tconst forceMonotype = ruleTable.valueRules.get('forcemonotype');\r\n\t\tthis.forceMonotype = forceMonotype && this.dex.types.get(forceMonotype).exists ?\r\n\t\t\tthis.dex.types.get(forceMonotype).name : undefined;\r\n\r\n\t\tthis.factoryTier = '';\r\n\t\tthis.format = format;\r\n\t\tthis.prng = prng && !Array.isArray(prng) ? prng : new PRNG(prng);\r\n\r\n\t\tthis.moveEnforcementCheckers = {\r\n\t\t\tBug: (movePool) => movePool.includes('megahorn'),\r\n\t\t\tDark: (movePool, moves, abilities, types, counter) => !counter.get('Dark'),\r\n\t\t\tDragon: (movePool, moves, abilities, types, counter) => (\r\n\t\t\t\t!counter.get('Dragon') &&\r\n\t\t\t\t!movePool.includes('dualwingbeat')\r\n\t\t\t),\r\n\t\t\tElectric: (movePool, moves, abilities, types, counter) => !counter.get('Electric'),\r\n\t\t\tFairy: (movePool, moves, abilities, types, counter) => !counter.get('Fairy'),\r\n\t\t\tFighting: (movePool, moves, abilities, types, counter) => !counter.get('Fighting'),\r\n\t\t\tFire: (movePool, moves, abilities, types, counter, species) => !counter.get('Fire'),\r\n\t\t\tFlying: (movePool, moves, abilities, types, counter) => !counter.get('Flying'),\r\n\t\t\tGhost: (movePool, moves, abilities, types, counter) => !counter.get('Ghost'),\r\n\t\t\tGrass: (movePool, moves, abilities, types, counter, species) => (\r\n\t\t\t\t!counter.get('Grass') && (\r\n\t\t\t\t\tmovePool.includes('leafstorm') || species.baseStats.atk >= 100 ||\r\n\t\t\t\t\ttypes.includes('Electric') || abilities.has('Seed Sower')\r\n\t\t\t\t)\r\n\t\t\t),\r\n\t\t\tGround: (movePool, moves, abilities, types, counter) => !counter.get('Ground'),\r\n\t\t\tIce: (movePool, moves, abilities, types, counter) => (movePool.includes('freezedry') || !counter.get('Ice')),\r\n\t\t\tNormal: (movePool, moves, types, counter) => (movePool.includes('boomburst') || movePool.includes('hypervoice')),\r\n\t\t\tPoison: (movePool, moves, abilities, types, counter) => {\r\n\t\t\t\tif (types.includes('Ground')) return false;\r\n\t\t\t\treturn !counter.get('Poison');\r\n\t\t\t},\r\n\t\t\tPsychic: (movePool, moves, abilities, types, counter) => {\r\n\t\t\t\tif (counter.get('Psychic')) return false;\r\n\t\t\t\tif (movePool.includes('calmmind') || movePool.includes('psychicfangs') || movePool.includes('psychocut')) return true;\r\n\t\t\t\treturn abilities.has('Psychic Surge') || types.includes('Fire') || types.includes('Electric');\r\n\t\t\t},\r\n\t\t\tRock: (movePool, moves, abilities, types, counter, species) => !counter.get('Rock') && species.baseStats.atk >= 80,\r\n\t\t\tSteel: (movePool, moves, abilities, types, counter, species) => {\r\n\t\t\t\tif (species.baseStats.atk <= 95 && !movePool.includes('makeitrain')) return false;\r\n\t\t\t\treturn !counter.get('Steel');\r\n\t\t\t},\r\n\t\t\tWater: (movePool, moves, abilities, types, counter, species) => {\r\n\t\t\t\tif (types.includes('Ground')) return false;\r\n\t\t\t\treturn !counter.get('Water');\r\n\t\t\t},\r\n\t\t};\r\n\t}\r\n\r\n\tsetSeed(prng?: PRNG | PRNGSeed) {\r\n\t\tthis.prng = prng && !Array.isArray(prng) ? prng : new PRNG(prng);\r\n\t}\r\n\r\n\tgetTeam(options?: PlayerOptions | null): PokemonSet[] {\r\n\t\tconst generatorName = (\r\n\t\t\ttypeof this.format.team === 'string' && this.format.team.startsWith('random')\r\n\t\t ) ? this.format.team + 'Team' : '';\r\n\t\t// @ts-ignore\r\n\t\treturn this[generatorName || 'randomTeam'](options);\r\n\t}\r\n\r\n\trandomChance(numerator: number, denominator: number) {\r\n\t\treturn this.prng.randomChance(numerator, denominator);\r\n\t}\r\n\r\n\tsample(items: readonly T[]): T {\r\n\t\treturn this.prng.sample(items);\r\n\t}\r\n\r\n\tsampleIfArray(item: T | T[]): T {\r\n\t\tif (Array.isArray(item)) {\r\n\t\t\treturn this.sample(item);\r\n\t\t}\r\n\t\treturn item;\r\n\t}\r\n\r\n\trandom(m?: number, n?: number) {\r\n\t\treturn this.prng.next(m, n);\r\n\t}\r\n\r\n\t/**\r\n\t * Remove an element from an unsorted array significantly faster\r\n\t * than .splice\r\n\t */\r\n\tfastPop(list: any[], index: number) {\r\n\t\t// If an array doesn't need to be in order, replacing the\r\n\t\t// element at the given index with the removed element\r\n\t\t// is much, much faster than using list.splice(index, 1).\r\n\t\tconst length = list.length;\r\n\t\tif (index < 0 || index >= list.length) {\r\n\t\t\t// sanity check\r\n\t\t\tthrow new Error(`Index ${index} out of bounds for given array`);\r\n\t\t}\r\n\r\n\t\tconst element = list[index];\r\n\t\tlist[index] = list[length - 1];\r\n\t\tlist.pop();\r\n\t\treturn element;\r\n\t}\r\n\r\n\t/**\r\n\t * Remove a random element from an unsorted array and return it.\r\n\t * Uses the battle's RNG if in a battle.\r\n\t */\r\n\tsampleNoReplace(list: any[]) {\r\n\t\tconst length = list.length;\r\n\t\tif (length === 0) return null;\r\n\t\tconst index = this.random(length);\r\n\t\treturn this.fastPop(list, index);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes n random elements from an unsorted array and returns them.\r\n\t * If n is less than the array's length, randomly removes and returns all the elements\r\n\t * in the array (so the returned array could have length < n).\r\n\t */\r\n\tmultipleSamplesNoReplace(list: T[], n: number): T[] {\r\n\t\tconst samples = [];\r\n\t\twhile (samples.length < n && list.length) {\r\n\t\t\tsamples.push(this.sampleNoReplace(list));\r\n\t\t}\r\n\r\n\t\treturn samples;\r\n\t}\r\n\r\n\t/**\r\n\t * Check if user has directly tried to ban/unban/restrict things in a custom battle.\r\n\t * Doesn't count bans nested inside other formats/rules.\r\n\t */\r\n\tprivate hasDirectCustomBanlistChanges() {\r\n\t\tif (this.format.banlist.length || this.format.restricted.length || this.format.unbanlist.length) return true;\r\n\t\tif (!this.format.customRules) return false;\r\n\t\tfor (const rule of this.format.customRules) {\r\n\t\t\tfor (const banlistOperator of ['-', '+', '*']) {\r\n\t\t\t\tif (rule.startsWith(banlistOperator)) return true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * Inform user when custom bans are unsupported in a team generator.\r\n\t */\r\n\tprotected enforceNoDirectCustomBanlistChanges() {\r\n\t\tif (this.hasDirectCustomBanlistChanges()) {\r\n\t\t\tthrow new Error(`Custom bans are not currently supported in ${this.format.name}.`);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Inform user when complex bans are unsupported in a team generator.\r\n\t */\r\n\tprotected enforceNoDirectComplexBans() {\r\n\t\tif (!this.format.customRules) return false;\r\n\t\tfor (const rule of this.format.customRules) {\r\n\t\t\tif (rule.includes('+') && !rule.startsWith('+')) {\r\n\t\t\t\tthrow new Error(`Complex bans are not currently supported in ${this.format.name}.`);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Validate set element pool size is sufficient to support size requirements after simple bans.\r\n\t */\r\n\tprivate enforceCustomPoolSizeNoComplexBans(\r\n\t\teffectTypeName: string,\r\n\t\tbasicEffectPool: BasicEffect[],\r\n\t\trequiredCount: number,\r\n\t\trequiredCountExplanation: string\r\n\t) {\r\n\t\tif (basicEffectPool.length >= requiredCount) return;\r\n\t\tthrow new Error(`Legal ${effectTypeName} count is insufficient to support ${requiredCountExplanation} (${basicEffectPool.length} / ${requiredCount}).`);\r\n\t}\r\n\r\n\tqueryMoves(\r\n\t\tmoves: Set | null,\r\n\t\tspecies: Species,\r\n\t\tteraType: string,\r\n\t\tabilities: Set = new Set(),\r\n\t): MoveCounter {\r\n\t\t// This is primarily a helper function for random setbuilder functions.\r\n\t\tconst counter = new MoveCounter();\r\n\t\tconst types = species.types;\r\n\t\tif (!moves?.size) return counter;\r\n\r\n\t\tconst categories = {Physical: 0, Special: 0, Status: 0};\r\n\r\n\t\t// Iterate through all moves we've chosen so far and keep track of what they do:\r\n\t\tfor (const moveid of moves) {\r\n\t\t\tconst move = this.dex.moves.get(moveid);\r\n\r\n\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\tif (move.damage || move.damageCallback) {\r\n\t\t\t\t// Moves that do a set amount of damage:\r\n\t\t\t\tcounter.add('damage');\r\n\t\t\t\tcounter.damagingMoves.add(move);\r\n\t\t\t} else {\r\n\t\t\t\t// Are Physical/Special/Status moves:\r\n\t\t\t\tcategories[move.category]++;\r\n\t\t\t}\r\n\t\t\t// Moves that have a low base power:\r\n\t\t\tif (moveid === 'lowkick' || (move.basePower && move.basePower <= 60 && moveid !== 'rapidspin')) {\r\n\t\t\t\tcounter.add('technician');\r\n\t\t\t}\r\n\t\t\t// Moves that hit up to 5 times:\r\n\t\t\tif (move.multihit && Array.isArray(move.multihit) && move.multihit[1] === 5) counter.add('skilllink');\r\n\t\t\tif (move.recoil || move.hasCrashDamage) counter.add('recoil');\r\n\t\t\tif (move.drain) counter.add('drain');\r\n\t\t\t// Moves which have a base power, but aren't super-weak:\r\n\t\t\tif (move.basePower > 30 || move.multihit || move.basePowerCallback) {\r\n\t\t\t\tif (!this.noStab.includes(moveid) || PriorityPokemon.includes(species.id) && move.priority > 0) {\r\n\t\t\t\t\tcounter.add(moveType);\r\n\t\t\t\t\tif (types.includes(moveType)) counter.stabCounter++;\r\n\t\t\t\t\tif (teraType === moveType) counter.add('stabtera');\r\n\t\t\t\t}\r\n\t\t\t\tif (move.flags['bite']) counter.add('strongjaw');\r\n\t\t\t\tif (move.flags['punch']) counter.ironFist++;\r\n\t\t\t\tif (move.flags['sound']) counter.add('sound');\r\n\t\t\t\tif (move.priority > 0 || (moveid === 'grassyglide' && abilities.has('Grassy Surge'))) {\r\n\t\t\t\t\tcounter.add('priority');\r\n\t\t\t\t}\r\n\t\t\t\tcounter.damagingMoves.add(move);\r\n\t\t\t}\r\n\t\t\t// Moves with secondary effects:\r\n\t\t\tif (move.secondary || move.hasSheerForce) {\r\n\t\t\t\tcounter.add('sheerforce');\r\n\t\t\t\tif (sereneGraceBenefits(move)) {\r\n\t\t\t\t\tcounter.add('serenegrace');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Moves with low accuracy:\r\n\t\t\tif (move.accuracy && move.accuracy !== true && move.accuracy < 90) counter.add('inaccurate');\r\n\r\n\t\t\t// Moves that change stats:\r\n\t\t\tif (RecoveryMove.includes(moveid)) counter.add('recovery');\r\n\t\t\tif (ContraryMoves.includes(moveid)) counter.add('contrary');\r\n\t\t\tif (PhysicalSetup.includes(moveid)) counter.add('physicalsetup');\r\n\t\t\tif (SpecialSetup.includes(moveid)) counter.add('specialsetup');\r\n\t\t\tif (MixedSetup.includes(moveid)) counter.add('mixedsetup');\r\n\t\t\tif (SpeedSetup.includes(moveid)) counter.add('speedsetup');\r\n\t\t\tif (Setup.includes(moveid)) counter.add('setup');\r\n\t\t\tif (Hazards.includes(moveid)) counter.add('hazards');\r\n\t\t}\r\n\r\n\t\tcounter.set('Physical', Math.floor(categories['Physical']));\r\n\t\tcounter.set('Special', Math.floor(categories['Special']));\r\n\t\tcounter.set('Status', categories['Status']);\r\n\t\treturn counter;\r\n\t}\r\n\r\n\tcullMovePool(\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tabilities: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tmovePool: string[],\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): void {\r\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\r\n\t\t// If we have two unfilled moves and only one unpaired move, cull the unpaired move.\r\n\t\tif (moves.size === this.maxMoveCount - 2) {\r\n\t\t\tconst unpairedMoves = [...movePool];\r\n\t\t\tfor (const pair of MovePairs) {\r\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\r\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[0]));\r\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[1]));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (unpairedMoves.length === 1) {\r\n\t\t\t\tthis.fastPop(movePool, movePool.indexOf(unpairedMoves[0]));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// These moves are paired, and shouldn't appear if there is not room for them both.\r\n\t\tif (moves.size === this.maxMoveCount - 1) {\r\n\t\t\tfor (const pair of MovePairs) {\r\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\r\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[0]));\r\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[1]));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Develop additional move lists\r\n\t\tconst pivotingMoves = ['chillyreception', 'flipturn', 'partingshot', 'shedtail', 'teleport', 'uturn', 'voltswitch'];\r\n\t\tconst statusMoves = this.dex.moves.all()\r\n\t\t\t.filter(move => move.category === 'Status')\r\n\t\t\t.map(move => move.id);\r\n\r\n\t\t// Team-based move culls\r\n\t\tif (teamDetails.stealthRock) {\r\n\t\t\tif (movePool.includes('stealthrock')) this.fastPop(movePool, movePool.indexOf('stealthrock'));\r\n\t\t}\r\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\r\n\t\tif (teamDetails.defog || teamDetails.rapidSpin) {\r\n\t\t\tif (movePool.includes('defog')) this.fastPop(movePool, movePool.indexOf('defog'));\r\n\t\t\tif (movePool.includes('rapidspin')) this.fastPop(movePool, movePool.indexOf('rapidspin'));\r\n\t\t}\r\n\t\tif (teamDetails.stickyWeb) {\r\n\t\t\tif (movePool.includes('stickyweb')) this.fastPop(movePool, movePool.indexOf('stickyweb'));\r\n\t\t}\r\n\r\n\t\t// These moves don't mesh well with other aspects of the set\r\n\t\tthis.incompatibleMoves(moves, movePool, statusMoves, ['healingwish', 'switcheroo', 'trick']);\r\n\t\tif (species.id !== \"scyther\" && species.id !== \"scizor\") {\r\n\t\t\tthis.incompatibleMoves(moves, movePool, Setup, pivotingMoves);\r\n\t\t}\r\n\t\tthis.incompatibleMoves(moves, movePool, Setup, Hazards);\r\n\t\tthis.incompatibleMoves(moves, movePool, Setup, ['defog', 'nuzzle', 'toxic', 'waterspout', 'yawn', 'haze']);\r\n\t\tthis.incompatibleMoves(moves, movePool, PhysicalSetup, PhysicalSetup);\r\n\t\tthis.incompatibleMoves(moves, movePool, SpecialSetup, 'thunderwave');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'substitute', pivotingMoves);\r\n\t\tthis.incompatibleMoves(moves, movePool, SpeedSetup, ['aquajet', 'rest', 'trickroom']);\r\n\t\tthis.incompatibleMoves(moves, movePool, 'curse', 'rapidspin');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'dragondance', 'dracometeor');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'healingwish', 'uturn');\r\n\r\n\r\n\t\t// These attacks are redundant with each other\r\n\t\tthis.incompatibleMoves(moves, movePool, 'psychic', 'psyshock');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'surf', 'hydropump');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'liquidation', 'wavecrash');\r\n\t\tthis.incompatibleMoves(moves, movePool, ['airslash', 'bravebird', 'hurricane'], ['airslash', 'bravebird', 'hurricane']);\r\n\t\tthis.incompatibleMoves(moves, movePool, 'knockoff', 'foulplay');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'doubleedge', 'headbutt');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'fireblast', ['fierydance', 'flamethrower']);\r\n\t\tthis.incompatibleMoves(moves, movePool, 'lavaplume', 'magmastorm');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'thunderpunch', 'wildcharge');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'gunkshot', ['direclaw', 'poisonjab']);\r\n\t\tthis.incompatibleMoves(moves, movePool, 'aurasphere', 'focusblast');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'closecombat', 'drainpunch');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'bugbite', 'pounce');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'bittermalice', 'shadowball');\r\n\t\tthis.incompatibleMoves(moves, movePool, ['dragonpulse', 'spacialrend'], 'dracometeor');\r\n\r\n\r\n\t\t// These status moves are redundant with each other\r\n\t\tthis.incompatibleMoves(moves, movePool, ['taunt', 'strengthsap'], 'encore');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'toxic', 'willowisp');\r\n\t\tthis.incompatibleMoves(moves, movePool, ['thunderwave', 'toxic', 'willowisp'], 'toxicspikes');\r\n\t\tthis.incompatibleMoves(moves, movePool, 'thunderwave', 'yawn');\r\n\r\n\t\t// This space reserved for assorted hardcodes that otherwise make little sense out of context\r\n\t\tif (species.id === \"dugtrio\") {\r\n\t\t\tthis.incompatibleMoves(moves, movePool, statusMoves, 'memento');\r\n\t\t}\r\n\t\t// Landorus\r\n\t\tthis.incompatibleMoves(moves, movePool, 'nastyplot', 'rockslide');\r\n\t\t// Persian and Grafaiai\r\n\t\tthis.incompatibleMoves(moves, movePool, 'switcheroo', ['fakeout', 'superfang']);\r\n\t\t// Beartic\r\n\t\tthis.incompatibleMoves(moves, movePool, 'snowscape', 'swordsdance');\r\n\t\t// Cryogonal\r\n\t\tif (!teamDetails.defog && !teamDetails.rapidSpin && species.id === 'cryogonal') {\r\n\t\t\tif (movePool.includes('haze')) this.fastPop(movePool, movePool.indexOf('haze'));\r\n\t\t}\r\n\t\t// Magnezone\r\n\t\tthis.incompatibleMoves(moves, movePool, 'bodypress', 'mirrorcoat');\r\n\t\t// Amoonguss, though this can work well as a general rule later\r\n\t\tthis.incompatibleMoves(moves, movePool, 'toxic', 'clearsmog');\r\n\t}\r\n\r\n\t// Checks for and removes incompatible moves, starting with the first move in movesA.\r\n\tincompatibleMoves(\r\n\t\tmoves: Set,\r\n\t\tmovePool: string[],\r\n\t\tmovesA: string | string[],\r\n\t\tmovesB: string | string[],\r\n\t): void {\r\n\t\tconst moveArrayA = (Array.isArray(movesA)) ? movesA : [movesA];\r\n\t\tconst moveArrayB = (Array.isArray(movesB)) ? movesB : [movesB];\r\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\r\n\t\tfor (const moveid1 of moves) {\r\n\t\t\tif (moveArrayB.includes(moveid1)) {\r\n\t\t\t\tfor (const moveid2 of moveArrayA) {\r\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\r\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\r\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (moveArrayA.includes(moveid1)) {\r\n\t\t\t\tfor (const moveid2 of moveArrayB) {\r\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\r\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\r\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Adds a move to the moveset, returns the MoveCounter\r\n\taddMove(\r\n\t\tmove: string,\r\n\t\tmoves: Set,\r\n\t\ttypes: string[],\r\n\t\tabilities: Set,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tmovePool: string[],\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): MoveCounter {\r\n\t\tmoves.add(move);\r\n\t\tthis.fastPop(movePool, movePool.indexOf(move));\r\n\t\tconst counter = this.queryMoves(moves, species, teraType, abilities);\r\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead, isDoubles, teraType, role);\r\n\t\treturn counter;\r\n\t}\r\n\r\n\t// Returns the type of a given move for STAB/coverage enforcement purposes\r\n\tgetMoveType(move: Move, species: Species, abilities: Set, teraType: string): string {\r\n\t\tif (move.id === 'terablast') return teraType;\r\n\t\tif (['judgment', 'revelationdance'].includes(move.id)) return species.types[0];\r\n\r\n\t\tif (move.name === \"Raging Bull\" && species.name.startsWith(\"Tauros-Paldea\")) {\r\n\t\t\tif (species.name.endsWith(\"Combat\")) return \"Fighting\";\r\n\t\t\tif (species.name.endsWith(\"Blaze\")) return \"Fire\";\r\n\t\t\tif (species.name.endsWith(\"Aqua\")) return \"Water\";\r\n\t\t}\r\n\r\n\t\tconst moveType = move.type;\r\n\t\tif (moveType === 'Normal') {\r\n\t\t\tif (abilities.has('Aerilate')) return 'Flying';\r\n\t\t\tif (abilities.has('Galvanize')) return 'Electric';\r\n\t\t\tif (abilities.has('Pixilate')) return 'Fairy';\r\n\t\t\tif (abilities.has('Refrigerate')) return 'Ice';\r\n\t\t}\r\n\t\treturn moveType;\r\n\t}\r\n\r\n\t// Generate random moveset for a given species, role, tera type.\r\n\trandomMoveset(\r\n\t\ttypes: string[],\r\n\t\tabilities: Set,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tmovePool: string[],\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): Set {\r\n\t\tconst moves = new Set();\r\n\t\tlet counter = this.queryMoves(moves, species, teraType, abilities);\r\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead, isDoubles, teraType, role);\r\n\r\n\t\t// If there are only four moves, add all moves and return early\r\n\t\tif (movePool.length <= this.maxMoveCount) {\r\n\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\tmoves.add(moveid);\r\n\t\t\t}\r\n\t\t\treturn moves;\r\n\t\t}\r\n\r\n\t\tconst runEnforcementChecker = (checkerName: string) => {\r\n\t\t\tif (!this.moveEnforcementCheckers[checkerName]) return false;\r\n\t\t\treturn this.moveEnforcementCheckers[checkerName](\r\n\t\t\t\tmovePool, moves, abilities, types, counter, species, teamDetails, isLead, isDoubles, teraType, role\r\n\t\t\t);\r\n\t\t};\r\n\r\n\t\tif (role === \"Tera Blast user\") {\r\n\t\t\tcounter = this.addMove('terablast', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\t\t// Add required move (e.g. Relic Song for Meloetta-P)\r\n\t\tif (species.requiredMove) {\r\n\t\t\tconst move = this.dex.moves.get(species.requiredMove).id;\r\n\t\t\tcounter = this.addMove(move, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Add other moves you really want to have, e.g. STAB, recovery, setup.\r\n\r\n\t\t// Enforce Facade if Guts is a possible ability\r\n\t\tif (movePool.includes('facade') && abilities.has('Guts')) {\r\n\t\t\tcounter = this.addMove('facade', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Enforce Sticky Web\r\n\t\tif (movePool.includes('stickyweb')) {\r\n\t\t\tcounter = this.addMove('stickyweb', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Enforce Revival Blessing\r\n\t\tif (movePool.includes('revivalblessing')) {\r\n\t\t\tcounter = this.addMove('revivalblessing', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Enforce Salt Cure\r\n\t\tif (movePool.includes('saltcure')) {\r\n\t\t\tcounter = this.addMove('saltcure', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Enforce Toxic on Grafaiai\r\n\t\tif (movePool.includes('toxic') && species.id === 'grafaiai') {\r\n\t\t\tcounter = this.addMove('toxic', moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t}\r\n\r\n\t\t// Enforce STAB priority\r\n\t\tif (role === 'Bulky Attacker' || role === 'Bulky Setup' || PriorityPokemon.includes(species.id)) {\r\n\t\t\tconst priorityMoves = [];\r\n\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\tif (types.includes(moveType) && move.priority > 0 && move.category !== 'Status') {\r\n\t\t\t\t\tpriorityMoves.push(moveid);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (priorityMoves.length) {\r\n\t\t\t\tconst moveid = this.sample(priorityMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Enforce STAB\r\n\t\tfor (const type of types) {\r\n\t\t\t// Check if a STAB move of that type should be required\r\n\t\t\tconst stabMoves = [];\r\n\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\tif (type === moveType &&\r\n\t\t\t\t\t(move.basePower > 30 || move.multihit || move.basePowerCallback) &&\r\n\t\t\t\t\t(!this.noStab.includes(moveid) || abilities.has('Technician') && moveid === 'machpunch')) {\r\n\t\t\t\t\tstabMoves.push(moveid);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\twhile (runEnforcementChecker(type)) {\r\n\t\t\t\tif (!stabMoves.length) break;\r\n\t\t\t\tconst moveid = this.sampleNoReplace(stabMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If no STAB move was added in the previous step, add a STAB move\r\n\t\tif (!counter.stabCounter) {\r\n\t\t\tconst stabMoves = [];\r\n\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower > 30 || move.multihit || move.basePowerCallback) &&\r\n\t\t\t\t\ttypes.includes(moveType)) {\r\n\t\t\t\t\tstabMoves.push(moveid);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (stabMoves.length) {\r\n\t\t\t\tconst moveid = this.sample(stabMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Enforce Tera STAB\r\n\t\tif (!counter.get('stabtera') && role !== \"Bulky Support\" && species.baseSpecies !== 'Dudunsparce') {\r\n\t\t\tconst stabMoves = [];\r\n\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower > 30 || move.multihit || move.basePowerCallback)) {\r\n\t\t\t\t\tif (teraType === moveType) {\r\n\t\t\t\t\t\tstabMoves.push(moveid);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (stabMoves.length) {\r\n\t\t\t\tconst moveid = this.sample(stabMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Enforce recovery\r\n\t\tif ([\"Bulky Support\", \"Bulky Attacker\", \"Bulky Setup\"].includes(role)) {\r\n\t\t\tconst recoveryMoves = movePool.filter(moveid => RecoveryMove.includes(moveid));\r\n\t\t\tif (recoveryMoves.length) {\r\n\t\t\t\tconst moveid = this.sample(recoveryMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Enforce setup\r\n\t\tif (role.includes('Setup') || role === 'Tera Blast user') {\r\n\t\t\t// First, try to add a non-Speed setup move\r\n\t\t\tconst nonSpeedSetupMoves = movePool.filter(moveid => Setup.includes(moveid) && !SpeedSetup.includes(moveid));\r\n\t\t\tif (nonSpeedSetupMoves.length) {\r\n\t\t\t\tconst moveid = this.sample(nonSpeedSetupMoves);\r\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t} else {\r\n\t\t\t\t// No non-Speed setup moves, so add any (Speed) setup move\r\n\t\t\t\tconst setupMoves = movePool.filter(moveid => Setup.includes(moveid));\r\n\t\t\t\tif (setupMoves.length) {\r\n\t\t\t\t\tconst moveid = this.sample(setupMoves);\r\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Enforce coverage move\r\n\t\tif (!['AV Pivot', 'Fast Support', 'Bulky Support'].includes(role)) {\r\n\t\t\tif (counter.damagingMoves.size <= 1) {\r\n\t\t\t\t// Find the type of the current attacking move\r\n\t\t\t\tlet currentAttackType: string;\r\n\t\t\t\tfor (const moveid of moves) {\r\n\t\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\t\tif (move.basePower > 30 || move.multihit || move.basePowerCallback) {\r\n\t\t\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\t\t\tcurrentAttackType = moveType;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t// Choose an attacking move that is of different type to the current single attack\r\n\t\t\t\tconst coverageMoves = [];\r\n\t\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\t\tconst move = this.dex.moves.get(moveid);\r\n\t\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\r\n\t\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower > 30 || move.multihit || move.basePowerCallback)) {\r\n\t\t\t\t\t\tif (currentAttackType! !== moveType) coverageMoves.push(moveid);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (coverageMoves.length) {\r\n\t\t\t\t\tconst moveid = this.sample(coverageMoves);\r\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Add (moves.size < this.maxMoveCount) as a condition if moves is getting larger than 4 moves.\r\n\t\t// If you want moves to be favored but not required, add something like && this.randomChance(1, 2) to your condition.\r\n\r\n\t\t// Choose remaining moves randomly from movepool and add them to moves list:\r\n\t\twhile (moves.size < this.maxMoveCount && movePool.length) {\r\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) {\r\n\t\t\t\tfor (const moveid of movePool) {\r\n\t\t\t\t\tmoves.add(moveid);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tconst moveid = this.sample(movePool);\r\n\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\tmovePool, teraType, role);\r\n\t\t\tfor (const pair of MovePairs) {\r\n\t\t\t\tif (moveid === pair[0] && movePool.includes(pair[1])) {\r\n\t\t\t\t\tcounter = this.addMove(pair[1], moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t\t}\r\n\t\t\t\tif (moveid === pair[1] && movePool.includes(pair[0])) {\r\n\t\t\t\t\tcounter = this.addMove(pair[0], moves, types, abilities, teamDetails, species, isLead, isDoubles,\r\n\t\t\t\t\t\tmovePool, teraType, role);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn moves;\r\n\t}\r\n\r\n\tshouldCullAbility(\r\n\t\tability: string,\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tabilities: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): boolean {\r\n\t\tif ([\r\n\t\t\t'Armor Tail', 'Battle Bond', 'Early Bird', 'Flare Boost', 'Gluttony', 'Harvest', 'Hydration', 'Ice Body', 'Immunity',\r\n\t\t\t'Own Tempo', 'Pressure', 'Quick Feet', 'Rain Dish', 'Sand Veil', 'Snow Cloak', 'Steadfast', 'Steam Engine',\r\n\t\t].includes(ability)) return true;\r\n\r\n\t\tswitch (ability) {\r\n\t\t// Abilities which are primarily useful for certain moves\r\n\t\tcase 'Contrary': case 'Serene Grace': case 'Skill Link': case 'Strong Jaw':\r\n\t\t\treturn !counter.get(toID(ability));\r\n\t\tcase 'Chlorophyll':\r\n\t\t\treturn (!moves.has('sunnyday') && !teamDetails.sun && species.id !== 'lilligant');\r\n\t\tcase 'Cloud Nine':\r\n\t\t\treturn (species.id !== 'golduck');\r\n\t\tcase 'Competitive':\r\n\t\t\treturn (species.id === 'kilowattrel');\r\n\t\tcase 'Compound Eyes': case 'No Guard':\r\n\t\t\treturn !counter.get('inaccurate');\r\n\t\tcase 'Cursed Body':\r\n\t\t\treturn abilities.has('Infiltrator');\r\n\t\tcase 'Defiant':\r\n\t\t\treturn (!counter.get('Physical') || (abilities.has('Prankster') && (moves.has('thunderwave') || moves.has('taunt'))));\r\n\t\tcase 'Flash Fire':\r\n\t\t\treturn (\r\n\t\t\t\t['Flame Body', 'Intimidate', 'Rock Head', 'Weak Armor'].some(m => abilities.has(m)) &&\r\n\t\t\t\tthis.dex.getEffectiveness('Fire', species) < 0\r\n\t\t\t);\r\n\t\tcase 'Guts':\r\n\t\t\treturn (!moves.has('facade') && !moves.has('sleeptalk'));\r\n\t\tcase 'Hustle':\r\n\t\t\treturn (counter.get('Physical') < 2);\r\n\t\tcase 'Infiltrator':\r\n\t\t\treturn (isDoubles && abilities.has('Clear Body'));\r\n\t\tcase 'Insomnia':\r\n\t\t\treturn (role === 'Wallbreaker');\r\n\t\tcase 'Intimidate':\r\n\t\t\tif (abilities.has('Hustle')) return true;\r\n\t\t\tif (abilities.has('Sheer Force') && !!counter.get('sheerforce')) return true;\r\n\t\t\treturn (abilities.has('Stakeout'));\r\n\t\tcase 'Iron Fist':\r\n\t\t\treturn !counter.ironFist;\r\n\t\tcase 'Justified':\r\n\t\t\treturn !counter.get('Physical');\r\n\t\tcase 'Mold Breaker':\r\n\t\t\treturn (abilities.has('Sharpness') || abilities.has('Unburden'));\r\n\t\tcase 'Moxie':\r\n\t\t\treturn (!counter.get('Physical') || moves.has('stealthrock'));\r\n\t\tcase 'Natural Cure':\r\n\t\t\treturn species.id === 'pawmot';\r\n\t\tcase 'Overgrow':\r\n\t\t\treturn !counter.get('Grass');\r\n\t\tcase 'Prankster':\r\n\t\t\treturn !counter.get('Status');\r\n\t\tcase 'Reckless':\r\n\t\t\treturn !counter.get('recoil');\r\n\t\tcase 'Rock Head':\r\n\t\t\treturn !counter.get('recoil');\r\n\t\tcase 'Sand Force': case 'Sand Rush':\r\n\t\t\treturn !teamDetails.sand;\r\n\t\tcase 'Sap Sipper':\r\n\t\t\treturn species.id === 'wyrdeer';\r\n\t\tcase 'Seed Sower':\r\n\t\t\treturn role === 'Bulky Support';\r\n\t\tcase 'Shed Skin':\r\n\t\t\treturn species.id === 'seviper';\r\n\t\tcase 'Sheer Force':\r\n\t\t\tconst braviaryCase = (species.id === 'braviaryhisui' && role === 'Wallbreaker');\r\n\t\t\tconst abilitiesCase = (abilities.has('Guts') || abilities.has('Sharpness'));\r\n\t\t\treturn (!counter.get('sheerforce') || moves.has('bellydrum') || braviaryCase || abilitiesCase);\r\n\t\tcase 'Slush Rush':\r\n\t\t\treturn !teamDetails.snow;\r\n\t\tcase 'Sniper':\r\n\t\t\treturn abilities.has('Torrent');\r\n\t\tcase 'Solar Power':\r\n\t\t\treturn (!teamDetails.sun || !counter.get('Special'));\r\n\t\tcase 'Stakeout':\r\n\t\t\treturn (counter.damagingMoves.size < 1);\r\n\t\tcase 'Sturdy':\r\n\t\t\treturn !!counter.get('recoil');\r\n\t\tcase 'Swarm':\r\n\t\t\treturn (!counter.get('Bug') || !!counter.get('recovery'));\r\n\t\tcase 'Sweet Veil':\r\n\t\t\treturn types.includes('Grass');\r\n\t\tcase 'Swift Swim':\r\n\t\t\treturn (!moves.has('raindance') && !teamDetails.rain);\r\n\t\tcase 'Synchronize':\r\n\t\t\treturn (species.id !== 'umbreon' && species.id !== 'rabsca');\r\n\t\tcase 'Technician':\r\n\t\t\treturn (!counter.get('technician') || abilities.has('Punk Rock'));\r\n\t\tcase 'Tinted Lens':\r\n\t\t\treturn (species.id === 'braviaryhisui' && role === 'Fast Support');\r\n\t\tcase 'Unburden':\r\n\t\t\treturn (abilities.has('Prankster') || !counter.get('setup'));\r\n\t\tcase 'Volt Absorb':\r\n\t\t\tif (abilities.has('Iron Fist') && counter.ironFist >= 2) return true;\r\n\t\t\treturn (this.dex.getEffectiveness('Electric', species) < -1);\r\n\t\tcase 'Water Absorb':\r\n\t\t\treturn species.id === 'quagsire';\r\n\t\tcase 'Weak Armor':\r\n\t\t\treturn moves.has('shellsmash');\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\r\n\tgetAbility(\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tabilities: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): string {\r\n\t\tconst abilityData = Array.from(abilities).map(a => this.dex.abilities.get(a));\r\n\t\tUtils.sortBy(abilityData, abil => -abil.rating);\r\n\r\n\t\tif (abilityData.length <= 1) return abilityData[0].name;\r\n\r\n\t\t// Hard-code abilities here\r\n\t\tif (species.id === 'arcaninehisui') return 'Rock Head';\r\n\t\tif (species.id === 'staraptor') return 'Reckless';\r\n\t\tif (species.id === 'vespiquen') return 'Pressure';\r\n\t\tif (species.id === 'enamorus' && moves.has('calmmind')) return 'Cute Charm';\r\n\t\tif (species.id === 'cetitan' && role === 'Wallbreaker') return 'Sheer Force';\r\n\t\tif (abilities.has('Cud Chew') && moves.has('substitute')) return 'Cud Chew';\r\n\t\tif (abilities.has('Guts') && (moves.has('facade') || moves.has('sleeptalk'))) return 'Guts';\r\n\t\tif (abilities.has('Harvest') && moves.has('substitute')) return 'Harvest';\r\n\t\tif (species.id === 'hypno') return 'Insomnia';\r\n\t\tif (abilities.has('Serene Grace') && moves.has('headbutt')) return 'Serene Grace';\r\n\t\tif (abilities.has('Technician') && counter.get('technician')) return 'Technician';\r\n\t\tif (abilities.has('Own Tempo') && moves.has('petaldance')) return 'Own Tempo';\r\n\t\tif (abilities.has('Slush Rush') && moves.has('snowscape')) return 'Slush Rush';\r\n\t\tif (abilities.has('Soundproof') && moves.has('substitute')) return 'Soundproof';\r\n\r\n\t\tlet abilityAllowed: Ability[] = [];\r\n\t\t// Obtain a list of abilities that are allowed (not culled)\r\n\t\tfor (const ability of abilityData) {\r\n\t\t\tif (ability.rating >= 1 && !this.shouldCullAbility(\r\n\t\t\t\tability.name, types, moves, abilities, counter, teamDetails, species, isLead, isDoubles, teraType, role\r\n\t\t\t)) {\r\n\t\t\t\tabilityAllowed.push(ability);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If all abilities are culled, re-allow all\r\n\t\tif (!abilityAllowed.length) abilityAllowed = abilityData;\r\n\r\n\t\tif (abilityAllowed.length === 1) return abilityAllowed[0].name;\r\n\t\t// Sort abilities by rating with an element of randomness\r\n\t\t// All three abilities can be chosen\r\n\t\tif (abilityAllowed[2] && abilityAllowed[0].rating - 0.5 <= abilityAllowed[2].rating) {\r\n\t\t\tif (abilityAllowed[1].rating <= abilityAllowed[2].rating) {\r\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\r\n\t\t\t} else {\r\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\r\n\t\t\t}\r\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\r\n\t\t\t\tif (this.randomChance(2, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\r\n\t\t\t} else {\r\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// Third ability cannot be chosen\r\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\r\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\r\n\t\t\t} else if (abilityAllowed[0].rating - 0.5 <= abilityAllowed[1].rating) {\r\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// After sorting, choose the first ability\r\n\t\treturn abilityAllowed[0].name;\r\n\t}\r\n\r\n\tgetPriorityItem(\r\n\t\tability: string,\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t) {\r\n\t\tif (species.requiredItems) {\r\n\t\t\t// Z-Crystals aren't available in Gen 9, so require Plates\r\n\t\t\tif (species.baseSpecies === 'Arceus') {\r\n\t\t\t\treturn species.requiredItems[0];\r\n\t\t\t}\r\n\t\t\treturn this.sample(species.requiredItems);\r\n\t\t}\r\n\t\tif (role === 'AV Pivot') return 'Assault Vest';\r\n\t\tif (\r\n\t\t\t!isLead && role === 'Bulky Setup' &&\r\n\t\t\t(ability === 'Quark Drive' || ability === 'Protosynthesis')\r\n\t\t) {\r\n\t\t\treturn 'Booster Energy';\r\n\t\t}\r\n\t\tif (species.id === 'pikachu') return 'Light Ball';\r\n\t\tif (species.id === 'regieleki') return 'Magnet';\r\n\t\tif (species.id === 'pincurchin') return 'Shuca Berry';\r\n\t\tif (species.id === 'cyclizar' && role === 'Fast Attacker') return 'Choice Scarf';\r\n\t\tif (species.id === 'lokix') {\r\n\t\t\treturn (role === 'Fast Attacker') ? 'Silver Powder' : 'Life Orb';\r\n\t\t}\r\n\t\tif (species.id === 'toxtricity' && moves.has('shiftgear')) return 'Throat Spray';\r\n\t\tif (species.baseSpecies === 'Magearna' && role === 'Tera Blast user') return 'Weakness Policy';\r\n\t\tif (moves.has('lastrespects')) return 'Choice Scarf';\r\n\t\tif (ability === 'Imposter' || (species.id === 'magnezone' && moves.has('bodypress'))) return 'Choice Scarf';\r\n\t\tif (moves.has('bellydrum') && moves.has('substitute')) return 'Salac Berry';\r\n\t\tif (\r\n\t\t\t['Cheek Pouch', 'Cud Chew', 'Harvest'].some(m => ability === m) ||\r\n\t\t\tmoves.has('bellydrum') || moves.has('filletaway')\r\n\t\t) {\r\n\t\t\treturn 'Sitrus Berry';\r\n\t\t}\r\n\t\tif (['healingwish', 'switcheroo', 'trick'].some(m => moves.has(m))) {\r\n\t\t\tif (species.baseStats.spe >= 60 && species.baseStats.spe <= 108 && role !== 'Wallbreaker') {\r\n\t\t\t\treturn 'Choice Scarf';\r\n\t\t\t} else {\r\n\t\t\t\treturn (counter.get('Physical') > counter.get('Special')) ? 'Choice Band' : 'Choice Specs';\r\n\t\t\t}\r\n\t\t}\r\n\t\tif ((ability === 'Guts' || moves.has('facade')) && !moves.has('sleeptalk')) {\r\n\t\t\treturn (types.includes('Fire') || ability === 'Toxic Boost') ? 'Toxic Orb' : 'Flame Orb';\r\n\t\t}\r\n\t\tif (\r\n\t\t\t(ability === 'Magic Guard' && counter.damagingMoves.size > 1) ||\r\n\t\t\t(ability === 'Sheer Force' && counter.get('sheerforce'))\r\n\t\t) {\r\n\t\t\treturn 'Life Orb';\r\n\t\t}\r\n\t\tif (moves.has('shellsmash')) return 'White Herb';\r\n\t\tif (moves.has('populationbomb')) return 'Wide Lens';\r\n\t\tif (moves.has('courtchange')) return 'Heavy-Duty Boots';\r\n\t\tif (moves.has('stuffcheeks')) return this.randomChance(1, 2) ? 'Liechi Berry' : 'Salac Berry';\r\n\t\tif (ability === 'Unburden') return moves.has('closecombat') ? 'White Herb' : 'Sitrus Berry';\r\n\t\tif (moves.has('acrobatics')) return ability === 'Grassy Surge' ? 'Grassy Seed' : '';\r\n\t\tif (moves.has('auroraveil') || moves.has('lightscreen') && moves.has('reflect')) return 'Light Clay';\r\n\t\tif (\r\n\t\t\tmoves.has('rest') && !moves.has('sleeptalk') &&\r\n\t\t\tability !== 'Natural Cure' && ability !== 'Shed Skin'\r\n\t\t) {\r\n\t\t\treturn 'Chesto Berry';\r\n\t\t}\r\n\t\tif (species.id === 'scyther') return (isLead && !moves.has('uturn')) ? 'Eviolite' : 'Heavy-Duty Boots';\r\n\t\tif (species.nfe) return 'Eviolite';\r\n\t\tif (this.dex.getEffectiveness('Rock', species) >= 2) return 'Heavy-Duty Boots';\r\n\t}\r\n\r\n\t/** Item generation specific to Random Doubles */\r\n\t// This will be changed and used later, once doubles is actually coming out.\r\n\tgetDoublesItem(\r\n\t\tability: string,\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t) {\r\n\t\tconst defensiveStatTotal = species.baseStats.hp + species.baseStats.def + species.baseStats.spd;\r\n\r\n\t\tif (\r\n\t\t\t(['dragonenergy', 'eruption', 'waterspout'].some(m => moves.has(m))) &&\r\n\t\t\tcounter.damagingMoves.size >= 4\r\n\t\t) return 'Choice Scarf';\r\n\t\tif (moves.has('blizzard') && ability !== 'Snow Warning' && !teamDetails.snow) return 'Blunder Policy';\r\n\t\tif (this.dex.getEffectiveness('Rock', species) >= 2 && !types.includes('Flying')) return 'Heavy-Duty Boots';\r\n\t\tif (counter.get('Physical') >= 4 && ['fakeout', 'feint', 'rapidspin', 'suckerpunch'].every(m => !moves.has(m)) && (\r\n\t\t\ttypes.includes('Dragon') || types.includes('Fighting') || types.includes('Rock') ||\r\n\t\t\tmoves.has('flipturn') || moves.has('uturn')\r\n\t\t)) {\r\n\t\t\treturn (\r\n\t\t\t\t!counter.get('priority') && ability !== 'Speed Boost' &&\r\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 100 &&\r\n\t\t\t\tthis.randomChance(1, 2)\r\n\t\t\t) ? 'Choice Scarf' : 'Choice Band';\r\n\t\t}\r\n\t\tif (\r\n\t\t\t(\r\n\t\t\t\tcounter.get('Special') >= 4 &&\r\n\t\t\t\t(types.includes('Dragon') || types.includes('Fighting') || types.includes('Rock') || moves.has('voltswitch'))\r\n\t\t\t) || (\r\n\t\t\t\t(counter.get('Special') >= 3 && (moves.has('flipturn') || moves.has('uturn'))) &&\r\n\t\t\t\t!moves.has('acidspray') && !moves.has('electroweb')\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\treturn (\r\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 100 && this.randomChance(1, 2)\r\n\t\t\t) ? 'Choice Scarf' : 'Choice Specs';\r\n\t\t}\r\n\t\t// This one is intentionally below the Choice item checks.\r\n\t\tif ((defensiveStatTotal < 250 && ability === 'Regenerator') || species.name === 'Pheromosa') return 'Life Orb';\r\n\t\tif (counter.damagingMoves.size >= 4 && defensiveStatTotal >= 275) return 'Assault Vest';\r\n\t\tif (\r\n\t\t\tcounter.damagingMoves.size >= 3 &&\r\n\t\t\tspecies.baseStats.spe >= 60 &&\r\n\t\t\tability !== 'Multiscale' && ability !== 'Sturdy' &&\r\n\t\t\t[\r\n\t\t\t\t'acidspray', 'clearsmog', 'electroweb', 'fakeout', 'feint', 'icywind',\r\n\t\t\t\t'incinerate', 'naturesmadness', 'rapidspin', 'snarl', 'uturn',\r\n\t\t\t].every(m => !moves.has(m))\r\n\t\t) return (ability === 'Defeatist' || defensiveStatTotal >= 275) ? 'Sitrus Berry' : 'Life Orb';\r\n\t}\r\n\r\n\tgetItem(\r\n\t\tability: string,\r\n\t\ttypes: string[],\r\n\t\tmoves: Set,\r\n\t\tcounter: MoveCounter,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\r\n\t\tspecies: Species,\r\n\t\tisLead: boolean,\r\n\t\tisDoubles: boolean,\r\n\t\tteraType: string,\r\n\t\trole: string,\r\n\t): string | undefined {\r\n\t\tif (\r\n\t\t\t(counter.get('Physical') >= 4 ||\r\n\t\t\t(counter.get('Physical') >= 3 && moves.has('memento'))) &&\r\n\t\t\t['fakeout', 'firstimpression', 'flamecharge', 'rapidspin', 'ruination', 'superfang'].every(m => !moves.has(m))\r\n\t\t) {\r\n\t\t\tconst scarfReqs = (\r\n\t\t\t\trole !== 'Wallbreaker' &&\r\n\t\t\t\t(species.baseStats.atk >= 100 || ability === 'Huge Power' || ability === 'Pure Power') &&\r\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\r\n\t\t\t\tability !== 'Speed Boost' && !counter.get('priority') && !moves.has('aquastep')\r\n\t\t\t);\r\n\t\t\treturn (scarfReqs && this.randomChance(1, 2)) ? 'Choice Scarf' : 'Choice Band';\r\n\t\t}\r\n\t\tif (\r\n\t\t\t(counter.get('Special') >= 4) ||\r\n\t\t\t(counter.get('Special') >= 3 && ['flipturn', 'partingshot', 'uturn'].some(m => moves.has(m)))\r\n\t\t) {\r\n\t\t\tconst scarfReqs = (\r\n\t\t\t\trole !== 'Wallbreaker' &&\r\n\t\t\t\tspecies.baseStats.spa >= 100 &&\r\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\r\n\t\t\t\tability !== 'Speed Boost' && ability !== 'Tinted Lens' && !counter.get('Physical')\r\n\t\t\t);\r\n\t\t\treturn (scarfReqs && this.randomChance(1, 2)) ? 'Choice Scarf' : 'Choice Specs';\r\n\t\t}\r\n\t\tif (!counter.get('Status') && role !== 'Fast Attacker' && role !== 'Wallbreaker') return 'Assault Vest';\r\n\t\tif (counter.get('speedsetup') && this.dex.getEffectiveness('Ground', species) < 1) return 'Weakness Policy';\r\n\t\tif (species.id === 'urshifurapidstrike') return 'Punching Glove';\r\n\t\tif (species.id === 'palkia') return 'Lustrous Orb';\r\n\t\tif (moves.has('substitute') || ability === 'Moody') return 'Leftovers';\r\n\t\tif (moves.has('stickyweb') && isLead) return 'Focus Sash';\r\n\t\tif (\r\n\t\t\t!teamDetails.defog && !teamDetails.rapidSpin &&\r\n\t\t\tthis.dex.getEffectiveness('Rock', species) >= 1\r\n\t\t) return 'Heavy-Duty Boots';\r\n\t\tif (\r\n\t\t\trole === 'Fast Support' &&\r\n\t\t\t['defog', 'rapidspin', 'uturn', 'voltswitch'].some(m => moves.has(m)) &&\r\n\t\t\t!types.includes('Flying') && ability !== 'Levitate'\r\n\t\t) return 'Heavy-Duty Boots';\r\n\r\n\t\t// Low Priority\r\n\t\tif (moves.has('outrage')) return 'Lum Berry';\r\n\t\tif (\r\n\t\t\t(species.id === 'garchomp' && role === 'Fast Support') ||\r\n\t\t\t(ability === 'Regenerator' && types.includes('Water') && species.baseStats.def >= 110 && this.randomChance(1, 3))\r\n\t\t) return 'Rocky Helmet';\r\n\t\tif (\r\n\t\t\trole === 'Fast Support' && isLead &&\r\n\t\t\t!counter.get('recovery') && !counter.get('recoil') && !moves.has('protect') &&\r\n\t\t\t(species.baseStats.hp + species.baseStats.def + species.baseStats.spd) < 258\r\n\t\t) return 'Focus Sash';\r\n\t\tif (\r\n\t\t\trole !== 'Fast Attacker' && role !== 'Tera Blast user' && ability !== 'Levitate' &&\r\n\t\t\tthis.dex.getEffectiveness('Ground', species) >= 2\r\n\t\t) return 'Air Balloon';\r\n\t\tif (['Bulky Attacker', 'Bulky Support', 'Bulky Setup'].some(m => role === (m))) return 'Leftovers';\r\n\t\tif (role === 'Fast Support' || role === 'Fast Bulky Setup') {\r\n\t\t\treturn (counter.damagingMoves.size >= 3 && !moves.has('nuzzle')) ? 'Life Orb' : 'Leftovers';\r\n\t\t}\r\n\t\tif (role === 'Tera Blast user' && counter.get('recovery') && counter.damagingMoves.size < 3) return 'Leftovers';\r\n\t\tif (\r\n\t\t\t['flamecharge', 'rapidspin'].every(m => !moves.has(m)) &&\r\n\t\t\t['Fast Attacker', 'Setup Sweeper', 'Tera Blast user', 'Wallbreaker'].some(m => role === (m))\r\n\t\t) return 'Life Orb';\r\n\t\tif (isDoubles) return 'Sitrus Berry';\r\n\t\treturn 'Leftovers';\r\n\t}\r\n\r\n\tgetLevel(\r\n\t\tspecies: Species,\r\n\t\tisDoubles: boolean,\r\n\t): number {\r\n\t\tif (this.adjustLevel) return this.adjustLevel;\r\n\t\t// doubles levelling\r\n\t\tif (isDoubles && this.randomDoublesSets[species.id][\"level\"]) return this.randomDoublesSets[species.id][\"level\"];\r\n\t\tif (!isDoubles && this.randomSets[species.id][\"level\"]) return this.randomSets[species.id][\"level\"];\r\n\t\t// Default to tier-based levelling\r\n\t\tconst tier = species.tier;\r\n\t\tconst tierScale: Partial> = {\r\n\t\t\tUber: 76,\r\n\t\t\tOU: 80,\r\n\t\t\tUUBL: 81,\r\n\t\t\tUU: 82,\r\n\t\t\tRUBL: 83,\r\n\t\t\tRU: 84,\r\n\t\t\tNUBL: 85,\r\n\t\t\tNU: 86,\r\n\t\t\tPUBL: 87,\r\n\t\t\tPU: 88, \"(PU)\": 88, NFE: 88,\r\n\t\t};\r\n\t\treturn tierScale[tier] || 80;\r\n\t}\r\n\r\n\trandomSet(\r\n\t\tspecies: string | Species,\r\n\t\tteamDetails: RandomTeamsTypes.TeamDetails = {},\r\n\t\tisLead = false,\r\n\t\tisDoubles = false\r\n\t): RandomTeamsTypes.RandomSet {\r\n\t\tspecies = this.dex.species.get(species);\r\n\t\tlet forme = species.name;\r\n\r\n\t\tif (typeof species.battleOnly === 'string') {\r\n\t\t\t// Only change the forme. The species has custom moves, and may have different typing and requirements.\r\n\t\t\tforme = species.battleOnly;\r\n\t\t}\r\n\t\tif (species.cosmeticFormes) {\r\n\t\t\tforme = this.sample([species.name].concat(species.cosmeticFormes));\r\n\t\t}\r\n\t\tconst sets = (this as any)[`random${isDoubles ? 'Doubles' : ''}Sets`][species.id][\"sets\"];\r\n\t\tconst possibleSets = [];\r\n\t\tfor (const set of sets) {\r\n\t\t\tif (teamDetails.teraBlast && set.role === \"Tera Blast user\") {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tpossibleSets.push(set);\r\n\t\t}\r\n\t\tconst set = this.sampleIfArray(possibleSets);\r\n\t\tconst role = set.role;\r\n\t\tconst movePool: string[] = [];\r\n\t\tfor (const movename of set.movepool) {\r\n\t\t\tmovePool.push(this.dex.moves.get(movename).id);\r\n\t\t}\r\n\t\tconst teraTypes = set.teraTypes;\r\n\t\tconst teraType = this.sampleIfArray(teraTypes);\r\n\r\n\t\tif (this.format.gameType === 'multi' || this.format.gameType === 'freeforall') {\r\n\t\t\t// Random Multi Battle uses doubles move pools, but Ally Switch fails in multi battles\r\n\t\t\t// Random Free-For-All also uses doubles move pools, for now\r\n\t\t\tconst allySwitch = movePool.indexOf('allyswitch');\r\n\t\t\tif (allySwitch > -1) {\r\n\t\t\t\tif (movePool.length > this.maxMoveCount) {\r\n\t\t\t\t\tthis.fastPop(movePool, allySwitch);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Ideally, we'll never get here, but better to have a move that usually does nothing than one that always does\r\n\t\t\t\t\tmovePool[allySwitch] = 'sleeptalk';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tlet ability = '';\r\n\t\tlet item = undefined;\r\n\r\n\t\tconst evs = {hp: 85, atk: 85, def: 85, spa: 85, spd: 85, spe: 85};\r\n\t\tconst ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};\r\n\r\n\t\tconst types = species.types;\r\n\t\tconst abilities = new Set(Object.values(species.abilities));\r\n\t\tif (species.unreleasedHidden) abilities.delete(species.abilities.H);\r\n\r\n\t\t// Get moves\r\n\t\tconst moves = this.randomMoveset(types, abilities, teamDetails, species, isLead, isDoubles, movePool, teraType, role);\r\n\t\tconst counter = this.queryMoves(moves, species, teraType, abilities);\r\n\r\n\t\t// Get ability\r\n\t\tability = this.getAbility(types, moves, abilities, counter, teamDetails, species, isLead, isDoubles, teraType, role);\r\n\r\n\t\t// Get items\r\n\t\t// First, the priority items\r\n\t\titem = this.getPriorityItem(ability, types, moves, counter, teamDetails, species, isLead, isDoubles, teraType, role);\r\n\t\tif (item === undefined && isDoubles) {\r\n\t\t\titem = this.getDoublesItem(ability, types, moves, counter, teamDetails, species, teraType, role);\r\n\t\t}\r\n\t\tif (item === undefined) {\r\n\t\t\titem = this.getItem(ability, types, moves, counter, teamDetails, species, isLead, isDoubles, teraType, role);\r\n\t\t}\r\n\r\n\t\t// fallback\r\n\t\tif (item === undefined) item = isDoubles ? 'Sitrus Berry' : 'Leftovers';\r\n\r\n\t\tif (species.baseSpecies === 'Pikachu') {\r\n\t\t\tforme = 'Pikachu' + this.sample(['', '-Original', '-Hoenn', '-Sinnoh', '-Unova', '-Kalos', '-Alola', '-Partner', '-World']);\r\n\t\t}\r\n\r\n\t\t// Get level\r\n\t\tconst level = this.getLevel(species, isDoubles);\r\n\r\n\t\t// Prepare optimal HP\r\n\t\tconst srImmunity = ability === 'Magic Guard' || item === 'Heavy-Duty Boots';\r\n\t\tconst srWeakness = srImmunity ? 0 : this.dex.getEffectiveness('Rock', species);\r\n\t\twhile (evs.hp > 1) {\r\n\t\t\tconst hp = Math.floor(Math.floor(2 * species.baseStats.hp + ivs.hp + Math.floor(evs.hp / 4) + 100) * level / 100 + 10);\r\n\t\t\tif ((moves.has('substitute') && ['Sitrus Berry', 'Salac Berry'].includes(item))) {\r\n\t\t\t\t// Two Substitutes should activate Sitrus Berry\r\n\t\t\t\tif (hp % 4 === 0) break;\r\n\t\t\t} else if ((moves.has('bellydrum') || moves.has('filletaway')) && (item === 'Sitrus Berry' || ability === 'Gluttony')) {\r\n\t\t\t\t// Belly Drum should activate Sitrus Berry\r\n\t\t\t\tif (hp % 2 === 0) break;\r\n\t\t\t} else {\r\n\t\t\t\t// Maximize number of Stealth Rock switch-ins\r\n\t\t\t\tif (srWeakness <= 0 || hp % (4 / srWeakness) > 0 || ['Leftovers', 'Life Orb'].includes(item)) break;\r\n\t\t\t}\r\n\t\t\tevs.hp -= 4;\r\n\t\t}\r\n\r\n\t\t// Minimize confusion damage\r\n\t\tconst noAttackStatMoves = [...moves].every(m => {\r\n\t\t\tconst move = this.dex.moves.get(m);\r\n\t\t\tif (move.damageCallback || move.damage) return true;\r\n\t\t\tif (move.id === 'shellsidearm') return false;\r\n\t\t\t// Magearna, though this can work well as a general rule\r\n\t\t\tif (move.id === 'terablast' && moves.has('shiftgear')) return false;\r\n\t\t\treturn move.category !== 'Physical' || move.id === 'bodypress' || move.id === 'foulplay';\r\n\t\t});\r\n\t\tif (noAttackStatMoves && !moves.has('transform')) {\r\n\t\t\tevs.atk = 0;\r\n\t\t\tivs.atk = 0;\r\n\t\t}\r\n\r\n\t\tif (moves.has('gyroball') || moves.has('trickroom')) {\r\n\t\t\tevs.spe = 0;\r\n\t\t\tivs.spe = 0;\r\n\t\t}\r\n\r\n\t\t// shuffle moves to add more randomness to camomons\r\n\t\tconst shuffledMoves = Array.from(moves);\r\n\t\tthis.prng.shuffle(shuffledMoves);\r\n\t\treturn {\r\n\t\t\tname: species.baseSpecies,\r\n\t\t\tspecies: forme,\r\n\t\t\tgender: species.gender,\r\n\t\t\tshiny: this.randomChance(1, 1024),\r\n\t\t\tlevel,\r\n\t\t\tmoves: shuffledMoves,\r\n\t\t\tability,\r\n\t\t\tevs,\r\n\t\t\tivs,\r\n\t\t\titem,\r\n\t\t\tteraType,\r\n\t\t\trole,\r\n\t\t};\r\n\t}\r\n\r\n\tgetPokemonPool(\r\n\t\ttype: string,\r\n\t\tpokemonToExclude: RandomTeamsTypes.RandomSet[] = [],\r\n\t\tisMonotype = false,\r\n\t\tisDoubles = false,\r\n\t) {\r\n\t\tconst exclude = pokemonToExclude.map(p => toID(p.species));\r\n\t\tconst pokemonPool = [];\r\n\t\tconst baseSpeciesPool: string[] = [];\r\n\t\tif (isDoubles) {\r\n\t\t\tfor (const pokemon of Object.keys(this.randomDoublesSets)) {\r\n\t\t\t\tlet species = this.dex.species.get(pokemon);\r\n\t\t\t\tif (species.gen > this.gen || exclude.includes(species.id)) continue;\r\n\t\t\t\tif (isMonotype) {\r\n\t\t\t\t\tif (!species.types.includes(type)) continue;\r\n\t\t\t\t\tif (typeof species.battleOnly === 'string') {\r\n\t\t\t\t\t\tspecies = this.dex.species.get(species.battleOnly);\r\n\t\t\t\t\t\tif (!species.types.includes(type)) continue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tpokemonPool.push(pokemon);\r\n\t\t\t\tif (!baseSpeciesPool.includes(species.baseSpecies)) baseSpeciesPool.push(species.baseSpecies);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tfor (const pokemon of Object.keys(this.randomSets)) {\r\n\t\t\t\tlet species = this.dex.species.get(pokemon);\r\n\t\t\t\tif (species.gen > this.gen || exclude.includes(species.id)) continue;\r\n\t\t\t\tif (isMonotype) {\r\n\t\t\t\t\tif (!species.types.includes(type)) continue;\r\n\t\t\t\t\tif (typeof species.battleOnly === 'string') {\r\n\t\t\t\t\t\tspecies = this.dex.species.get(species.battleOnly);\r\n\t\t\t\t\t\tif (!species.types.includes(type)) continue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tpokemonPool.push(pokemon);\r\n\t\t\t\tif (!baseSpeciesPool.includes(species.baseSpecies)) baseSpeciesPool.push(species.baseSpecies);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [pokemonPool, baseSpeciesPool];\r\n\t}\r\n\r\n\t// TODO: Make types for this\r\n\trandomSets: AnyObject = require('./random-sets.json');\r\n\trandomDoublesSets: AnyObject = require('./random-sets.json'); // Doubles sets are the same as singles for now\r\n\r\n\trandomTeam() {\r\n\t\tthis.enforceNoDirectCustomBanlistChanges();\r\n\r\n\t\tconst seed = this.prng.seed;\r\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\r\n\t\tconst pokemon: RandomTeamsTypes.RandomSet[] = [];\r\n\r\n\t\t// For Monotype\r\n\t\tconst isMonotype = !!this.forceMonotype || ruleTable.has('sametypeclause');\r\n\t\tconst isDoubles = this.format.gameType !== 'singles';\r\n\t\tconst typePool = this.dex.types.names();\r\n\t\tconst type = this.forceMonotype || this.sample(typePool);\r\n\r\n\t\t// PotD stuff\r\n\t\tconst usePotD = global.Config && Config.potd && ruleTable.has('potd');\r\n\t\tconst potd = usePotD ? this.dex.species.get(Config.potd) : null;\r\n\r\n\t\tconst baseFormes: {[k: string]: number} = {};\r\n\r\n\t\tconst tierCount: {[k: string]: number} = {};\r\n\t\tconst typeCount: {[k: string]: number} = {};\r\n\t\tconst typeComboCount: {[k: string]: number} = {};\r\n\t\tconst typeWeaknesses: {[k: string]: number} = {};\r\n\t\tconst teamDetails: RandomTeamsTypes.TeamDetails = {};\r\n\t\tconst [pokemonPool, baseSpeciesPool] = this.getPokemonPool(type, pokemon, isMonotype, isDoubles);\r\n\t\twhile (baseSpeciesPool.length && pokemon.length < this.maxTeamSize) {\r\n\t\t\tconst baseSpecies = this.sampleNoReplace(baseSpeciesPool);\r\n\t\t\tconst currentSpeciesPool: Species[] = [];\r\n\t\t\tfor (const poke of pokemonPool) {\r\n\t\t\t\tconst species = this.dex.species.get(poke);\r\n\t\t\t\tif (species.baseSpecies === baseSpecies) currentSpeciesPool.push(species);\r\n\t\t\t}\r\n\t\t\tlet species = this.sample(currentSpeciesPool);\r\n\t\t\tif (!species.exists) continue;\r\n\t\t\t// Illusion shouldn't be on the last slot\r\n\t\t\tif (species.baseSpecies === 'Zoroark' && pokemon.length >= (this.maxTeamSize - 1)) continue;\r\n\r\n\t\t\t// If Zoroark is in the team, the sixth slot should not be a Pokemon with extremely low level\r\n\t\t\tif (\r\n\t\t\t\tpokemon.some(pkmn => pkmn.name === 'Zoroark') &&\r\n\t\t\t\tpokemon.length >= (this.maxTeamSize - 1) &&\r\n\t\t\t\tthis.getLevel(species, isDoubles) < 72 &&\r\n\t\t\t\t!this.adjustLevel\r\n\t\t\t) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\t// Pokemon with Last Respects, Intrepid Sword, and Dauntless Shield shouldn't be leading\r\n\t\t\tif (['Basculegion', 'Houndstone', 'Zacian', 'Zamazenta'].includes(species.baseSpecies) && !pokemon.length) continue;\r\n\r\n\t\t\tconst tier = species.tier;\r\n\t\t\tconst types = species.types;\r\n\t\t\tconst typeCombo = types.slice().sort().join();\r\n\t\t\t// Dynamically scale limits for different team sizes. The default and minimum value is 1.\r\n\t\t\tconst limitFactor = Math.round(this.maxTeamSize / 6) || 1;\r\n\r\n\t\t\t// Limit one Pokemon per tier, two for Monotype\r\n\t\t\t// Disable this for now, since it is still a new gen\r\n\t\t\t// Unless you want to have a lot of Ubers!\r\n\t\t\t// if (\r\n\t\t\t// \t(tierCount[tier] >= (this.forceMonotype || isMonotype ? 2 : 1) * limitFactor) &&\r\n\t\t\t// \t!this.randomChance(1, Math.pow(5, tierCount[tier]))\r\n\t\t\t// ) {\r\n\t\t\t// \tcontinue;\r\n\t\t\t// }\r\n\r\n\t\t\tif (!isMonotype && !this.forceMonotype) {\r\n\t\t\t\tlet skip = false;\r\n\r\n\t\t\t\t// Limit two of any type\r\n\t\t\t\tfor (const typeName of types) {\r\n\t\t\t\t\tif (typeCount[typeName] >= 2 * limitFactor) {\r\n\t\t\t\t\t\tskip = true;\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 (skip) continue;\r\n\r\n\t\t\t\t// Limit three weak to any type\r\n\t\t\t\tfor (const typeName of this.dex.types.names()) {\r\n\t\t\t\t\t// it's weak to the type\r\n\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\r\n\t\t\t\t\t\tif (!typeWeaknesses[typeName]) typeWeaknesses[typeName] = 0;\r\n\t\t\t\t\t\tif (typeWeaknesses[typeName] >= 3 * limitFactor) {\r\n\t\t\t\t\t\t\tskip = 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 (skip) continue;\r\n\t\t\t}\r\n\r\n\t\t\t// Limit one of any type combination, two in Monotype\r\n\t\t\tif (!this.forceMonotype && typeComboCount[typeCombo] >= (isMonotype ? 2 : 1) * limitFactor) continue;\r\n\r\n\t\t\t// The Pokemon of the Day\r\n\t\t\tif (potd?.exists && (pokemon.length === 1 || this.maxTeamSize === 1)) species = potd;\r\n\r\n\t\t\tconst set = this.randomSet(species, teamDetails, pokemon.length === 0, isDoubles);\r\n\r\n\t\t\t// Okay, the set passes, add it to our team\r\n\t\t\tpokemon.push(set);\r\n\t\t\tif (pokemon.length === this.maxTeamSize) {\r\n\t\t\t\t// Set Zoroark's level to be the same as the last Pokemon\r\n\t\t\t\tconst illusion = teamDetails.illusion;\r\n\t\t\t\tif (illusion) pokemon[illusion - 1].level = pokemon[this.maxTeamSize - 1].level;\r\n\r\n\t\t\t\t// Don't bother tracking details for the last Pokemon\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// Now that our Pokemon has passed all checks, we can increment our counters\r\n\t\t\tbaseFormes[species.baseSpecies] = 1;\r\n\r\n\t\t\t// Increment tier counter\r\n\t\t\tif (tierCount[tier]) {\r\n\t\t\t\ttierCount[tier]++;\r\n\t\t\t} else {\r\n\t\t\t\ttierCount[tier] = 1;\r\n\t\t\t}\r\n\r\n\t\t\t// Increment type counters\r\n\t\t\tfor (const typeName of types) {\r\n\t\t\t\tif (typeName in typeCount) {\r\n\t\t\t\t\ttypeCount[typeName]++;\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttypeCount[typeName] = 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (typeCombo in typeComboCount) {\r\n\t\t\t\ttypeComboCount[typeCombo]++;\r\n\t\t\t} else {\r\n\t\t\t\ttypeComboCount[typeCombo] = 1;\r\n\t\t\t}\r\n\r\n\t\t\t// Increment weakness counter\r\n\t\t\tfor (const typeName of this.dex.types.names()) {\r\n\t\t\t\t// it's weak to the type\r\n\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\r\n\t\t\t\t\ttypeWeaknesses[typeName]++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Track what the team has\r\n\t\t\tif (set.ability === 'Drizzle' || set.moves.includes('raindance')) teamDetails.rain = 1;\r\n\t\t\tif (set.ability === 'Drought' || set.ability === 'Orichalcum Pulse' || set.moves.includes('sunnyday')) {\r\n\t\t\t\tteamDetails.sun = 1;\r\n\t\t\t}\r\n\t\t\tif (set.ability === 'Sand Stream') teamDetails.sand = 1;\r\n\t\t\tif (set.ability === 'Snow Warning' || set.moves.includes('snowscape') || set.moves.includes('chillyreception')) {\r\n\t\t\t\tteamDetails.snow = 1;\r\n\t\t\t}\r\n\t\t\tif (set.moves.includes('spikes')) teamDetails.spikes = (teamDetails.spikes || 0) + 1;\r\n\t\t\tif (set.moves.includes('stealthrock')) teamDetails.stealthRock = 1;\r\n\t\t\tif (set.moves.includes('stickyweb')) teamDetails.stickyWeb = 1;\r\n\t\t\tif (set.moves.includes('stoneaxe')) teamDetails.stealthRock = 1;\r\n\t\t\tif (set.moves.includes('toxicspikes')) teamDetails.toxicSpikes = 1;\r\n\t\t\tif (set.moves.includes('defog')) teamDetails.defog = 1;\r\n\t\t\tif (set.moves.includes('rapidspin')) teamDetails.rapidSpin = 1;\r\n\t\t\tif (set.moves.includes('mortalspin')) teamDetails.rapidSpin = 1;\r\n\t\t\tif (set.moves.includes('tidyup')) teamDetails.rapidSpin = 1;\r\n\t\t\tif (set.moves.includes('auroraveil') || (set.moves.includes('reflect') && set.moves.includes('lightscreen'))) {\r\n\t\t\t\tteamDetails.screens = 1;\r\n\t\t\t}\r\n\t\t\tif (set.role === 'Tera Blast user') teamDetails.teraBlast = 1;\r\n\r\n\t\t\t// For setting Zoroark's level\r\n\t\t\tif (set.ability === 'Illusion') teamDetails.illusion = pokemon.length;\r\n\t\t}\r\n\t\tif (pokemon.length < this.maxTeamSize && pokemon.length < 12) { // large teams sometimes cannot be built\r\n\t\t\tthrow new Error(`Could not build a random team for ${this.format} (seed=${seed})`);\r\n\t\t}\r\n\r\n\t\treturn pokemon;\r\n\t}\r\n\r\n\trandomCCTeam(): RandomTeamsTypes.RandomSet[] {\r\n\t\tthis.enforceNoDirectCustomBanlistChanges();\r\n\r\n\t\tconst dex = this.dex;\r\n\t\tconst team = [];\r\n\r\n\t\tconst natures = this.dex.natures.all();\r\n\t\tconst items = this.dex.items.all();\r\n\r\n\t\tconst randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, undefined, undefined, true);\r\n\r\n\t\tfor (let forme of randomN) {\r\n\t\t\tlet species = dex.species.get(forme);\r\n\t\t\tif (species.isNonstandard) species = dex.species.get(species.baseSpecies);\r\n\r\n\t\t\t// Random legal item\r\n\t\t\tlet item = '';\r\n\t\t\tlet isIllegalItem;\r\n\t\t\tlet isBadItem;\r\n\t\t\tif (this.gen >= 2) {\r\n\t\t\t\tdo {\r\n\t\t\t\t\titem = this.sample(items).name;\r\n\t\t\t\t\tisIllegalItem = this.dex.items.get(item).gen > this.gen || this.dex.items.get(item).isNonstandard;\r\n\t\t\t\t\tisBadItem = item.startsWith(\"TR\") || this.dex.items.get(item).isPokeball;\r\n\t\t\t\t} while (isIllegalItem || (isBadItem && this.randomChance(19, 20)));\r\n\t\t\t}\r\n\r\n\t\t\t// Make sure forme is legal\r\n\t\t\tif (species.battleOnly) {\r\n\t\t\t\tif (typeof species.battleOnly === 'string') {\r\n\t\t\t\t\tspecies = dex.species.get(species.battleOnly);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tspecies = dex.species.get(this.sample(species.battleOnly));\r\n\t\t\t\t}\r\n\t\t\t\tforme = species.name;\r\n\t\t\t} else if (species.requiredItems && !species.requiredItems.some(req => toID(req) === item)) {\r\n\t\t\t\tif (!species.changesFrom) throw new Error(`${species.name} needs a changesFrom value`);\r\n\t\t\t\tspecies = dex.species.get(species.changesFrom);\r\n\t\t\t\tforme = species.name;\r\n\t\t\t}\r\n\r\n\t\t\t// Make sure that a base forme does not hold any forme-modifier items.\r\n\t\t\tlet itemData = this.dex.items.get(item);\r\n\t\t\tif (itemData.forcedForme && forme === this.dex.species.get(itemData.forcedForme).baseSpecies) {\r\n\t\t\t\tdo {\r\n\t\t\t\t\titemData = this.sample(items);\r\n\t\t\t\t\titem = itemData.name;\r\n\t\t\t\t} while (\r\n\t\t\t\t\titemData.gen > this.gen ||\r\n\t\t\t\t\titemData.isNonstandard ||\r\n\t\t\t\t\t(itemData.forcedForme && forme === this.dex.species.get(itemData.forcedForme).baseSpecies)\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t// Random legal ability\r\n\t\t\tconst abilities = Object.values(species.abilities).filter(a => this.dex.abilities.get(a).gen <= this.gen);\r\n\t\t\tconst ability: string = this.gen <= 2 ? 'No Ability' : this.sample(abilities);\r\n\r\n\t\t\t// Four random unique moves from the movepool\r\n\t\t\tlet pool = ['struggle'];\r\n\t\t\tif (forme === 'Smeargle') {\r\n\t\t\t\tpool = this.dex.moves\r\n\t\t\t\t\t.all()\r\n\t\t\t\t\t.filter(move => !(move.isNonstandard || move.isZ || move.isMax || move.realMove))\r\n\t\t\t\t\t.map(m => m.id);\r\n\t\t\t} else {\r\n\t\t\t\tconst formes = ['gastrodoneast', 'pumpkaboosuper', 'zygarde10'];\r\n\t\t\t\tlet learnset = this.dex.species.getLearnset(species.id);\r\n\t\t\t\tlet learnsetSpecies = species;\r\n\t\t\t\tif (formes.includes(species.id) || !learnset) {\r\n\t\t\t\t\tlearnsetSpecies = this.dex.species.get(species.baseSpecies);\r\n\t\t\t\t\tlearnset = this.dex.species.getLearnset(learnsetSpecies.id);\r\n\t\t\t\t}\r\n\t\t\t\tif (learnset) {\r\n\t\t\t\t\tpool = Object.keys(learnset).filter(\r\n\t\t\t\t\t\tmoveid => learnset![moveid].find(learned => learned.startsWith(String(this.gen)))\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tif (learnset && learnsetSpecies === species && species.changesFrom) {\r\n\t\t\t\t\tlearnset = this.dex.species.getLearnset(toID(species.changesFrom));\r\n\t\t\t\t\tfor (const moveid in learnset) {\r\n\t\t\t\t\t\tif (!pool.includes(moveid) && learnset[moveid].some(source => source.startsWith(String(this.gen)))) {\r\n\t\t\t\t\t\t\tpool.push(moveid);\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\tconst evoRegion = learnsetSpecies.evoRegion && learnsetSpecies.gen !== this.gen;\r\n\t\t\t\twhile (learnsetSpecies.prevo) {\r\n\t\t\t\t\tlearnsetSpecies = this.dex.species.get(learnsetSpecies.prevo);\r\n\t\t\t\t\tfor (const moveid in learnset) {\r\n\t\t\t\t\t\tif (!pool.includes(moveid) &&\r\n\t\t\t\t\t\t\tlearnset[moveid].some(source => source.startsWith(String(this.gen)) && !evoRegion)) {\r\n\t\t\t\t\t\t\tpool.push(moveid);\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\r\n\t\t\tconst moves = this.multipleSamplesNoReplace(pool, this.maxMoveCount);\r\n\r\n\t\t\t// Random EVs\r\n\t\t\tconst evs: StatsTable = {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0};\r\n\t\t\tconst s: StatID[] = [\"hp\", \"atk\", \"def\", \"spa\", \"spd\", \"spe\"];\r\n\t\t\tlet evpool = 510;\r\n\t\t\tdo {\r\n\t\t\t\tconst x = this.sample(s);\r\n\t\t\t\tconst y = this.random(Math.min(256 - evs[x], evpool + 1));\r\n\t\t\t\tevs[x] += y;\r\n\t\t\t\tevpool -= y;\r\n\t\t\t} while (evpool > 0);\r\n\r\n\t\t\t// Random IVs\r\n\t\t\tconst ivs = {\r\n\t\t\t\thp: this.random(32),\r\n\t\t\t\tatk: this.random(32),\r\n\t\t\t\tdef: this.random(32),\r\n\t\t\t\tspa: this.random(32),\r\n\t\t\t\tspd: this.random(32),\r\n\t\t\t\tspe: this.random(32),\r\n\t\t\t};\r\n\r\n\t\t\t// Random nature\r\n\t\t\tconst nature = this.sample(natures).name;\r\n\r\n\t\t\t// Level balance--calculate directly from stats rather than using some silly lookup table\r\n\t\t\tconst mbstmin = 1307; // Sunkern has the lowest modified base stat total, and that total is 807\r\n\r\n\t\t\tlet stats = species.baseStats;\r\n\t\t\t// If Wishiwashi, use the school-forme's much higher stats\r\n\t\t\tif (species.baseSpecies === 'Wishiwashi') stats = Dex.species.get('wishiwashischool').baseStats;\r\n\r\n\t\t\t// Modified base stat total assumes 31 IVs, 85 EVs in every stat\r\n\t\t\tlet mbst = (stats[\"hp\"] * 2 + 31 + 21 + 100) + 10;\r\n\t\t\tmbst += (stats[\"atk\"] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats[\"def\"] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats[\"spa\"] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats[\"spd\"] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats[\"spe\"] * 2 + 31 + 21 + 100) + 5;\r\n\r\n\t\t\tlet level;\r\n\t\t\tif (this.adjustLevel) {\r\n\t\t\t\tlevel = this.adjustLevel;\r\n\t\t\t} else {\r\n\t\t\t\tlevel = Math.floor(100 * mbstmin / mbst); // Initial level guess will underestimate\r\n\r\n\t\t\t\twhile (level < 100) {\r\n\t\t\t\t\tmbst = Math.floor((stats[\"hp\"] * 2 + 31 + 21 + 100) * level / 100 + 10);\r\n\t\t\t\t\t// Since damage is roughly proportional to level\r\n\t\t\t\t\tmbst += Math.floor(((stats[\"atk\"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\r\n\t\t\t\t\tmbst += Math.floor((stats[\"def\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\t\t\t\t\tmbst += Math.floor(((stats[\"spa\"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\r\n\t\t\t\t\tmbst += Math.floor((stats[\"spd\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\t\t\t\t\tmbst += Math.floor((stats[\"spe\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\r\n\t\t\t\t\tif (mbst >= mbstmin) break;\r\n\t\t\t\t\tlevel++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Random happiness\r\n\t\t\tconst happiness = this.random(256);\r\n\r\n\t\t\t// Random shininess\r\n\t\t\tconst shiny = this.randomChance(1, 1024);\r\n\r\n\t\t\tconst set: RandomTeamsTypes.RandomSet = {\r\n\t\t\t\tname: species.baseSpecies,\r\n\t\t\t\tspecies: species.name,\r\n\t\t\t\tgender: species.gender,\r\n\t\t\t\titem,\r\n\t\t\t\tability,\r\n\t\t\t\tmoves,\r\n\t\t\t\tevs,\r\n\t\t\t\tivs,\r\n\t\t\t\tnature,\r\n\t\t\t\tlevel,\r\n\t\t\t\thappiness,\r\n\t\t\t\tshiny,\r\n\t\t\t};\r\n\t\t\tif (this.gen === 9) {\r\n\t\t\t\t// Tera type\r\n\t\t\t\tset.teraType = this.sample(this.dex.types.all()).name;\r\n\t\t\t}\r\n\t\t\tteam.push(set);\r\n\t\t}\r\n\r\n\t\treturn team;\r\n\t}\r\n\r\n\trandomNPokemon(n: number, requiredType?: string, minSourceGen?: number, ruleTable?: RuleTable, requireMoves = false) {\r\n\t\t// Picks `n` random pokemon--no repeats, even among formes\r\n\t\t// Also need to either normalize for formes or select formes at random\r\n\t\t// Unreleased are okay but no CAP\r\n\t\tconst last = [0, 151, 251, 386, 493, 649, 721, 807, 898, 1010][this.gen];\r\n\r\n\t\tif (n <= 0 || n > last) throw new Error(`n must be a number between 1 and ${last} (got ${n})`);\r\n\t\tif (requiredType && !this.dex.types.get(requiredType).exists) {\r\n\t\t\tthrow new Error(`\"${requiredType}\" is not a valid type.`);\r\n\t\t}\r\n\r\n\t\tconst isNotCustom = !ruleTable;\r\n\r\n\t\tconst pool: number[] = [];\r\n\t\tlet speciesPool: Species[] = [];\r\n\t\tif (isNotCustom) {\r\n\t\t\tspeciesPool = [...this.dex.species.all()];\r\n\t\t\tfor (const species of speciesPool) {\r\n\t\t\t\tif (species.isNonstandard && species.isNonstandard !== 'Unobtainable') continue;\r\n\t\t\t\tif (requireMoves) {\r\n\t\t\t\t\tconst hasMovesInCurrentGen = Object.values(this.dex.species.getLearnset(species.id) || {})\r\n\t\t\t\t\t\t.some(sources => sources.some(source => source.startsWith('9')));\r\n\t\t\t\t\tif (!hasMovesInCurrentGen) continue;\r\n\t\t\t\t}\r\n\t\t\t\tif (requiredType && !species.types.includes(requiredType)) continue;\r\n\t\t\t\tif (minSourceGen && species.gen < minSourceGen) continue;\r\n\t\t\t\tconst num = species.num;\r\n\t\t\t\tif (num <= 0 || pool.includes(num)) continue;\r\n\t\t\t\tif (num > last) break;\r\n\t\t\t\tpool.push(num);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconst EXISTENCE_TAG = ['past', 'future', 'lgpe', 'unobtainable', 'cap', 'custom', 'nonexistent'];\r\n\t\t\tconst nonexistentBanReason = ruleTable.check('nonexistent');\r\n\t\t\t// Assume tierSpecies does not differ from species here (mega formes can be used without their stone, etc)\r\n\t\t\tfor (const species of this.dex.species.all()) {\r\n\t\t\t\tif (requiredType && !species.types.includes(requiredType)) continue;\r\n\r\n\t\t\t\tlet banReason = ruleTable.check('pokemon:' + species.id);\r\n\t\t\t\tif (banReason) continue;\r\n\t\t\t\tif (banReason !== '') {\r\n\t\t\t\t\tif (species.isMega && ruleTable.check('pokemontag:mega')) continue;\r\n\r\n\t\t\t\t\tbanReason = ruleTable.check('basepokemon:' + toID(species.baseSpecies));\r\n\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\tif (banReason !== '' || this.dex.species.get(species.baseSpecies).isNonstandard !== species.isNonstandard) {\r\n\t\t\t\t\t\tconst nonexistentCheck = Tags.nonexistent.genericFilter!(species) && nonexistentBanReason;\r\n\t\t\t\t\t\tlet tagWhitelisted = false;\r\n\t\t\t\t\t\tlet tagBlacklisted = false;\r\n\t\t\t\t\t\tfor (const ruleid of ruleTable.tagRules) {\r\n\t\t\t\t\t\t\tif (ruleid.startsWith('*')) continue;\r\n\t\t\t\t\t\t\tconst tagid = ruleid.slice(12);\r\n\t\t\t\t\t\t\tconst tag = Tags[tagid];\r\n\t\t\t\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) {\r\n\t\t\t\t\t\t\t\tconst existenceTag = EXISTENCE_TAG.includes(tagid);\r\n\t\t\t\t\t\t\t\tif (ruleid.startsWith('+')) {\r\n\t\t\t\t\t\t\t\t\tif (!existenceTag && nonexistentCheck) continue;\r\n\t\t\t\t\t\t\t\t\ttagWhitelisted = true;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\ttagBlacklisted = true;\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (tagBlacklisted) continue;\r\n\t\t\t\t\t\tif (!tagWhitelisted) {\r\n\t\t\t\t\t\t\tif (ruleTable.check('pokemontag:allpokemon')) continue;\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\tspeciesPool.push(species);\r\n\t\t\t\tconst num = species.num;\r\n\t\t\t\tif (pool.includes(num)) continue;\r\n\t\t\t\tpool.push(num);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst hasDexNumber: {[k: string]: number} = {};\r\n\t\tfor (let i = 0; i < n; i++) {\r\n\t\t\tconst num = this.sampleNoReplace(pool);\r\n\t\t\thasDexNumber[num] = i;\r\n\t\t}\r\n\r\n\t\tconst formes: string[][] = [];\r\n\t\tfor (const species of speciesPool) {\r\n\t\t\tif (!(species.num in hasDexNumber)) continue;\r\n\t\t\tif (isNotCustom && (species.gen > this.gen ||\r\n\t\t\t\t(species.isNonstandard && species.isNonstandard !== 'Unobtainable'))) continue;\r\n\t\t\tif (!formes[hasDexNumber[species.num]]) formes[hasDexNumber[species.num]] = [];\r\n\t\t\tformes[hasDexNumber[species.num]].push(species.name);\r\n\t\t}\r\n\r\n\t\tif (formes.length < n) {\r\n\t\t\tthrow new Error(`Legal Pokemon forme count insufficient to support Max Team Size: (${formes.length} / ${n}).`);\r\n\t\t}\r\n\r\n\t\tconst nPokemon = [];\r\n\t\tfor (let i = 0; i < n; i++) {\r\n\t\t\tif (!formes[i].length) {\r\n\t\t\t\tthrow new Error(`Invalid pokemon gen ${this.gen}: ${JSON.stringify(formes)} numbers ${JSON.stringify(hasDexNumber)}`);\r\n\t\t\t}\r\n\t\t\tnPokemon.push(this.sample(formes[i]));\r\n\t\t}\r\n\t\treturn nPokemon;\r\n\t}\r\n\r\n\trandomHCTeam(): PokemonSet[] {\r\n\t\tconst hasCustomBans = this.hasDirectCustomBanlistChanges();\r\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\r\n\t\tconst hasNonexistentBan = hasCustomBans && ruleTable.check('nonexistent');\r\n\t\tconst hasNonexistentWhitelist = hasCustomBans && (hasNonexistentBan === '');\r\n\r\n\t\tif (hasCustomBans) {\r\n\t\t\tthis.enforceNoDirectComplexBans();\r\n\t\t}\r\n\r\n\t\t// Item Pool\r\n\t\tconst doItemsExist = this.gen > 1;\r\n\t\tlet itemPool: Item[] = [];\r\n\t\tif (doItemsExist) {\r\n\t\t\tif (!hasCustomBans) {\r\n\t\t\t\titemPool = [...this.dex.items.all()].filter(item => (item.gen <= this.gen && !item.isNonstandard));\r\n\t\t\t} else {\r\n\t\t\t\tconst hasAllItemsBan = ruleTable.check('pokemontag:allitems');\r\n\t\t\t\tfor (const item of this.dex.items.all()) {\r\n\t\t\t\t\tlet banReason = ruleTable.check('item:' + item.id);\r\n\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\tif (banReason !== '' && item.id) {\r\n\t\t\t\t\t\tif (hasAllItemsBan) continue;\r\n\t\t\t\t\t\tif (item.isNonstandard) {\r\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(item.isNonstandard));\r\n\t\t\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\t\t\tif (banReason !== '' && item.isNonstandard !== 'Unobtainable') {\r\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\r\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\titemPool.push(item);\r\n\t\t\t\t}\r\n\t\t\t\tif (ruleTable.check('item:noitem')) {\r\n\t\t\t\t\tthis.enforceCustomPoolSizeNoComplexBans('item', itemPool, this.maxTeamSize, 'Max Team Size');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Ability Pool\r\n\t\tconst doAbilitiesExist = (this.gen > 2) && (this.dex.currentMod !== 'gen7letsgo');\r\n\t\tlet abilityPool: Ability[] = [];\r\n\t\tif (doAbilitiesExist) {\r\n\t\t\tif (!hasCustomBans) {\r\n\t\t\t\tabilityPool = [...this.dex.abilities.all()].filter(ability => (ability.gen <= this.gen && !ability.isNonstandard));\r\n\t\t\t} else {\r\n\t\t\t\tconst hasAllAbilitiesBan = ruleTable.check('pokemontag:allabilities');\r\n\t\t\t\tfor (const ability of this.dex.abilities.all()) {\r\n\t\t\t\t\tlet banReason = ruleTable.check('ability:' + ability.id);\r\n\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\tif (banReason !== '') {\r\n\t\t\t\t\t\tif (hasAllAbilitiesBan) continue;\r\n\t\t\t\t\t\tif (ability.isNonstandard) {\r\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(ability.isNonstandard));\r\n\t\t\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\t\t\tif (banReason !== '') {\r\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\r\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tabilityPool.push(ability);\r\n\t\t\t\t}\r\n\t\t\t\tif (ruleTable.check('ability:noability')) {\r\n\t\t\t\t\tthis.enforceCustomPoolSizeNoComplexBans('ability', abilityPool, this.maxTeamSize, 'Max Team Size');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Move Pool\r\n\t\tconst setMoveCount = ruleTable.maxMoveCount;\r\n\t\tlet movePool: Move[] = [];\r\n\t\tif (!hasCustomBans) {\r\n\t\t\tmovePool = [...this.dex.moves.all()].filter(move =>\r\n\t\t\t\t(move.gen <= this.gen && !move.isNonstandard));\r\n\t\t} else {\r\n\t\t\tconst hasAllMovesBan = ruleTable.check('pokemontag:allmoves');\r\n\t\t\tfor (const move of this.dex.moves.all()) {\r\n\t\t\t\tlet banReason = ruleTable.check('move:' + move.id);\r\n\t\t\t\tif (banReason) continue;\r\n\t\t\t\tif (banReason !== '') {\r\n\t\t\t\t\tif (hasAllMovesBan) continue;\r\n\t\t\t\t\tif (move.isNonstandard) {\r\n\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(move.isNonstandard));\r\n\t\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\t\tif (banReason !== '' && move.isNonstandard !== 'Unobtainable') {\r\n\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\r\n\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\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\tmovePool.push(move);\r\n\t\t\t}\r\n\t\t\tthis.enforceCustomPoolSizeNoComplexBans('move', movePool, this.maxTeamSize * setMoveCount, 'Max Team Size * Max Move Count');\r\n\t\t}\r\n\r\n\t\t// Nature Pool\r\n\t\tconst doNaturesExist = this.gen > 2;\r\n\t\tlet naturePool: Nature[] = [];\r\n\t\tif (doNaturesExist) {\r\n\t\t\tif (!hasCustomBans) {\r\n\t\t\t\tnaturePool = [...this.dex.natures.all()];\r\n\t\t\t} else {\r\n\t\t\t\tconst hasAllNaturesBan = ruleTable.check('pokemontag:allnatures');\r\n\t\t\t\tfor (const nature of this.dex.natures.all()) {\r\n\t\t\t\t\tlet banReason = ruleTable.check('nature:' + nature.id);\r\n\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\tif (banReason !== '' && nature.id) {\r\n\t\t\t\t\t\tif (hasAllNaturesBan) continue;\r\n\t\t\t\t\t\tif (nature.isNonstandard) {\r\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(nature.isNonstandard));\r\n\t\t\t\t\t\t\tif (banReason) continue;\r\n\t\t\t\t\t\t\tif (banReason !== '' && nature.isNonstandard !== 'Unobtainable') {\r\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\r\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tnaturePool.push(nature);\r\n\t\t\t\t}\r\n\t\t\t\t// There is no 'nature:nonature' rule so do not constrain pool size\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, undefined,\r\n\t\t\thasCustomBans ? ruleTable : undefined);\r\n\r\n\t\tconst team = [];\r\n\t\tfor (const forme of randomN) {\r\n\t\t\t// Choose forme\r\n\t\t\tconst species = this.dex.species.get(forme);\r\n\r\n\t\t\t// Random unique item\r\n\t\t\tlet item = '';\r\n\t\t\tlet itemData;\r\n\t\t\tlet isBadItem;\r\n\t\t\tif (doItemsExist) {\r\n\t\t\t\t// We discard TRs and Balls with 95% probability because of their otherwise overwhelming presence\r\n\t\t\t\tdo {\r\n\t\t\t\t\titemData = this.sampleNoReplace(itemPool);\r\n\t\t\t\t\titem = itemData?.name;\r\n\t\t\t\t\tisBadItem = item.startsWith(\"TR\") || itemData.isPokeball;\r\n\t\t\t\t} while (isBadItem && this.randomChance(19, 20) && itemPool.length > this.maxTeamSize);\r\n\t\t\t}\r\n\r\n\t\t\t// Random unique ability\r\n\t\t\tlet ability = 'No Ability';\r\n\t\t\tlet abilityData;\r\n\t\t\tif (doAbilitiesExist) {\r\n\t\t\t\tabilityData = this.sampleNoReplace(abilityPool);\r\n\t\t\t\tability = abilityData?.name;\r\n\t\t\t}\r\n\r\n\t\t\t// Random unique moves\r\n\t\t\tconst m = [];\r\n\t\t\tdo {\r\n\t\t\t\tconst move = this.sampleNoReplace(movePool);\r\n\t\t\t\tm.push(move.id);\r\n\t\t\t} while (m.length < setMoveCount);\r\n\r\n\t\t\t// Random EVs\r\n\t\t\tconst evs = {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0};\r\n\t\t\tif (this.gen === 6) {\r\n\t\t\t\tlet evpool = 510;\r\n\t\t\t\tdo {\r\n\t\t\t\t\tconst x = this.sample(Dex.stats.ids());\r\n\t\t\t\t\tconst y = this.random(Math.min(256 - evs[x], evpool + 1));\r\n\t\t\t\t\tevs[x] += y;\r\n\t\t\t\t\tevpool -= y;\r\n\t\t\t\t} while (evpool > 0);\r\n\t\t\t} else {\r\n\t\t\t\tfor (const x of Dex.stats.ids()) {\r\n\t\t\t\t\tevs[x] = this.random(256);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Random IVs\r\n\t\t\tconst ivs: StatsTable = {\r\n\t\t\t\thp: this.random(32),\r\n\t\t\t\tatk: this.random(32),\r\n\t\t\t\tdef: this.random(32),\r\n\t\t\t\tspa: this.random(32),\r\n\t\t\t\tspd: this.random(32),\r\n\t\t\t\tspe: this.random(32),\r\n\t\t\t};\r\n\r\n\t\t\t// Random nature\r\n\t\t\tlet nature = '';\r\n\t\t\tif (doNaturesExist && (naturePool.length > 0)) {\r\n\t\t\t\tnature = this.sample(naturePool).name;\r\n\t\t\t}\r\n\r\n\t\t\t// Level balance\r\n\t\t\tconst mbstmin = 1307;\r\n\t\t\tconst stats = species.baseStats;\r\n\t\t\tlet mbst = (stats['hp'] * 2 + 31 + 21 + 100) + 10;\r\n\t\t\tmbst += (stats['atk'] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats['def'] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats['spa'] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats['spd'] * 2 + 31 + 21 + 100) + 5;\r\n\t\t\tmbst += (stats['spe'] * 2 + 31 + 21 + 100) + 5;\r\n\r\n\t\t\tlet level;\r\n\t\t\tif (this.adjustLevel) {\r\n\t\t\t\tlevel = this.adjustLevel;\r\n\t\t\t} else {\r\n\t\t\t\tlevel = Math.floor(100 * mbstmin / mbst);\r\n\t\t\t\twhile (level < 100) {\r\n\t\t\t\t\tmbst = Math.floor((stats['hp'] * 2 + 31 + 21 + 100) * level / 100 + 10);\r\n\t\t\t\t\tmbst += Math.floor(((stats['atk'] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\r\n\t\t\t\t\tmbst += Math.floor((stats['def'] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\t\t\t\t\tmbst += Math.floor(((stats['spa'] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\r\n\t\t\t\t\tmbst += Math.floor((stats['spd'] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\t\t\t\t\tmbst += Math.floor((stats['spe'] * 2 + 31 + 21 + 100) * level / 100 + 5);\r\n\t\t\t\t\tif (mbst >= mbstmin) break;\r\n\t\t\t\t\tlevel++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Random happiness\r\n\t\t\tconst happiness = this.random(256);\r\n\r\n\t\t\t// Random shininess\r\n\t\t\tconst shiny = this.randomChance(1, 1024);\r\n\r\n\t\t\tconst set: PokemonSet = {\r\n\t\t\t\tname: species.baseSpecies,\r\n\t\t\t\tspecies: species.name,\r\n\t\t\t\tgender: species.gender,\r\n\t\t\t\titem,\r\n\t\t\t\tability,\r\n\t\t\t\tmoves: m,\r\n\t\t\t\tevs,\r\n\t\t\t\tivs,\r\n\t\t\t\tnature,\r\n\t\t\t\tlevel,\r\n\t\t\t\thappiness,\r\n\t\t\t\tshiny,\r\n\t\t\t};\r\n\t\t\tif (this.gen === 9) {\r\n\t\t\t\t// Random Tera type\r\n\t\t\t\tset.teraType = this.sample(this.dex.types.all()).name;\r\n\t\t\t}\r\n\t\t\tteam.push(set);\r\n\t\t}\r\n\r\n\t\treturn team;\r\n\t}\r\n}\r\n\r\nexport default RandomTeams;\r\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,i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