@pkmn/mods 0.7.36 → 0.7.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/gen1stadium/conditions.ts","../../src/gen1stadium/rulesets.ts","../../src/gen1stadium/moves.ts","../../src/gen1stadium/scripts.ts"],"sourcesContent":["import type {ModdedConditionData} from '@pkmn/sim';\n\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(63, 256)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\tpokemon.removeVolatile('lockedmove');\n\t\t\t\tpokemon.removeVolatile('twoturnmove');\n\t\t\t\tpokemon.removeVolatile('invulnerability');\n\t\t\t\tpokemon.removeVolatile('partialtrappinglock');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-3 turns\n\t\t\tthis.effectState.startTime = this.random(1, 4);\n\t\t\tthis.effectState.time = this.effectState.startTime;\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (pokemon.statusState.time <= 0) pokemon.cureStatus();\n\t\t},\n\t},\n\tfrz: {\n\t\tname: 'frz',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'frz');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tthis.add('cant', pokemon, 'frz');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonHit(target, source, move) {\n\t\t\tif (move.type === 'Fire' && move.category !== 'Status') {\n\t\t\t\ttarget.cureStatus();\n\t\t\t}\n\t\t},\n\t},\n\tpsn: {\n\t\tname: 'psn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'psn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\tonStart(target) {\n\t\t\tthis.add('-start', target, 'confusion');\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t},\n\tflinch: {\n\t\tinherit: true,\n\t\tonStart() {},\n\t},\n\tpartiallytrapped: {\n\t\tname: 'partiallytrapped',\n\t\tduration: 2,\n\t\tonBeforeMovePriority: 1,\n\t\tonStart(target, source, effect) {\n\t\t\tthis.add('-activate', target, 'move: ' + effect, '[of] ' + source);\n\t\t},\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.effectState.source && (!this.effectState.source.isActive || this.effectState.source.hp <= 0)) {\n\t\t\t\tpokemon.removeVolatile('partiallytrapped');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'partiallytrapped');\n\t\t\treturn false;\n\t\t},\n\t\tonEnd(pokemon) {\n\t\t\tthis.add('-end', pokemon, this.effectState.sourceEffect, '[partiallytrapped]');\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Species Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod'],\n\t},\n};\n","import type {ActiveMove, ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\tbide: {\n\t\tinherit: true,\n\t\tpriority: 0,\n\t\taccuracy: true,\n\t\tcondition: {\n\t\t\tdurationCallback(target, source, effect) {\n\t\t\t\treturn this.random(3, 5);\n\t\t\t},\n\t\t\tonStart(pokemon) {\n\t\t\t\tthis.effectState.totalDamage = 0;\n\t\t\t\tthis.effectState.lastDamage = 0;\n\t\t\t\tthis.add('-start', pokemon, 'Bide');\n\t\t\t},\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (source && source !== target && move.category !== 'Physical' && move.category !== 'Special') {\n\t\t\t\t\tconst damage = this.effectState.totalDamage;\n\t\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonDamage(damage, target, source, move) {\n\t\t\t\tif (!source || source.isAlly(target)) return;\n\t\t\t\tif (!move || move.effectType !== 'Move') return;\n\t\t\t\tif (!damage && this.effectState.lastDamage > 0) {\n\t\t\t\t\tdamage = this.effectState.totalDamage;\n\t\t\t\t}\n\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t},\n\t\t\tonAfterSetStatus(status, pokemon) {\n\t\t\t\t// Sleep, freeze, and partial trap will just pause duration.\n\t\t\t\tif (pokemon.volatiles['flinch']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else if (pokemon.volatiles['partiallytrapped']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else {\n\t\t\t\t\tswitch (status.id) {\n\t\t\t\t\tcase 'slp':\n\t\t\t\t\tcase 'frz':\n\t\t\t\t\t\tthis.effectState.duration++;\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\tonBeforeMove(pokemon, t, move) {\n\t\t\t\tif (this.effectState.duration === 1) {\n\t\t\t\t\tthis.add('-end', pokemon, 'Bide');\n\t\t\t\t\tif (!this.effectState.totalDamage) {\n\t\t\t\t\t\tthis.debug(\"Bide failed because no damage was taken\");\n\t\t\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.getAtSlot(this.effectState.sourceSlot);\n\t\t\t\t\tif (target.isSemiInvulnerable()) {\n\t\t\t\t\t\tthis.add('-message', 'The foe ' + target.name + ' can\\'t be hit while flying!');\n\t\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.actions.moveHit(target, pokemon, move, {damage: this.effectState.totalDamage * 2} as ActiveMove);\n\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.add('-activate', pokemon, 'Bide');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tonDisableMove(pokemon) {\n\t\t\t\tif (!pokemon.hasMove('bide')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const moveSlot of pokemon.moveSlots) {\n\t\t\t\t\tif (moveSlot.id !== 'bide') {\n\t\t\t\t\t\tpokemon.disableMove(moveSlot.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttype: \"???\", // Will look as Normal but it's STAB-less\n\t},\n\tbind: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tclamp: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tcounter: {\n\t\tinherit: true,\n\t\tignoreImmunity: true,\n\t\twillCrit: false,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon, target) {\n\t\t\t// Counter mechanics in Stadium 1:\n\t\t\t// - a move is Counterable if it is Normal or Fighting type, has nonzero Base Power, and is not Counter\n\t\t\t// - Counter succeeds if the target used a Counterable move earlier this turn\n\n\t\t\tconst lastMoveThisTurn = target.side.lastMove && target.side.lastMove.id === target.side.lastSelectedMove &&\n\t\t\t\t!this.queue.willMove(target) && this.dex.moves.get(target.side.lastMove.id);\n\t\t\tif (!lastMoveThisTurn) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: last move was not this turn\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst lastMoveThisTurnIsCounterable = lastMoveThisTurn && lastMoveThisTurn.basePower > 0 &&\n\t\t\t\t['Normal', 'Fighting'].includes(lastMoveThisTurn.type) && lastMoveThisTurn.id !== 'counter';\n\t\t\tif (!lastMoveThisTurnIsCounterable) {\n\t\t\t\tthis.debug(`Stadium 1 Counter: last move ${lastMoveThisTurn.name} was not Counterable`);\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (this.lastDamage <= 0) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: no previous damage exists\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn 2 * this.lastDamage;\n\t\t},\n\t},\n\tfirespin: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\thaze: {\n\t\tinherit: true,\n\t\tonHit(target, source) {\n\t\t\tthis.add('-activate', target, 'move: Haze');\n\t\t\tthis.add('-clearallboost', '[silent]');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.cureStatus(true);\n\t\t\t\tfor (const id of Object.keys(pokemon.volatiles)) {\n\t\t\t\t\tpokemon.removeVolatile(id);\n\t\t\t\t\tthis.add('-end', pokemon, id, '[silent]');\n\t\t\t\t}\n\t\t\t\tpokemon.recalculateStats!();\n\t\t\t}\n\t\t},\n\t},\n\thyperbeam: {\n\t\tinherit: true,\n\t\tonMoveFail(target, source, move) {\n\t\t\tsource.addVolatile('mustrecharge');\n\t\t},\n\t},\n\tpsywave: {\n\t\tinherit: true,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon) {\n\t\t\treturn this.random(1, this.trunc(1.5 * pokemon.level));\n\t\t},\n\t},\n\trage: {\n\t\tinherit: true,\n\t\tself: {\n\t\t\tvolatileStatus: 'rage',\n\t\t},\n\t\tcondition: {\n\t\t\t// Rage lock\n\t\t\tonStart(target, source, effect) {\n\t\t\t\tthis.effectState.move = 'rage';\n\t\t\t},\n\t\t\tonLockMove: 'rage',\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (target.boosts.atk < 6 && (move.category !== 'Status' || move.id === 'disable')) {\n\t\t\t\t\tthis.boost({atk: 1});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\trecover: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\trest: {\n\t\tinherit: true,\n\t\tonHit(target, source, move) {\n\t\t\t// Fails if the difference between\n\t\t\t// max HP and current HP is 0, 255, or 511\n\t\t\tif (target.hp >= target.maxhp) return false;\n\t\t\tif (!target.setStatus('slp', source, move)) return false;\n\t\t\ttarget.statusState.time = 2;\n\t\t\ttarget.statusState.startTime = 2;\n\t\t\ttarget.recalculateStats!(); // Stadium Rest removes statdrops given by Major Status Conditions.\n\t\t\tthis.heal(target.maxhp); // Aesthetic only as the healing happens after you fall asleep in-game\n\t\t},\n\t},\n\tsoftboiled: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\t// Fail when health is 255 or 511 less than max\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\tsubstitute: {\n\t\tinherit: true,\n\t\tonTryHit(target) {\n\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Stadium fixes the 25% = you die gag\n\t\t\tif (target.hp <= target.maxhp / 4) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute', '[weak]');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcondition: {\n\t\t\tonStart(target) {\n\t\t\t\tthis.add('-start', target, 'Substitute');\n\t\t\t\tthis.effectState.hp = Math.floor(target.maxhp / 4);\n\t\t\t\tdelete target.volatiles['partiallytrapped'];\n\t\t\t},\n\t\t\tonTryHitPriority: -1,\n\t\t\tonTryHit(target, source, move) {\n\t\t\t\tif (target === source) {\n\t\t\t\t\tthis.debug('sub bypass: self hit');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.drain) {\n\t\t\t\t\tthis.add('-miss', source);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (move.category === 'Status') {\n\t\t\t\t\tconst SubBlocked = ['leechseed', 'lockon', 'mindreader', 'nightmare'];\n\t\t\t\t\tif (move.status || move.boosts || move.volatileStatus === 'confusion' || SubBlocked.includes(move.id)) {\n\t\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[block] ' + move.name);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.volatileStatus && target === source) return;\n\t\t\t\tlet damage = this.actions.getDamage(source, target, move);\n\t\t\t\tif (damage && damage > target.volatiles['substitute'].hp) {\n\t\t\t\t\tdamage = target.volatiles['substitute'].hp;\n\t\t\t\t}\n\t\t\t\tif (!damage && damage !== 0) return null;\n\t\t\t\tdamage = this.runEvent('SubDamage', target, source, move, damage);\n\t\t\t\tif (!damage && damage !== 0) return damage;\n\t\t\t\ttarget.volatiles['substitute'].hp -= damage;\n\t\t\t\tthis.lastDamage = damage;\n\t\t\t\tif (target.volatiles['substitute'].hp <= 0) {\n\t\t\t\t\tthis.debug('Substitute broke');\n\t\t\t\t\ttarget.removeVolatile('substitute');\n\t\t\t\t\ttarget.subFainted = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[damage]');\n\t\t\t\t}\n\t\t\t\t// Drain/recoil does not happen if the substitute breaks\n\t\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\t\tif (move.recoil) {\n\t\t\t\t\t\tthis.damage(this.clampIntRange(Math.floor(damage * move.recoil[0] / move.recoil[1]), 1), source, target, 'recoil');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterSubDamage', target, source, move, damage);\n\t\t\t\t// Add here counter damage\n\t\t\t\tconst lastAttackedBy = target.getLastAttackedBy();\n\t\t\t\tif (!lastAttackedBy) {\n\t\t\t\t\ttarget.attackedBy.push({source: source, move: move.id, damage: damage, slot: source.getSlot(), thisTurn: true});\n\t\t\t\t} else {\n\t\t\t\t\tlastAttackedBy.move = move.id;\n\t\t\t\t\tlastAttackedBy.damage = damage;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t\tonEnd(target) {\n\t\t\t\tthis.add('-end', target, 'Substitute');\n\t\t\t},\n\t\t},\n\t\tsecondary: null,\n\t\ttarget: \"self\",\n\t\ttype: \"Normal\",\n\t},\n\tstruggle: {\n\t\tinherit: true,\n\t\tignoreImmunity: {'Normal': true},\n\t},\n\twrap: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n};\n","import type {ActiveMove, BoostID, ModdedBattleScriptsData, StatIDExceptHP} from '@pkmn/sim';\n\n/**\n * Stadium mechanics inherit from gen 1 mechanics, but fixes some stuff.\n */\n\nconst SKIP_LASTDAMAGE = new Set([\n\t'confuseray', 'conversion', 'counter', 'focusenergy', 'glare', 'haze', 'leechseed', 'lightscreen',\n\t'mimic', 'mist', 'poisongas', 'poisonpowder', 'recover', 'reflect', 'rest', 'softboiled',\n\t'splash', 'stunspore', 'substitute', 'supersonic', 'teleport', 'thunderwave', 'toxic', 'transform',\n]);\n\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen1',\n\tgen: 1,\n\t// BattlePokemon scripts. Stadium shares gen 1 code but it fixes some problems with it.\n\tpokemon: {\n\t\tinherit: true,\n\t\t// This is run on Stadium after boosts and status changes.\n\t\trecalculateStats() {\n\t\t\tlet statName: StatIDExceptHP;\n\t\t\tfor (statName in this.storedStats) {\n\t\t\t\tlet stat = this.species.baseStats[statName];\n\t\t\t\tstat = Math.floor(\n\t\t\t\t\tMath.floor(\n\t\t\t\t\t\t2 * stat + this.set.ivs[statName] + Math.floor(this.set.evs[statName] / 4)\n\t\t\t\t\t) * this.level / 100 + 5\n\t\t\t\t);\n\t\t\t\tthis.baseStoredStats[statName] = this.storedStats[statName] = Math.floor(stat);\n\t\t\t\tthis.modifiedStats![statName] = Math.floor(stat);\n\t\t\t\t// Re-apply drops, if necessary.\n\t\t\t\tif (this.status === 'par' && statName === 'spe') this.modifyStat!('spe', 0.25);\n\t\t\t\tif (this.status === 'brn' && statName === 'atk') this.modifyStat!('atk', 0.5);\n\t\t\t\tif (this.boosts[statName] !== 0) {\n\t\t\t\t\tif (this.boosts[statName] >= 0) {\n\t\t\t\t\t\tthis.modifyStat!(statName, [1, 1.5, 2, 2.5, 3, 3.5, 4][this.boosts[statName]]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.modifyStat!(statName, [100, 66, 50, 40, 33, 28, 25][-this.boosts[statName]] / 100);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Stadium's fixed boosting function.\n\t\tboostBy(boost) {\n\t\t\tlet changed = false;\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in boost) {\n\t\t\t\tlet delta = boost[i];\n\t\t\t\tif (delta === undefined) continue;\n\t\t\t\tthis.boosts[i] += delta;\n\t\t\t\tif (this.boosts[i] > 6) {\n\t\t\t\t\tdelta -= this.boosts[i] - 6;\n\t\t\t\t\tthis.boosts[i] = 6;\n\t\t\t\t}\n\t\t\t\tif (this.boosts[i] < -6) {\n\t\t\t\t\tdelta -= this.boosts[i] - (-6);\n\t\t\t\t\tthis.boosts[i] = -6;\n\t\t\t\t}\n\t\t\t\tif (delta) changed = true;\n\t\t\t}\n\t\t\tthis.recalculateStats!();\n\t\t\treturn changed;\n\t\t},\n\t\t// Remove stat recalculation logic from gen 1\n\t\tclearBoosts() {\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in this.boosts) {\n\t\t\t\tthis.boosts[i] = 0;\n\t\t\t}\n\t\t},\n\t},\n\tactions: {\n\t\tinherit: true,\n\t\trunMove(moveOrMoveName, pokemon, targetLoc, sourceEffect) {\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\t\t\tconst target = this.battle.getTarget(pokemon, move, targetLoc);\n\t\t\tif (target?.subFainted) target.subFainted = null;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tif (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {\n\t\t\t\tthis.battle.debug('' + pokemon.fullname + ' move interrupted; movedThisTurn: ' + pokemon.moveThisTurn);\n\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t// This is only run for sleep\n\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (move.beforeMoveCallback) {\n\t\t\t\tif (move.beforeMoveCallback.call(this.battle, pokemon, target, move)) {\n\t\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet lockedMove = this.battle.runEvent('LockMove', pokemon);\n\t\t\tif (lockedMove === true) lockedMove = false;\n\t\t\tif (\n\t\t\t\t!lockedMove &&\n\t\t\t\t(!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].locked !== target)\n\t\t\t) {\n\t\t\t\tpokemon.deductPP(move, null, target);\n\t\t\t} else {\n\t\t\t\tsourceEffect = move;\n\t\t\t}\n\t\t\tthis.battle.actions.useMove(move, pokemon, target, sourceEffect);\n\t\t},\n\t\t// This function deals with AfterMoveSelf events.\n\t\t// This leads with partial trapping moves shenanigans after the move has been used.\n\t\tuseMove(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tconst moveResult = this.useMoveInner(moveOrMoveName, pokemon, target, sourceEffect);\n\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\n\t\t\tif (move.id !== 'metronome') {\n\t\t\t\tif (move.id !== 'mirrormove' ||\n\t\t\t\t\t(!pokemon.side.foe.active[0]?.lastMove || pokemon.side.foe.active[0].lastMove?.id === 'mirrormove')) {\n\t\t\t\t\t// The move is our 'final' move (a failed Mirror Move, or any move that isn't Metronome or Mirror Move).\n\t\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t\t\tpokemon.lastMove = move;\n\t\t\t\t\tthis.battle.singleEvent('AfterMove', move, null, pokemon, target, move);\n\n\t\t\t\t\t// If target fainted\n\t\t\t\t\tif (target && target.hp <= 0) {\n\t\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\t\t}\n\t\t\t\t\tif (pokemon.volatiles['mustrecharge']) this.battle.add('-mustrecharge', pokemon);\n\n\t\t\t\t\t// For partial trapping moves, we are saving the target.\n\t\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target && target.hp > 0) {\n\t\t\t\t\t\t// It hit, so let's remove must recharge volatile. Yup, this happens on Stadium.\n\t\t\t\t\t\ttarget.removeVolatile('mustrecharge');\n\t\t\t\t\t\t// Let's check if the lock exists\n\t\t\t\t\t\tif (pokemon.volatiles['partialtrappinglock'] && target.volatiles['partiallytrapped']) {\n\t\t\t\t\t\t\t// Here the partialtrappinglock volatile has been already applied\n\t\t\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\t\t\t\t// If it's the first hit, we save the target\n\t\t\t\t\t\t\t\tpokemon.volatiles['partialtrappinglock'].locked = target;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // If we move to here, the move failed and there's no partial trapping lock\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn moveResult;\n\t\t},\n\t\t// This is the function that actually uses the move, running ModifyMove events.\n\t\t// It uses the move and then deals with the effects after the move.\n\t\tuseMoveInner(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t\tthis.battle.debug('not a gen 1 mechanic');\n\t\t\t}\n\t\t\tif (!move) return false;\n\n\t\t\tlet attrs = '';\n\t\t\tif (pokemon.fainted) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (sourceEffect) attrs += '|[from]' + this.battle.dex.conditions.get(sourceEffect);\n\t\t\tthis.battle.addMove('move', pokemon, move.name, target + attrs);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.battle.singleEvent('TryMove', move, null, pokemon, target, move) ||\n\t\t\t\t!this.battle.runEvent('TryMove', pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tlet damage: number | undefined | false | '' = false;\n\t\t\tif (!target || target.fainted) {\n\t\t\t\tthis.battle.attrLastMove('[notarget]');\n\t\t\t\tthis.battle.add('-notarget');\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// Store 0 damage for last damage if the move is not in the array.\n\t\t\tif (!SKIP_LASTDAMAGE.has(move.id)) this.battle.lastDamage = 0;\n\n\t\t\tdamage = this.tryMoveHit(target, pokemon, move);\n\n\t\t\t// Go ahead with results of the used move.\n\t\t\tif (damage === false) {\n\t\t\t\tthis.battle.singleEvent('MoveFail', move, null, target, pokemon, move);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondarySelf', move, null, pokemon, target, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondarySelf', pokemon, target, move);\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\t// First, check if the target is semi-invulnerable\n\t\t\tlet hitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Then, check if the Pokemon is immune to this move.\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, null, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tlet accuracy = move.accuracy;\n\n\t\t\t// Partial trapping moves: true accuracy while it lasts\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target === pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\taccuracy = true;\n\t\t\t\t} else if (pokemon.volatiles['partialtrappinglock'].locked !== target) {\n\t\t\t\t\t// The target switched, therefor, you fail using wrap.\n\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// OHKO moves only have a chance to hit if the user is at least as fast as the target\n\t\t\tif (move.ohko) {\n\t\t\t\tif (target.speed > pokemon.speed) {\n\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate true accuracy for gen 1, which uses 0-255.\n\t\t\t// Stadium uses the Gen 2 boost table for accuracy and evasiveness, except for 1/3 instead of 0.33\n\t\t\tconst boostTable = [1 / 3, 0.36, 0.43, 0.5, 0.66, 0.75, 1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\t// Check also for accuracy modifiers.\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[pokemon.boosts.accuracy + 6]);\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[-target.boosts.evasion + 6]);\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\n\t\t\t// Stadium fixes the 1/256 accuracy bug.\n\t\t\tif (accuracy !== true && !this.battle.randomChance(accuracy + 1, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t\tthis.battle.lastDamage = 0;\n\t\t\t}\n\n\t\t\t// If damage is 0 and not false it means it didn't miss, let's calc.\n\t\t\tif (damage !== false) {\n\t\t\t\tif (move.multihit) {\n\t\t\t\t\tlet hits = move.multihit;\n\t\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\t\t// Yes, it's hardcoded... meh\n\t\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thits = Math.floor(hits);\n\t\t\t\t\t// In gen 1, all the hits have the same damage for multihits move\n\t\t\t\t\tlet moveDamage: number | false | undefined = 0;\n\t\t\t\t\tlet i: number;\n\t\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\t\t// Move damage is fixed to be the first move's damage\n\t\t\t\t\t\tif (i === 0) move.damage = damage;\n\t\t\t\t\t\tif (target.subFainted) {\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmove.damage = null;\n\t\t\t\t\tif (i === 0) return 1;\n\t\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t\t} else {\n\t\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (move.category !== 'Status') target.gotAttacked(move, damage, pokemon);\n\n\t\t\tif (move.selfdestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t}\n\n\t\t\t// The move missed.\n\t\t\tif (damage === false) {\n\t\t\t\t// Delete the partial trap lock if necessary.\n\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tmoveHit(target, pokemon, moveOrMoveName, moveData, isSecondary, isSelf) {\n\t\t\tlet damage: number | false | null | undefined = 0;\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\n\t\t\tif (!isSecondary && !isSelf) this.battle.setActiveMove(move, pokemon, target);\n\t\t\tlet hitResult: number | boolean = true;\n\t\t\tif (!moveData) moveData = move;\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\thitResult = this.battle.singleEvent('TryHit', moveData, {}, target, pokemon, move);\n\n\t\t\t\t// Partial trapping moves still apply their volatile to Pokémon behind a Sub\n\t\t\t\tconst targetHadSub = !!target.volatiles['substitute'];\n\t\t\t\tif (targetHadSub && moveData.volatileStatus && moveData.volatileStatus === 'partiallytrapped') {\n\t\t\t\t\ttarget.addVolatile(moveData.volatileStatus, pokemon, move);\n\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].duration > 1) {\n\t\t\t\t\t\ttarget.volatiles[moveData.volatileStatus].duration = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Only run the hit events for the hit itself, not the secondary or self hits\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\t\t\tif (!hitResult) {\n\t\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\t\t// Special Substitute hit flag\n\t\t\t\t\t\tif (hitResult !== 0) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!this.battle.runEvent('TryFieldHit', target, pokemon, move)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else if (isSecondary && !moveData.self) {\n\t\t\t\t\thitResult = this.battle.runEvent('TrySecondaryHit', target, pokemon, moveData);\n\t\t\t\t}\n\n\t\t\t\tif (hitResult === 0) {\n\t\t\t\t\ttarget = null;\n\t\t\t\t} else if (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\tlet didSomething = false;\n\n\t\t\t\tdamage = this.getDamage(pokemon, target, moveData);\n\t\t\t\tif (damage && damage > target.hp) {\n\t\t\t\t\tdamage = target.hp;\n\t\t\t\t}\n\t\t\t\tif ((damage || damage === 0) && !target.fainted) {\n\t\t\t\t\tdamage = this.battle.damage(damage, target, pokemon, move);\n\t\t\t\t\tif (!(damage || damage === 0)) return false;\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t} else if (damage === false && typeof hitResult === 'undefined') {\n\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t}\n\t\t\t\tif (damage === false || damage === null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (moveData.boosts && !target.fainted) {\n\t\t\t\t\tthis.battle.boost(moveData.boosts, target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (moveData.heal && !target.fainted) {\n\t\t\t\t\tconst d = target.heal(Math.floor(target.maxhp * moveData.heal[0] / moveData.heal[1]));\n\t\t\t\t\tif (!d) {\n\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.battle.add('-heal', target, target.getHealth);\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.status) {\n\t\t\t\t\tif (!target.status) {\n\t\t\t\t\t\ttarget.setStatus(moveData.status, pokemon, move);\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t} else if (!isSecondary) {\n\t\t\t\t\t\tif (target.status === moveData.status) {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target, target.status);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.forceStatus) {\n\t\t\t\t\tif (target.setStatus(moveData.forceStatus, pokemon, move)) {\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.volatileStatus) {\n\t\t\t\t\tif (target.addVolatile(moveData.volatileStatus, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.sideCondition) {\n\t\t\t\t\tif (target.side.addSideCondition(moveData.sideCondition, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.pseudoWeather) {\n\t\t\t\t\tif (this.battle.field.addPseudoWeather(moveData.pseudoWeather, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Hit events\n\t\t\t\thitResult = this.battle.singleEvent('Hit', moveData, {}, target, pokemon, move);\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\tthis.battle.runEvent('Hit', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult && !didSomething) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Here's where self effects are applied.\n\t\t\tif (moveData.self) {\n\t\t\t\tthis.moveHit(pokemon, pokemon, move, moveData.self, isSecondary, true);\n\t\t\t}\n\n\t\t\t// Now we can save the partial trapping damage.\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tpokemon.volatiles['partialtrappinglock'].damage = this.battle.lastDamage;\n\t\t\t}\n\n\t\t\t// Apply move secondaries.\n\t\t\tif (moveData.secondaries && target && target.hp > 0) {\n\t\t\t\tfor (const secondary of moveData.secondaries) {\n\t\t\t\t\t// Multi-hit moves only roll for status once\n\t\t\t\t\tif (!move.multihit || move.lastHit) {\n\t\t\t\t\t\t// We check here whether to negate the probable secondary status if it's para, burn, or freeze.\n\t\t\t\t\t\t// In the game, this is checked and if true, the random number generator is not called.\n\t\t\t\t\t\t// That means that a move that does not share the type of the target can status it.\n\t\t\t\t\t\t// If a move that was not fire-type would exist on Gen 1, it could burn a Pokémon.\n\t\t\t\t\t\tif (!(secondary.status && ['par', 'brn', 'frz'].includes(secondary.status) && target.hasType(move.type))) {\n\t\t\t\t\t\t\tconst effectChance = Math.floor((secondary.chance || 100) * 255 / 100);\n\t\t\t\t\t\t\tif (typeof secondary.chance === 'undefined' || this.battle.randomChance(effectChance + 1, 256)) {\n\t\t\t\t\t\t\t\tthis.moveHit(target, pokemon, move, secondary, true, isSelf);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (move.selfSwitch && pokemon.hp) {\n\t\t\t\tpokemon.switchFlag = move.selfSwitch === true ? true : this.dex.toID(move.selfSwitch);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's see if the target is immune to the move.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn 65535;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback if necessary.\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves (seismic toss).\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we return that.\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// If it's the first hit on a Normal-type partially trap move, it hits Ghosts anyways but damage is 0.\n\t\t\tif (move.volatileStatus === 'partiallytrapped' && move.type === 'Normal' && target.hasType('Ghost')) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Let's check if we are in middle of a partial trap sequence to return the previous damage.\n\t\t\tif (source.volatiles['partialtrappinglock'] && (target === source.volatiles['partialtrappinglock'].locked)) {\n\t\t\t\treturn source.volatiles['partialtrappinglock'].damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage.\n\t\t\tif (!move.category) move.category = 'Physical';\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary.\n\t\t\tlet basePower: number | false | null = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\t\t\tif (!basePower) {\n\t\t\t\treturn basePower === 0 ? undefined : basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit possibility. We check if it's a 100% crit move, otherwise we calculate the chance.\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (!isCrit) {\n\t\t\t\t// In Stadium, the critical chance is based on speed.\n\t\t\t\t// First, we get the base speed and store it. Then we add 76. This is our current crit chance.\n\t\t\t\tlet critChance = source.species.baseStats['spe'] + 76;\n\n\t\t\t\t// Now we right logical shift it two places, essentially dividing by 4 and flooring it.\n\t\t\t\tcritChance = critChance >> 2;\n\n\t\t\t\t// Now we check for focus energy volatile.\n\t\t\t\tif (source.volatiles['focusenergy']) {\n\t\t\t\t\t// If it exists, crit chance is multiplied by 4 and floored with a logical left shift.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t\t// Then we add 160.\n\t\t\t\t\tcritChance += 160;\n\t\t\t\t} else {\n\t\t\t\t\t// If it is not active, we left shift it by 1.\n\t\t\t\t\tcritChance = critChance << 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we check for the move's critical hit ratio.\n\t\t\t\tif (move.critRatio === 2) {\n\t\t\t\t\t// High crit ratio, we multiply the result so far by 4.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t} else if (move.critRatio === 1) {\n\t\t\t\t\t// Normal hit ratio, we divide the crit chance by 2 and floor the result again.\n\t\t\t\t\tcritChance = critChance >> 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we make sure it's a number between 1 and 255.\n\t\t\t\tcritChance = this.battle.clampIntRange(critChance, 1, 255);\n\n\t\t\t\t// Last, we check deppending on ratio if the move critical hits or not.\n\t\t\t\t// We compare our critical hit chance against a random number between 0 and 255.\n\t\t\t\t// If the random number is lower, we get a critical hit. This means there is always a 1/255 chance of not hitting critically.\n\t\t\t\tif (critChance > 0) {\n\t\t\t\t\tisCrit = this.battle.randomChance(critChance, 256);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// There is a critical hit.\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation.\n\t\t\tif (basePower) {\n\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower);\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check attacker's and defender's stats.\n\t\t\tlet level = source.level;\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet attack = attacker.getStat(atkType);\n\t\t\tlet defense = defender.getStat(defType);\n\n\t\t\t// In gen 1, screen effect is applied here.\n\t\t\tif ((defType === 'def' && defender.volatiles['reflect']) || (defType === 'spd' && defender.volatiles['lightscreen'])) {\n\t\t\t\tthis.battle.debug('Screen doubling (Sp)Def');\n\t\t\t\tdefense *= 2;\n\t\t\t\tdefense = this.battle.clampIntRange(defense, 1, 1998);\n\t\t\t}\n\n\t\t\t// In the event of a critical hit, the offense and defense changes are ignored.\n\t\t\t// This includes both boosts and screens.\n\t\t\t// Also, level is doubled in damage calculation.\n\t\t\tif (isCrit) {\n\t\t\t\tmove.ignoreOffensive = true;\n\t\t\t\tmove.ignoreDefensive = true;\n\t\t\t\tlevel *= 2;\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t}\n\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\tattack = attacker.getStat(atkType, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true);\n\t\t\t}\n\n\t\t\t// When either attack or defense are higher than 256, they are both divided by 4 and moded by 256.\n\t\t\t// This is what cuases the roll over bugs.\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(attack / 4) % 256, 1);\n\t\t\t\t// Defense isn't checked on the cartridge, but we don't want those / 0 bugs on the sim.\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 4) % 256, 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = this.battle.clampIntRange(Math.floor(damage / 50), 0, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness.\n\t\t\t// In Gen 1, type effectiveness is applied against each of the target's types.\n\t\t\tfor (const targetType of target.types) {\n\t\t\t\tconst typeMod = this.battle.dex.getEffectiveness(type, targetType);\n\t\t\t\tif (typeMod > 0) {\n\t\t\t\t\t// Super effective against targetType\n\t\t\t\t\tdamage *= 20;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\t// Not very effective against targetType\n\t\t\t\t\tdamage *= 5;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t}\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t}\n\n\t\t\t// If damage becomes 0, the move is made to miss.\n\t\t\t// This occurs when damage was either 2 or 3 prior to applying STAB/Type matchup, and target is 4x resistant to the move.\n\t\t\tif (damage === 0) return damage;\n\n\t\t\t// Apply random factor if damage is greater than 1\n\t\t\tif (damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage.\n\t\t\treturn Math.floor(damage);\n\t\t},\n\t},\n};\n"],"mappings":";AAEO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AAAA,IAClC;AAAA,IACA,yBAAyB;AAAA,IACzB,gBAAgB,SAAS;AACxB,WAAK,OAAO,KAAK,cAAc,KAAK,MAAM,QAAQ,QAAQ,EAAE,GAAG,CAAC,CAAC;AAAA,IAClE;AAAA,IACA,oBAAoB,SAAS;AAC5B,WAAK,OAAO,KAAK,cAAc,KAAK,MAAM,QAAQ,QAAQ,EAAE,GAAG,CAAC,CAAC;AAAA,IAClE;AAAA,EACD;AAAA,EACA,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AAAA,IAClC;AAAA,IACA,sBAAsB;AAAA,IACtB,aAAa,SAAS;AACrB,UAAI,KAAK,aAAa,IAAI,GAAG,GAAG;AAC/B,aAAK,IAAI,QAAQ,SAAS,KAAK;AAC/B,gBAAQ,eAAe,MAAM;AAC7B,gBAAQ,eAAe,YAAY;AACnC,gBAAQ,eAAe,aAAa;AACpC,gBAAQ,eAAe,iBAAiB;AACxC,gBAAQ,eAAe,qBAAqB;AAC5C,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ,QAAQ,cAAc;AACrC,UAAI,gBAAgB,aAAa,eAAe,QAAQ;AACvD,aAAK,IAAI,WAAW,Q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O,IAAI,aAAa,MAAM;AAAA,MAC3D;AAIA,UAAI,WAAW;AAAG,eAAO;AAGzB,UAAI,SAAS,GAAG;AACf,kBAAU,KAAK,OAAO,OAAO,KAAK,GAAG;AACrC,iBAAS,KAAK,MAAM,SAAS,GAAG;AAAA,MACjC;AAGA,aAAO,KAAK,MAAM,MAAM;AAAA,IACzB;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/gen1stadium/conditions.ts","../../src/gen1stadium/rulesets.ts","../../src/gen1stadium/moves.ts","../../src/gen1stadium/scripts.ts"],"sourcesContent":["import type {ModdedConditionData} from '@pkmn/sim';\n\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(63, 256)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\tpokemon.removeVolatile('lockedmove');\n\t\t\t\tpokemon.removeVolatile('twoturnmove');\n\t\t\t\tpokemon.removeVolatile('invulnerability');\n\t\t\t\tpokemon.removeVolatile('partialtrappinglock');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-3 turns\n\t\t\tthis.effectState.startTime = this.random(1, 4);\n\t\t\tthis.effectState.time = this.effectState.startTime;\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (pokemon.statusState.time <= 0) pokemon.cureStatus();\n\t\t},\n\t},\n\tfrz: {\n\t\tname: 'frz',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'frz');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tthis.add('cant', pokemon, 'frz');\n\t\t\tpokemon.lastMove = null;\n\t\t\treturn false;\n\t\t},\n\t\tonHit(target, source, move) {\n\t\t\tif (move.type === 'Fire' && move.category !== 'Status') {\n\t\t\t\ttarget.cureStatus();\n\t\t\t}\n\t\t},\n\t},\n\tpsn: {\n\t\tname: 'psn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'psn');\n\t\t},\n\t\tonAfterMoveSelfPriority: 2,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tthis.damage(this.clampIntRange(Math.floor(pokemon.maxhp / 16), 1));\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\tonStart(target) {\n\t\t\tthis.add('-start', target, 'confusion');\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t},\n\tflinch: {\n\t\tinherit: true,\n\t\tonStart() {},\n\t},\n\tpartiallytrapped: {\n\t\tname: 'partiallytrapped',\n\t\tduration: 2,\n\t\tonBeforeMovePriority: 1,\n\t\tonStart(target, source, effect) {\n\t\t\tthis.add('-activate', target, 'move: ' + effect, '[of] ' + source);\n\t\t},\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.effectState.source && (!this.effectState.source.isActive || this.effectState.source.hp <= 0)) {\n\t\t\t\tpokemon.removeVolatile('partiallytrapped');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'partiallytrapped');\n\t\t\treturn false;\n\t\t},\n\t\tonEnd(pokemon) {\n\t\t\tthis.add('-end', pokemon, this.effectState.sourceEffect, '[partiallytrapped]');\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Species Clause', 'Nickname Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod'],\n\t},\n};\n","import type {ActiveMove, ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\tbide: {\n\t\tinherit: true,\n\t\tpriority: 0,\n\t\taccuracy: true,\n\t\tcondition: {\n\t\t\tdurationCallback(target, source, effect) {\n\t\t\t\treturn this.random(3, 5);\n\t\t\t},\n\t\t\tonStart(pokemon) {\n\t\t\t\tthis.effectState.totalDamage = 0;\n\t\t\t\tthis.effectState.lastDamage = 0;\n\t\t\t\tthis.add('-start', pokemon, 'Bide');\n\t\t\t},\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (source && source !== target && move.category !== 'Physical' && move.category !== 'Special') {\n\t\t\t\t\tconst damage = this.effectState.totalDamage;\n\t\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonDamage(damage, target, source, move) {\n\t\t\t\tif (!source || source.isAlly(target)) return;\n\t\t\t\tif (!move || move.effectType !== 'Move') return;\n\t\t\t\tif (!damage && this.effectState.lastDamage > 0) {\n\t\t\t\t\tdamage = this.effectState.totalDamage;\n\t\t\t\t}\n\t\t\t\tthis.effectState.totalDamage += damage;\n\t\t\t\tthis.effectState.lastDamage = damage;\n\t\t\t\tthis.effectState.sourceSlot = source.getSlot();\n\t\t\t},\n\t\t\tonAfterSetStatus(status, pokemon) {\n\t\t\t\t// Sleep, freeze, and partial trap will just pause duration.\n\t\t\t\tif (pokemon.volatiles['flinch']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else if (pokemon.volatiles['partiallytrapped']) {\n\t\t\t\t\tthis.effectState.duration++;\n\t\t\t\t} else {\n\t\t\t\t\tswitch (status.id) {\n\t\t\t\t\tcase 'slp':\n\t\t\t\t\tcase 'frz':\n\t\t\t\t\t\tthis.effectState.duration++;\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\tonBeforeMove(pokemon, t, move) {\n\t\t\t\tif (this.effectState.duration === 1) {\n\t\t\t\t\tthis.add('-end', pokemon, 'Bide');\n\t\t\t\t\tif (!this.effectState.totalDamage) {\n\t\t\t\t\t\tthis.debug(\"Bide failed because no damage was taken\");\n\t\t\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.getAtSlot(this.effectState.sourceSlot);\n\t\t\t\t\tif (target.isSemiInvulnerable()) {\n\t\t\t\t\t\tthis.add('-message', 'The foe ' + target.name + ' can\\'t be hit while flying!');\n\t\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.actions.moveHit(target, pokemon, move, {damage: this.effectState.totalDamage * 2} as ActiveMove);\n\t\t\t\t\tpokemon.removeVolatile('bide');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.add('-activate', pokemon, 'Bide');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tonDisableMove(pokemon) {\n\t\t\t\tif (!pokemon.hasMove('bide')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const moveSlot of pokemon.moveSlots) {\n\t\t\t\t\tif (moveSlot.id !== 'bide') {\n\t\t\t\t\t\tpokemon.disableMove(moveSlot.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttype: \"???\", // Will look as Normal but it's STAB-less\n\t},\n\tbind: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tclamp: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\tcounter: {\n\t\tinherit: true,\n\t\tignoreImmunity: true,\n\t\twillCrit: false,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon, target) {\n\t\t\t// Counter mechanics in Stadium 1:\n\t\t\t// - a move is Counterable if it is Normal or Fighting type, has nonzero Base Power, and is not Counter\n\t\t\t// - Counter succeeds if the target used a Counterable move earlier this turn\n\n\t\t\tconst lastMoveThisTurn = target.side.lastMove && target.side.lastMove.id === target.side.lastSelectedMove &&\n\t\t\t\t!this.queue.willMove(target) && this.dex.moves.get(target.side.lastMove.id);\n\t\t\tif (!lastMoveThisTurn) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: last move was not this turn\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst lastMoveThisTurnIsCounterable = lastMoveThisTurn && lastMoveThisTurn.basePower > 0 &&\n\t\t\t\t['Normal', 'Fighting'].includes(lastMoveThisTurn.type) && lastMoveThisTurn.id !== 'counter';\n\t\t\tif (!lastMoveThisTurnIsCounterable) {\n\t\t\t\tthis.debug(`Stadium 1 Counter: last move ${lastMoveThisTurn.name} was not Counterable`);\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (this.lastDamage <= 0) {\n\t\t\t\tthis.debug(\"Stadium 1 Counter: no previous damage exists\");\n\t\t\t\tthis.add('-fail', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn 2 * this.lastDamage;\n\t\t},\n\t},\n\tfirespin: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n\thaze: {\n\t\tinherit: true,\n\t\tonHit(target, source) {\n\t\t\tthis.add('-activate', target, 'move: Haze');\n\t\t\tthis.add('-clearallboost', '[silent]');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.cureStatus(true);\n\t\t\t\tfor (const id of Object.keys(pokemon.volatiles)) {\n\t\t\t\t\tpokemon.removeVolatile(id);\n\t\t\t\t\tthis.add('-end', pokemon, id, '[silent]');\n\t\t\t\t}\n\t\t\t\tpokemon.recalculateStats!();\n\t\t\t}\n\t\t},\n\t},\n\thyperbeam: {\n\t\tinherit: true,\n\t\tonMoveFail(target, source, move) {\n\t\t\tsource.addVolatile('mustrecharge');\n\t\t},\n\t},\n\tpsywave: {\n\t\tinherit: true,\n\t\tbasePower: 1,\n\t\tdamageCallback(pokemon) {\n\t\t\treturn this.random(1, this.trunc(1.5 * pokemon.level));\n\t\t},\n\t},\n\trage: {\n\t\tinherit: true,\n\t\tself: {\n\t\t\tvolatileStatus: 'rage',\n\t\t},\n\t\tcondition: {\n\t\t\t// Rage lock\n\t\t\tonStart(target, source, effect) {\n\t\t\t\tthis.effectState.move = 'rage';\n\t\t\t},\n\t\t\tonLockMove: 'rage',\n\t\t\tonHit(target, source, move) {\n\t\t\t\tif (target.boosts.atk < 6 && (move.category !== 'Status' || move.id === 'disable')) {\n\t\t\t\t\tthis.boost({atk: 1});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\trecover: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\trest: {\n\t\tinherit: true,\n\t\tonHit(target, source, move) {\n\t\t\t// Fails if the difference between\n\t\t\t// max HP and current HP is 0, 255, or 511\n\t\t\tif (target.hp >= target.maxhp) return false;\n\t\t\tif (!target.setStatus('slp', source, move)) return false;\n\t\t\ttarget.statusState.time = 2;\n\t\t\ttarget.statusState.startTime = 2;\n\t\t\ttarget.recalculateStats!(); // Stadium Rest removes statdrops given by Major Status Conditions.\n\t\t\tthis.heal(target.maxhp); // Aesthetic only as the healing happens after you fall asleep in-game\n\t\t},\n\t},\n\tsoftboiled: {\n\t\tinherit: true,\n\t\theal: null,\n\t\tonHit(target) {\n\t\t\t// Fail when health is 255 or 511 less than max\n\t\t\tif (target.hp === target.maxhp) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.heal(Math.floor(target.maxhp / 2), target, target);\n\t\t},\n\t},\n\tsubstitute: {\n\t\tinherit: true,\n\t\tonTryHit(target) {\n\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Stadium fixes the 25% = you die gag\n\t\t\tif (target.hp <= target.maxhp / 4) {\n\t\t\t\tthis.add('-fail', target, 'move: Substitute', '[weak]');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcondition: {\n\t\t\tonStart(target) {\n\t\t\t\tthis.add('-start', target, 'Substitute');\n\t\t\t\tthis.effectState.hp = Math.floor(target.maxhp / 4);\n\t\t\t\tdelete target.volatiles['partiallytrapped'];\n\t\t\t},\n\t\t\tonTryHitPriority: -1,\n\t\t\tonTryHit(target, source, move) {\n\t\t\t\tif (target === source) {\n\t\t\t\t\tthis.debug('sub bypass: self hit');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.drain) {\n\t\t\t\t\tthis.add('-miss', source);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (move.category === 'Status') {\n\t\t\t\t\tconst SubBlocked = ['leechseed', 'lockon', 'mindreader', 'nightmare'];\n\t\t\t\t\tif (move.status || move.boosts || move.volatileStatus === 'confusion' || SubBlocked.includes(move.id)) {\n\t\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[block] ' + move.name);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (move.volatileStatus && target === source) return;\n\t\t\t\tlet damage = this.actions.getDamage(source, target, move);\n\t\t\t\tif (damage && damage > target.volatiles['substitute'].hp) {\n\t\t\t\t\tdamage = target.volatiles['substitute'].hp;\n\t\t\t\t}\n\t\t\t\tif (!damage && damage !== 0) return null;\n\t\t\t\tdamage = this.runEvent('SubDamage', target, source, move, damage);\n\t\t\t\tif (!damage && damage !== 0) return damage;\n\t\t\t\ttarget.volatiles['substitute'].hp -= damage;\n\t\t\t\tthis.lastDamage = damage;\n\t\t\t\tif (target.volatiles['substitute'].hp <= 0) {\n\t\t\t\t\tthis.debug('Substitute broke');\n\t\t\t\t\ttarget.removeVolatile('substitute');\n\t\t\t\t\ttarget.subFainted = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis.add('-activate', target, 'Substitute', '[damage]');\n\t\t\t\t}\n\t\t\t\t// Drain/recoil does not happen if the substitute breaks\n\t\t\t\tif (target.volatiles['substitute']) {\n\t\t\t\t\tif (move.recoil) {\n\t\t\t\t\t\tthis.damage(this.clampIntRange(Math.floor(damage * move.recoil[0] / move.recoil[1]), 1), source, target, 'recoil');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterSubDamage', target, source, move, damage);\n\t\t\t\t// Add here counter damage\n\t\t\t\tconst lastAttackedBy = target.getLastAttackedBy();\n\t\t\t\tif (!lastAttackedBy) {\n\t\t\t\t\ttarget.attackedBy.push({source: source, move: move.id, damage: damage, slot: source.getSlot(), thisTurn: true});\n\t\t\t\t} else {\n\t\t\t\t\tlastAttackedBy.move = move.id;\n\t\t\t\t\tlastAttackedBy.damage = damage;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t},\n\t\t\tonEnd(target) {\n\t\t\t\tthis.add('-end', target, 'Substitute');\n\t\t\t},\n\t\t},\n\t\tsecondary: null,\n\t\ttarget: \"self\",\n\t\ttype: \"Normal\",\n\t},\n\tstruggle: {\n\t\tinherit: true,\n\t\tignoreImmunity: {'Normal': true},\n\t},\n\twrap: {\n\t\tinherit: true,\n\t\t// FIXME: onBeforeMove() {},\n\t},\n};\n","import type {ActiveMove, BoostID, ModdedBattleScriptsData, StatIDExceptHP} from '@pkmn/sim';\n\n/**\n * Stadium mechanics inherit from gen 1 mechanics, but fixes some stuff.\n */\n\nconst SKIP_LASTDAMAGE = new Set([\n\t'confuseray', 'conversion', 'counter', 'focusenergy', 'glare', 'haze', 'leechseed', 'lightscreen',\n\t'mimic', 'mist', 'poisongas', 'poisonpowder', 'recover', 'reflect', 'rest', 'softboiled',\n\t'splash', 'stunspore', 'substitute', 'supersonic', 'teleport', 'thunderwave', 'toxic', 'transform',\n]);\n\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen1',\n\tgen: 1,\n\t// BattlePokemon scripts. Stadium shares gen 1 code but it fixes some problems with it.\n\tpokemon: {\n\t\tinherit: true,\n\t\t// This is run on Stadium after boosts and status changes.\n\t\trecalculateStats() {\n\t\t\tlet statName: StatIDExceptHP;\n\t\t\tfor (statName in this.storedStats) {\n\t\t\t\tlet stat = this.species.baseStats[statName];\n\t\t\t\tstat = Math.floor(\n\t\t\t\t\tMath.floor(\n\t\t\t\t\t\t2 * stat + this.set.ivs[statName] + Math.floor(this.set.evs[statName] / 4)\n\t\t\t\t\t) * this.level / 100 + 5\n\t\t\t\t);\n\t\t\t\tthis.baseStoredStats[statName] = this.storedStats[statName] = Math.floor(stat);\n\t\t\t\tthis.modifiedStats![statName] = Math.floor(stat);\n\t\t\t\t// Re-apply drops, if necessary.\n\t\t\t\tif (this.status === 'par' && statName === 'spe') this.modifyStat!('spe', 0.25);\n\t\t\t\tif (this.status === 'brn' && statName === 'atk') this.modifyStat!('atk', 0.5);\n\t\t\t\tif (this.boosts[statName] !== 0) {\n\t\t\t\t\tif (this.boosts[statName] >= 0) {\n\t\t\t\t\t\tthis.modifyStat!(statName, [1, 1.5, 2, 2.5, 3, 3.5, 4][this.boosts[statName]]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.modifyStat!(statName, [100, 66, 50, 40, 33, 28, 25][-this.boosts[statName]] / 100);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Stadium's fixed boosting function.\n\t\tboostBy(boost) {\n\t\t\tlet changed = false;\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in boost) {\n\t\t\t\tlet delta = boost[i];\n\t\t\t\tif (delta === undefined) continue;\n\t\t\t\tthis.boosts[i] += delta;\n\t\t\t\tif (this.boosts[i] > 6) {\n\t\t\t\t\tdelta -= this.boosts[i] - 6;\n\t\t\t\t\tthis.boosts[i] = 6;\n\t\t\t\t}\n\t\t\t\tif (this.boosts[i] < -6) {\n\t\t\t\t\tdelta -= this.boosts[i] - (-6);\n\t\t\t\t\tthis.boosts[i] = -6;\n\t\t\t\t}\n\t\t\t\tif (delta) changed = true;\n\t\t\t}\n\t\t\tthis.recalculateStats!();\n\t\t\treturn changed;\n\t\t},\n\t\t// Remove stat recalculation logic from gen 1\n\t\tclearBoosts() {\n\t\t\tlet i: BoostID;\n\t\t\tfor (i in this.boosts) {\n\t\t\t\tthis.boosts[i] = 0;\n\t\t\t}\n\t\t},\n\t},\n\tactions: {\n\t\tinherit: true,\n\t\trunMove(moveOrMoveName, pokemon, targetLoc, sourceEffect) {\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\t\t\tconst target = this.battle.getTarget(pokemon, move, targetLoc);\n\t\t\tif (target?.subFainted) target.subFainted = null;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tif (pokemon.moveThisTurn || !this.battle.runEvent('BeforeMove', pokemon, target, move)) {\n\t\t\t\tthis.battle.debug('' + pokemon.fullname + ' move interrupted; movedThisTurn: ' + pokemon.moveThisTurn);\n\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t// This is only run for sleep\n\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (move.beforeMoveCallback) {\n\t\t\t\tif (move.beforeMoveCallback.call(this.battle, pokemon, target, move)) {\n\t\t\t\t\tthis.battle.clearActiveMove(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet lockedMove = this.battle.runEvent('LockMove', pokemon);\n\t\t\tif (lockedMove === true) lockedMove = false;\n\t\t\tif (\n\t\t\t\t!lockedMove &&\n\t\t\t\t(!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].locked !== target)\n\t\t\t) {\n\t\t\t\tpokemon.deductPP(move, null, target);\n\t\t\t} else {\n\t\t\t\tsourceEffect = move;\n\t\t\t}\n\t\t\tthis.battle.actions.useMove(move, pokemon, target, sourceEffect);\n\t\t},\n\t\t// This function deals with AfterMoveSelf events.\n\t\t// This leads with partial trapping moves shenanigans after the move has been used.\n\t\tuseMove(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tconst moveResult = this.useMoveInner(moveOrMoveName, pokemon, target, sourceEffect);\n\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\n\t\t\tif (move.id !== 'metronome') {\n\t\t\t\tif (move.id !== 'mirrormove' ||\n\t\t\t\t\t(!pokemon.side.foe.active[0]?.lastMove || pokemon.side.foe.active[0].lastMove?.id === 'mirrormove')) {\n\t\t\t\t\t// The move is our 'final' move (a failed Mirror Move, or any move that isn't Metronome or Mirror Move).\n\t\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t\t\tpokemon.lastMove = move;\n\t\t\t\t\tthis.battle.singleEvent('AfterMove', move, null, pokemon, target, move);\n\n\t\t\t\t\t// If target fainted\n\t\t\t\t\tif (target && target.hp <= 0) {\n\t\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.runEvent('AfterMoveSelf', pokemon, target, move);\n\t\t\t\t\t}\n\t\t\t\t\tif (pokemon.volatiles['mustrecharge']) this.battle.add('-mustrecharge', pokemon);\n\n\t\t\t\t\t// For partial trapping moves, we are saving the target.\n\t\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target && target.hp > 0) {\n\t\t\t\t\t\t// It hit, so let's remove must recharge volatile. Yup, this happens on Stadium.\n\t\t\t\t\t\ttarget.removeVolatile('mustrecharge');\n\t\t\t\t\t\t// Let's check if the lock exists\n\t\t\t\t\t\tif (pokemon.volatiles['partialtrappinglock'] && target.volatiles['partiallytrapped']) {\n\t\t\t\t\t\t\t// Here the partialtrappinglock volatile has been already applied\n\t\t\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\t\t\t\t// If it's the first hit, we save the target\n\t\t\t\t\t\t\t\tpokemon.volatiles['partialtrappinglock'].locked = target;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // If we move to here, the move failed and there's no partial trapping lock\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn moveResult;\n\t\t},\n\t\t// This is the function that actually uses the move, running ModifyMove events.\n\t\t// It uses the move and then deals with the effects after the move.\n\t\tuseMoveInner(moveOrMoveName, pokemon, target, sourceEffect) {\n\t\t\tif (!sourceEffect && this.battle.effect.id) sourceEffect = this.battle.effect;\n\t\t\tconst baseMove = this.battle.dex.moves.get(moveOrMoveName);\n\t\t\tlet move = this.battle.dex.getActiveMove(baseMove);\n\t\t\tif (target === undefined) target = this.battle.getRandomTarget(pokemon, move);\n\t\t\tif (move.target === 'self') {\n\t\t\t\ttarget = pokemon;\n\t\t\t}\n\t\t\tif (sourceEffect) move.sourceEffect = sourceEffect.id;\n\n\t\t\tthis.battle.setActiveMove(move, pokemon, target);\n\n\t\t\tthis.battle.singleEvent('ModifyMove', move, null, pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Target changed in ModifyMove, so we must adjust it here\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t}\n\t\t\tmove = this.battle.runEvent('ModifyMove', pokemon, target, move, move);\n\t\t\tif (baseMove.target !== move.target) {\n\t\t\t\t// Check again, this shouldn't ever happen on Gen 1.\n\t\t\t\ttarget = this.battle.getRandomTarget(pokemon, move);\n\t\t\t\tthis.battle.debug('not a gen 1 mechanic');\n\t\t\t}\n\t\t\tif (!move) return false;\n\n\t\t\tlet attrs = '';\n\t\t\tif (pokemon.fainted) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (sourceEffect) attrs += '|[from]' + this.battle.dex.conditions.get(sourceEffect);\n\t\t\tthis.battle.addMove('move', pokemon, move.name, target + attrs);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.battle.singleEvent('TryMove', move, null, pokemon, target, move) ||\n\t\t\t\t!this.battle.runEvent('TryMove', pokemon, target, move)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tlet damage: number | undefined | false | '' = false;\n\t\t\tif (!target || target.fainted) {\n\t\t\t\tthis.battle.attrLastMove('[notarget]');\n\t\t\t\tthis.battle.add('-notarget');\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// Store 0 damage for last damage if the move is not in the array.\n\t\t\tif (!SKIP_LASTDAMAGE.has(move.id)) this.battle.lastDamage = 0;\n\n\t\t\tdamage = this.tryMoveHit(target, pokemon, move);\n\n\t\t\t// Go ahead with results of the used move.\n\t\t\tif (damage === false) {\n\t\t\t\tthis.battle.singleEvent('MoveFail', move, null, target, pokemon, move);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondarySelf', move, null, pokemon, target, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondarySelf', pokemon, target, move);\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\t// First, check if the target is semi-invulnerable\n\t\t\tlet hitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Then, check if the Pokemon is immune to this move.\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\tif (move.selfdestruct) {\n\t\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, null, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tlet accuracy = move.accuracy;\n\n\t\t\t// Partial trapping moves: true accuracy while it lasts\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tif (move.volatileStatus === 'partiallytrapped' && target === pokemon.volatiles['partialtrappinglock'].locked) {\n\t\t\t\t\taccuracy = true;\n\t\t\t\t} else if (pokemon.volatiles['partialtrappinglock'].locked !== target) {\n\t\t\t\t\t// The target switched, therefor, you fail using wrap.\n\t\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// OHKO moves only have a chance to hit if the user is at least as fast as the target\n\t\t\tif (move.ohko) {\n\t\t\t\tif (target.speed > pokemon.speed) {\n\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate true accuracy for gen 1, which uses 0-255.\n\t\t\t// Stadium uses the Gen 2 boost table for accuracy and evasiveness, except for 1/3 instead of 0.33\n\t\t\tconst boostTable = [1 / 3, 0.36, 0.43, 0.5, 0.66, 0.75, 1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\t// Check also for accuracy modifiers.\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[pokemon.boosts.accuracy + 6]);\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\taccuracy = Math.floor(accuracy * boostTable[-target.boosts.evasion + 6]);\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\n\t\t\t// Stadium fixes the 1/256 accuracy bug.\n\t\t\tif (accuracy !== true && !this.battle.randomChance(accuracy + 1, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t\tthis.battle.lastDamage = 0;\n\t\t\t}\n\n\t\t\t// If damage is 0 and not false it means it didn't miss, let's calc.\n\t\t\tif (damage !== false) {\n\t\t\t\tif (move.multihit) {\n\t\t\t\t\tlet hits = move.multihit;\n\t\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\t\t// Yes, it's hardcoded... meh\n\t\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thits = Math.floor(hits);\n\t\t\t\t\t// In gen 1, all the hits have the same damage for multihits move\n\t\t\t\t\tlet moveDamage: number | false | undefined = 0;\n\t\t\t\t\tlet i: number;\n\t\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\t\t// Move damage is fixed to be the first move's damage\n\t\t\t\t\t\tif (i === 0) move.damage = damage;\n\t\t\t\t\t\tif (target.subFainted) {\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmove.damage = null;\n\t\t\t\t\tif (i === 0) return 1;\n\t\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t\t} else {\n\t\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (move.category !== 'Status') target.gotAttacked(move, damage, pokemon);\n\n\t\t\tif (move.selfdestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t}\n\n\t\t\t// The move missed.\n\t\t\tif (damage === false) {\n\t\t\t\t// Delete the partial trap lock if necessary.\n\t\t\t\tdelete pokemon.volatiles['partialtrappinglock'];\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tmoveHit(target, pokemon, moveOrMoveName, moveData, isSecondary, isSelf) {\n\t\t\tlet damage: number | false | null | undefined = 0;\n\t\t\tconst move = this.dex.getActiveMove(moveOrMoveName);\n\n\t\t\tif (!isSecondary && !isSelf) this.battle.setActiveMove(move, pokemon, target);\n\t\t\tlet hitResult: number | boolean = true;\n\t\t\tif (!moveData) moveData = move;\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\thitResult = this.battle.singleEvent('TryHit', moveData, {}, target, pokemon, move);\n\n\t\t\t\t// Partial trapping moves still apply their volatile to Pokémon behind a Sub\n\t\t\t\tconst targetHadSub = !!target.volatiles['substitute'];\n\t\t\t\tif (targetHadSub && moveData.volatileStatus && moveData.volatileStatus === 'partiallytrapped') {\n\t\t\t\t\ttarget.addVolatile(moveData.volatileStatus, pokemon, move);\n\t\t\t\t\tif (!pokemon.volatiles['partialtrappinglock'] || pokemon.volatiles['partialtrappinglock'].duration > 1) {\n\t\t\t\t\t\ttarget.volatiles[moveData.volatileStatus].duration = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Only run the hit events for the hit itself, not the secondary or self hits\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\t\t\tif (!hitResult) {\n\t\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\t\t// Special Substitute hit flag\n\t\t\t\t\t\tif (hitResult !== 0) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!this.battle.runEvent('TryFieldHit', target, pokemon, move)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else if (isSecondary && !moveData.self) {\n\t\t\t\t\thitResult = this.battle.runEvent('TrySecondaryHit', target, pokemon, moveData);\n\t\t\t\t}\n\n\t\t\t\tif (hitResult === 0) {\n\t\t\t\t\ttarget = null;\n\t\t\t\t} else if (!hitResult) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (target) {\n\t\t\t\tlet didSomething = false;\n\n\t\t\t\tdamage = this.getDamage(pokemon, target, moveData);\n\t\t\t\tif (damage && damage > target.hp) {\n\t\t\t\t\tdamage = target.hp;\n\t\t\t\t}\n\t\t\t\tif ((damage || damage === 0) && !target.fainted) {\n\t\t\t\t\tdamage = this.battle.damage(damage, target, pokemon, move);\n\t\t\t\t\tif (!(damage || damage === 0)) return false;\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t} else if (damage === false && typeof hitResult === 'undefined') {\n\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t}\n\t\t\t\tif (damage === false || damage === null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (moveData.boosts && !target.fainted) {\n\t\t\t\t\tthis.battle.boost(moveData.boosts, target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (moveData.heal && !target.fainted) {\n\t\t\t\t\tconst d = target.heal(Math.floor(target.maxhp * moveData.heal[0] / moveData.heal[1]));\n\t\t\t\t\tif (!d) {\n\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.battle.add('-heal', target, target.getHealth);\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.status) {\n\t\t\t\t\tif (!target.status) {\n\t\t\t\t\t\ttarget.setStatus(moveData.status, pokemon, move);\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t} else if (!isSecondary) {\n\t\t\t\t\t\tif (target.status === moveData.status) {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target, target.status);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.battle.add('-fail', target);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdidSomething = true;\n\t\t\t\t}\n\t\t\t\tif (moveData.forceStatus) {\n\t\t\t\t\tif (target.setStatus(moveData.forceStatus, pokemon, move)) {\n\t\t\t\t\t\ttarget.recalculateStats!();\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.volatileStatus) {\n\t\t\t\t\tif (target.addVolatile(moveData.volatileStatus, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.sideCondition) {\n\t\t\t\t\tif (target.side.addSideCondition(moveData.sideCondition, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (moveData.pseudoWeather) {\n\t\t\t\t\tif (this.battle.field.addPseudoWeather(moveData.pseudoWeather, pokemon, move)) {\n\t\t\t\t\t\tdidSomething = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Hit events\n\t\t\t\thitResult = this.battle.singleEvent('Hit', moveData, {}, target, pokemon, move);\n\t\t\t\tif (!isSelf && !isSecondary) {\n\t\t\t\t\tthis.battle.runEvent('Hit', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult && !didSomething) {\n\t\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Here's where self effects are applied.\n\t\t\tif (moveData.self) {\n\t\t\t\tthis.moveHit(pokemon, pokemon, move, moveData.self, isSecondary, true);\n\t\t\t}\n\n\t\t\t// Now we can save the partial trapping damage.\n\t\t\tif (pokemon.volatiles['partialtrappinglock']) {\n\t\t\t\tpokemon.volatiles['partialtrappinglock'].damage = this.battle.lastDamage;\n\t\t\t}\n\n\t\t\t// Apply move secondaries.\n\t\t\tif (moveData.secondaries && target && target.hp > 0) {\n\t\t\t\tfor (const secondary of moveData.secondaries) {\n\t\t\t\t\t// Multi-hit moves only roll for status once\n\t\t\t\t\tif (!move.multihit || move.lastHit) {\n\t\t\t\t\t\t// We check here whether to negate the probable secondary status if it's para, burn, or freeze.\n\t\t\t\t\t\t// In the game, this is checked and if true, the random number generator is not called.\n\t\t\t\t\t\t// That means that a move that does not share the type of the target can status it.\n\t\t\t\t\t\t// If a move that was not fire-type would exist on Gen 1, it could burn a Pokémon.\n\t\t\t\t\t\tif (!(secondary.status && ['par', 'brn', 'frz'].includes(secondary.status) && target.hasType(move.type))) {\n\t\t\t\t\t\t\tconst effectChance = Math.floor((secondary.chance || 100) * 255 / 100);\n\t\t\t\t\t\t\tif (typeof secondary.chance === 'undefined' || this.battle.randomChance(effectChance + 1, 256)) {\n\t\t\t\t\t\t\t\tthis.moveHit(target, pokemon, move, secondary, true, isSelf);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (move.selfSwitch && pokemon.hp) {\n\t\t\t\tpokemon.switchFlag = move.selfSwitch === true ? true : this.dex.toID(move.selfSwitch);\n\t\t\t}\n\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's see if the target is immune to the move.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn 65535;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback if necessary.\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves (seismic toss).\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we return that.\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// If it's the first hit on a Normal-type partially trap move, it hits Ghosts anyways but damage is 0.\n\t\t\tif (move.volatileStatus === 'partiallytrapped' && move.type === 'Normal' && target.hasType('Ghost')) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Let's check if we are in middle of a partial trap sequence to return the previous damage.\n\t\t\tif (source.volatiles['partialtrappinglock'] && (target === source.volatiles['partialtrappinglock'].locked)) {\n\t\t\t\treturn source.volatiles['partialtrappinglock'].damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage.\n\t\t\tif (!move.category) move.category = 'Physical';\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary.\n\t\t\tlet basePower: number | false | null = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\t\t\tif (!basePower) {\n\t\t\t\treturn basePower === 0 ? undefined : basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit possibility. We check if it's a 100% crit move, otherwise we calculate the chance.\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (!isCrit) {\n\t\t\t\t// In Stadium, the critical chance is based on speed.\n\t\t\t\t// First, we get the base speed and store it. Then we add 76. This is our current crit chance.\n\t\t\t\tlet critChance = source.species.baseStats['spe'] + 76;\n\n\t\t\t\t// Now we right logical shift it two places, essentially dividing by 4 and flooring it.\n\t\t\t\tcritChance = critChance >> 2;\n\n\t\t\t\t// Now we check for focus energy volatile.\n\t\t\t\tif (source.volatiles['focusenergy']) {\n\t\t\t\t\t// If it exists, crit chance is multiplied by 4 and floored with a logical left shift.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t\t// Then we add 160.\n\t\t\t\t\tcritChance += 160;\n\t\t\t\t} else {\n\t\t\t\t\t// If it is not active, we left shift it by 1.\n\t\t\t\t\tcritChance = critChance << 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we check for the move's critical hit ratio.\n\t\t\t\tif (move.critRatio === 2) {\n\t\t\t\t\t// High crit ratio, we multiply the result so far by 4.\n\t\t\t\t\tcritChance = critChance << 2;\n\t\t\t\t} else if (move.critRatio === 1) {\n\t\t\t\t\t// Normal hit ratio, we divide the crit chance by 2 and floor the result again.\n\t\t\t\t\tcritChance = critChance >> 1;\n\t\t\t\t}\n\n\t\t\t\t// Now we make sure it's a number between 1 and 255.\n\t\t\t\tcritChance = this.battle.clampIntRange(critChance, 1, 255);\n\n\t\t\t\t// Last, we check deppending on ratio if the move critical hits or not.\n\t\t\t\t// We compare our critical hit chance against a random number between 0 and 255.\n\t\t\t\t// If the random number is lower, we get a critical hit. This means there is always a 1/255 chance of not hitting critically.\n\t\t\t\tif (critChance > 0) {\n\t\t\t\t\tisCrit = this.battle.randomChance(critChance, 256);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// There is a critical hit.\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation.\n\t\t\tif (basePower) {\n\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower);\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check attacker's and defender's stats.\n\t\t\tlet level = source.level;\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet attack = attacker.getStat(atkType);\n\t\t\tlet defense = defender.getStat(defType);\n\n\t\t\t// In gen 1, screen effect is applied here.\n\t\t\tif ((defType === 'def' && defender.volatiles['reflect']) || (defType === 'spd' && defender.volatiles['lightscreen'])) {\n\t\t\t\tthis.battle.debug('Screen doubling (Sp)Def');\n\t\t\t\tdefense *= 2;\n\t\t\t\tdefense = this.battle.clampIntRange(defense, 1, 1998);\n\t\t\t}\n\n\t\t\t// In the event of a critical hit, the offense and defense changes are ignored.\n\t\t\t// This includes both boosts and screens.\n\t\t\t// Also, level is doubled in damage calculation.\n\t\t\tif (isCrit) {\n\t\t\t\tmove.ignoreOffensive = true;\n\t\t\t\tmove.ignoreDefensive = true;\n\t\t\t\tlevel *= 2;\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t}\n\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\tattack = attacker.getStat(atkType, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true);\n\t\t\t}\n\n\t\t\t// When either attack or defense are higher than 256, they are both divided by 4 and moded by 256.\n\t\t\t// This is what cuases the roll over bugs.\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(attack / 4) % 256, 1);\n\t\t\t\t// Defense isn't checked on the cartridge, but we don't want those / 0 bugs on the sim.\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 4) % 256, 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = this.battle.clampIntRange(Math.floor(damage / 50), 0, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness.\n\t\t\t// In Gen 1, type effectiveness is applied against each of the target's types.\n\t\t\tfor (const targetType of target.types) {\n\t\t\t\tconst typeMod = this.battle.dex.getEffectiveness(type, targetType);\n\t\t\t\tif (typeMod > 0) {\n\t\t\t\t\t// Super effective against targetType\n\t\t\t\t\tdamage *= 20;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\t// Not very effective against targetType\n\t\t\t\t\tdamage *= 5;\n\t\t\t\t\tdamage = Math.floor(damage / 10);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t}\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t}\n\n\t\t\t// If damage becomes 0, the move is made to miss.\n\t\t\t// This occurs when damage was either 2 or 3 prior to applying STAB/Type matchup, and target is 4x resistant to the move.\n\t\t\tif (damage === 0) return damage;\n\n\t\t\t// Apply random factor if damage is greater than 1\n\t\t\tif (damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage.\n\t\t\treturn Math.floor(damage);\n\t\t},\n\t},\n};\n"],"mappings":";AAEO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AAAA,IAClC;AAAA,IACA,yBAAyB;AAAA,IACzB,gBAAgB,SAAS;AACxB,WAAK,OAAO,KAAK,cAAc,KAAK,MAAM,QAAQ,QAAQ,EAAE,GAAG,CAAC,CAAC;AAAA,IAClE;AAAA,IACA,oBAAoB,SAAS;AAC5B,WAAK,OAAO,KAAK,cAAc,KAAK,MAAM,QAAQ,QAAQ,EAAE,GAAG,CAAC,CAAC;AAAA,IAClE;AAAA,EACD;AAAA,EACA,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AAAA,IAClC;AAAA,IACA,sBAAsB;AAAA,IACtB,aAAa,SAAS;AACrB,UAAI,KAAK,aAAa,IAAI,GAAG,GAAG;AAC/B,aAAK,IAAI,QAAQ,SAAS,KAAK;AAC/B,gBAAQ,eAAe,MAAM;AAC7B,gBAAQ,eAAe,YAAY;AACnC,gBAAQ,eAAe,aAAa;AACpC,gBAAQ,eAAe,iBAAiB;AACxC,gBAAQ,eAAe,qBAAqB;AAC5C,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA,KAAK;AAAA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AI,eAAe,GAAG;AACrB,YAAI,CAAC;AAAkB,eAAK,OAAO,IAAI,mBAAmB,MAAM;AAAA,MACjE;AACA,UAAI,eAAe,GAAG;AACrB,YAAI,CAAC;AAAkB,eAAK,OAAO,IAAI,aAAa,MAAM;AAAA,MAC3D;AAIA,UAAI,WAAW;AAAG,eAAO;AAGzB,UAAI,SAAS,GAAG;AACf,kBAAU,KAAK,OAAO,OAAO,KAAK,GAAG;AACrC,iBAAS,KAAK,MAAM,SAAS,GAAG;AAAA,MACjC;AAGA,aAAO,KAAK,MAAM,MAAM;AAAA,IACzB;AAAA,EACD;AACD;","names":[]}
@@ -215,7 +215,7 @@ var Rulesets = {
215
215
  standard: {
216
216
  effectType: "ValidatorRule",
217
217
  name: "Standard",
218
- ruleset: ["Obtainable", "Team Preview", "Stadium Sleep Clause", "Freeze Clause Mod", "Self-KO Clause", "Species Clause", "OHKO Clause", "Evasion Moves Clause", "Exact HP Mod", "Cancel Mod", "Stadium Items Clause"]
218
+ ruleset: ["Obtainable", "Team Preview", "Stadium Sleep Clause", "Freeze Clause Mod", "Self-KO Clause", "Species Clause", "Nickname Clause", "OHKO Clause", "Evasion Moves Clause", "Exact HP Mod", "Cancel Mod", "Stadium Items Clause"]
219
219
  },
220
220
  selfkoclause: {
221
221
  effectType: "Rule",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/gen2stadium2/conditions.ts","../../src/gen2stadium2/items.ts","../../src/gen2stadium2/moves.ts","../../src/gen2stadium2/rulesets.ts","../../src/gen2stadium2/scripts.ts"],"names":[],"mappings":";AAQO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AACjC,aAAO,YAAY,eAAe;AAAA,IACnC;AAAA,IACA,yBAAyB;AAAA,IACzB,gBAAgB,SAAS;AACxB,kBAAY,MAAM,OAAO;AAAA,IAC1B;AAAA,IAC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GAAG,aAAa,MAAM;AAC3D,aAAK,IAAI,KAAK,EAAE;AAChB,eAAO;AAAA,MACR,WAAW,KAAK,GAAG,aAAa,QAAQ,KAAK,GAAG,aAAa,MAAM;AAClE,aAAK,IAAI,KAAK,EAAE;AAChB,eAAO;AAAA,MACR;AACA,WAAK,IAAI,YAAY,UAAU,OAAO,KAAK,MAAM,IAAI;AACrD,aAAO;AAAA,IACR;AACA,QAAI,CAAC,KAAK,GAAG,aAAa;AACzB,WAAK,IAAI,KAAK,EAAE;AAChB,aAAO;AAAA,IACR;AACA,QAAI,CAAC,KAAK,GAAG,aAAa;AACzB,WAAK,IAAI,KAAK,EAAE;AAChB,aAAO;AAAA,IACR;AACA,QAAI,WAAW;AACd,WAAK,SAAS,cAAc,UAAU,QAAQ,UAAU,QAAQ,UAAU,QAAQ,MAAM;AAAA,IACzF;AACA,WAAO;AAAA,EACR;AACD","sourcesContent":["import type {ActiveMove, Battle, ModdedConditionData, Pokemon} from '@pkmn/sim';\n\n/**\n * Since Stadium 2 ignores stat drops while recalculating stats due to boosting moves, haze,\n * or stat-lowering moves. The status conditions which affect a targets stats (brn and par) have\n * a volatile along with them to keep track of if their respective stat changes should be factored\n * in during stat calculations or not.\n */\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t\ttarget.addVolatile('brnattackdrop');\n\t\t},\n\t\tonAfterMoveSelfPriority: 3,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tresidualdmg(this, pokemon);\n\t\t},\n\t\tonSwitchIn(pokemon) {\n\t\t\tpokemon.addVolatile('brnattackdrop');\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tresidualdmg(this, pokemon);\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t\ttarget.addVolatile('parspeeddrop');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(1, 4)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\tonSwitchIn(pokemon) {\n\t\t\tpokemon.addVolatile('parspeeddrop');\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-4 turns, guaranteed 1 turn of sleep.\n\t\t\tthis.effectState.time = this.random(2, 5);\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 10,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tif (pokemon.statusState.time <= 0) {\n\t\t\t\tpokemon.cureStatus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tif (move.sleepUsable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\t// Stadium 2 fixed Berserk Gene afflicting Confusion for 255 turns.\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.id === 'lockedmove') {\n\t\t\t\tthis.add('-start', target, 'confusion', '[silent]');\n\t\t\t} else {\n\t\t\t\tthis.add('-start', target, 'confusion');\n\t\t\t}\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.volatiles['confusion'].time--;\n\t\t\tif (!pokemon.volatiles['confusion'].time) {\n\t\t\t\tpokemon.removeVolatile('confusion');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('-activate', pokemon, 'confusion');\n\t\t\tif (this.randomChance(1, 2)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmove = {\n\t\t\t\tbasePower: 40,\n\t\t\t\ttype: '???',\n\t\t\t\tbaseMoveType: move.type,\n\t\t\t\tcategory: 'Physical',\n\t\t\t\twillCrit: false,\n\t\t\t\tisConfusionSelfHit: true,\n\t\t\t\tnoDamageVariance: true,\n\t\t\t\tflags: {},\n\t\t\t\tselfdestruct: move.selfdestruct,\n\t\t\t} as unknown as ActiveMove;\n\t\t\tconst damage = this.actions.getDamage(pokemon, pokemon, move);\n\t\t\tif (typeof damage !== 'number') throw new Error(\"Confusion damage not dealt\");\n\t\t\tthis.directDamage(damage);\n\t\t\treturn false;\n\t\t},\n\t},\n\tresidualdmg: {\n\t\tname: 'residualdmg',\n\t\tonStart(target) {\n\t\t\ttarget.volatiles['residualdmg'].counter = 0;\n\t\t},\n\t\tonAfterMoveSelfPriority: 100,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tif (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;\n\t\t},\n\t},\n};\n\nfunction residualdmg(battle: Battle, pokemon: Pokemon) {\n\tif (pokemon.volatiles['residualdmg']) {\n\t\tconst residualDmg = battle.clampIntRange(\n\t\t\tMath.floor(pokemon.maxhp / 16) * pokemon.volatiles['residualdmg'].counter, 1\n\t\t);\n\t\tbattle.damage(residualDmg, pokemon);\n\t\tbattle.hint(\"In Gen 2, Toxic's counter is retained through Baton Pass/Heal Bell and applies to PSN/BRN.\", true);\n\t} else {\n\t\tbattle.damage(battle.clampIntRange(Math.floor(pokemon.maxhp / 8), 1), pokemon);\n\t}\n}\n","import type {ModdedItemData} from '@pkmn/sim';\n\n// Gen 2 Stadium fixes Dragon Fang and Dragon Scale having the wrong effects.\nexport const Items: {[k: string]: ModdedItemData} = {\n\tdragonfang: {\n\t\tinherit: true,\n\t\tonModifyDamage(damage, source, target, move) {\n\t\t\tif (move?.type === 'Dragon') {\n\t\t\t\treturn damage * 1.1;\n\t\t\t}\n\t\t},\n\t},\n\tdragonscale: {\n\t\tinherit: true,\n\t\tonModifyDamage() {},\n\t},\n};\n","import type {ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\t// Belly Drum no longer boosts attack by 2 stages if under 50% health.\n\tbellydrum: {\n\t\tinherit: true,\n\t\tonHit(target) {\n\t\t\tif (target.boosts.atk >= 6 || target.hp <= target.maxhp / 2) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.directDamage(target.maxhp / 2);\n\t\t\tconst originalStage = target.boosts.atk;\n\t\t\tlet currentStage = originalStage;\n\t\t\tlet boosts = 0;\n\t\t\tlet loopStage = 0;\n\t\t\twhile (currentStage < 6) {\n\t\t\t\tloopStage = currentStage;\n\t\t\t\tcurrentStage++;\n\t\t\t\tif (currentStage < 6) currentStage++;\n\t\t\t\ttarget.boosts.atk = loopStage;\n\t\t\t\tif (target.getStat('atk', false, true) < 999) {\n\t\t\t\t\ttarget.boosts.atk = currentStage;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttarget.boosts.atk = currentStage - 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tboosts = target.boosts.atk - originalStage;\n\t\t\ttarget.boosts.atk = originalStage;\n\t\t\tthis.boost({atk: boosts});\n\t\t},\n\t},\n\tdestinybond: {\n\t\tinherit: true,\n\t\tonPrepareHit(pokemon) {\n\t\t\tif (pokemon.side.pokemonLeft === 1) {\n\t\t\t\tthis.hint(\"In Pokemon Stadium 2, Destiny Bond fails if it is being used by your last Pokemon.\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\t/**\n\t * In Stadium 2, moves which affect the stat stages of a Pokemon, such as moves which boost ones own stats,\n\t * lower the targets stats, or Haze, causes the afflicted stat to be re-calculated without factoring in\n\t * status aliments, thus if a Pokemon is burned or paralyzed and either active Pokemon uses Haze, then their\n\t * attack and speed are re-calculated while ignoring their status ailments, so their attack would go from 50% to normal\n\t */\n\thaze: {\n\t\tinherit: true,\n\t\tonHitField() {\n\t\t\tthis.add('-clearallboost');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.removeVolatile('brnattackdrop');\n\t\t\t\tpokemon.removeVolatile('parspeeddrop');\n\t\t\t}\n\t\t},\n\t},\n\tperishsong: {\n\t\tinherit: true,\n\t\tonPrepareHit(pokemon) {\n\t\t\tif (pokemon.side.pokemonLeft === 1) {\n\t\t\t\tthis.hint(\"In Pokemon Stadium 2, Perish Song fails if it is being used by your last Pokemon.\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Team Preview', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Self-KO Clause', 'Species Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod', 'Stadium Items Clause'],\n\t},\n\tselfkoclause: {\n\t\teffectType: 'Rule',\n\t\tname: 'Self-KO Clause',\n\t\tdesc: \"If a player's last Pokemon uses Self-Destruct or Explosion, they automatically lose the battle.\",\n\t\tonBegin() {\n\t\t\tthis.add('rule', 'Self-KO Clause: If a player\\'s last Pokemon uses Self-Destruct/Explosion, they automatically lose');\n\t\t},\n\t},\n};\n","import type {\n\tActiveMove,\n\tBoostID,\n\tModdedBattleScriptsData,\n\tPokemon,\n\tSparseBoostsTable,\n\tStatIDExceptHP,\n} from '@pkmn/sim';\n\n/**\n * Stadium 2 mechanics inherit from gen 2 mechanics, but fixes some bugs.\n */\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen2',\n\tgen: 2,\n\tpokemon: {\n\t\tinherit: true,\n\t\tgetStat(statName, unboosted, unmodified, fastReturn) {\n\t\t\t// @ts-ignore - type checking prevents 'hp' from being passed, but we're paranoid\n\t\t\tif (statName === 'hp') throw new Error(\"Please read `maxhp` directly\");\n\n\t\t\t// base stat\n\t\t\tlet stat = this.storedStats[statName];\n\n\t\t\t// Stat boosts.\n\t\t\tif (!unboosted) {\n\t\t\t\tlet boost = this.boosts[statName];\n\t\t\t\tif (boost > 6) boost = 6;\n\t\t\t\tif (boost < -6) boost = -6;\n\t\t\t\tif (boost >= 0) {\n\t\t\t\t\tconst boostTable = [1, 1.5, 2, 2.5, 3, 3.5, 4];\n\t\t\t\t\tstat = Math.floor(stat * boostTable[boost]);\n\t\t\t\t} else {\n\t\t\t\t\tconst numerators = [100, 66, 50, 40, 33, 28, 25];\n\t\t\t\t\tstat = Math.floor(stat * numerators[-boost] / 100);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.status === 'par' && statName === 'spe' && this.volatiles['parspeeddrop']) {\n\t\t\t\tstat = Math.floor(stat / 4);\n\t\t\t}\n\t\t\tif (!unmodified) {\n\t\t\t\tif (this.status === 'brn' && statName === 'atk' && this.volatiles['brnattackdrop']) {\n\t\t\t\t\tstat = Math.floor(stat / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Gen 2 caps stats at 999 and min is 1.\n\t\t\tstat = this.battle.clampIntRange(stat, 1, 999);\n\t\t\tif (fastReturn) return stat;\n\n\t\t\t// Screens\n\t\t\tif (!unboosted) {\n\t\t\t\tif (\n\t\t\t\t\t(statName === 'def' && this.side.sideConditions['reflect']) ||\n\t\t\t\t\t(statName === 'spd' && this.side.sideConditions['lightscreen'])\n\t\t\t\t) {\n\t\t\t\t\tstat *= 2;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle boosting items\n\t\t\tif (\n\t\t\t\t(['Cubone', 'Marowak'].includes(this.species.name) && this.item === 'thickclub' && statName === 'atk') ||\n\t\t\t\t(this.species.name === 'Pikachu' && this.item === 'lightball' && statName === 'spa')\n\t\t\t) {\n\t\t\t\tstat *= 2;\n\t\t\t} else if (this.species.name === 'Ditto' && this.item === 'metalpowder' && ['def', 'spd'].includes(statName)) {\n\t\t\t\tstat = Math.floor(stat * 1.5);\n\t\t\t}\n\n\t\t\treturn stat;\n\t\t},\n\t},\n\t// Stadium 2 shares gen 2 code but it fixes some problems with it.\n\tactions: {\n\t\tinherit: true,\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tconst positiveBoostTable = [1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tconst negativeBoostTable = [1, 0.75, 0.6, 0.5, 0.43, 0.36, 0.33];\n\t\t\tconst doSelfDestruct = true;\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\tif (move.selfdestruct && doSelfDestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t/**\n\t\t\t\t * Keeping track of the last move used for self-ko clause,\n\t\t\t\t * making sure to clear the opponents last move so that self-destruct and explosion\n\t\t\t\t * does not persist between Pokemon, preventing problems caused by situations,\n\t\t\t\t * such as a player from blowing up both they and their opponents second last Pokemon\n\t\t\t\t * and their opponent blowing up their last Pokemon. If we did not clear here, there would be a problem.\n\t\t\t\t */\n\t\t\t\ttarget.side.lastMove = null;\n\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t}\n\n\t\t\tlet hitResult = this.battle.singleEvent('PrepareHit', move, {}, target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.battle.runEvent('PrepareHit', pokemon, target, move);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.target === 'all' || move.target === 'foeSide' || move.target === 'allySide' || move.target === 'allyTeam') {\n\t\t\t\tif (move.target === 'all') {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitField', target, pokemon, move);\n\t\t\t\t} else {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitSide', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) {\n\t\t\t\t\t\tthis.battle.add('-fail', pokemon);\n\t\t\t\t\t\tthis.battle.attrLastMove('[still]');\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn this.moveHit(target, pokemon, move);\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, {}, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet accuracy = move.accuracy;\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\tif (move.ohko) {\n\t\t\t\t\tif (pokemon.level >= target.level) {\n\t\t\t\t\t\taccuracy += (pokemon.level - target.level) * 2;\n\t\t\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\tif (pokemon.boosts.accuracy > 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[pokemon.boosts.accuracy];\n\t\t\t\t\t} else {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[-pokemon.boosts.accuracy];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\tif (target.boosts.evasion > 0 && !move.ignorePositiveEvasion) {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[target.boosts.evasion];\n\t\t\t\t\t} else if (target.boosts.evasion < 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[-target.boosts.evasion];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(Math.floor(accuracy), 255);\n\t\t\t\taccuracy = Math.max(accuracy, 1);\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('ModifyAccuracy', target, pokemon, move, accuracy);\n\t\t\tif (accuracy !== true) accuracy = Math.max(accuracy, 0);\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\tif (accuracy !== true && accuracy !== 255 && !this.battle.randomChance(accuracy, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t\treturn damage;\n\t\t\t}\n\t\t\tmove.totalDamage = 0;\n\t\t\tpokemon.lastDamage = 0;\n\t\t\tif (move.multihit) {\n\t\t\t\tlet hits = move.multihit;\n\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thits = Math.floor(hits);\n\t\t\t\tlet nullDamage = true;\n\t\t\t\tlet moveDamage: number | undefined | false;\n\n\t\t\t\tconst isSleepUsable = move.sleepUsable || this.dex.moves.get(move.sourceEffect).sleepUsable;\n\t\t\t\tlet i: number;\n\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\tif (pokemon.status === 'slp' && !isSleepUsable) break;\n\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\tif (nullDamage && (moveDamage || moveDamage === 0 || moveDamage === undefined)) nullDamage = false;\n\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\tmove.totalDamage += damage;\n\t\t\t\t\tthis.battle.eachEvent('Update');\n\t\t\t\t}\n\t\t\t\tif (i === 0) return 1;\n\t\t\t\tif (nullDamage) damage = false;\n\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t} else {\n\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\tmove.totalDamage = damage;\n\t\t\t}\n\t\t\tif (move.category !== 'Status') {\n\t\t\t\ttarget.gotAttacked(move, damage, pokemon);\n\t\t\t}\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\t\t\t// Implementing Recoil mechanics from Stadium 2.\n\t\t\t// If a pokemon caused the other to faint with a recoil move and only one pokemon remains on both sides,\n\t\t\t// recoil damage will not be taken.\n\t\t\tif (move.recoil && move.totalDamage && (pokemon.side.pokemonLeft > 1 || target.side.pokemonLeft > 1 || target.hp)) {\n\t\t\t\tthis.battle.damage(this.calcRecoilDamage(move.totalDamage, move), pokemon, target, 'recoil');\n\t\t\t}\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as unknown as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's test for immunities.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn target.maxhp;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we run it\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage\n\t\t\tmove.category = this.battle.getCategory(move);\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary\n\t\t\tlet basePower: number | false | null | undefined = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\n\t\t\t// We check for Base Power\n\t\t\tif (!basePower) {\n\t\t\t\tif (basePower === 0) return; // Returning undefined means not dealing damage\n\t\t\t\treturn basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit ratio\n\t\t\tlet critRatio = this.battle.runEvent('ModifyCritRatio', source, target, move, move.critRatio || 0);\n\t\t\tcritRatio = this.battle.clampIntRange(critRatio, 0, 5);\n\t\t\tconst critMult = [0, 16, 8, 4, 3, 2];\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (typeof move.willCrit === 'undefined') {\n\t\t\t\tif (critRatio) {\n\t\t\t\t\tisCrit = this.battle.randomChance(1, critMult[critRatio]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation\n\t\t\tif (basePower) {\n\t\t\t\t// confusion damage\n\t\t\t\tif (move.isConfusionSelfHit) {\n\t\t\t\t\tmove.type = move.baseMoveType!;\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t\tmove.type = '???';\n\t\t\t\t} else {\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t}\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check for attacker and defender\n\t\t\tlet level = source.level;\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tthis.battle.add('-activate', source, 'move: Beat Up', '[of] ' + move.allies[0].name);\n\t\t\t\tlevel = move.allies[0].level;\n\t\t\t}\n\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet unboosted = false;\n\t\t\tlet noburndrop = false;\n\n\t\t\tif (isCrit) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t\t// Stat level modifications are ignored if they are neutral to or favour the defender.\n\t\t\t\t// Reflect and Light Screen defensive boosts are only ignored if stat level modifications were also ignored as a result of that.\n\t\t\t\tif (attacker.boosts[atkType] <= defender.boosts[defType]) {\n\t\t\t\t\tunboosted = true;\n\t\t\t\t\tnoburndrop = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet attack = attacker.getStat(atkType, unboosted, noburndrop);\n\t\t\tlet defense = defender.getStat(defType, unboosted);\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tattack = move.allies[0].species.baseStats.atk;\n\t\t\t\tmove.allies.shift();\n\t\t\t\tdefense = defender.species.baseStats.def;\n\t\t\t}\n\n\t\t\t// Moves that ignore offense and defense respectively.\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\t// The attack drop from the burn is only applied when attacker's attack level is higher than defender's defense level.\n\t\t\t\tattack = attacker.getStat(atkType, true, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true, true);\n\t\t\t}\n\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(attack, 1, 999) / 4), 1);\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(defense, 1, 999) / 4), 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = Math.floor(damage / 50);\n\t\t\tif (isCrit) damage *= 2;\n\t\t\tdamage = Math.floor(this.battle.runEvent('ModifyDamage', attacker, defender, move, damage));\n\t\t\tdamage = this.battle.clampIntRange(damage, 1, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// Weather modifiers\n\t\t\tif (\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Fire' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage * 1.5);\n\t\t\t} else if (\n\t\t\t\t((type === 'Fire' || move.id === 'solarbeam') && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\t// Super effective attack\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t\tdamage *= 2;\n\t\t\t\tif (totalTypeMod >= 2) {\n\t\t\t\t\tdamage *= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Resisted attack\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\tif (totalTypeMod <= -2) {\n\t\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply random factor if damage is greater than 1, except for Flail and Reversal\n\t\t\tif (!move.noDamageVariance && damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t}\n\n\t\t\t// If damage is less than 1, we return 1\n\t\t\tif (basePower && !Math.floor(damage)) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage\n\t\t\treturn damage;\n\t\t},\n\t},\n\t/**\n\t * Stadium 2 ignores stat drops due to status ailments upon boosting the dropped stat.\n\t * For example: if a burned Snorlax uses Curse then it will ignore the attack drop from\n\t * burn when it is recalculating its attack stat. This is why volatiles are added to status\n\t * conditions, so that we can keep track of whether or not to apply the stat drop from\n\t * statuses.\n\t */\n\tboost(boost, target, source = null, effect = null) {\n\t\tif (this.event) {\n\t\t\tif (!target) target = this.event.target;\n\t\t\tif (!source) source = this.event.source;\n\t\t\tif (!effect) effect = this.effect;\n\t\t}\n\t\tif (typeof effect === 'string') effect = this.dex.conditions.get(effect);\n\t\tif (!target?.hp) return 0;\n\t\tlet success = null;\n\t\tboost = this.runEvent('TryBoost', target, source, effect, {...boost});\n\t\tlet i: BoostID;\n\t\tfor (i in boost) {\n\t\t\tconst currentBoost: SparseBoostsTable = {};\n\t\t\tcurrentBoost[i] = boost[i];\n\t\t\tlet boostBy = target.boostBy(currentBoost);\n\t\t\tlet msg = '-boost';\n\t\t\tif (boost[i]! < 0) {\n\t\t\t\tmsg = '-unboost';\n\t\t\t\tboostBy = -boostBy;\n\t\t\t}\n\t\t\tif (boostBy) {\n\t\t\t\tsuccess = true;\n\t\t\t\t// Check for boost increases deleting attack or speed drops\n\t\t\t\tif (i === 'atk' && target.status === 'brn' && target.volatiles['brnattackdrop']) {\n\t\t\t\t\ttarget.removeVolatile('brnattackdrop');\n\t\t\t\t}\n\t\t\t\tif (i === 'spe' && target.status === 'par' && target.volatiles['parspeeddrop']) {\n\t\t\t\t\ttarget.removeVolatile('parspeeddrop');\n\t\t\t\t}\n\t\t\t\tif (!effect || effect.effectType === 'Move') {\n\t\t\t\t\tthis.add(msg, target, i, boostBy);\n\t\t\t\t} else {\n\t\t\t\t\tthis.add(msg, target, i, boostBy, '[from] ' + effect.fullname);\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterEachBoost', target, source, effect, currentBoost);\n\t\t\t}\n\t\t}\n\t\tthis.runEvent('AfterBoost', target, source, effect, boost);\n\t\treturn success;\n\t},\n\t/**\n\t * Implementing Self-KO Clause by having it check what the last move used by the players were\n\t * in the case both Pokemon faint. Since the only way this can happen in Stadium 2 is if a player\n\t * uses self-destruct or explosion, I can use this to determine who should win.\n\t */\n\tfaintMessages(lastFirst) {\n\t\tif (this.ended) return;\n\t\tconst length = this.faintQueue.length;\n\t\tif (!length) return false;\n\t\tif (lastFirst) {\n\t\t\tthis.faintQueue.unshift(this.faintQueue[this.faintQueue.length - 1]);\n\t\t\tthis.faintQueue.pop();\n\t\t}\n\t\tlet faintData;\n\t\twhile (this.faintQueue.length) {\n\t\t\tfaintData = this.faintQueue.shift()!;\n\t\t\tconst pokemon: Pokemon = faintData.target;\n\t\t\tif (!pokemon.fainted &&\n\t\t\t\tthis.runEvent('BeforeFaint', pokemon, faintData.source, faintData.effect)) {\n\t\t\t\tthis.add('faint', pokemon);\n\t\t\t\tpokemon.side.pokemonLeft--;\n\t\t\t\tif (pokemon.side.totalFainted < 100) pokemon.side.totalFainted++;\n\t\t\t\tthis.runEvent('Faint', pokemon, faintData.source, faintData.effect);\n\t\t\t\tthis.singleEvent('End', pokemon.getAbility(), pokemon.abilityState, pokemon);\n\t\t\t\tpokemon.clearVolatile(false);\n\t\t\t\tpokemon.fainted = true;\n\t\t\t\tpokemon.isActive = false;\n\t\t\t\tpokemon.isStarted = false;\n\t\t\t\tpokemon.side.faintedThisTurn = pokemon;\n\t\t\t}\n\t\t}\n\n\t\tif (this.gen <= 1) {\n\t\t\t// in gen 1, fainting skips the rest of the turn\n\t\t\t// residuals don't exist in gen 1\n\t\t\tthis.queue.clear();\n\t\t\t// Fainting clears accumulated Bide damage\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (pokemon.volatiles['bide'] && pokemon.volatiles['bide'].damage) {\n\t\t\t\t\tpokemon.volatiles['bide'].damage = 0;\n\t\t\t\t\tthis.hint(\"Desync Clause Mod activated!\");\n\t\t\t\t\tthis.hint(\"In Gen 1, Bide's accumulated damage is reset to 0 when a Pokemon faints.\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.gen <= 3 && this.gameType === 'singles') {\n\t\t\t// in gen 3 or earlier, fainting in singles skips to residuals\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (this.gen <= 2) {\n\t\t\t\t\t// in gen 2, fainting skips moves only\n\t\t\t\t\tthis.queue.cancelMove(pokemon);\n\t\t\t\t} else {\n\t\t\t\t\t// in gen 3, fainting skips all moves and switches\n\t\t\t\t\tthis.queue.cancelAction(pokemon);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!this.p1.pokemonLeft && !this.p2.pokemonLeft) {\n\t\t\tif (this.p1.lastMove !== null && this.p2.lastMove === null) {\n\t\t\t\tthis.win(this.p2);\n\t\t\t\treturn true;\n\t\t\t} else if (this.p2.lastMove !== null && this.p1.lastMove === null) {\n\t\t\t\tthis.win(this.p1);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.win(faintData ? faintData.target.side.foe : null);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p1.pokemonLeft) {\n\t\t\tthis.win(this.p2);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p2.pokemonLeft) {\n\t\t\tthis.win(this.p1);\n\t\t\treturn true;\n\t\t}\n\t\tif (faintData) {\n\t\t\tthis.runEvent('AfterFaint', faintData.target, faintData.source, faintData.effect, length);\n\t\t}\n\t\treturn false;\n\t},\n};\n"]}
1
+ {"version":3,"sources":["../../src/gen2stadium2/conditions.ts","../../src/gen2stadium2/items.ts","../../src/gen2stadium2/moves.ts","../../src/gen2stadium2/rulesets.ts","../../src/gen2stadium2/scripts.ts"],"names":[],"mappings":";AAQO,IAAM,aAAiD;AAAA,EAC7D,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ,QAAQ;AACf,WAAK,IAAI,WAAW,QAAQ,KAAK;AACjC,aAAO,YAAY,eAAe;AAAA,IACnC;AAAA,IACA,yBAAyB;AAAA,IACzB,gBAAgB,SAAS;AACxB,kBAAY,MAAM,OAAO;AAAA,IAC1B;AAAA,IACA,WAAW,SAAS;AACnB,cAAQ,YAAY,eAAe;AAAA,IACpC;AAAA,IACA,oBAAoB,SAAS;AAC5B,kBAAY,MAAM,OAAO;AAAA,IAC1B;AAAA,EACD;AAAA,EACA,KAAK;AAAA,IACJ,MAAM;AAAA,IACN,YAAY;AAAA,IACZ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ACA,WAAK,IAAI,YAAY,UAAU,OAAO,KAAK,MAAM,IAAI;AACrD,aAAO;AAAA,IACR;AACA,QAAI,CAAC,KAAK,GAAG,aAAa;AACzB,WAAK,IAAI,KAAK,EAAE;AAChB,aAAO;AAAA,IACR;AACA,QAAI,CAAC,KAAK,GAAG,aAAa;AACzB,WAAK,IAAI,KAAK,EAAE;AAChB,aAAO;AAAA,IACR;AACA,QAAI,WAAW;AACd,WAAK,SAAS,cAAc,UAAU,QAAQ,UAAU,QAAQ,UAAU,QAAQ,MAAM;AAAA,IACzF;AACA,WAAO;AAAA,EACR;AACD","sourcesContent":["import type {ActiveMove, Battle, ModdedConditionData, Pokemon} from '@pkmn/sim';\n\n/**\n * Since Stadium 2 ignores stat drops while recalculating stats due to boosting moves, haze,\n * or stat-lowering moves. The status conditions which affect a targets stats (brn and par) have\n * a volatile along with them to keep track of if their respective stat changes should be factored\n * in during stat calculations or not.\n */\nexport const Conditions: {[k: string]: ModdedConditionData} = {\n\tbrn: {\n\t\tname: 'brn',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'brn');\n\t\t\ttarget.addVolatile('brnattackdrop');\n\t\t},\n\t\tonAfterMoveSelfPriority: 3,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tresidualdmg(this, pokemon);\n\t\t},\n\t\tonSwitchIn(pokemon) {\n\t\t\tpokemon.addVolatile('brnattackdrop');\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tresidualdmg(this, pokemon);\n\t\t},\n\t},\n\tpar: {\n\t\tname: 'par',\n\t\teffectType: 'Status',\n\t\tonStart(target) {\n\t\t\tthis.add('-status', target, 'par');\n\t\t\ttarget.addVolatile('parspeeddrop');\n\t\t},\n\t\tonBeforeMovePriority: 2,\n\t\tonBeforeMove(pokemon) {\n\t\t\tif (this.randomChance(1, 4)) {\n\t\t\t\tthis.add('cant', pokemon, 'par');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\tonSwitchIn(pokemon) {\n\t\t\tpokemon.addVolatile('parspeeddrop');\n\t\t},\n\t},\n\tslp: {\n\t\tname: 'slp',\n\t\teffectType: 'Status',\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.effectType === 'Move') {\n\t\t\t\tthis.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);\n\t\t\t} else {\n\t\t\t\tthis.add('-status', target, 'slp');\n\t\t\t}\n\t\t\t// 1-4 turns, guaranteed 1 turn of sleep.\n\t\t\tthis.effectState.time = this.random(2, 5);\n\n\t\t\tif (target.removeVolatile('nightmare')) {\n\t\t\t\tthis.add('-end', target, 'Nightmare', '[silent]');\n\t\t\t}\n\t\t},\n\t\tonBeforeMovePriority: 10,\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.statusState.time--;\n\t\t\tif (pokemon.statusState.time <= 0) {\n\t\t\t\tpokemon.cureStatus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('cant', pokemon, 'slp');\n\t\t\tif (move.sleepUsable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t},\n\tconfusion: {\n\t\tinherit: true,\n\t\t// Stadium 2 fixed Berserk Gene afflicting Confusion for 255 turns.\n\t\tonStart(target, source, sourceEffect) {\n\t\t\tif (sourceEffect && sourceEffect.id === 'lockedmove') {\n\t\t\t\tthis.add('-start', target, 'confusion', '[silent]');\n\t\t\t} else {\n\t\t\t\tthis.add('-start', target, 'confusion');\n\t\t\t}\n\t\t\tthis.effectState.time = this.random(2, 6);\n\t\t},\n\t\tonBeforeMove(pokemon, target, move) {\n\t\t\tpokemon.volatiles['confusion'].time--;\n\t\t\tif (!pokemon.volatiles['confusion'].time) {\n\t\t\t\tpokemon.removeVolatile('confusion');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.add('-activate', pokemon, 'confusion');\n\t\t\tif (this.randomChance(1, 2)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmove = {\n\t\t\t\tbasePower: 40,\n\t\t\t\ttype: '???',\n\t\t\t\tbaseMoveType: move.type,\n\t\t\t\tcategory: 'Physical',\n\t\t\t\twillCrit: false,\n\t\t\t\tisConfusionSelfHit: true,\n\t\t\t\tnoDamageVariance: true,\n\t\t\t\tflags: {},\n\t\t\t\tselfdestruct: move.selfdestruct,\n\t\t\t} as unknown as ActiveMove;\n\t\t\tconst damage = this.actions.getDamage(pokemon, pokemon, move);\n\t\t\tif (typeof damage !== 'number') throw new Error(\"Confusion damage not dealt\");\n\t\t\tthis.directDamage(damage);\n\t\t\treturn false;\n\t\t},\n\t},\n\tresidualdmg: {\n\t\tname: 'residualdmg',\n\t\tonStart(target) {\n\t\t\ttarget.volatiles['residualdmg'].counter = 0;\n\t\t},\n\t\tonAfterMoveSelfPriority: 100,\n\t\tonAfterMoveSelf(pokemon) {\n\t\t\tif (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;\n\t\t},\n\t\tonAfterSwitchInSelf(pokemon) {\n\t\t\tif (['brn', 'psn', 'tox'].includes(pokemon.status)) pokemon.volatiles['residualdmg'].counter++;\n\t\t},\n\t},\n};\n\nfunction residualdmg(battle: Battle, pokemon: Pokemon) {\n\tif (pokemon.volatiles['residualdmg']) {\n\t\tconst residualDmg = battle.clampIntRange(\n\t\t\tMath.floor(pokemon.maxhp / 16) * pokemon.volatiles['residualdmg'].counter, 1\n\t\t);\n\t\tbattle.damage(residualDmg, pokemon);\n\t\tbattle.hint(\"In Gen 2, Toxic's counter is retained through Baton Pass/Heal Bell and applies to PSN/BRN.\", true);\n\t} else {\n\t\tbattle.damage(battle.clampIntRange(Math.floor(pokemon.maxhp / 8), 1), pokemon);\n\t}\n}\n","import type {ModdedItemData} from '@pkmn/sim';\n\n// Gen 2 Stadium fixes Dragon Fang and Dragon Scale having the wrong effects.\nexport const Items: {[k: string]: ModdedItemData} = {\n\tdragonfang: {\n\t\tinherit: true,\n\t\tonModifyDamage(damage, source, target, move) {\n\t\t\tif (move?.type === 'Dragon') {\n\t\t\t\treturn damage * 1.1;\n\t\t\t}\n\t\t},\n\t},\n\tdragonscale: {\n\t\tinherit: true,\n\t\tonModifyDamage() {},\n\t},\n};\n","import type {ModdedMoveData} from '@pkmn/sim';\n\nexport const Moves: {[k: string]: ModdedMoveData} = {\n\t// Belly Drum no longer boosts attack by 2 stages if under 50% health.\n\tbellydrum: {\n\t\tinherit: true,\n\t\tonHit(target) {\n\t\t\tif (target.boosts.atk >= 6 || target.hp <= target.maxhp / 2) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.directDamage(target.maxhp / 2);\n\t\t\tconst originalStage = target.boosts.atk;\n\t\t\tlet currentStage = originalStage;\n\t\t\tlet boosts = 0;\n\t\t\tlet loopStage = 0;\n\t\t\twhile (currentStage < 6) {\n\t\t\t\tloopStage = currentStage;\n\t\t\t\tcurrentStage++;\n\t\t\t\tif (currentStage < 6) currentStage++;\n\t\t\t\ttarget.boosts.atk = loopStage;\n\t\t\t\tif (target.getStat('atk', false, true) < 999) {\n\t\t\t\t\ttarget.boosts.atk = currentStage;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttarget.boosts.atk = currentStage - 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tboosts = target.boosts.atk - originalStage;\n\t\t\ttarget.boosts.atk = originalStage;\n\t\t\tthis.boost({atk: boosts});\n\t\t},\n\t},\n\tdestinybond: {\n\t\tinherit: true,\n\t\tonPrepareHit(pokemon) {\n\t\t\tif (pokemon.side.pokemonLeft === 1) {\n\t\t\t\tthis.hint(\"In Pokemon Stadium 2, Destiny Bond fails if it is being used by your last Pokemon.\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n\t/**\n\t * In Stadium 2, moves which affect the stat stages of a Pokemon, such as moves which boost ones own stats,\n\t * lower the targets stats, or Haze, causes the afflicted stat to be re-calculated without factoring in\n\t * status aliments, thus if a Pokemon is burned or paralyzed and either active Pokemon uses Haze, then their\n\t * attack and speed are re-calculated while ignoring their status ailments, so their attack would go from 50% to normal\n\t */\n\thaze: {\n\t\tinherit: true,\n\t\tonHitField() {\n\t\t\tthis.add('-clearallboost');\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tpokemon.clearBoosts();\n\t\t\t\tpokemon.removeVolatile('brnattackdrop');\n\t\t\t\tpokemon.removeVolatile('parspeeddrop');\n\t\t\t}\n\t\t},\n\t},\n\tperishsong: {\n\t\tinherit: true,\n\t\tonPrepareHit(pokemon) {\n\t\t\tif (pokemon.side.pokemonLeft === 1) {\n\t\t\t\tthis.hint(\"In Pokemon Stadium 2, Perish Song fails if it is being used by your last Pokemon.\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t},\n};\n","import type {ModdedFormatData} from '@pkmn/sim';\n\nexport const Rulesets: {[k: string]: ModdedFormatData} = {\n\tstandard: {\n\t\teffectType: 'ValidatorRule',\n\t\tname: 'Standard',\n\t\truleset: ['Obtainable', 'Team Preview', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Self-KO Clause', 'Species Clause', 'Nickname Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Exact HP Mod', 'Cancel Mod', 'Stadium Items Clause'],\n\t},\n\tselfkoclause: {\n\t\teffectType: 'Rule',\n\t\tname: 'Self-KO Clause',\n\t\tdesc: \"If a player's last Pokemon uses Self-Destruct or Explosion, they automatically lose the battle.\",\n\t\tonBegin() {\n\t\t\tthis.add('rule', 'Self-KO Clause: If a player\\'s last Pokemon uses Self-Destruct/Explosion, they automatically lose');\n\t\t},\n\t},\n};\n","import type {\n\tActiveMove,\n\tBoostID,\n\tModdedBattleScriptsData,\n\tPokemon,\n\tSparseBoostsTable,\n\tStatIDExceptHP,\n} from '@pkmn/sim';\n\n/**\n * Stadium 2 mechanics inherit from gen 2 mechanics, but fixes some bugs.\n */\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen2',\n\tgen: 2,\n\tpokemon: {\n\t\tinherit: true,\n\t\tgetStat(statName, unboosted, unmodified, fastReturn) {\n\t\t\t// @ts-ignore - type checking prevents 'hp' from being passed, but we're paranoid\n\t\t\tif (statName === 'hp') throw new Error(\"Please read `maxhp` directly\");\n\n\t\t\t// base stat\n\t\t\tlet stat = this.storedStats[statName];\n\n\t\t\t// Stat boosts.\n\t\t\tif (!unboosted) {\n\t\t\t\tlet boost = this.boosts[statName];\n\t\t\t\tif (boost > 6) boost = 6;\n\t\t\t\tif (boost < -6) boost = -6;\n\t\t\t\tif (boost >= 0) {\n\t\t\t\t\tconst boostTable = [1, 1.5, 2, 2.5, 3, 3.5, 4];\n\t\t\t\t\tstat = Math.floor(stat * boostTable[boost]);\n\t\t\t\t} else {\n\t\t\t\t\tconst numerators = [100, 66, 50, 40, 33, 28, 25];\n\t\t\t\t\tstat = Math.floor(stat * numerators[-boost] / 100);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.status === 'par' && statName === 'spe' && this.volatiles['parspeeddrop']) {\n\t\t\t\tstat = Math.floor(stat / 4);\n\t\t\t}\n\t\t\tif (!unmodified) {\n\t\t\t\tif (this.status === 'brn' && statName === 'atk' && this.volatiles['brnattackdrop']) {\n\t\t\t\t\tstat = Math.floor(stat / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Gen 2 caps stats at 999 and min is 1.\n\t\t\tstat = this.battle.clampIntRange(stat, 1, 999);\n\t\t\tif (fastReturn) return stat;\n\n\t\t\t// Screens\n\t\t\tif (!unboosted) {\n\t\t\t\tif (\n\t\t\t\t\t(statName === 'def' && this.side.sideConditions['reflect']) ||\n\t\t\t\t\t(statName === 'spd' && this.side.sideConditions['lightscreen'])\n\t\t\t\t) {\n\t\t\t\t\tstat *= 2;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle boosting items\n\t\t\tif (\n\t\t\t\t(['Cubone', 'Marowak'].includes(this.species.name) && this.item === 'thickclub' && statName === 'atk') ||\n\t\t\t\t(this.species.name === 'Pikachu' && this.item === 'lightball' && statName === 'spa')\n\t\t\t) {\n\t\t\t\tstat *= 2;\n\t\t\t} else if (this.species.name === 'Ditto' && this.item === 'metalpowder' && ['def', 'spd'].includes(statName)) {\n\t\t\t\tstat = Math.floor(stat * 1.5);\n\t\t\t}\n\n\t\t\treturn stat;\n\t\t},\n\t},\n\t// Stadium 2 shares gen 2 code but it fixes some problems with it.\n\tactions: {\n\t\tinherit: true,\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tconst positiveBoostTable = [1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tconst negativeBoostTable = [1, 0.75, 0.6, 0.5, 0.43, 0.36, 0.33];\n\t\t\tconst doSelfDestruct = true;\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\tif (move.selfdestruct && doSelfDestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t/**\n\t\t\t\t * Keeping track of the last move used for self-ko clause,\n\t\t\t\t * making sure to clear the opponents last move so that self-destruct and explosion\n\t\t\t\t * does not persist between Pokemon, preventing problems caused by situations,\n\t\t\t\t * such as a player from blowing up both they and their opponents second last Pokemon\n\t\t\t\t * and their opponent blowing up their last Pokemon. If we did not clear here, there would be a problem.\n\t\t\t\t */\n\t\t\t\ttarget.side.lastMove = null;\n\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t}\n\n\t\t\tlet hitResult = this.battle.singleEvent('PrepareHit', move, {}, target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.battle.runEvent('PrepareHit', pokemon, target, move);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.target === 'all' || move.target === 'foeSide' || move.target === 'allySide' || move.target === 'allyTeam') {\n\t\t\t\tif (move.target === 'all') {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitField', target, pokemon, move);\n\t\t\t\t} else {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitSide', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) {\n\t\t\t\t\t\tthis.battle.add('-fail', pokemon);\n\t\t\t\t\t\tthis.battle.attrLastMove('[still]');\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn this.moveHit(target, pokemon, move);\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, {}, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet accuracy = move.accuracy;\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\tif (move.ohko) {\n\t\t\t\t\tif (pokemon.level >= target.level) {\n\t\t\t\t\t\taccuracy += (pokemon.level - target.level) * 2;\n\t\t\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\tif (pokemon.boosts.accuracy > 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[pokemon.boosts.accuracy];\n\t\t\t\t\t} else {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[-pokemon.boosts.accuracy];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\tif (target.boosts.evasion > 0 && !move.ignorePositiveEvasion) {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[target.boosts.evasion];\n\t\t\t\t\t} else if (target.boosts.evasion < 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[-target.boosts.evasion];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(Math.floor(accuracy), 255);\n\t\t\t\taccuracy = Math.max(accuracy, 1);\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('ModifyAccuracy', target, pokemon, move, accuracy);\n\t\t\tif (accuracy !== true) accuracy = Math.max(accuracy, 0);\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\tif (accuracy !== true && accuracy !== 255 && !this.battle.randomChance(accuracy, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t\treturn damage;\n\t\t\t}\n\t\t\tmove.totalDamage = 0;\n\t\t\tpokemon.lastDamage = 0;\n\t\t\tif (move.multihit) {\n\t\t\t\tlet hits = move.multihit;\n\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thits = Math.floor(hits);\n\t\t\t\tlet nullDamage = true;\n\t\t\t\tlet moveDamage: number | undefined | false;\n\n\t\t\t\tconst isSleepUsable = move.sleepUsable || this.dex.moves.get(move.sourceEffect).sleepUsable;\n\t\t\t\tlet i: number;\n\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\tif (pokemon.status === 'slp' && !isSleepUsable) break;\n\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\tif (nullDamage && (moveDamage || moveDamage === 0 || moveDamage === undefined)) nullDamage = false;\n\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\tmove.totalDamage += damage;\n\t\t\t\t\tthis.battle.eachEvent('Update');\n\t\t\t\t}\n\t\t\t\tif (i === 0) return 1;\n\t\t\t\tif (nullDamage) damage = false;\n\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t} else {\n\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\tmove.totalDamage = damage;\n\t\t\t}\n\t\t\tif (move.category !== 'Status') {\n\t\t\t\ttarget.gotAttacked(move, damage, pokemon);\n\t\t\t}\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\t\t\t// Implementing Recoil mechanics from Stadium 2.\n\t\t\t// If a pokemon caused the other to faint with a recoil move and only one pokemon remains on both sides,\n\t\t\t// recoil damage will not be taken.\n\t\t\tif (move.recoil && move.totalDamage && (pokemon.side.pokemonLeft > 1 || target.side.pokemonLeft > 1 || target.hp)) {\n\t\t\t\tthis.battle.damage(this.calcRecoilDamage(move.totalDamage, move), pokemon, target, 'recoil');\n\t\t\t}\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as unknown as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's test for immunities.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn target.maxhp;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we run it\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage\n\t\t\tmove.category = this.battle.getCategory(move);\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary\n\t\t\tlet basePower: number | false | null | undefined = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\n\t\t\t// We check for Base Power\n\t\t\tif (!basePower) {\n\t\t\t\tif (basePower === 0) return; // Returning undefined means not dealing damage\n\t\t\t\treturn basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit ratio\n\t\t\tlet critRatio = this.battle.runEvent('ModifyCritRatio', source, target, move, move.critRatio || 0);\n\t\t\tcritRatio = this.battle.clampIntRange(critRatio, 0, 5);\n\t\t\tconst critMult = [0, 16, 8, 4, 3, 2];\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (typeof move.willCrit === 'undefined') {\n\t\t\t\tif (critRatio) {\n\t\t\t\t\tisCrit = this.battle.randomChance(1, critMult[critRatio]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation\n\t\t\tif (basePower) {\n\t\t\t\t// confusion damage\n\t\t\t\tif (move.isConfusionSelfHit) {\n\t\t\t\t\tmove.type = move.baseMoveType!;\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t\tmove.type = '???';\n\t\t\t\t} else {\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t}\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check for attacker and defender\n\t\t\tlet level = source.level;\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tthis.battle.add('-activate', source, 'move: Beat Up', '[of] ' + move.allies[0].name);\n\t\t\t\tlevel = move.allies[0].level;\n\t\t\t}\n\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet unboosted = false;\n\t\t\tlet noburndrop = false;\n\n\t\t\tif (isCrit) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t\t// Stat level modifications are ignored if they are neutral to or favour the defender.\n\t\t\t\t// Reflect and Light Screen defensive boosts are only ignored if stat level modifications were also ignored as a result of that.\n\t\t\t\tif (attacker.boosts[atkType] <= defender.boosts[defType]) {\n\t\t\t\t\tunboosted = true;\n\t\t\t\t\tnoburndrop = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet attack = attacker.getStat(atkType, unboosted, noburndrop);\n\t\t\tlet defense = defender.getStat(defType, unboosted);\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tattack = move.allies[0].species.baseStats.atk;\n\t\t\t\tmove.allies.shift();\n\t\t\t\tdefense = defender.species.baseStats.def;\n\t\t\t}\n\n\t\t\t// Moves that ignore offense and defense respectively.\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\t// The attack drop from the burn is only applied when attacker's attack level is higher than defender's defense level.\n\t\t\t\tattack = attacker.getStat(atkType, true, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true, true);\n\t\t\t}\n\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(attack, 1, 999) / 4), 1);\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(defense, 1, 999) / 4), 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = Math.floor(damage / 50);\n\t\t\tif (isCrit) damage *= 2;\n\t\t\tdamage = Math.floor(this.battle.runEvent('ModifyDamage', attacker, defender, move, damage));\n\t\t\tdamage = this.battle.clampIntRange(damage, 1, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// Weather modifiers\n\t\t\tif (\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Fire' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage * 1.5);\n\t\t\t} else if (\n\t\t\t\t((type === 'Fire' || move.id === 'solarbeam') && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\t// Super effective attack\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t\tdamage *= 2;\n\t\t\t\tif (totalTypeMod >= 2) {\n\t\t\t\t\tdamage *= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Resisted attack\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\tif (totalTypeMod <= -2) {\n\t\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply random factor if damage is greater than 1, except for Flail and Reversal\n\t\t\tif (!move.noDamageVariance && damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t}\n\n\t\t\t// If damage is less than 1, we return 1\n\t\t\tif (basePower && !Math.floor(damage)) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage\n\t\t\treturn damage;\n\t\t},\n\t},\n\t/**\n\t * Stadium 2 ignores stat drops due to status ailments upon boosting the dropped stat.\n\t * For example: if a burned Snorlax uses Curse then it will ignore the attack drop from\n\t * burn when it is recalculating its attack stat. This is why volatiles are added to status\n\t * conditions, so that we can keep track of whether or not to apply the stat drop from\n\t * statuses.\n\t */\n\tboost(boost, target, source = null, effect = null) {\n\t\tif (this.event) {\n\t\t\tif (!target) target = this.event.target;\n\t\t\tif (!source) source = this.event.source;\n\t\t\tif (!effect) effect = this.effect;\n\t\t}\n\t\tif (typeof effect === 'string') effect = this.dex.conditions.get(effect);\n\t\tif (!target?.hp) return 0;\n\t\tlet success = null;\n\t\tboost = this.runEvent('TryBoost', target, source, effect, {...boost});\n\t\tlet i: BoostID;\n\t\tfor (i in boost) {\n\t\t\tconst currentBoost: SparseBoostsTable = {};\n\t\t\tcurrentBoost[i] = boost[i];\n\t\t\tlet boostBy = target.boostBy(currentBoost);\n\t\t\tlet msg = '-boost';\n\t\t\tif (boost[i]! < 0) {\n\t\t\t\tmsg = '-unboost';\n\t\t\t\tboostBy = -boostBy;\n\t\t\t}\n\t\t\tif (boostBy) {\n\t\t\t\tsuccess = true;\n\t\t\t\t// Check for boost increases deleting attack or speed drops\n\t\t\t\tif (i === 'atk' && target.status === 'brn' && target.volatiles['brnattackdrop']) {\n\t\t\t\t\ttarget.removeVolatile('brnattackdrop');\n\t\t\t\t}\n\t\t\t\tif (i === 'spe' && target.status === 'par' && target.volatiles['parspeeddrop']) {\n\t\t\t\t\ttarget.removeVolatile('parspeeddrop');\n\t\t\t\t}\n\t\t\t\tif (!effect || effect.effectType === 'Move') {\n\t\t\t\t\tthis.add(msg, target, i, boostBy);\n\t\t\t\t} else {\n\t\t\t\t\tthis.add(msg, target, i, boostBy, '[from] ' + effect.fullname);\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterEachBoost', target, source, effect, currentBoost);\n\t\t\t}\n\t\t}\n\t\tthis.runEvent('AfterBoost', target, source, effect, boost);\n\t\treturn success;\n\t},\n\t/**\n\t * Implementing Self-KO Clause by having it check what the last move used by the players were\n\t * in the case both Pokemon faint. Since the only way this can happen in Stadium 2 is if a player\n\t * uses self-destruct or explosion, I can use this to determine who should win.\n\t */\n\tfaintMessages(lastFirst) {\n\t\tif (this.ended) return;\n\t\tconst length = this.faintQueue.length;\n\t\tif (!length) return false;\n\t\tif (lastFirst) {\n\t\t\tthis.faintQueue.unshift(this.faintQueue[this.faintQueue.length - 1]);\n\t\t\tthis.faintQueue.pop();\n\t\t}\n\t\tlet faintData;\n\t\twhile (this.faintQueue.length) {\n\t\t\tfaintData = this.faintQueue.shift()!;\n\t\t\tconst pokemon: Pokemon = faintData.target;\n\t\t\tif (!pokemon.fainted &&\n\t\t\t\tthis.runEvent('BeforeFaint', pokemon, faintData.source, faintData.effect)) {\n\t\t\t\tthis.add('faint', pokemon);\n\t\t\t\tpokemon.side.pokemonLeft--;\n\t\t\t\tif (pokemon.side.totalFainted < 100) pokemon.side.totalFainted++;\n\t\t\t\tthis.runEvent('Faint', pokemon, faintData.source, faintData.effect);\n\t\t\t\tthis.singleEvent('End', pokemon.getAbility(), pokemon.abilityState, pokemon);\n\t\t\t\tpokemon.clearVolatile(false);\n\t\t\t\tpokemon.fainted = true;\n\t\t\t\tpokemon.isActive = false;\n\t\t\t\tpokemon.isStarted = false;\n\t\t\t\tpokemon.side.faintedThisTurn = pokemon;\n\t\t\t}\n\t\t}\n\n\t\tif (this.gen <= 1) {\n\t\t\t// in gen 1, fainting skips the rest of the turn\n\t\t\t// residuals don't exist in gen 1\n\t\t\tthis.queue.clear();\n\t\t\t// Fainting clears accumulated Bide damage\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (pokemon.volatiles['bide'] && pokemon.volatiles['bide'].damage) {\n\t\t\t\t\tpokemon.volatiles['bide'].damage = 0;\n\t\t\t\t\tthis.hint(\"Desync Clause Mod activated!\");\n\t\t\t\t\tthis.hint(\"In Gen 1, Bide's accumulated damage is reset to 0 when a Pokemon faints.\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.gen <= 3 && this.gameType === 'singles') {\n\t\t\t// in gen 3 or earlier, fainting in singles skips to residuals\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (this.gen <= 2) {\n\t\t\t\t\t// in gen 2, fainting skips moves only\n\t\t\t\t\tthis.queue.cancelMove(pokemon);\n\t\t\t\t} else {\n\t\t\t\t\t// in gen 3, fainting skips all moves and switches\n\t\t\t\t\tthis.queue.cancelAction(pokemon);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!this.p1.pokemonLeft && !this.p2.pokemonLeft) {\n\t\t\tif (this.p1.lastMove !== null && this.p2.lastMove === null) {\n\t\t\t\tthis.win(this.p2);\n\t\t\t\treturn true;\n\t\t\t} else if (this.p2.lastMove !== null && this.p1.lastMove === null) {\n\t\t\t\tthis.win(this.p1);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.win(faintData ? faintData.target.side.foe : null);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p1.pokemonLeft) {\n\t\t\tthis.win(this.p2);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p2.pokemonLeft) {\n\t\t\tthis.win(this.p1);\n\t\t\treturn true;\n\t\t}\n\t\tif (faintData) {\n\t\t\tthis.runEvent('AfterFaint', faintData.target, faintData.source, faintData.effect, length);\n\t\t}\n\t\treturn false;\n\t},\n};\n"]}