{ "version": 3, "sources": ["../../../../../data/mods/gen7/random-teams.ts"], "sourcesContent": ["import {MoveCounter, TeamData, RandomGen8Teams} from '../gen8/random-teams';\nimport {PRNG, PRNGSeed} from '../../../sim/prng';\nimport {Utils} from '../../../lib';\nimport {toID} from '../../../sim/dex';\n\nexport interface BattleFactorySpecies {\n\tflags: {megaOnly?: 1, zmoveOnly?: 1, limEevee?: 1};\n\tsets: BattleFactorySet[];\n}\ninterface BattleFactorySet {\n\tspecies: string;\n\titem: string;\n\tability: string;\n\tnature: string;\n\tmoves: string[];\n\tevs?: Partial;\n\tivs?: Partial;\n}\n\nexport const ZeroAttackHPIVs: {[k: string]: SparseStatsTable} = {\n\tgrass: {hp: 30, spa: 30},\n\tfire: {spa: 30, spe: 30},\n\tice: {def: 30},\n\tground: {spa: 30, spd: 30},\n\tfighting: {def: 30, spa: 30, spd: 30, spe: 30},\n\telectric: {def: 30, spe: 30},\n\tpsychic: {spe: 30},\n\tflying: {spa: 30, spd: 30, spe: 30},\n\trock: {def: 30, spd: 30, spe: 30},\n};\n\n// Moves that restore HP:\nconst RECOVERY_MOVES = [\n\t'healorder', 'milkdrink', 'moonlight', 'morningsun', 'recover', 'recycle', 'roost', 'shoreup', 'slackoff', 'softboiled', 'strengthsap', 'synthesis',\n];\n// Moves that drop stats:\nconst CONTRARY_MOVES = [\n\t'closecombat', 'leafstorm', 'overheat', 'superpower', 'vcreate',\n];\n// Moves that boost Attack:\nconst PHYSICAL_SETUP = [\n\t'bellydrum', 'bulkup', 'coil', 'curse', 'dragondance', 'honeclaws', 'howl', 'meditate', 'poweruppunch', 'screech', 'swordsdance',\n];\n// Moves which boost Special Attack:\nconst SPECIAL_SETUP = [\n\t'calmmind', 'chargebeam', 'geomancy', 'nastyplot', 'quiverdance', 'tailglow',\n];\n// Moves that boost Attack AND Special Attack:\nconst MIXED_SETUP = [\n\t'celebrate', 'growth', 'happyhour', 'holdhands', 'shellsmash', 'workup',\n];\n// Some moves that only boost Speed:\nconst SPEED_SETUP = [\n\t'agility', 'autotomize', 'flamecharge', 'rockpolish',\n];\n// Conglomerate for ease of access\nconst SETUP = [\n\t'acidarmor', 'agility', 'autotomize', 'bellydrum', 'bulkup', 'calmmind', 'celebrate', 'coil', 'conversion', 'curse', 'dragondance',\n\t'electricterrain', 'flamecharge', 'focusenergy', 'geomancy', 'growth', 'happyhour', 'holdhands', 'honeclaws', 'howl', 'irondefense', 'meditate',\n\t'nastyplot', 'poweruppunch', 'quiverdance', 'raindance', 'rockpolish', 'shellsmash', 'shiftgear', 'swordsdance', 'tailglow', 'workup',\n];\n// Moves that shouldn't be the only STAB moves:\nconst NO_STAB = [\n\t'accelerock', 'aquajet', 'bulletpunch', 'clearsmog', 'dragontail', 'eruption', 'explosion',\n\t'fakeout', 'firstimpression', 'flamecharge', 'futuresight', 'iceshard', 'icywind', 'incinerate', 'machpunch', 'nuzzle',\n\t'pluck', 'poweruppunch', 'pursuit', 'quickattack', 'rapidspin', 'reversal', 'selfdestruct', 'shadowsneak', 'skyattack',\n\t'skydrop', 'snarl', 'suckerpunch', 'uturn', 'watershuriken', 'vacuumwave', 'voltswitch', 'waterspout',\n];\n// Hazard-setting moves\nconst HAZARDS = [\n\t'spikes', 'stealthrock', 'stickyweb', 'toxicspikes',\n];\n// Protect and its variants\nconst PROTECT_MOVES = [\n\t'banefulbunker', 'kingsshield', 'protect', 'spikyshield',\n];\n// Moves that switch the user out\nconst PIVOT_MOVES = [\n\t'partingshot', 'uturn', 'voltswitch',\n];\n\n// Moves that should be paired together when possible\nconst MOVE_PAIRS = [\n\t['lightscreen', 'reflect'],\n\t['sleeptalk', 'rest'],\n\t['protect', 'wish'],\n\t['spikyshield', 'wish'],\n\t['leechseed', 'substitute'],\n\t['perishsong', 'protect'],\n\t['solarbeam', 'sunnyday'],\n];\n\n/** Pokemon who always want priority STAB, and are fine with it as its only STAB move of that type */\nconst PRIORITY_POKEMON = [\n\t'aegislashblade', 'banette', 'breloom', 'cacturne', 'doublade', 'dusknoir', 'golisopod', 'honchkrow', 'mimikyu', 'scizor', 'scizormega', 'shedinja',\n];\nfunction sereneGraceBenefits(move: Move) {\n\treturn move.secondary?.chance && move.secondary.chance >= 20 && move.secondary.chance < 100;\n}\n\nexport class RandomGen7Teams extends RandomGen8Teams {\n\trandomSets: {[species: string]: RandomTeamsTypes.RandomSpeciesData} = require('./random-sets.json');\n\n\tconstructor(format: Format | string, prng: PRNG | PRNGSeed | null) {\n\t\tsuper(format, prng);\n\n\t\tthis.noStab = NO_STAB;\n\t\tthis.priorityPokemon = PRIORITY_POKEMON;\n\n\t\tthis.moveEnforcementCheckers = {\n\t\t\tBug: (movePool, moves, abilities, types, counter) => (\n\t\t\t\t['megahorn', 'pinmissile'].some(m => movePool.includes(m)) ||\n\t\t\t\t!counter.get('Bug') && (abilities.has('Tinted Lens') || abilities.has('Adaptability'))\n\t\t\t),\n\t\t\tDark: (movePool, moves, abilities, types, counter) => !counter.get('Dark'),\n\t\t\tDragon: (movePool, moves, abilities, types, counter) => !counter.get('Dragon') && !abilities.has('Aerilate'),\n\t\t\tElectric: (movePool, moves, abilities, types, counter) => !counter.get('Electric'),\n\t\t\tFairy: (movePool, moves, abilities, types, counter) => !counter.get('Fairy'),\n\t\t\tFighting: (movePool, moves, abilities, types, counter) => !counter.get('Fighting'),\n\t\t\tFire: (movePool, moves, abilities, types, counter) => !counter.get('Fire'),\n\t\t\tFlying: (movePool, moves, abilities, types, counter, species) => (\n\t\t\t\t!counter.get('Flying') && !['aerodactylmega', 'charizardmegay', 'mantine'].includes(species.id) &&\n\t\t\t\t!movePool.includes('hiddenpowerflying')\n\t\t\t),\n\t\t\tGhost: (movePool, moves, abilities, types, counter) => !counter.get('Ghost'),\n\t\t\tGrass: (movePool, moves, abilities, types, counter, species) => (\n\t\t\t\t!counter.get('Grass') && (species.baseStats.atk >= 100 || movePool.includes('leafstorm'))\n\t\t\t),\n\t\t\tGround: (movePool, moves, abilities, types, counter) => !counter.get('Ground'),\n\t\t\tIce: (movePool, moves, abilities, types, counter) => (\n\t\t\t\t!counter.get('Ice') || (!moves.has('blizzard') && movePool.includes('freezedry')) ||\n\t\t\t\tabilities.has('Refrigerate') && (movePool.includes('return') || movePool.includes('hypervoice'))\n\t\t\t),\n\t\t\tNormal: movePool => movePool.includes('boomburst'),\n\t\t\tPoison: (movePool, moves, abilities, types, counter) => !counter.get('Poison'),\n\t\t\tPsychic: (movePool, moves, abilities, types, counter) => (\n\t\t\t\t!counter.get('Psychic') && (\n\t\t\t\t\ttypes.has('Fighting') || movePool.includes('psychicfangs') || movePool.includes('calmmind')\n\t\t\t\t)\n\t\t\t),\n\t\t\tRock: (movePool, moves, abilities, types, counter, species) => (\n\t\t\t\t!counter.get('Rock') && (species.baseStats.atk >= 100 || abilities.has('Rock Head'))\n\t\t\t),\n\t\t\tSteel: (movePool, moves, abilities, types, counter, species) => (\n\t\t\t\t!counter.get('Steel') && species.baseStats.atk >= 100\n\t\t\t),\n\t\t\tWater: (movePool, moves, abilities, types, counter) => !counter.get('Water'),\n\t\t};\n\t}\n\n\tnewQueryMoves(\n\t\tmoves: Set | null,\n\t\tspecies: Species,\n\t\tpreferredType: string,\n\t\tabilities: Set = new Set(),\n\t): MoveCounter {\n\t\t// This is primarily a helper function for random setbuilder functions.\n\t\tconst counter = new MoveCounter();\n\t\tconst types = species.types;\n\t\tif (!moves?.size) return counter;\n\n\t\tconst categories = {Physical: 0, Special: 0, Status: 0};\n\n\t\t// Iterate through all moves we've chosen so far and keep track of what they do:\n\t\tfor (const moveid of moves) {\n\t\t\tlet move = this.dex.moves.get(moveid);\n\t\t\t// Nature Power calls Earthquake in Gen 5\n\t\t\tif (this.gen === 5 && moveid === 'naturepower') move = this.dex.moves.get('earthquake');\n\n\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\tif (move.damage || move.damageCallback) {\n\t\t\t\t// Moves that do a set amount of damage:\n\t\t\t\tcounter.add('damage');\n\t\t\t\tcounter.damagingMoves.add(move);\n\t\t\t} else {\n\t\t\t\t// Are Physical/Special/Status moves:\n\t\t\t\tcategories[move.category]++;\n\t\t\t}\n\t\t\t// Moves that have a low base power:\n\t\t\tif (moveid === 'lowkick' || (move.basePower && move.basePower <= 60 && !['nuzzle', 'rapidspin'].includes(moveid))) {\n\t\t\t\tcounter.add('technician');\n\t\t\t}\n\t\t\t// Moves that hit up to 5 times:\n\t\t\tif (move.multihit && Array.isArray(move.multihit) && move.multihit[1] === 5) counter.add('skilllink');\n\t\t\tif (move.recoil || move.hasCrashDamage) counter.add('recoil');\n\t\t\tif (move.drain) counter.add('drain');\n\t\t\t// Moves which have a base power:\n\t\t\tif (move.basePower || move.basePowerCallback) {\n\t\t\t\tif (!this.noStab.includes(moveid) || this.priorityPokemon.includes(species.id) && move.priority > 0) {\n\t\t\t\t\tcounter.add(moveType);\n\t\t\t\t\tif (types.includes(moveType)) counter.add('stab');\n\t\t\t\t\tif (preferredType === moveType) counter.add('preferred');\n\t\t\t\t\tcounter.damagingMoves.add(move);\n\t\t\t\t}\n\t\t\t\tif (move.flags['bite']) counter.add('strongjaw');\n\t\t\t\tif (move.flags['punch']) counter.add('ironfist');\n\t\t\t\tif (move.flags['sound']) counter.add('sound');\n\t\t\t\tif (move.priority > 0 || (moveid === 'grassyglide' && abilities.has('Grassy Surge'))) {\n\t\t\t\t\tcounter.add('priority');\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Moves with secondary effects:\n\t\t\tif (move.secondary || move.hasSheerForce) {\n\t\t\t\tcounter.add('sheerforce');\n\t\t\t\tif (sereneGraceBenefits(move)) {\n\t\t\t\t\tcounter.add('serenegrace');\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Moves with low accuracy:\n\t\t\tif (move.accuracy && move.accuracy !== true && move.accuracy < 90) counter.add('inaccurate');\n\n\t\t\t// Moves that change stats:\n\t\t\tif (RECOVERY_MOVES.includes(moveid)) counter.add('recovery');\n\t\t\tif (CONTRARY_MOVES.includes(moveid)) counter.add('contrary');\n\t\t\tif (PHYSICAL_SETUP.includes(moveid)) counter.add('physicalsetup');\n\t\t\tif (SPECIAL_SETUP.includes(moveid)) counter.add('specialsetup');\n\t\t\tif (MIXED_SETUP.includes(moveid)) counter.add('mixedsetup');\n\t\t\tif (SPEED_SETUP.includes(moveid)) counter.add('speedsetup');\n\t\t\tif (SETUP.includes(moveid)) counter.add('setup');\n\t\t\tif (HAZARDS.includes(moveid)) counter.add('hazards');\n\t\t}\n\n\t\tcounter.set('Physical', Math.floor(categories['Physical']));\n\t\tcounter.set('Special', Math.floor(categories['Special']));\n\t\tcounter.set('Status', categories['Status']);\n\t\treturn counter;\n\t}\n\n\tcullMovePool(\n\t\ttypes: string[],\n\t\tmoves: Set,\n\t\tabilities: Set,\n\t\tcounter: MoveCounter,\n\t\tmovePool: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): void {\n\t\t// Pokemon cannot have multiple Hidden Powers in any circumstance\n\t\tlet hasHiddenPower = false;\n\t\tfor (const move of moves) {\n\t\t\tif (move.startsWith('hiddenpower')) hasHiddenPower = true;\n\t\t}\n\t\tif (hasHiddenPower) {\n\t\t\tlet movePoolHasHiddenPower = true;\n\t\t\twhile (movePoolHasHiddenPower) {\n\t\t\t\tmovePoolHasHiddenPower = false;\n\t\t\t\tfor (const moveid of movePool) {\n\t\t\t\t\tif (moveid.startsWith('hiddenpower')) {\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid));\n\t\t\t\t\t\tmovePoolHasHiddenPower = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t// If we have two unfilled moves and only one unpaired move, cull the unpaired move.\n\t\tif (moves.size === this.maxMoveCount - 2) {\n\t\t\tconst unpairedMoves = [...movePool];\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[0]));\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[1]));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (unpairedMoves.length === 1) {\n\t\t\t\tthis.fastPop(movePool, movePool.indexOf(unpairedMoves[0]));\n\t\t\t}\n\t\t}\n\n\t\t// These moves are paired, and shouldn't appear if there is not room for them both.\n\t\tif (moves.size === this.maxMoveCount - 1) {\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[0]));\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[1]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Team-based move culls\n\t\tif (teamDetails.screens && movePool.length >= this.maxMoveCount + 2) {\n\t\t\tif (movePool.includes('reflect')) this.fastPop(movePool, movePool.indexOf('reflect'));\n\t\t\tif (movePool.includes('lightscreen')) this.fastPop(movePool, movePool.indexOf('lightscreen'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.stickyWeb) {\n\t\t\tif (movePool.includes('stickyweb')) this.fastPop(movePool, movePool.indexOf('stickyweb'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.stealthRock) {\n\t\t\tif (movePool.includes('stealthrock')) this.fastPop(movePool, movePool.indexOf('stealthrock'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.defog || teamDetails.rapidSpin) {\n\t\t\tif (movePool.includes('defog')) this.fastPop(movePool, movePool.indexOf('defog'));\n\t\t\tif (movePool.includes('rapidspin')) this.fastPop(movePool, movePool.indexOf('rapidspin'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.toxicSpikes) {\n\t\t\tif (movePool.includes('toxicspikes')) this.fastPop(movePool, movePool.indexOf('toxicspikes'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.spikes && teamDetails.spikes >= 2) {\n\t\t\tif (movePool.includes('spikes')) this.fastPop(movePool, movePool.indexOf('spikes'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\n\t\t// Develop additional move lists\n\t\tconst badWithSetup = ['defog', 'dragontail', 'haze', 'healbell', 'nuzzle', 'pursuit', 'rapidspin', 'toxic'];\n\t\tconst statusMoves = this.dex.moves.all()\n\t\t\t.filter(move => move.category === 'Status')\n\t\t\t.map(move => move.id);\n\n\t\t// General incompatibilities\n\t\tconst incompatiblePairs = [\n\t\t\t// These moves don't mesh well with other aspects of the set\n\t\t\t[statusMoves, ['healingwish', 'memento', 'switcheroo', 'trick']],\n\t\t\t[SETUP, PIVOT_MOVES],\n\t\t\t[SETUP, HAZARDS],\n\t\t\t[SETUP, badWithSetup],\n\t\t\t[PHYSICAL_SETUP, PHYSICAL_SETUP],\n\t\t\t[SPEED_SETUP, 'quickattack'],\n\t\t\t['defog', HAZARDS],\n\t\t\t[['fakeout', 'uturn'], ['switcheroo', 'trick']],\n\t\t\t['substitute', PIVOT_MOVES],\n\t\t\t['leechseed', 'dragontail'],\n\t\t\t['rest', 'substitute'],\n\t\t\t[PHYSICAL_SETUP, 'dracometeor'],\n\t\t\t[SPECIAL_SETUP, 'knockoff'],\n\n\t\t\t// These attacks are redundant with each other\n\t\t\t['psychic', 'psyshock'],\n\t\t\t['scald', ['hydropump', 'originpulse', 'waterpulse']],\n\t\t\t['return', ['bodyslam', 'doubleedge']],\n\t\t\t[['fierydance', 'firelash', 'lavaplume'], ['fireblast', 'magmastorm']],\n\t\t\t[['flamethrower', 'flareblitz'], ['fireblast', 'overheat']],\n\t\t\t['hornleech', 'woodhammer'],\n\t\t\t[['gigadrain', 'leafstorm'], ['leafstorm', 'petaldance', 'powerwhip']],\n\t\t\t['wildcharge', 'thunderbolt'],\n\t\t\t['gunkshot', 'poisonjab'],\n\t\t\t[['drainpunch', 'focusblast'], ['closecombat', 'highjumpkick', 'superpower']],\n\t\t\t['stoneedge', 'headsmash'],\n\t\t\t['dracometeor', 'dragonpulse'],\n\t\t\t['dragonclaw', 'outrage'],\n\t\t\t['knockoff', ['darkestlariat', 'darkpulse', 'foulplay']],\n\n\t\t\t// Status move incompatibilities\n\t\t\t['toxic', 'toxicspikes'],\n\t\t\t['taunt', 'disable'],\n\t\t\t['defog', ['leechseed', 'substitute']],\n\n\t\t\t// Assorted hardcodes go here:\n\t\t\t// Lunatone\n\t\t\t['moonlight', 'rockpolish'],\n\t\t\t// Smeargle\n\t\t\t['destinybond', 'whirlwind'],\n\t\t\t// Liepard\n\t\t\t['copycat', 'uturn'],\n\t\t\t// Seviper\n\t\t\t['switcheroo', 'suckerpunch'],\n\t\t\t// Jirachi\n\t\t\t['bodyslam', 'healingwish'],\n\t\t];\n\n\t\tfor (const pair of incompatiblePairs) this.incompatibleMoves(moves, movePool, pair[0], pair[1]);\n\n\t\tif (!types.includes('Dark') && preferredType !== 'Dark') {\n\t\t\tthis.incompatibleMoves(moves, movePool, 'knockoff', ['pursuit', 'suckerpunch']);\n\t\t}\n\n\t\tconst statusInflictingMoves = ['thunderwave', 'toxic', 'willowisp', 'yawn'];\n\t\tif (!abilities.has('Prankster')) {\n\t\t\tthis.incompatibleMoves(moves, movePool, statusInflictingMoves, statusInflictingMoves);\n\t\t}\n\n\t\tif (abilities.has('Guts')) this.incompatibleMoves(moves, movePool, 'protect', 'swordsdance');\n\n\t\t// Z-Conversion Porygon-Z\n\t\tif (species.id === 'porygonz') {\n\t\t\tthis.incompatibleMoves(moves, movePool, 'shadowball', 'recover');\n\t\t}\n\t}\n\n\t// Checks for and removes incompatible moves, starting with the first move in movesA.\n\tincompatibleMoves(\n\t\tmoves: Set,\n\t\tmovePool: string[],\n\t\tmovesA: string | string[],\n\t\tmovesB: string | string[],\n\t): void {\n\t\tconst moveArrayA = (Array.isArray(movesA)) ? movesA : [movesA];\n\t\tconst moveArrayB = (Array.isArray(movesB)) ? movesB : [movesB];\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\tfor (const moveid1 of moves) {\n\t\t\tif (moveArrayB.includes(moveid1)) {\n\t\t\t\tfor (const moveid2 of moveArrayA) {\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (moveArrayA.includes(moveid1)) {\n\t\t\t\tfor (const moveid2 of moveArrayB) {\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Adds a move to the moveset, returns the MoveCounter\n\taddMove(\n\t\tmove: string,\n\t\tmoves: Set,\n\t\ttypes: string[],\n\t\tabilities: Set,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tmovePool: string[],\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): MoveCounter {\n\t\tmoves.add(move);\n\t\tthis.fastPop(movePool, movePool.indexOf(move));\n\t\tconst counter = this.newQueryMoves(moves, species, preferredType, abilities);\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead,\n\t\t\tpreferredType, role);\n\t\treturn counter;\n\t}\n\n\t// Returns the type of a given move for STAB/coverage enforcement purposes\n\tgetMoveType(move: Move, species: Species, abilities: Set, preferredType: string): string {\n\t\tif (['judgment', 'multiattack', 'revelationdance'].includes(move.id)) return species.types[0];\n\t\tif (species.id === 'genesectdouse' && move.id === 'technoblast') return 'Water';\n\n\t\tconst moveType = move.type;\n\t\tif (moveType === 'Normal') {\n\t\t\tif (abilities.has('Aerilate')) return 'Flying';\n\t\t\tif (abilities.has('Galvanize')) return 'Electric';\n\t\t\tif (abilities.has('Pixilate')) return 'Fairy';\n\t\t\tif (abilities.has('Refrigerate')) return 'Ice';\n\t\t}\n\t\treturn moveType;\n\t}\n\n\t// Generate random moveset for a given species, role, preferred type.\n\trandomMoveset(\n\t\ttypes: string[],\n\t\tabilities: Set,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tmovePool: string[],\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): Set {\n\t\tconst moves = new Set();\n\t\tlet counter = this.newQueryMoves(moves, species, preferredType, abilities);\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead,\n\t\t\tpreferredType, role);\n\n\t\t// If there are only four moves, add all moves and return early\n\t\tif (movePool.length <= this.maxMoveCount) {\n\t\t\t// Still need to ensure that multiple Hidden Powers are not added (if maxMoveCount is increased)\n\t\t\twhile (movePool.length) {\n\t\t\t\tconst moveid = this.sample(movePool);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t\treturn moves;\n\t\t}\n\n\t\tconst runEnforcementChecker = (checkerName: string) => {\n\t\t\tif (!this.moveEnforcementCheckers[checkerName]) return false;\n\t\t\treturn this.moveEnforcementCheckers[checkerName](\n\t\t\t\tmovePool, moves, abilities, new Set(types), counter, species, teamDetails\n\t\t\t);\n\t\t};\n\n\t\t// Add required move (e.g. Relic Song for Meloetta-P)\n\t\tif (species.requiredMove) {\n\t\t\tconst move = this.dex.moves.get(species.requiredMove).id;\n\t\t\tcounter = this.addMove(move, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\tmovePool, preferredType, role);\n\t\t}\n\n\t\t// Add other moves you really want to have, e.g. STAB, recovery, setup.\n\n\t\t// Enforce Facade if Guts is a possible ability\n\t\tif (movePool.includes('facade') && abilities.has('Guts')) {\n\t\t\tcounter = this.addMove('facade', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\tmovePool, preferredType, role);\n\t\t}\n\n\t\t// Enforce Blizzard, Seismic Toss, Spore, and Sticky Web\n\t\tfor (const moveid of ['blizzard', 'seismictoss', 'spore', 'stickyweb']) {\n\t\t\tif (movePool.includes(moveid)) {\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Thunder Wave on Prankster users\n\t\tif (movePool.includes('thunderwave') && abilities.has('Prankster')) {\n\t\t\tcounter = this.addMove('thunderwave', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\tmovePool, preferredType, role);\n\t\t}\n\n\t\t// Enforce Shadow Sneak on Kecleon\n\t\tif (movePool.includes('shadowsneak') && species.id === 'kecleon') {\n\t\t\tcounter = this.addMove('shadowsneak', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\tmovePool, preferredType, role);\n\t\t}\n\n\t\t// Enforce hazard removal on Bulky Support if the team doesn't already have it\n\t\tif (role === 'Bulky Support' && !teamDetails.defog && !teamDetails.rapidSpin) {\n\t\t\tif (movePool.includes('rapidspin')) {\n\t\t\t\tcounter = this.addMove('rapidspin', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t\tif (movePool.includes('defog')) {\n\t\t\t\tcounter = this.addMove('defog', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce STAB priority\n\t\tif (['Bulky Attacker', 'Bulky Setup'].includes(role) || this.priorityPokemon.includes(species.id)) {\n\t\t\tconst priorityMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\t\tif (types.includes(moveType) && move.priority > 0 && (move.basePower || move.basePowerCallback)) {\n\t\t\t\t\tpriorityMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (priorityMoves.length) {\n\t\t\t\tconst moveid = this.sample(priorityMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce STAB\n\t\tfor (const type of types) {\n\t\t\t// Check if a STAB move of that type should be required\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && type === moveType) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (runEnforcementChecker(type)) {\n\t\t\t\tif (!stabMoves.length) break;\n\t\t\t\tconst moveid = this.sampleNoReplace(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Preferred Type\n\t\tif (!counter.get('preferred')) {\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && preferredType === moveType) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (stabMoves.length) {\n\t\t\t\tconst moveid = this.sample(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// If no STAB move was added, add a STAB move\n\t\tif (!counter.get('stab')) {\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && types.includes(moveType)) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (stabMoves.length) {\n\t\t\t\tconst moveid = this.sample(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t} else {\n\t\t\t\t// If they have no regular STAB move, enforce U-turn on Bug types.\n\t\t\t\tif (movePool.includes('uturn') && types.includes('Bug')) {\n\t\t\t\t\tcounter = this.addMove('uturn', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Enforce recovery\n\t\tif (['Bulky Support', 'Bulky Attacker', 'Bulky Setup', 'Staller'].includes(role)) {\n\t\t\tconst recoveryMoves = movePool.filter(moveid => RECOVERY_MOVES.includes(moveid));\n\t\t\tif (recoveryMoves.length) {\n\t\t\t\tconst moveid = this.sample(recoveryMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Staller moves\n\t\tif (role === 'Staller') {\n\t\t\tconst enforcedMoves = [...PROTECT_MOVES, 'toxic', 'wish'];\n\t\t\tfor (const move of enforcedMoves) {\n\t\t\t\tif (movePool.includes(move)) {\n\t\t\t\t\tcounter = this.addMove(move, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Enforce setup\n\t\tif (role.includes('Setup') || role === 'Z-Move user') {\n\t\t\t// Prioritise other setup moves over Flame Charge\n\t\t\tconst setupMoves = movePool.filter(moveid => SETUP.includes(moveid) && moveid !== 'flamecharge');\n\t\t\tif (setupMoves.length) {\n\t\t\t\tconst moveid = this.sample(setupMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t} else {\n\t\t\t\tif (movePool.includes('flamecharge')) {\n\t\t\t\t\tcounter = this.addMove('flamecharge', moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Enforce a move not on the noSTAB list\n\t\tif (!counter.damagingMoves.size && !(moves.has('uturn') && types.includes('Bug'))) {\n\t\t\t// Choose an attacking move\n\t\t\tconst attackingMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.category !== 'Status')) attackingMoves.push(moveid);\n\t\t\t}\n\t\t\tif (attackingMoves.length) {\n\t\t\t\tconst moveid = this.sample(attackingMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce coverage move\n\t\tif (['Fast Attacker', 'Setup Sweeper', 'Bulky Attacker', 'Wallbreaker', 'Z-Move user'].includes(role)) {\n\t\t\tif (counter.damagingMoves.size === 1) {\n\t\t\t\t// Find the type of the current attacking move\n\t\t\t\tconst currentAttackType = counter.damagingMoves.values().next().value.type;\n\t\t\t\t// Choose an attacking move that is of different type to the current single attack\n\t\t\t\tconst coverageMoves = [];\n\t\t\t\tfor (const moveid of movePool) {\n\t\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, preferredType);\n\t\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback)) {\n\t\t\t\t\t\tif (currentAttackType !== moveType) coverageMoves.push(moveid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (coverageMoves.length) {\n\t\t\t\t\tconst moveid = this.sample(coverageMoves);\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Choose remaining moves randomly from movepool and add them to moves list:\n\t\twhile (moves.size < this.maxMoveCount && movePool.length) {\n\t\t\tconst moveid = this.sample(movePool);\n\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\tmovePool, preferredType, role);\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (moveid === pair[0] && movePool.includes(pair[1])) {\n\t\t\t\t\tcounter = this.addMove(pair[1], moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t\tif (moveid === pair[1] && movePool.includes(pair[0])) {\n\t\t\t\t\tcounter = this.addMove(pair[0], moves, types, abilities, teamDetails, species, isLead,\n\t\t\t\t\t\tmovePool, preferredType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn moves;\n\t}\n\n\tshouldCullAbility(\n\t\tability: string,\n\t\ttypes: Set,\n\t\tmoves: Set,\n\t\tabilities: Set,\n\t\tcounter: MoveCounter,\n\t\tmovePool: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role\n\t): boolean {\n\t\tswitch (ability) {\n\t\tcase 'Battle Bond': case 'Dazzling': case 'Flare Boost': case 'Gluttony': case 'Harvest': case 'Hyper Cutter':\n\t\tcase 'Ice Body': case 'Innards Out': case 'Liquid Voice': case 'Magician': case 'Moody': case 'Pressure':\n\t\tcase 'Sand Veil': case 'Sniper': case 'Snow Cloak': case 'Steadfast': case 'Weak Armor':\n\t\t\treturn true;\n\t\tcase 'Aerilate': case 'Galvanize': case 'Pixilate': case 'Refrigerate':\n\t\t\treturn ['doubleedge', 'hypervoice', 'return'].every(m => !moves.has(m));\n\t\tcase 'Chlorophyll':\n\t\t\t// Petal Dance is for Lilligant\n\t\t\treturn (\n\t\t\t\tspecies.baseStats.spe > 100 || moves.has('petaldance') ||\n\t\t\t\t(!moves.has('sunnyday') && !teamDetails.sun)\n\t\t\t);\n\t\tcase 'Competitive':\n\t\t\treturn !counter.get('Special');\n\t\tcase 'Compound Eyes': case 'No Guard':\n\t\t\t// Shadow Punch bit is for Golurk\n\t\t\treturn (!counter.get('inaccurate') || moves.has('shadowpunch'));\n\t\tcase 'Contrary': case 'Skill Link': case 'Strong Jaw':\n\t\t\treturn !counter.get(toID(ability));\n\t\tcase 'Defiant': case 'Justified': case 'Moxie':\n\t\t\treturn !counter.get('Physical');\n\t\tcase 'Guts':\n\t\t\treturn (!moves.has('facade') && !moves.has('sleeptalk'));\n\t\tcase 'Hustle':\n\t\t\treturn counter.get('Physical') < 2;\n\t\tcase 'Hydration': case 'Rain Dish': case 'Swift Swim':\n\t\t\treturn (\n\t\t\t\tspecies.baseStats.spe > 100 || !moves.has('raindance') && !teamDetails.rain ||\n\t\t\t\t!moves.has('raindance') && ['Rock Head', 'Water Absorb'].some(abil => abilities.has(abil))\n\t\t\t);\n\t\tcase 'Intimidate':\n\t\t\t// Slam part is for Tauros\n\t\t\treturn (moves.has('bodyslam') || species.id === 'staraptor');\n\t\tcase 'Iron Fist':\n\t\t\t// Dynamic Punch bit is for Golurk\n\t\t\treturn (!counter.get(toID(ability)) || moves.has('dynamicpunch'));\n\t\tcase 'Lightning Rod':\n\t\t\treturn (\n\t\t\t\ttypes.has('Ground') || species.id === 'marowakalola' ||\n\t\t\t\t((!!teamDetails.rain || moves.has('raindance')) && species.id === 'seaking')\n\t\t\t);\n\t\tcase 'Magic Guard': case 'Speed Boost':\n\t\t\treturn (abilities.has('Tinted Lens') && role === 'Wallbreaker');\n\t\tcase 'Mold Breaker':\n\t\t\treturn (\n\t\t\t\tspecies.baseSpecies === 'Basculin' || species.id === 'pangoro' || species.id === 'pinsirmega' ||\n\t\t\t\tabilities.has('Sheer Force')\n\t\t\t);\n\t\tcase 'Oblivious': case 'Prankster':\n\t\t\treturn (!counter.get('Status') || (species.id === 'tornadus' && moves.has('bulkup')));\n\t\tcase 'Overcoat':\n\t\t\treturn types.has('Grass');\n\t\tcase 'Overgrow':\n\t\t\treturn !counter.get('Grass');\n\t\tcase 'Power Construct':\n\t\t\treturn species.forme === '10%';\n\t\tcase 'Synchronize':\n\t\t\treturn (counter.get('Status') < 2 || !!counter.get('recoil') || !!species.isMega);\n\t\tcase 'Regenerator':\n\t\t\treturn species.id === 'mienshao' || species.id === 'reuniclus';\n\t\tcase 'Reckless': case 'Rock Head':\n\t\t\treturn (!counter.get('recoil') || !!species.isMega);\n\t\tcase 'Sand Force': case 'Sand Rush':\n\t\t\treturn !teamDetails.sand;\n\t\tcase 'Scrappy':\n\t\t\treturn !types.has('Normal');\n\t\tcase 'Serene Grace':\n\t\t\treturn !counter.get('serenegrace');\n\t\tcase 'Sheer Force':\n\t\t\treturn (\n\t\t\t\t!counter.get('sheerforce') ||\n\t\t\t\tmoves.has('doubleedge') || abilities.has('Guts') ||\n\t\t\t\t!!species.isMega\n\t\t\t);\n\t\tcase 'Simple':\n\t\t\treturn !counter.get('setup');\n\t\tcase 'Slush Rush':\n\t\t\treturn !teamDetails.hail;\n\t\tcase 'Snow Warning':\n\t\t\t// Aurorus\n\t\t\treturn moves.has('hypervoice');\n\t\tcase 'Solar Power':\n\t\t\treturn (!counter.get('Special') || !teamDetails.sun || !!species.isMega);\n\t\tcase 'Sturdy':\n\t\t\treturn (!!counter.get('recoil') && !counter.get('recovery') ||\n\t\t\t\t(species.id === 'steelix' && role === 'Wallbreaker'));\n\t\tcase 'Swarm':\n\t\t\treturn ((!counter.get('Bug') && !moves.has('uturn')) || !!species.isMega);\n\t\tcase 'Technician':\n\t\t\treturn (!counter.get('technician') || moves.has('tailslap') || !!species.isMega || species.id === 'persianalola');\n\t\tcase 'Tinted Lens':\n\t\t\treturn (['illumise', 'sigilyph', 'yanmega'].some(m => species.id === (m)) && role !== 'Wallbreaker');\n\t\tcase 'Torrent':\n\t\t\treturn (!counter.get('Water') || !!species.isMega);\n\t\tcase 'Unaware':\n\t\t\treturn (role !== 'Bulky Support' && role !== 'Staller');\n\t\tcase 'Unburden':\n\t\t\treturn (!!species.isMega || !counter.get('setup') && !moves.has('acrobatics'));\n\t\tcase 'Water Absorb':\n\t\t\treturn moves.has('raindance') || ['Drizzle', 'Unaware', 'Volt Absorb'].some(abil => abilities.has(abil));\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tgetAbility(\n\t\ttypes: Set,\n\t\tmoves: Set,\n\t\tabilities: Set,\n\t\tcounter: MoveCounter,\n\t\tmovePool: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string {\n\t\tif (species.battleOnly && !species.requiredAbility) {\n\t\t\tabilities = new Set(Object.values(this.dex.species.get(species.battleOnly as string).abilities));\n\t\t}\n\t\tconst abilityData = Array.from(abilities).map(a => this.dex.abilities.get(a));\n\t\tUtils.sortBy(abilityData, abil => -abil.rating);\n\n\t\tif (abilityData.length <= 1) return abilityData[0].name;\n\n\t\t// Hard-code abilities here\n\t\tif (species.id === 'gurdurr' || (\n\t\t\tabilities.has('Guts') &&\n\t\t\t!abilities.has('Quick Feet') &&\n\t\t\t(moves.has('facade') || (moves.has('sleeptalk') && moves.has('rest')))\n\t\t)) return 'Guts';\n\n\t\tif (species.id === 'starmie') return role === 'Wallbreaker' ? 'Analytic' : 'Natural Cure';\n\t\tif (species.id === 'drampa' && moves.has('roost')) return 'Berserk';\n\t\tif (species.id === 'ninetales') return 'Drought';\n\t\tif (species.id === 'talonflame' && role === 'Z-Move user') return 'Gale Wings';\n\t\tif (species.id === 'golemalola' && moves.has('return')) return 'Galvanize';\n\t\tif (species.id === 'raticatealola') return 'Hustle';\n\t\tif (species.id === 'ninjask' || species.id === 'seviper') return 'Infiltrator';\n\t\tif (species.id === 'arcanine') return 'Intimidate';\n\t\tif (species.id === 'lucariomega') return 'Justified';\n\t\tif (species.id === 'toucannon' && !counter.get('sheerforce') && !counter.get('skilllink')) return 'Keen Eye';\n\t\tif (species.baseSpecies === 'Altaria') return 'Natural Cure';\n\t\t// If Ambipom doesn't qualify for Technician, Skill Link is useless on it\n\t\tif (species.id === 'ambipom' && !counter.get('technician')) return 'Pickup';\n\t\tif (species.id === 'muk') return 'Poison Touch';\n\t\tif (\n\t\t\t['dusknoir', 'raikou', 'suicune', 'vespiquen'].includes(species.id)\n\t\t) return 'Pressure';\n\t\tif (species.id === 'tsareena') return 'Queenly Majesty';\n\t\tif (species.id === 'druddigon' && role === 'Bulky Support') return 'Rough Skin';\n\t\tif (species.id === 'pangoro' && !counter.get('ironfist')) return 'Scrappy';\n\t\tif (species.id === 'kommoo' && role === 'Z-Move user') return 'Soundproof';\n\t\tif (species.id === 'stunfisk') return 'Static';\n\t\tif (species.id === 'breloom') return 'Technician';\n\t\tif (species.id === 'zangoose') return 'Toxic Boost';\n\t\tif (species.id === 'porygon2') return 'Trace';\n\n\t\tif (abilities.has('Gluttony') && (moves.has('recycle') || moves.has('bellydrum'))) return 'Gluttony';\n\t\tif (abilities.has('Harvest') && (role === 'Bulky Support' || role === 'Staller')) return 'Harvest';\n\t\tif (abilities.has('Moxie') && (counter.get('Physical') > 3 || moves.has('bounce'))) return 'Moxie';\n\t\tif (abilities.has('Regenerator') && role === 'AV Pivot') return 'Regenerator';\n\t\tif (abilities.has('Shed Skin') && moves.has('rest') && !moves.has('sleeptalk')) return 'Shed Skin';\n\t\tif (abilities.has('Sniper') && moves.has('focusenergy')) return 'Sniper';\n\t\tif (abilities.has('Unburden') && ['acrobatics', 'bellydrum', 'closecombat'].some(m => moves.has(m))) return 'Unburden';\n\t\tif (abilities.has('Weak Armor') && types.has('Water') && counter.get('setup')) return 'Weak Armor';\n\n\t\tlet abilityAllowed: Ability[] = [];\n\t\t// Obtain a list of abilities that are allowed (not culled)\n\t\tfor (const ability of abilityData) {\n\t\t\tif (ability.rating >= 1 && !this.shouldCullAbility(\n\t\t\t\tability.name, types, moves, abilities, counter, movePool, teamDetails, species, preferredType, role\n\t\t\t)) {\n\t\t\t\tabilityAllowed.push(ability);\n\t\t\t}\n\t\t}\n\n\t\t// If all abilities are rejected, re-allow all abilities\n\t\tif (!abilityAllowed.length) {\n\t\t\tfor (const ability of abilityData) {\n\t\t\t\tif (ability.rating > 0) abilityAllowed.push(ability);\n\t\t\t}\n\t\t\tif (!abilityAllowed.length) abilityAllowed = abilityData;\n\t\t}\n\n\t\tif (abilityAllowed.length === 1) return abilityAllowed[0].name;\n\t\t// Sort abilities by rating with an element of randomness\n\t\t// All three abilities can be chosen\n\t\tif (abilityAllowed[2] && abilityAllowed[0].rating - 0.5 <= abilityAllowed[2].rating) {\n\t\t\tif (abilityAllowed[1].rating <= abilityAllowed[2].rating) {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\n\t\t\t} else {\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\n\t\t\t}\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(2, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t} else {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t}\n\t\t} else {\n\t\t\t// Third ability cannot be chosen\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t} else if (abilityAllowed[0].rating - 0.5 <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t}\n\t\t}\n\n\t\t// After sorting, choose the first ability\n\t\treturn abilityAllowed[0].name;\n\t}\n\n\tgetPriorityItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set,\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string | undefined {\n\t\t// Z-Moves\n\t\tif (role === 'Z-Move user') {\n\t\t\t// Specific Z-Crystals\n\t\t\tif (species.baseSpecies === 'Arceus' && species.requiredItems) return species.requiredItems[1];\n\t\t\tif (species.name === 'Raichu-Alola') return 'Aloraichium Z';\n\t\t\tif (species.name === 'Decidueye') return 'Decidium Z';\n\t\t\tif (species.name === 'Kommo-o') return 'Kommonium Z';\n\t\t\tif (species.name === 'Lunala') return 'Lunalium Z';\n\t\t\tif (species.baseSpecies === 'Lycanroc') return 'Lycanium Z';\n\t\t\tif (species.name === 'Marshadow') return 'Marshadium Z';\n\t\t\tif (species.name === 'Mew') return 'Mewnium Z';\n\t\t\tif (species.name === 'Mimikyu') return 'Mimikium Z';\n\t\t\tif (species.name === 'Necrozma-Dusk-Mane' || species.name === 'Necrozma-Dawn-Wings') {\n\t\t\t\tif (moves.has('autotomize') && moves.has('sunsteelstrike')) return 'Solganium Z';\n\t\t\t\tif (moves.has('autotomize') && moves.has('moongeistbeam')) return 'Lunalium Z';\n\t\t\t\treturn 'Ultranecrozium Z';\n\t\t\t}\n\t\t\t// General Z-Crystals\n\t\t\tif (preferredType === 'Normal') return 'Normalium Z';\n\t\t\tif (preferredType) return this.dex.species.get(`Arceus-${preferredType}`).requiredItems![1];\n\t\t}\n\t\tif (species.requiredItems) {\n\t\t\tif (species.baseSpecies === 'Arceus') return species.requiredItems[0];\n\t\t\treturn this.sample(species.requiredItems);\n\t\t}\n\t\tif (role === 'AV Pivot') return 'Assault Vest';\n\t\tif (species.name === 'Farfetch\\u2019d') return 'Stick';\n\t\tif (species.baseSpecies === 'Marowak') return 'Thick Club';\n\t\tif (species.name === 'Pikachu') return 'Light Ball';\n\t\tif (species.name === 'Shedinja' || species.name === 'Smeargle') return 'Focus Sash';\n\t\tif (species.name === 'Unfezant' || moves.has('focusenergy')) return 'Scope Lens';\n\t\tif (species.name === 'Unown') return 'Choice Specs';\n\t\tif (species.name === 'Wobbuffet') return 'Custap Berry';\n\t\tif (species.name === 'Shuckle') return 'Mental Herb';\n\t\tif (\n\t\t\tability === 'Harvest' || ability === 'Cheek Pouch' || (ability === 'Emergency Exit' && !!counter.get('Status'))\n\t\t) return 'Sitrus Berry';\n\t\tif (species.name === 'Ditto') return 'Choice Scarf';\n\t\tif (ability === 'Poison Heal') return 'Toxic Orb';\n\t\tif (ability === 'Speed Boost') return 'Life Orb';\n\t\tif (species.nfe) return (species.name === 'Scyther' && role === 'Fast Attacker') ? 'Choice Band' : 'Eviolite';\n\t\tif (['healingwish', 'memento', 'switcheroo', 'trick'].some(m => moves.has(m))) {\n\t\t\tif (species.baseStats.spe >= 60 && species.baseStats.spe <= 108 && role !== 'Wallbreaker') {\n\t\t\t\treturn 'Choice Scarf';\n\t\t\t} else {\n\t\t\t\treturn (counter.get('Physical') > counter.get('Special')) ? 'Choice Band' : 'Choice Specs';\n\t\t\t}\n\t\t}\n\t\tif (moves.has('bellydrum') || moves.has('recycle')) {\n\t\t\tif (ability === 'Gluttony') {\n\t\t\t\treturn `${this.sample(['Aguav', 'Figy', 'Iapapa', 'Mago', 'Wiki'])} Berry`;\n\t\t\t} else {\n\t\t\t\treturn 'Sitrus Berry';\n\t\t\t}\n\t\t}\n\t\tif (moves.has('geomancy') || moves.has('skyattack')) return 'Power Herb';\n\t\tif (moves.has('shellsmash')) {\n\t\t\treturn (ability === 'Solid Rock' && !!counter.get('priority')) ? 'Weakness Policy' : 'White Herb';\n\t\t}\n\t\tif ((ability === 'Guts' || moves.has('facade')) && !moves.has('sleeptalk')) {\n\t\t\treturn (types.includes('Fire') || ability === 'Quick Feet' || ability === 'Toxic Boost') ? 'Toxic Orb' : 'Flame Orb';\n\t\t}\n\t\tif (ability === 'Magic Guard' && role !== 'Bulky Support') {\n\t\t\treturn moves.has('counter') ? 'Focus Sash' : 'Life Orb';\n\t\t}\n\t\tif (species.id === 'rampardos' && role === 'Fast Attacker') return 'Choice Scarf';\n\t\tif (ability === 'Sheer Force' && counter.get('sheerforce')) return 'Life Orb';\n\t\tif (ability === 'Unburden') return moves.has('closecombat') ? 'White Herb' : 'Sitrus Berry';\n\t\tif (moves.has('acrobatics')) return '';\n\t\tif (moves.has('auroraveil') || moves.has('lightscreen') && moves.has('reflect')) return 'Light Clay';\n\t\tif (moves.has('rest') && !moves.has('sleeptalk') && !['Hydration', 'Natural Cure', 'Shed Skin'].includes(ability)) {\n\t\t\treturn 'Chesto Berry';\n\t\t}\n\t\tif (role === 'Staller') return 'Leftovers';\n\t}\n\n\tgetItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set,\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tpreferredType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string {\n\t\tconst defensiveStatTotal = species.baseStats.hp + species.baseStats.def + species.baseStats.spd;\n\n\t\tconst scarfReqs = (\n\t\t\trole !== 'Wallbreaker' &&\n\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\n\t\t\t!counter.get('priority') && !moves.has('pursuit')\n\t\t);\n\n\t\tif (\n\t\t\tmoves.has('pursuit') && moves.has('suckerpunch') && counter.get('Dark') && !this.priorityPokemon.includes(species.id)\n\t\t) return 'Black Glasses';\n\t\tif (counter.get('Special') === 4) {\n\t\t\treturn (\n\t\t\t\tscarfReqs && species.baseStats.spa >= 90 && this.randomChance(1, 2)\n\t\t\t) ? 'Choice Scarf' : 'Choice Specs';\n\t\t}\n\t\tif (counter.get('Special') === 3 && moves.has('uturn')) return 'Choice Specs';\n\t\tif (counter.get('Physical') === 4 && species.id !== 'jirachi' &&\n\t\t\t['dragontail', 'fakeout', 'flamecharge', 'nuzzle', 'rapidspin'].every(m => !moves.has(m))\n\t\t) {\n\t\t\treturn (\n\t\t\t\tscarfReqs && (species.baseStats.atk >= 100 || ability === 'Pure Power' || ability === 'Huge Power') &&\n\t\t\t\tthis.randomChance(1, 2)\n\t\t\t) ? 'Choice Scarf' : 'Choice Band';\n\t\t}\n\n\t\tif (ability === 'Sturdy' && moves.has('explosion') && !counter.get('speedsetup')) return 'Custap Berry';\n\t\tif (types.includes('Normal') && moves.has('fakeout') && !!counter.get('Normal')) return 'Silk Scarf';\n\t\tif (role === 'Bulky Setup' && !!counter.get('speedsetup') && !moves.has('swordsdance')) {\n\t\t\treturn 'Weakness Policy';\n\t\t}\n\t\tif (species.id === 'palkia') return 'Lustrous Orb';\n\t\tif (species.id === 'archeops') return 'Expert Belt';\n\t\tif (!counter.get('Status') && (\n\t\t\t['Fast Support', 'Bulky Support', 'Bulky Attacker'].some(m => role === m) || moves.has('rapidspin')\n\t\t)) {\n\t\t\treturn 'Assault Vest';\n\t\t}\n\t\tif (moves.has('outrage') && counter.get('setup')) return 'Lum Berry';\n\t\tif (\n\t\t\t(ability === 'Rough Skin') || (species.id !== 'hooh' &&\n\t\t\tability === 'Regenerator' && species.baseStats.hp + species.baseStats.def >= 180 && this.randomChance(1, 2))\n\t\t) return 'Rocky Helmet';\n\t\tif (['kingsshield', 'protect', 'spikyshield', 'substitute'].some(m => moves.has(m))) return 'Leftovers';\n\t\tif (\n\t\t\tthis.dex.getEffectiveness('Ground', species) >= 2 &&\n\t\t\tability !== 'Levitate' && species.id !== 'golemalola'\n\t\t) {\n\t\t\treturn 'Air Balloon';\n\t\t}\n\t\tif (\n\t\t\t(role === 'Fast Support' || moves.has('stickyweb')) && isLead && defensiveStatTotal < 255 &&\n\t\t\t!counter.get('recovery') && !moves.has('defog') && (!counter.get('recoil') || ability === 'Rock Head') &&\n\t\t\tability !== 'Regenerator'\n\t\t) return 'Focus Sash';\n\n\t\t// Default Items\n\t\tif (role === 'Fast Support') {\n\t\t\treturn (\n\t\t\t\tcounter.get('Physical') + counter.get('Special') >= 3 &&\n\t\t\t\t['nuzzle', 'rapidspin', 'uturn', 'voltswitch'].every(m => !moves.has(m)) &&\n\t\t\t\tthis.dex.getEffectiveness('Rock', species) < 2\n\t\t\t) ? 'Life Orb' : 'Leftovers';\n\t\t}\n\t\tif (!counter.get('Status')) {\n\t\t\treturn (\n\t\t\t\t(moves.has('uturn') || moves.has('voltswitch')) && !counter.get('Dragon') && !counter.get('Normal')\n\t\t\t) ? 'Expert Belt' : 'Life Orb';\n\t\t}\n\t\tif (\n\t\t\t['Fast Attacker', 'Setup Sweeper', 'Wallbreaker'].some(m => role === m) &&\n\t\t\t(this.dex.getEffectiveness('Rock', species) < 2 || species.id === 'ninjask') &&\n\t\t\tability !== 'Sturdy'\n\t\t) return 'Life Orb';\n\t\treturn 'Leftovers';\n\t}\n\n\tgetLevel(species: Species): number {\n\t\t// level set by rules\n\t\tif (this.adjustLevel) return this.adjustLevel;\n\t\tif (this.gen >= 3) {\n\t\t\t// Revamped generations use random-sets.json\n\t\t\tconst sets = this.randomSets[species.id];\n\t\t\tif (sets.level) return sets.level;\n\t\t} else {\n\t\t\t// Other generations use random-data.json\n\t\t\tconst data = this.randomData[species.id];\n\t\t\tif (data.level) return data.level;\n\t\t}\n\t\t// Gen 2 still uses tier-based levelling\n\t\tif (this.gen === 2) {\n\t\t\tconst levelScale: {[k: string]: number} = {\n\t\t\t\tZU: 81,\n\t\t\t\tZUBL: 79,\n\t\t\t\tPU: 77,\n\t\t\t\tPUBL: 75,\n\t\t\t\tNU: 73,\n\t\t\t\tNUBL: 71,\n\t\t\t\tUU: 69,\n\t\t\t\tUUBL: 67,\n\t\t\t\tOU: 65,\n\t\t\t\tUber: 61,\n\t\t\t};\n\t\t\tif (levelScale[species.tier]) return levelScale[species.tier];\n\t\t}\n\t\t// Default to 80\n\t\treturn 80;\n\t}\n\n\trandomSet(\n\t\tspecies: string | Species,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails = {},\n\t\tisLead = false\n\t): RandomTeamsTypes.RandomSet {\n\t\tspecies = this.dex.species.get(species);\n\t\tconst forme = this.getForme(species);\n\t\tconst sets = this.randomSets[species.id][\"sets\"];\n\t\tconst possibleSets = [];\n\t\t// Check if the Pokemon has a Z-Move user set\n\t\tlet canZMove = false;\n\t\tfor (const set of sets) {\n\t\t\tif (!teamDetails.zMove && set.role === 'Z-Move user') canZMove = true;\n\t\t}\n\t\tfor (const set of sets) {\n\t\t\t// Prevent multiple Z-Move users\n\t\t\tif (teamDetails.zMove && set.role === 'Z-Move user') continue;\n\t\t\t// Prevent Setup Sweeper and Bulky Setup if Z-Move user is available\n\t\t\tif (canZMove && ['Setup Sweeper', 'Bulky Setup'].includes(set.role)) continue;\n\t\t\tpossibleSets.push(set);\n\t\t}\n\t\tconst set = this.sampleIfArray(possibleSets);\n\t\tconst role = set.role;\n\t\tconst movePool: string[] = Array.from(set.movepool);\n\t\tconst preferredTypes = set.preferredTypes;\n\t\tconst preferredType = this.sampleIfArray(preferredTypes) || '';\n\n\t\tlet ability = '';\n\t\tlet item = undefined;\n\n\t\tconst evs = {hp: 85, atk: 85, def: 85, spa: 85, spd: 85, spe: 85};\n\t\tconst ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};\n\n\t\tconst types = species.types;\n\t\tconst abilities = new Set(Object.values(species.abilities));\n\t\tif (species.unreleasedHidden) abilities.delete(species.abilities.H);\n\n\t\t// Get moves\n\t\tconst moves = this.randomMoveset(types, abilities, teamDetails, species, isLead, movePool,\n\t\t\tpreferredType, role);\n\t\tconst counter = this.newQueryMoves(moves, species, preferredType, abilities);\n\n\t\t// Get ability\n\t\tability = this.getAbility(new Set(types), moves, abilities, counter, movePool, teamDetails, species,\n\t\t\tpreferredType, role);\n\n\t\t// Get items\n\t\titem = this.getPriorityItem(ability, types, moves, counter, teamDetails, species, isLead, preferredType, role);\n\t\tif (item === undefined) {\n\t\t\titem = this.getItem(ability, types, moves, counter, teamDetails, species, isLead, preferredType, role);\n\t\t}\n\n\t\t// For Trick / Switcheroo\n\t\tif (item === 'Leftovers' && types.includes('Poison')) {\n\t\t\titem = 'Black Sludge';\n\t\t}\n\n\t\tconst level = this.getLevel(species);\n\n\t\t// Minimize confusion damage\n\t\tif (!counter.get('Physical') && !moves.has('copycat') && !moves.has('transform')) {\n\t\t\tevs.atk = 0;\n\t\t\tivs.atk = 0;\n\t\t}\n\n\t\tif (ability === 'Beast Boost' && !counter.get('Special')) {\n\t\t\tevs.spa = 0;\n\t\t\tivs.spa = 0;\n\t\t}\n\n\t\t// We use a special variable to track Hidden Power\n\t\t// so that we can check for all Hidden Powers at once\n\t\tlet hasHiddenPower = false;\n\t\tfor (const move of moves) {\n\t\t\tif (move.startsWith('hiddenpower')) hasHiddenPower = true;\n\t\t}\n\n\t\t// Fix IVs for non-Bottle Cap-able sets\n\t\tif (hasHiddenPower && level < 100) {\n\t\t\tlet hpType;\n\t\t\tfor (const move of moves) {\n\t\t\t\tif (move.startsWith('hiddenpower')) hpType = move.substr(11);\n\t\t\t}\n\t\t\tif (!hpType) throw new Error(`hasHiddenPower is true, but no Hidden Power move was found.`);\n\t\t\tconst HPivs = ivs.atk === 0 ? ZeroAttackHPIVs[hpType] : this.dex.types.get(hpType).HPivs;\n\t\t\tlet iv: StatID;\n\t\t\tfor (iv in HPivs) {\n\t\t\t\tivs[iv] = HPivs[iv]!;\n\t\t\t}\n\t\t}\n\n\t\t// Prepare optimal HP\n\t\tconst srImmunity = ability === 'Magic Guard';\n\t\tlet srWeakness = srImmunity ? 0 : this.dex.getEffectiveness('Rock', species);\n\t\t// Crash damage move users want an odd HP to survive two misses\n\t\tif (['highjumpkick', 'jumpkick'].some(m => moves.has(m))) srWeakness = 2;\n\t\twhile (evs.hp > 1) {\n\t\t\tconst hp = Math.floor(Math.floor(2 * species.baseStats.hp + ivs.hp + Math.floor(evs.hp / 4) + 100) * level / 100 + 10);\n\t\t\tif (moves.has('substitute') && (item === 'Sitrus Berry' || (ability === 'Power Construct' && item !== 'Leftovers'))) {\n\t\t\t\t// Two Substitutes should activate Sitrus Berry or Power Construct\n\t\t\t\tif (hp % 4 === 0) break;\n\t\t\t} else if (moves.has('bellydrum') && (item === 'Sitrus Berry' || ability === 'Gluttony')) {\n\t\t\t\t// Belly Drum should activate Sitrus Berry\n\t\t\t\tif (hp % 2 === 0) break;\n\t\t\t} else {\n\t\t\t\t// Maximize number of Stealth Rock switch-ins\n\t\t\t\tif (srWeakness <= 0 || ability === 'Regenerator' || ['Black Sludge', 'Leftovers', 'Life Orb'].includes(item)) break;\n\t\t\t\tif (item !== 'Sitrus Berry' && hp % (4 / srWeakness) > 0) break;\n\t\t\t\t// Minimise number of Stealth Rock switch-ins to activate Sitrus Berry\n\t\t\t\tif (item === 'Sitrus Berry' && hp % (4 / srWeakness) === 0) break;\n\t\t\t}\n\t\t\tevs.hp -= 4;\n\t\t}\n\n\t\t// Ensure Nihilego's Beast Boost gives it Special Attack boosts instead of Special Defense\n\t\tif (forme === 'Nihilego') {\n\t\t\twhile (evs.spd > 1) {\n\t\t\t\tconst spa = Math.floor(Math.floor(2 * species.baseStats.spa + ivs.spa + Math.floor(evs.spa / 4)) * level / 100 + 5);\n\t\t\t\tconst spd = Math.floor(Math.floor(2 * species.baseStats.spd + ivs.spd + Math.floor(evs.spd / 4)) * level / 100 + 5);\n\t\t\t\tif (spa >= spd) break;\n\t\t\t\tevs.spd -= 4;\n\t\t\t}\n\t\t}\n\n\t\tif (['gyroball', 'metalburst', 'trickroom'].some(m => moves.has(m))) {\n\t\t\tevs.spe = 0;\n\t\t\tivs.spe = (hasHiddenPower && level < 100) ? ivs.spe - 30 : 0;\n\t\t}\n\n\t\t// shuffle moves to add more randomness to camomons\n\t\tconst shuffledMoves = Array.from(moves);\n\t\tthis.prng.shuffle(shuffledMoves);\n\n\t\t// Z-Conversion Porygon-Z should have Shadow Ball first if no Recover, otherwise Thunderbolt\n\t\tif (species.id === 'porygonz' && role === 'Z-Move user') {\n\t\t\tconst firstMove = (moves.has('shadowball') ? 'shadowball' : 'thunderbolt');\n\t\t\tthis.fastPop(shuffledMoves, shuffledMoves.indexOf(firstMove));\n\t\t\tshuffledMoves.unshift(firstMove);\n\t\t}\n\t\treturn {\n\t\t\tname: species.baseSpecies,\n\t\t\tspecies: forme,\n\t\t\tgender: species.baseSpecies === 'Greninja' ? 'M' : species.gender,\n\t\t\tshiny: this.randomChance(1, 1024),\n\t\t\tlevel,\n\t\t\tmoves: shuffledMoves,\n\t\t\tability,\n\t\t\tevs,\n\t\t\tivs,\n\t\t\titem,\n\t\t\trole,\n\t\t};\n\t}\n\n\trandomTeam() {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst seed = this.prng.seed;\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\n\t\tconst pokemon: RandomTeamsTypes.RandomSet[] = [];\n\n\t\t// For Monotype\n\t\tconst isMonotype = !!this.forceMonotype || ruleTable.has('sametypeclause');\n\t\tconst typePool = this.dex.types.names();\n\t\tconst type = this.forceMonotype || this.sample(typePool);\n\n\t\tconst baseFormes: {[k: string]: number} = {};\n\t\tlet hasMega = false;\n\n\t\tconst typeCount: {[k: string]: number} = {};\n\t\tconst typeComboCount: {[k: string]: number} = {};\n\t\tconst typeWeaknesses: {[k: string]: number} = {};\n\t\tconst teamDetails: RandomTeamsTypes.TeamDetails = {};\n\t\tlet numMaxLevelPokemon = 0;\n\n\t\t// We make at most two passes through the potential Pokemon pool when creating a team - if the first pass doesn't\n\t\t// result in a team of six Pokemon we perform a second iteration relaxing as many restrictions as possible.\n\t\tfor (const restrict of [true, false]) {\n\t\t\tif (pokemon.length >= this.maxTeamSize) break;\n\n\t\t\tconst pokemonList = Object.keys(this.randomSets);\n\t\t\tconst [pokemonPool, baseSpeciesPool] = this.getPokemonPool(type, pokemon, isMonotype, pokemonList);\n\t\t\twhile (baseSpeciesPool.length && pokemon.length < this.maxTeamSize) {\n\t\t\t\tconst baseSpecies = this.sampleNoReplace(baseSpeciesPool);\n\t\t\t\tconst currentSpeciesPool: Species[] = [];\n\t\t\t\t// Check if the base species has a mega forme available\n\t\t\t\tlet canMega = false;\n\t\t\t\tfor (const poke of pokemonPool[baseSpecies]) {\n\t\t\t\t\tconst species = this.dex.species.get(poke);\n\t\t\t\t\tif (!hasMega && species.isMega) canMega = true;\n\t\t\t\t}\n\t\t\t\tfor (const poke of pokemonPool[baseSpecies]) {\n\t\t\t\t\tconst species = this.dex.species.get(poke);\n\t\t\t\t\t// Prevent multiple megas\n\t\t\t\t\tif (hasMega && species.isMega) continue;\n\t\t\t\t\t// Prevent base forme, if a mega is available\n\t\t\t\t\tif (canMega && !species.isMega) continue;\n\t\t\t\t\tcurrentSpeciesPool.push(species);\n\t\t\t\t}\n\t\t\t\tconst species = this.sample(currentSpeciesPool);\n\n\t\t\t\tif (this.gen === 7) {\n\t\t\t\t\t// If the team has a Z-Move user, reject Pokemon that only have the Z-Move user role\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.randomSets[species.id][\"sets\"].length === 1 &&\n\t\t\t\t\t\tthis.randomSets[species.id][\"sets\"][0][\"role\"] === 'Z-Move user' &&\n\t\t\t\t\t\tteamDetails.zMove\n\t\t\t\t\t) continue;\n\t\t\t\t}\n\t\t\t\tif (!species.exists) continue;\n\n\t\t\t\t// Limit to one of each species (Species Clause)\n\t\t\t\tif (baseFormes[species.baseSpecies]) continue;\n\n\t\t\t\t// Limit one Mega per team\n\t\t\t\tif (hasMega && species.isMega) continue;\n\n\t\t\t\tconst types = species.types;\n\t\t\t\tconst typeCombo = types.slice().sort().join();\n\t\t\t\tconst weakToFreezeDry = (\n\t\t\t\t\tthis.dex.getEffectiveness('Ice', species) > 0 ||\n\t\t\t\t\t(this.dex.getEffectiveness('Ice', species) > -2 && types.includes('Water'))\n\t\t\t\t);\n\t\t\t\t// Dynamically scale limits for different team sizes. The default and minimum value is 1.\n\t\t\t\tconst limitFactor = Math.round(this.maxTeamSize / 6) || 1;\n\n\t\t\t\tif (restrict) {\n\t\t\t\t\tif (!isMonotype && !this.forceMonotype) {\n\t\t\t\t\t\t// Limit two of any type\n\t\t\t\t\t\tlet skip = false;\n\t\t\t\t\t\tfor (const typeName of types) {\n\t\t\t\t\t\t\tif (typeCount[typeName] >= 2 * limitFactor) {\n\t\t\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (skip) continue;\n\n\t\t\t\t\t\t// Limit three weak to any type\n\t\t\t\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t\t\t\t// it's weak to the type\n\t\t\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\n\t\t\t\t\t\t\t\tif (!typeWeaknesses[typeName]) typeWeaknesses[typeName] = 0;\n\t\t\t\t\t\t\t\tif (typeWeaknesses[typeName] >= 3 * limitFactor) {\n\t\t\t\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (skip) continue;\n\n\t\t\t\t\t\t// Limit four weak to Freeze-Dry\n\t\t\t\t\t\tif (weakToFreezeDry) {\n\t\t\t\t\t\t\tif (!typeWeaknesses['Freeze-Dry']) typeWeaknesses['Freeze-Dry'] = 0;\n\t\t\t\t\t\t\tif (typeWeaknesses['Freeze-Dry'] >= 4 * limitFactor) continue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Limit one level 100 Pokemon\n\t\t\t\t\t\tif (!this.adjustLevel && (this.getLevel(species) === 100) && numMaxLevelPokemon >= limitFactor) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Limit three of any type combination in Monotype\n\t\t\t\t\tif (!this.forceMonotype && isMonotype && (typeComboCount[typeCombo] >= 3 * limitFactor)) continue;\n\t\t\t\t}\n\n\t\t\t\tconst set = this.randomSet(\n\t\t\t\t\tspecies,\n\t\t\t\t\tteamDetails,\n\t\t\t\t\tpokemon.length === this.maxTeamSize - 1\n\t\t\t\t);\n\n\t\t\t\tconst item = this.dex.items.get(set.item);\n\n\t\t\t\t// Limit one Z-Move per team\n\t\t\t\tif (item.zMove && teamDetails.zMove) continue;\n\n\t\t\t\t// Zoroark copies the last Pokemon and should not be generated in that slot\n\t\t\t\tif (set.ability === 'Illusion' && pokemon.length < 1) continue;\n\n\t\t\t\t// Okay, the set passes, add it to our team\n\t\t\t\tpokemon.unshift(set);\n\n\t\t\t\t// Don't bother tracking details for the last Pokemon\n\t\t\t\tif (pokemon.length === this.maxTeamSize) break;\n\n\t\t\t\t// Now that our Pokemon has passed all checks, we can increment our counters\n\t\t\t\tbaseFormes[species.baseSpecies] = 1;\n\n\t\t\t\t// Increment type counters\n\t\t\t\tfor (const typeName of types) {\n\t\t\t\t\tif (typeName in typeCount) {\n\t\t\t\t\t\ttypeCount[typeName]++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttypeCount[typeName] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeCombo in typeComboCount) {\n\t\t\t\t\ttypeComboCount[typeCombo]++;\n\t\t\t\t} else {\n\t\t\t\t\ttypeComboCount[typeCombo] = 1;\n\t\t\t\t}\n\n\t\t\t\t// Increment weakness counter\n\t\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t\t// it's weak to the type\n\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\n\t\t\t\t\t\ttypeWeaknesses[typeName]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (weakToFreezeDry) typeWeaknesses['Freeze-Dry']++;\n\n\t\t\t\t// Increment level 100 counter\n\t\t\t\tif (set.level === 100) numMaxLevelPokemon++;\n\n\t\t\t\t// Track what the team has\n\t\t\t\tif (item.megaStone || species.name === 'Rayquaza-Mega') hasMega = true;\n\t\t\t\tif (item.zMove) teamDetails.zMove = 1;\n\t\t\t\tif (set.ability === 'Snow Warning' || set.moves.includes('hail')) teamDetails.hail = 1;\n\t\t\t\tif (set.moves.includes('raindance') || set.ability === 'Drizzle' && !item.onPrimal) teamDetails.rain = 1;\n\t\t\t\tif (set.ability === 'Sand Stream') teamDetails.sand = 1;\n\t\t\t\tif (set.moves.includes('sunnyday') || set.ability === 'Drought' && !item.onPrimal) teamDetails.sun = 1;\n\t\t\t\tif (set.moves.includes('spikes')) teamDetails.spikes = (teamDetails.spikes || 0) + 1;\n\t\t\t\tif (set.moves.includes('stealthrock')) teamDetails.stealthRock = 1;\n\t\t\t\tif (set.moves.includes('stickyweb')) teamDetails.stickyWeb = 1;\n\t\t\t\tif (set.moves.includes('toxicspikes')) teamDetails.toxicSpikes = 1;\n\t\t\t\tif (set.moves.includes('defog')) teamDetails.defog = 1;\n\t\t\t\tif (set.moves.includes('rapidspin')) teamDetails.rapidSpin = 1;\n\t\t\t\tif (set.moves.includes('auroraveil') || (set.moves.includes('reflect') && set.moves.includes('lightscreen'))) {\n\t\t\t\t\tteamDetails.screens = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pokemon.length < this.maxTeamSize && pokemon.length < 12) {\n\t\t\tthrow new Error(`Could not build a random team for ${this.format} (seed=${seed})`);\n\t\t}\n\n\t\treturn pokemon;\n\t}\n\n\trandomFactorySets: {[format: string]: {[species: string]: BattleFactorySpecies}} = require('./factory-sets.json');\n\n\trandomFactorySet(\n\t\tspecies: Species, teamData: RandomTeamsTypes.FactoryTeamDetails, tier: string\n\t): RandomTeamsTypes.RandomFactorySet | null {\n\t\tconst id = toID(species.name);\n\t\tconst setList = this.randomFactorySets[tier][id].sets;\n\n\t\tconst itemsMax: {[k: string]: number} = {\n\t\t\tchoicespecs: 1,\n\t\t\tchoiceband: 1,\n\t\t\tchoicescarf: 1,\n\t\t};\n\t\tconst movesMax: {[k: string]: number} = {\n\t\t\trapidspin: 1,\n\t\t\tbatonpass: 1,\n\t\t\tstealthrock: 1,\n\t\t\tdefog: 1,\n\t\t\tspikes: 1,\n\t\t\ttoxicspikes: 1,\n\t\t};\n\t\tconst requiredMoves: {[k: string]: string} = {\n\t\t\tstealthrock: 'hazardSet',\n\t\t\trapidspin: 'hazardClear',\n\t\t\tdefog: 'hazardClear',\n\t\t};\n\t\tconst weatherAbilitiesRequire: {[k: string]: string} = {\n\t\t\thydration: 'raindance', swiftswim: 'raindance',\n\t\t\tleafguard: 'sunnyday', solarpower: 'sunnyday', chlorophyll: 'sunnyday',\n\t\t\tsandforce: 'sandstorm', sandrush: 'sandstorm', sandveil: 'sandstorm',\n\t\t\tslushrush: 'hail', snowcloak: 'hail',\n\t\t};\n\t\tconst weatherAbilities = ['drizzle', 'drought', 'snowwarning', 'sandstream'];\n\n\t\t// Build a pool of eligible sets, given the team partners\n\t\t// Also keep track of sets with moves the team requires\n\t\tlet effectivePool: {set: AnyObject, moveVariants?: number[], item?: string, ability?: string}[] = [];\n\t\tconst priorityPool = [];\n\t\tfor (const curSet of setList) {\n\t\t\tif (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;\n\n\t\t\t// reject disallowed items\n\t\t\tconst allowedItems: string[] = [];\n\t\t\tfor (const itemString of curSet.item) {\n\t\t\t\tconst item = this.dex.items.get(itemString);\n\t\t\t\tif (teamData.megaCount && teamData.megaCount > 0 && item.megaStone) continue; // reject 2+ mega stones\n\t\t\t\tif (teamData.zCount && teamData.zCount > 0 && item.zMove) continue; // reject 2+ Z stones\n\t\t\t\tif (itemsMax[item.id] && teamData.has[item.id] >= itemsMax[item.id]) continue; // reject 2+ same choice item\n\t\t\t\tallowedItems.push(itemString);\n\t\t\t}\n\t\t\tif (allowedItems.length === 0) continue;\n\t\t\tconst curSetItem = this.sample(allowedItems);\n\n\t\t\t// reject bad weather abilities\n\t\t\tconst allowedAbilities: string[] = [];\n\t\t\tfor (const abilityString of curSet.ability) {\n\t\t\t\tconst ability = this.dex.abilities.get(abilityString);\n\t\t\t\tif (weatherAbilitiesRequire[ability.id] && teamData.weather !== weatherAbilitiesRequire[ability.id]) continue;\n\t\t\t\tif (teamData.weather && weatherAbilities.includes(ability.id)) continue; // reject 2+ weather setters\n\t\t\t\tallowedAbilities.push(abilityString);\n\t\t\t}\n\t\t\tif (allowedAbilities.length === 0) continue;\n\t\t\tconst curSetAbility = this.sample(allowedAbilities);\n\n\t\t\tlet reject = false;\n\t\t\tlet hasRequiredMove = false;\n\t\t\tconst curSetVariants = [];\n\t\t\tfor (const move of curSet.moves) {\n\t\t\t\tconst variantIndex = this.random(move.length);\n\t\t\t\tconst moveId = toID(move[variantIndex]);\n\t\t\t\tif (movesMax[moveId] && teamData.has[moveId] >= movesMax[moveId]) {\n\t\t\t\t\treject = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (requiredMoves[moveId] && !teamData.has[requiredMoves[moveId]]) {\n\t\t\t\t\thasRequiredMove = true;\n\t\t\t\t}\n\t\t\t\tcurSetVariants.push(variantIndex);\n\t\t\t}\n\t\t\tif (reject) continue;\n\n\t\t\tconst fullSetSpec = {set: curSet, moveVariants: curSetVariants, item: curSetItem, ability: curSetAbility};\n\t\t\teffectivePool.push(fullSetSpec);\n\t\t\tif (hasRequiredMove) priorityPool.push(fullSetSpec);\n\t\t}\n\t\tif (priorityPool.length) effectivePool = priorityPool;\n\n\t\tif (!effectivePool.length) {\n\t\t\tif (!teamData.forceResult) return null;\n\t\t\tfor (const curSet of setList) {\n\t\t\t\teffectivePool.push({set: curSet});\n\t\t\t}\n\t\t}\n\n\t\tconst setData = this.sample(effectivePool);\n\t\tconst moves = [];\n\t\tfor (const [i, moveSlot] of setData.set.moves.entries()) {\n\t\t\tmoves.push(setData.moveVariants ? moveSlot[setData.moveVariants[i]] : this.sample(moveSlot));\n\t\t}\n\n\n\t\tconst item = setData.item || this.sampleIfArray(setData.set.item);\n\t\tconst ability = setData.ability || this.sampleIfArray(setData.set.ability);\n\t\tconst nature = this.sampleIfArray(setData.set.nature);\n\t\tconst level = this.adjustLevel || setData.set.level || (tier === \"LC\" ? 5 : 100);\n\n\t\treturn {\n\t\t\tname: setData.set.name || species.baseSpecies,\n\t\t\tspecies: setData.set.species,\n\t\t\tgender: setData.set.gender || species.gender || (this.randomChance(1, 2) ? 'M' : 'F'),\n\t\t\titem: item || '',\n\t\t\tability: ability || species.abilities['0'],\n\t\t\tshiny: typeof setData.set.shiny === 'undefined' ? this.randomChance(1, 1024) : setData.set.shiny,\n\t\t\tlevel,\n\t\t\thappiness: typeof setData.set.happiness === 'undefined' ? 255 : setData.set.happiness,\n\t\t\tevs: {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0, ...setData.set.evs},\n\t\t\tivs: {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31, ...setData.set.ivs},\n\t\t\tnature: nature || 'Serious',\n\t\t\tmoves,\n\t\t};\n\t}\n\n\trandomFactoryTeam(side: PlayerOptions, depth = 0): RandomTeamsTypes.RandomFactorySet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst forceResult = (depth >= 12);\n\t\tconst isMonotype = !!this.forceMonotype || this.dex.formats.getRuleTable(this.format).has('sametypeclause');\n\n\t\t// The teams generated depend on the tier choice in such a way that\n\t\t// no exploitable information is leaked from rolling the tier in getTeam(p1).\n\t\tif (!this.factoryTier) {\n\t\t\tthis.factoryTier = isMonotype ? 'Mono' : this.sample(['Uber', 'OU', 'UU', 'RU', 'NU', 'PU', 'LC']);\n\t\t} else if (isMonotype && this.factoryTier !== 'Mono') {\n\t\t\t// I don't think this can ever happen?\n\t\t\tthrow new Error(`Can't generate a Monotype Battle Factory set in a battle with factory tier ${this.factoryTier}`);\n\t\t}\n\n\t\tconst tierValues: {[k: string]: number} = {\n\t\t\tUber: 5,\n\t\t\tOU: 4, UUBL: 4,\n\t\t\tUU: 3, RUBL: 3,\n\t\t\tRU: 2, NUBL: 2,\n\t\t\tNU: 1, PUBL: 1,\n\t\t\tPU: 0,\n\t\t};\n\n\t\tconst pokemon = [];\n\t\tconst pokemonPool = Object.keys(this.randomFactorySets[this.factoryTier]);\n\n\t\tconst typePool = this.dex.types.names();\n\t\tconst type = this.sample(typePool);\n\n\t\tconst teamData: TeamData = {\n\t\t\ttypeCount: {}, typeComboCount: {}, baseFormes: {}, megaCount: 0, zCount: 0,\n\t\t\thas: {}, forceResult: forceResult, weaknesses: {}, resistances: {},\n\t\t};\n\t\tconst requiredMoveFamilies = ['hazardSet', 'hazardClear'];\n\t\tconst requiredMoves: {[k: string]: string} = {\n\t\t\tstealthrock: 'hazardSet',\n\t\t\trapidspin: 'hazardClear',\n\t\t\tdefog: 'hazardClear',\n\t\t};\n\t\tconst weatherAbilitiesSet: {[k: string]: string} = {\n\t\t\tdrizzle: 'raindance',\n\t\t\tdrought: 'sunnyday',\n\t\t\tsnowwarning: 'hail',\n\t\t\tsandstream: 'sandstorm',\n\t\t};\n\t\tconst resistanceAbilities: {[k: string]: string[]} = {\n\t\t\tdryskin: ['Water'], waterabsorb: ['Water'], stormdrain: ['Water'],\n\t\t\tflashfire: ['Fire'], heatproof: ['Fire'],\n\t\t\tlightningrod: ['Electric'], motordrive: ['Electric'], voltabsorb: ['Electric'],\n\t\t\tsapsipper: ['Grass'],\n\t\t\tthickfat: ['Ice', 'Fire'],\n\t\t\tlevitate: ['Ground'],\n\t\t};\n\n\t\twhile (pokemonPool.length && pokemon.length < this.maxTeamSize) {\n\t\t\tconst species = this.dex.species.get(this.sampleNoReplace(pokemonPool));\n\t\t\tif (!species.exists) continue;\n\n\t\t\t// Lessen the need of deleting sets of Pokemon after tier shifts\n\t\t\tif (\n\t\t\t\tthis.factoryTier in tierValues && species.tier in tierValues &&\n\t\t\t\ttierValues[species.tier] > tierValues[this.factoryTier]\n\t\t\t) continue;\n\n\t\t\tconst speciesFlags = this.randomFactorySets[this.factoryTier][species.id].flags;\n\n\t\t\t// Limit to one of each species (Species Clause)\n\t\t\tif (teamData.baseFormes[species.baseSpecies]) continue;\n\n\t\t\t// Limit the number of Megas to one\n\t\t\tif (!teamData.megaCount) teamData.megaCount = 0;\n\t\t\tif (teamData.megaCount >= 1 && speciesFlags.megaOnly) continue;\n\n\t\t\tconst set = this.randomFactorySet(species, teamData, this.factoryTier);\n\t\t\tif (!set) continue;\n\n\t\t\tconst itemData = this.dex.items.get(set.item);\n\n\t\t\t// Actually limit the number of Megas to one\n\t\t\tif (teamData.megaCount >= 1 && itemData.megaStone) continue;\n\n\t\t\t// Limit the number of Z moves to one\n\t\t\tif (teamData.zCount && teamData.zCount >= 1 && itemData.zMove) continue;\n\n\t\t\tlet types = species.types;\n\t\t\t// Dynamically scale limits for different team sizes. The default and minimum value is 1.\n\t\t\tconst limitFactor = Math.round(this.maxTeamSize / 6) || 1;\n\n\t\t\t// Enforce Monotype\n\t\t\tif (isMonotype) {\n\t\t\t\t// Prevents Mega Evolutions from breaking the type limits\n\t\t\t\tif (itemData.megaStone) {\n\t\t\t\t\tconst megaSpecies = this.dex.species.get(itemData.megaStone);\n\t\t\t\t\tif (types.length > megaSpecies.types.length) types = [species.types[0]];\n\t\t\t\t\t// Only check the second type because a Mega Evolution should always share the first type with its base forme.\n\t\t\t\t\tif (megaSpecies.types[1] && types[1] && megaSpecies.types[1] !== types[1]) {\n\t\t\t\t\t\ttypes = [megaSpecies.types[0]];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!types.includes(type)) continue;\n\t\t\t} else {\n\t\t\t\t// If not Monotype, limit to two of each type\n\t\t\t\tlet skip = false;\n\t\t\t\tfor (const typeName of types) {\n\t\t\t\t\tif (teamData.typeCount[typeName] >= 2 * limitFactor && this.randomChance(4, 5)) {\n\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (skip) continue;\n\n\t\t\t\t// Limit 1 of any type combination\n\t\t\t\tlet typeCombo = types.slice().sort().join();\n\t\t\t\tif (set.ability + '' === 'Drought' || set.ability + '' === 'Drizzle') {\n\t\t\t\t// Drought and Drizzle don't count towards the type combo limit\n\t\t\t\t\ttypeCombo = set.ability + '';\n\t\t\t\t}\n\t\t\t\tif (teamData.typeComboCount[typeCombo] >= 1 * limitFactor) continue;\n\t\t\t}\n\n\t\t\t// Okay, the set passes, add it to our team\n\t\t\tpokemon.push(set);\n\t\t\tconst typeCombo = types.slice().sort().join();\n\t\t\t// Now that our Pokemon has passed all checks, we can update team data:\n\t\t\tfor (const typeName of types) {\n\t\t\t\tif (typeName in teamData.typeCount) {\n\t\t\t\t\tteamData.typeCount[typeName]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.typeCount[typeName] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tteamData.typeComboCount[typeCombo] = (teamData.typeComboCount[typeCombo] + 1) || 1;\n\n\t\t\tteamData.baseFormes[species.baseSpecies] = 1;\n\n\t\t\tif (itemData.megaStone) teamData.megaCount++;\n\t\t\tif (itemData.zMove) {\n\t\t\t\tif (!teamData.zCount) teamData.zCount = 0;\n\t\t\t\tteamData.zCount++;\n\t\t\t}\n\t\t\tif (itemData.id in teamData.has) {\n\t\t\t\tteamData.has[itemData.id]++;\n\t\t\t} else {\n\t\t\t\tteamData.has[itemData.id] = 1;\n\t\t\t}\n\n\t\t\tconst abilityState = this.dex.abilities.get(set.ability);\n\t\t\tif (abilityState.id in weatherAbilitiesSet) {\n\t\t\t\tteamData.weather = weatherAbilitiesSet[abilityState.id];\n\t\t\t}\n\n\t\t\tfor (const move of set.moves) {\n\t\t\t\tconst moveId = toID(move);\n\t\t\t\tif (moveId in teamData.has) {\n\t\t\t\t\tteamData.has[moveId]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.has[moveId] = 1;\n\t\t\t\t}\n\t\t\t\tif (moveId in requiredMoves) {\n\t\t\t\t\tteamData.has[requiredMoves[moveId]] = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t// Cover any major weakness (3+) with at least one resistance\n\t\t\t\tif (teamData.resistances[typeName] >= 1) continue;\n\t\t\t\tif (resistanceAbilities[abilityState.id]?.includes(typeName) || !this.dex.getImmunity(typeName, types)) {\n\t\t\t\t\t// Heuristic: assume that Pok\u00E9mon with these abilities don't have (too) negative typing.\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst typeMod = this.dex.getEffectiveness(typeName, types);\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t} else if (typeMod > 0) {\n\t\t\t\t\tteamData.weaknesses[typeName] = (teamData.weaknesses[typeName] || 0) + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pokemon.length < this.maxTeamSize) return this.randomFactoryTeam(side, ++depth);\n\n\t\t// Quality control\n\t\tif (!teamData.forceResult) {\n\t\t\tfor (const requiredFamily of requiredMoveFamilies) {\n\t\t\t\tif (!teamData.has[requiredFamily]) return this.randomFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t\tfor (const typeName in teamData.weaknesses) {\n\t\t\t\tif (teamData.weaknesses[typeName] >= 3) return this.randomFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t}\n\n\t\treturn pokemon;\n\t}\n\n\trandomBSSFactorySets: AnyObject = require('./bss-factory-sets.json');\n\n\trandomBSSFactorySet(\n\t\tspecies: Species, teamData: RandomTeamsTypes.FactoryTeamDetails\n\t): RandomTeamsTypes.RandomFactorySet | null {\n\t\tconst id = toID(species.name);\n\t\t// const flags = this.randomBSSFactorySets[tier][id].flags;\n\t\tconst setList = this.randomBSSFactorySets[id].sets;\n\n\t\tconst movesMax: {[k: string]: number} = {\n\t\t\tbatonpass: 1,\n\t\t\tstealthrock: 1,\n\t\t\tspikes: 1,\n\t\t\ttoxicspikes: 1,\n\t\t\tdoubleedge: 1,\n\t\t\ttrickroom: 1,\n\t\t};\n\t\tconst requiredMoves: {[k: string]: number} = {};\n\t\tconst weatherAbilitiesRequire: {[k: string]: string} = {\n\t\t\tswiftswim: 'raindance',\n\t\t\tsandrush: 'sandstorm', sandveil: 'sandstorm',\n\t\t};\n\t\tconst weatherAbilities = ['drizzle', 'drought', 'snowwarning', 'sandstream'];\n\n\t\t// Build a pool of eligible sets, given the team partners\n\t\t// Also keep track of sets with moves the team requires\n\t\tlet effectivePool: {set: AnyObject, moveVariants?: number[], itemVariants?: number, abilityVariants?: number}[] = [];\n\t\tconst priorityPool = [];\n\t\tfor (const curSet of setList) {\n\t\t\tif (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;\n\n\t\t\tconst item = this.dex.items.get(curSet.item);\n\t\t\tif (teamData.megaCount && teamData.megaCount > 1 && item.megaStone) continue; // reject 3+ mega stones\n\t\t\tif (teamData.zCount && teamData.zCount > 1 && item.zMove) continue; // reject 3+ Z stones\n\t\t\tif (teamData.has[item.id]) continue; // Item clause\n\n\t\t\tconst ability = this.dex.abilities.get(curSet.ability);\n\t\t\tif (weatherAbilitiesRequire[ability.id] && teamData.weather !== weatherAbilitiesRequire[ability.id]) continue;\n\t\t\tif (teamData.weather && weatherAbilities.includes(ability.id)) continue; // reject 2+ weather setters\n\n\t\t\tif (curSet.species === 'Aron' && teamData.weather !== 'sandstorm') continue; // reject Aron without a Sand Stream user\n\n\t\t\tlet reject = false;\n\t\t\tlet hasRequiredMove = false;\n\t\t\tconst curSetVariants = [];\n\t\t\tfor (const move of curSet.moves) {\n\t\t\t\tconst variantIndex = this.random(move.length);\n\t\t\t\tconst moveId = toID(move[variantIndex]);\n\t\t\t\tif (movesMax[moveId] && teamData.has[moveId] >= movesMax[moveId]) {\n\t\t\t\t\treject = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (requiredMoves[moveId] && !teamData.has[requiredMoves[moveId]]) {\n\t\t\t\t\thasRequiredMove = true;\n\t\t\t\t}\n\t\t\t\tcurSetVariants.push(variantIndex);\n\t\t\t}\n\t\t\tif (reject) continue;\n\t\t\teffectivePool.push({set: curSet, moveVariants: curSetVariants});\n\t\t\tif (hasRequiredMove) priorityPool.push({set: curSet, moveVariants: curSetVariants});\n\t\t}\n\t\tif (priorityPool.length) effectivePool = priorityPool;\n\n\t\tif (!effectivePool.length) {\n\t\t\tif (!teamData.forceResult) return null;\n\t\t\tfor (const curSet of setList) {\n\t\t\t\teffectivePool.push({set: curSet});\n\t\t\t}\n\t\t}\n\n\t\tconst setData = this.sample(effectivePool);\n\t\tconst moves = [];\n\t\tfor (const [i, moveSlot] of setData.set.moves.entries()) {\n\t\t\tmoves.push(setData.moveVariants ? moveSlot[setData.moveVariants[i]] : this.sample(moveSlot));\n\t\t}\n\n\t\treturn {\n\t\t\tname: setData.set.nickname || setData.set.name || species.baseSpecies,\n\t\t\tspecies: setData.set.species,\n\t\t\tgender: setData.set.gender || species.gender || (this.randomChance(1, 2) ? 'M' : 'F'),\n\t\t\titem: this.sampleIfArray(setData.set.item) || '',\n\t\t\tability: setData.set.ability || species.abilities['0'],\n\t\t\tshiny: typeof setData.set.shiny === 'undefined' ? this.randomChance(1, 1024) : setData.set.shiny,\n\t\t\tlevel: setData.set.level || 50,\n\t\t\thappiness: typeof setData.set.happiness === 'undefined' ? 255 : setData.set.happiness,\n\t\t\tevs: {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0, ...setData.set.evs},\n\t\t\tivs: {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31, ...setData.set.ivs},\n\t\t\tnature: setData.set.nature || 'Serious',\n\t\t\tmoves,\n\t\t};\n\t}\n\n\trandomBSSFactoryTeam(side: PlayerOptions, depth = 0): RandomTeamsTypes.RandomFactorySet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst forceResult = (depth >= 4);\n\n\t\tconst pokemon = [];\n\n\t\tconst pokemonPool = Object.keys(this.randomBSSFactorySets);\n\n\t\tconst teamData: TeamData = {\n\t\t\ttypeCount: {}, typeComboCount: {}, baseFormes: {}, megaCount: 0, zCount: 0,\n\t\t\teeveeLimCount: 0, has: {}, forceResult, weaknesses: {}, resistances: {},\n\t\t};\n\t\tconst requiredMoveFamilies: string[] = [];\n\t\tconst requiredMoves: {[k: string]: string} = {};\n\t\tconst weatherAbilitiesSet: {[k: string]: string} = {\n\t\t\tdrizzle: 'raindance',\n\t\t\tdrought: 'sunnyday',\n\t\t\tsnowwarning: 'hail',\n\t\t\tsandstream: 'sandstorm',\n\t\t};\n\t\tconst resistanceAbilities: {[k: string]: string[]} = {\n\t\t\twaterabsorb: ['Water'],\n\t\t\tflashfire: ['Fire'],\n\t\t\tlightningrod: ['Electric'], voltabsorb: ['Electric'],\n\t\t\tthickfat: ['Ice', 'Fire'],\n\t\t\tlevitate: ['Ground'],\n\t\t};\n\n\t\twhile (pokemonPool.length && pokemon.length < this.maxTeamSize) {\n\t\t\tconst species = this.dex.species.get(this.sampleNoReplace(pokemonPool));\n\t\t\tif (!species.exists) continue;\n\n\t\t\tconst speciesFlags = this.randomBSSFactorySets[species.id].flags;\n\t\t\tif (!teamData.megaCount) teamData.megaCount = 0;\n\n\t\t\t// Limit to one of each species (Species Clause)\n\t\t\tif (teamData.baseFormes[species.baseSpecies]) continue;\n\n\t\t\t// Limit the number of Megas + Z-moves to 3\n\t\t\tif (teamData.megaCount + (teamData.zCount ? teamData.zCount : 0) >= 3 && speciesFlags.megaOnly) continue;\n\n\t\t\t// Dynamically scale limits for different team sizes. The default and minimum value is 1.\n\t\t\tconst limitFactor = Math.round(this.maxTeamSize / 6) || 1;\n\n\t\t\t// Limit 2 of any type\n\t\t\tconst types = species.types;\n\t\t\tlet skip = false;\n\t\t\tfor (const type of types) {\n\t\t\t\tif (teamData.typeCount[type] >= 2 * limitFactor && this.randomChance(4, 5)) {\n\t\t\t\t\tskip = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (skip) continue;\n\n\t\t\t// Restrict Eevee with certain Pokemon\n\t\t\tif (speciesFlags.limEevee) {\n\t\t\t\tif (!teamData.eeveeLimCount) teamData.eeveeLimCount = 0;\n\t\t\t\tteamData.eeveeLimCount++;\n\t\t\t}\n\t\t\tif (teamData.eeveeLimCount && teamData.eeveeLimCount >= 1 && speciesFlags.limEevee) continue;\n\n\t\t\tconst set = this.randomBSSFactorySet(species, teamData);\n\t\t\tif (!set) continue;\n\n\t\t\t// Limit 1 of any type combination\n\t\t\tlet typeCombo = types.slice().sort().join();\n\t\t\tif (set.ability === 'Drought' || set.ability === 'Drizzle') {\n\t\t\t\t// Drought and Drizzle don't count towards the type combo limit\n\t\t\t\ttypeCombo = set.ability;\n\t\t\t}\n\t\t\tif (teamData.typeComboCount[typeCombo] >= 1 * limitFactor) continue;\n\n\t\t\t// Okay, the set passes, add it to our team\n\t\t\tpokemon.push(set);\n\n\t\t\t// Now that our Pokemon has passed all checks, we can update team data:\n\t\t\tfor (const type of types) {\n\t\t\t\tif (type in teamData.typeCount) {\n\t\t\t\t\tteamData.typeCount[type]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.typeCount[type] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tteamData.typeComboCount[typeCombo] = (teamData.typeComboCount[typeCombo] + 1) || 1;\n\n\t\t\tteamData.baseFormes[species.baseSpecies] = 1;\n\n\t\t\t// Limit Mega and Z-move\n\t\t\tconst itemData = this.dex.items.get(set.item);\n\t\t\tif (itemData.megaStone) teamData.megaCount++;\n\t\t\tif (itemData.zMove) {\n\t\t\t\tif (!teamData.zCount) teamData.zCount = 0;\n\t\t\t\tteamData.zCount++;\n\t\t\t}\n\t\t\tteamData.has[itemData.id] = 1;\n\n\t\t\tconst abilityState = this.dex.abilities.get(set.ability);\n\t\t\tif (abilityState.id in weatherAbilitiesSet) {\n\t\t\t\tteamData.weather = weatherAbilitiesSet[abilityState.id];\n\t\t\t}\n\n\t\t\tfor (const move of set.moves) {\n\t\t\t\tconst moveId = toID(move);\n\t\t\t\tif (moveId in teamData.has) {\n\t\t\t\t\tteamData.has[moveId]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.has[moveId] = 1;\n\t\t\t\t}\n\t\t\t\tif (moveId in requiredMoves) {\n\t\t\t\t\tteamData.has[requiredMoves[moveId]] = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t// Cover any major weakness (3+) with at least one resistance\n\t\t\t\tif (teamData.resistances[typeName] >= 1) continue;\n\t\t\t\tif (resistanceAbilities[abilityState.id]?.includes(typeName) || !this.dex.getImmunity(typeName, types)) {\n\t\t\t\t\t// Heuristic: assume that Pok\u00E9mon with these abilities don't have (too) negative typing.\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst typeMod = this.dex.getEffectiveness(typeName, types);\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t} else if (typeMod > 0) {\n\t\t\t\t\tteamData.weaknesses[typeName] = (teamData.weaknesses[typeName] || 0) + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pokemon.length < this.maxTeamSize) return this.randomBSSFactoryTeam(side, ++depth);\n\n\t\t// Quality control\n\t\tif (!teamData.forceResult) {\n\t\t\tfor (const requiredFamily of requiredMoveFamilies) {\n\t\t\t\tif (!teamData.has[requiredFamily]) return this.randomBSSFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t\tfor (const type in teamData.weaknesses) {\n\t\t\t\tif (teamData.weaknesses[type] >= 3) return this.randomBSSFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t}\n\n\t\treturn pokemon;\n\t}\n}\n\nexport default RandomGen7Teams;\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAqD;AAErD,iBAAoB;AACpB,iBAAmB;AAgBZ,MAAM,kBAAmD;AAAA,EAC/D,OAAO,EAAC,IAAI,IAAI,KAAK,GAAE;AAAA,EACvB,MAAM,EAAC,KAAK,IAAI,KAAK,GAAE;AAAA,EACvB,KAAK,EAAC,KAAK,GAAE;AAAA,EACb,QAAQ,EAAC,KAAK,IAAI,KAAK,GAAE;AAAA,EACzB,UAAU,EAAC,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,GAAE;AAAA,EAC7C,UAAU,EAAC,KAAK,IAAI,KAAK,GAA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